Skip to content
Last updated

Generate invoices for all active organizations with usage for a specific month. This endpoint is restricted to staff users only and processes multiple organizations in a single request.

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

Request Body

year integer required

Year for billing period (2024-2100).

month integer required

Month for billing period (1-12).

Returns

Returns a summary of the generation process including the number of invoices generated, failed, and details for each invoice or error.

Response Fields

generated integer

Number of invoices successfully generated.

failed integer

Number of organizations that failed invoice generation.

invoices array

Array of successfully generated invoice objects (without items for brevity).

errors array

Array of error objects for failed generations, including organization ID and error message.

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

Response:

{
  "generated": 42,
  "failed": 1,
  "invoices": [
    {
      "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": [],
      "created_at": "2024-12-31T23:59:59Z",
      "updated_at": "2024-12-31T23:59:59Z"
    }
  ],
  "errors": [
    {
      "organization_id": "org_456e4567e89b12d3a456426614174000",
      "error": "No usage data found for period"
    }
  ]
}