Skip to main content
POST
/
api
/
charge_baskets
/
generate_invoice
Generate invoice from charge baskets
curl --request POST \
  --url https://clarus-api.com/api/charge_baskets/generate_invoice \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'X-Clarus-Subdomain: <api-key>' \
  --data '
{
  "ids": [
    1,
    2,
    3
  ]
}
'
{
  "data": [
    {
      "id": "1",
      "type": "ar_documents",
      "attributes": {
        "document_date": "2026-03-12",
        "document_due_date": "2026-04-12",
        "document_number": "INV-001",
        "document_type": "invoice",
        "id": 1,
        "reference": null,
        "tax_status": "tax_exclusive"
      },
      "relationships": {
        "account": {
          "data": {
            "id": "1",
            "type": "accounts"
          }
        }
      }
    }
  ]
}

Behavior

  • Creates one AR document (invoice) per account from the charge basket line items
  • All documents are created with status ‘draft’
  • The request body is flat JSON (not JSON:API format)
  • Returns an array of created AR documents

Important Notes

  • invoice_status on charge baskets is automatically recalculated after invoice generation
  • Baskets must be in CLOSED status before generating invoices

Authorizations

Authorization
string
header
required

OAuth 2.0 authentication. Use the client credentials or authorization code flow to obtain an access token.

X-Clarus-Subdomain
string
header
required

The subdomain/tenant name identifying which tenant's data to access. Required for all API requests.

Body

application/json
ids
integer[]
required

Array of charge basket IDs to generate invoices from

Minimum array length: 1

Response

Invoices generated successfully

data
object[]