v1
latestOpenAPI 3.1.02026-08-042453938.9 KBUsage
Record internal usage (batched, high throughput)
Batch-optimized variant of POST /v1/usage/internal.
Events are buffered in memory and flushed to the database every ~2 seconds using a single bulk INSERT. This reduces per-event DB overhead by ~99% and is designed for customers sending 1M+ events/day.
Returns 202 immediately. The event will be persisted within 2 seconds. Idempotency is still enforced via idempotencyKey — duplicates are silently skipped during the bulk insert.
Requires a secret key (sk_*) with at least the OPERATOR role.
post/v1/usage/internal/batch
Request body
Example request
{
"customerId": "cus_abc123def456",
"externalCustomerId": "user_42",
"stripeCustomerId": "cus_NffrFeUfNV2Hib",
"usageType": "api_call",
"quantity": 100,
"units": "API calls",
"description": "Eligibility check for Pharmacy ABC (workflow: insurance_verify)",
"idempotencyKey": "req_20240115_abc123",
"metadata": {
"endpoint": "/v1/chat",
"model": "gpt-4"
}
}Response
Usage accepted for batched insert
Example response
{
"success": true,
"message": "Event queued for batched insert (~2s)"
}