Skip to content
Last updated

Generate an invoice for a specific organization and billing period. This endpoint is restricted to staff users only.

POSThttps://api.aitronos.com/v1/invoices/generate

Request Body

organization_id string required

Organization ID (format: org_<uuid>).

year integer required

Year for billing period (2024-2100).

month integer required

Month for billing period (1-12).

currency string optional

Currency code (CHF, USD, EUR, GBP). Defaults to CHF.

regenerate boolean optional

Regenerate if invoice already exists. Defaults to false.

Returns

Returns the generated invoice object with all line items, tax calculations, and metadata.

Bash
curl -X POST "https://api.aitronos.com/v1/invoices/generate" \
  -H "X-API-Key: $FREDDY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "organization_id": "org_123e4567e89b12d3a456426614174000",
    "year": 2024,
    "month": 12,
    "currency": "CHF",
    "regenerate": false
  }'

Response:

{
  "id": "inv_123e4567e89b12d3a456426614174000",
  "invoice_number": "INV-2024-12-AIT-001",
  "organization_id": "org_123e4567e89b12d3a456426614174000",
  "organization_name": "Aitronos AG",
  "billing_period_start": "2024-12-01T00:00:00Z",
  "billing_period_end": "2025-01-01T00:00:00Z",
  "issue_date": "2024-12-31T23:59:59Z",
  "due_date": "2025-01-30T23:59:59Z",
  "payment_date": null,
  "currency": "CHF",
  "exchange_rate": 1.0,
  "subtotal": 1250.50,
  "tax_rate": 0.081,
  "tax_amount": 101.29,
  "total_amount": 1351.79,
  "status": "issued",
  "items": [
    {
      "id": "invitem_123e4567e89b12d3a456426614174000",
      "description": "GPT-4 Turbo - Input Tokens",
      "model_name": "gpt-4-turbo",
      "provider": "openai",
      "quantity": 1250.5,
      "unit": "1K tokens",
      "unit_price": 0.01,
      "amount": 12.51,
      "input_tokens": 1250500,
      "output_tokens": null,
      "total_requests": 1523
    },
    {
      "id": "invitem_456e4567e89b12d3a456426614174000",
      "description": "GPT-4 Turbo - Output Tokens",
      "model_name": "gpt-4-turbo",
      "provider": "openai",
      "quantity": 3420.75,
      "unit": "1K tokens",
      "unit_price": 0.03,
      "amount": 102.62,
      "input_tokens": null,
      "output_tokens": 3420750,
      "total_requests": 1523
    }
  ],
  "created_at": "2024-12-31T23:59:59Z",
  "updated_at": "2024-12-31T23:59:59Z"
}