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

Set current usage

Set a metered feature's usage to an exact value for the current period. Use the Idempotency-Key header to make retries safe.

PUT
/usage

Set a metered feature's usage to an exact value for the current period. Use the Idempotency-Key header to make retries safe.

Authorization

ApiKeyAuth
x-api-key<token>

In: header

Header Parameters

Idempotency-Key?string

Unique key used to safely retry this write for 24 hours without applying it twice.

Length1 <= length <= 200

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

customerId*string
Length1 <= length <= 200
featureCode*string
Match^[a-z0-9_]+$
Length1 <= length <= 50
value*integer
Range0 <= value <= 2147483647
reason?string
Length1 <= length <= 500

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X PUT "https://example.com/usage" \  -H "Content-Type: application/json" \  -d '{    "customerId": "string",    "featureCode": "string",    "value": 0  }'
{  "id": "string",  "value": 0,  "previousValue": 0,  "adjustment": -9007199254740991,  "customerId": "string",  "reason": "string",  "ts": "2019-08-24T14:15:22Z",  "createdAt": "2019-08-24T14:15:22Z",  "featureCode": "string",  "object": "usage_adjustment",  "livemode": true}
{  "error": {    "type": "string",    "code": "string",    "message": "string",    "param": "string",    "details": null,    "doc_url": "string"  }}
{  "error": {    "type": "string",    "code": "string",    "message": "string",    "param": "string",    "details": null,    "doc_url": "string"  }}
{  "error": {    "type": "string",    "code": "string",    "message": "string",    "param": "string",    "details": null,    "doc_url": "string"  }}
{  "error": {    "type": "string",    "code": "string",    "message": "string",    "param": "string",    "details": null,    "doc_url": "string"  }}
{  "error": {    "type": "string",    "code": "string",    "message": "string",    "param": "string",    "details": null,    "doc_url": "string"  }}
{  "error": {    "type": "string",    "code": "string",    "message": "string",    "param": "string",    "details": null,    "doc_url": "string"  }}
{  "error": {    "type": "string",    "code": "string",    "message": "string",    "param": "string",    "details": null,    "doc_url": "string"  }}
{  "error": {    "type": "string",    "code": "string",    "message": "string",    "param": "string",    "details": null,    "doc_url": "string"  }}
{  "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.

Track usage event POST

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