Lucius API
Usage

Submit usage events

Submit up to 100 usage events in a single request. Each event is validated individually (schema and contract pricing program), persisted, rated immediately, and the corresponding invoice is updated. **Per-event validation:** Only the batch envelope (`events` array of 1–100 items) is validated up front. A malformed event (missing fields, invalid ISO timestamp, negative `quantity`/`fee_amount`, unknown contract or metric) is returned as `status: "rejected"` with its error without dropping valid events in the same batch. Rating priority: `fee_amount` (authoritative USD fee) → `applied_rate × quantity` → the contract usage rule. `applied_rate` is a decimal (0.0001 = 1 bps), not integer bps. `metric` is per contract — use `GET /v1/billing/contracts` → `metrics[]`. If that list is empty, add a usage rule first (`POST /v1/billing/contracts/{id}/pricing-rules`). See the Usage events guide. Events are idempotent — submitting the same `event_id` twice returns success without creating a duplicate.

POST
/v1/billing/usage

Authorization

AuthorizationBearer <token>

API key as Bearer token: Authorization: Bearer luc_live_.... Create keys in the dashboard under Settings > API Keys.

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

curl -X POST "https://example.com/v1/billing/usage" \  -H "Content-Type: application/json" \  -d '{    "events": [      {        "external_contract_id": "acme-corp-2026",        "event_id": "evt-2026-03-001",        "metric": "revenue_amount_invoiced",        "quantity": 10000,        "fee_amount": 37.5,        "applied_rate": 0.00375,        "timestamp": "2026-03-25T12:00:00.000Z"      }    ]  }'
{  "accepted": 1,  "rejected": 0,  "events": [    {      "event_id": "evt-2026-03-001",      "status": "accepted"    }  ]}

{  "error": "Missing API key"}