comecerodocs

Send usage events

POST
/v1/events

Sends a batch of 1 to 1,000 usage events from your server. Use a usage key, not a Comecero API token. The key sets the account and test or live mode. The whole JSON body is at most 1 MiB. Read every result: HTTP 200 can include rejected or conflicting events. Resend only retry results, or safely resend the same batch with the same operation ids. Billing uses the counted events; an event does not itself charge a customer. This route sends no CORS headers. See Send usage.

Authorization

usageKey
headerAuthorizationBearer <token>

A merchant usage key (apk_test_ or apk_live_), never a Comecero API token.

Request Body

application/json
  1. body
events*array<>
Items1 <= items <= 1000

Response Body

Every event has a final answer (counted, duplicate, conflict or rejected).

application/json
  1. response
counted?integer
duplicate?integer
conflict?integer
rejected?integer
retry?integer
results?array<>
Example Request
curl -X POST 'https://usage.comecero.com/v1/events' \  -H 'Content-Type: application/json' \  -d '{  "events": [    {      "operation_id": "request_5501",      "external_customer_id": "cust_8412",      "metric_key": "ai_tokens",      "quantity": "1250",      "properties": {        "model": "small"      }    }  ]}'
Example Response
{  "counted": 1,  "duplicate": 0,  "conflict": 0,  "rejected": 0,  "retry": 0,  "results": [    {      "index": 0,      "operation_id": "request_5501",      "status": "counted"    }  ]}