Billing API - Integration Reference

Operational documentation for synchronous invoice-receipt issuance in Moloni.

Base URL: https://billing.theinventors.io Endpoint: POST /api/v1/invoices/ Auth: API Key + Secret Target timeout: 10s

1. Endpoint Contract

This endpoint is synchronous: each request returns either a final issuance result or a final error.

2. Authentication

2.1 Required headers

The credentials below are for demonstration only and do not grant real access.

X-Client-Id: airtable_ops_prod
X-Api-Key: ak_demo_9f83b7d1a5c40c22
X-Api-Secret: as_demo_5baf4f0f613949f0863b83de8f4c4f90

3. JSON Payload

Optional fields can be omitted. If VAT number is missing, the system applies final-consumer VAT number internally.

{
  "reference": "TI-2026-05-18-0007",
  "customer": {
    "name": "Eduardo Costa",
    "vat_number": "509999999",
    "email": "[email protected]",
    "address": "Rua do Campo Grande 45, Lisboa"
  },
  "items": [
    {
      "product": "mensalidade TheInventors",
      "gross_price": 10.00,
      "vat_rate": 23
    }
  ]
}

Relevant rules

Optional fields (accepted and processed)

FieldTypeBehavior
customer.vat_numberstringIf present, validated as PT VAT number (9 digits + checksum). If omitted, final-consumer VAT number is used.
customer.addressstringIf present, forwarded to customer create/update flow in Moloni.
customer.emailstringIf present, validated as email and forwarded to customer flow in Moloni.

4. cURL Example (realistic request)

#!/usr/bin/env bash
set -euo pipefail

PATH_URL="/api/v1/invoices/"
BASE_URL="https://billing.theinventors.io"
IDEMP="2878e76a-6654-4e52-a11b-dcc525eef985"
CLIENT_ID="airtable_ops_prod"
API_KEY="ak_demo_9f83b7d1a5c40c22"
API_SECRET="as_demo_5baf4f0f613949f0863b83de8f4c4f90"

BODY='{"reference":"TI-2026-05-18-0007","customer":{"name":"Eduardo Costa","email":"[email protected]","address":"Rua do Campo Grande 45, Lisboa"},"items":[{"product":"mensalidade TheInventors","gross_price":10.00,"vat_rate":23}]}'

curl -sS -X POST "${BASE_URL}${PATH_URL}" \
  -H "Content-Type: application/json" \
  -H "X-Client-Id: ${CLIENT_ID}" \
  -H "X-Api-Key: ${API_KEY}" \
  -H "X-Api-Secret: ${API_SECRET}" \
  -H "Idempotency-Key: ${IDEMP}" \
  --data "$BODY"

5. Success Response

{
  "success": true,
  "request_id": "req_4ad9b2ec1d9f3a71",
  "reference": "TI-2026-05-18-0007",
  "document": {
    "type": "invoice_receipt",
    "moloni_document_id": 974989624,
    "number": "FR M/32",
    "series": "M",
    "total_gross": 10,
    "currency": "EUR",
    "pdf_url": "https://...",
    "created_at": "2026-05-18T15:07:21Z"
  }
}

6. Error Response

{
  "success": false,
  "request_id": "req_62d03a9dabc7e8f4",
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "items[0].vat_rate is invalid.",
    "details": null
  }
}

7. HTTP and Functional Codes

HTTPCodeWhen it happens
201Document issued successfully.
400VALIDATION_ERRORInvalid payload or missing Idempotency-Key.
401AUTH_ERRORInvalid credentials, signature, timestamp, or nonce.
403IP_NOT_ALLOWEDSource IP is outside the key whitelist.
409IDEMPOTENCY_CONFLICTSame Idempotency-Key used with a different body.
422MOLONI_BUSINESS_ERRORBusiness rule rejected by Moloni API.
422CUSTOMER_AMBIGUOUSAmbiguous customer during resolution process.
502MOLONI_BAD_GATEWAYInvalid/intermediary response from Moloni.
503MOLONI_UNAVAILABLEMoloni service unavailable.
504MOLONI_TIMEOUTTimeout while communicating with Moloni.

8. Integration Notes

Backoffice: https://billing.theinventors.io/admin/