Record usage logs
Records one usage log against a catalogue unit, addressed by its stable `agentKey`. Units are fixed-price meters with no tokens — the price comes from the unit's catalogue configuration, so a caller can never post a price.
Authorization
apiKey Per-organisation API key from Settings → API Keys, sent as Authorization: Bearer cnk_…. Missing, unknown or expired keys return 401.
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Records one usage log against a catalogue unit. There is no quantity — one call is one unit.
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/units" \ -H "Content-Type: application/json" \ -d '{ "customerId": "cus_abc123", "agentKey": "seats", "member": "dana@acme.com" }'{ "statusCode": 200, "statusDetail": { "status": "SUCCESS", "message": "OK" }, "result": { "unitUsage": { "id": "string", "customerId": "string", "unit": "string", "agentKey": "string", "billingMode": "ADVANCE", "remaining": 0, "customerCost": 0, "member": "string", "createdAt": "2019-08-24T14:15:22Z" } }}{ "statusCode": 400, "statusDetail": { "status": "ERROR", "message": "Request body must be valid JSON." }, "result": {}}{ "statusCode": 401, "statusDetail": { "status": "ERROR", "message": "Invalid API key." }, "result": {}}{ "statusCode": 404, "statusDetail": { "status": "ERROR", "message": "No customer with id \"cus_abc123\"." }, "result": {}}{ "statusCode": 409, "statusDetail": { "status": "ERROR", "message": "Customer \"cus_abc123\" is archived." }, "result": {}}{ "statusCode": 422, "statusDetail": { "status": "ERROR", "message": "No credit with agent key \"summarize\" exists in this workspace." }, "result": {}}{ "statusCode": 500, "statusDetail": { "status": "ERROR", "message": "Could not complete the request." }, "result": {}}