Track usage event
Track a usage event for a metered feature. Deducts from balance/credits if applicable.
Track a usage event for a metered feature. Deducts from balance/credits if applicable.
Authorization
ApiKeyAuth x-api-key<token>
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
feature*string
customerId*string
idempotencyKey?string
timestamp*unknown
properties*array<>
value*number
model?string
inputTokens?integer
outputTokens?integer
cacheReadTokens?integer
cacheWriteTokens?integer
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/usage/events" \ -H "Content-Type: application/json" \ -d '{ "feature": "string", "customerId": "string", "timestamp": null, "properties": [], "value": 1 }'{ "success": true, "data": { "id": "string", "feature": "string", "value": 0, "customerId": "string", "idempotencyKey": "string", "ts": "2019-08-24T14:15:22Z", "createdAt": "2019-08-24T14:15:22Z", "properties": [ { "property": "string", "value": "string" } ], "consumption": { "model": "string", "deducted": 0, "remaining": 0, "blocked": true }, "object": "usage_event", "livemode": true }}{ "success": false, "error": { "type": "string", "code": "string", "message": "string", "param": "string", "details": null, "doc_url": "string" }}{ "success": false, "error": { "type": "string", "code": "string", "message": "string", "param": "string", "details": null, "doc_url": "string" }}{ "success": false, "error": { "type": "string", "code": "string", "message": "string", "param": "string", "details": null, "doc_url": "string" }}{ "success": false, "error": { "type": "string", "code": "string", "message": "string", "param": "string", "details": null, "doc_url": "string" }}{ "success": false, "error": { "type": "string", "code": "string", "message": "string", "param": "string", "details": null, "doc_url": "string" }}{ "success": false, "error": { "type": "string", "code": "string", "message": "string", "param": "string", "details": null, "doc_url": "string" }}{ "success": false, "error": { "type": "string", "code": "string", "message": "string", "param": "string", "details": null, "doc_url": "string" }}