Commet
  • Precios
Iniciar SesiónRegistrarse
Check usage availability POSTTrack usage event POST
DocumentaciónRecursosConstruir con AIAPI ReferenceWebhooks

Track usage event

Track a usage event for a metered feature. Deducts from balance/credits if applicable.

POST
/usage/events

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"  }}

Check usage availability POST

Check if a customer can consume a feature before actual consumption. Returns availability and cost estimates based on the plan's consumption model.

Create webhook endpoint POST

Create a new webhook endpoint. The response includes the signing secret which is only returned once.