Skip to content
Indiana
Dashboard
Docs
Browse docs / Track usage by event

Track usage by event

POST/api/v1/usage/track

A trusted server consumes usage for features mapped to eventName or for a specific internal_feature_id and returns balance receipts. Choose one target type. Retries reuse the original idempotency key and receipts; inspect each receipt's accepted status.

API v1Updated

Make the request

A trusted server consumes usage for features mapped to eventName or for a specific internal_feature_id and returns balance receipts. Choose one target type. Retries reuse the original idempotency key and receipts; inspect each receipt's accepted status.

Credential
Server API key only. Call from your trusted backend.
Permission
credits:consume
Set the base URL and App ID from SDK setup. These examples use placeholders and do not execute requests. Never put a server key in browser code.
request.shShell
curl -X POST "$INDIANA_BASE_URL/api/v1/usage/track" \  -H "Authorization: Bearer $INDIANA_SECRET_KEY" \  -H "X-Indiana-Project: $INDIANA_PROJECT_ID" \  -H "X-Indiana-Environment: sandbox" \  -H "Content-Type: application/json" \  -d '{  "customerId": "00000000-0000-4000-8000-000000000001",  "command": {    "eventName": "document_exported",    "quantity": "1",    "properties": {},    "idempotencyKey": "export:export_123"  }}'

The response tab lists field types, not an example payload. Actual values depend on customer state.

Request parameters

JSON body

customerIduuidRequired

Indiana customer ID mapped from a verified identity on the server. Omit for customer-token calls, which use the token-bound customer.

commandobject | objectRequired

The command value for this operation. Its accepted type and constraints are listed above and below.

Show child fields
eventNamestringOptional

The eventName value for this operation. Its accepted type and constraints are listed above and below.

minLength: 1

quantitystring | stringOptional

Use the declared field type for business quantity. Credit operations use decimal strings to avoid floating-point error. quote/reserve/confirm/refund require positive quantities; consume can record zero-cost events.

propertiesobject | objectOptional

Validated pricing properties used to match dimensions and multipliers.

entityIduuid | uuidOptional

Entity ID within the current customer scope, for configured entity and license features.

idempotencyKeystring | stringRequired

Stable business idempotency key. The same key and payload replay the result; do not randomize on retries.

internal_feature_iduuidOptional

The internal_feature_id value for this operation. Its accepted type and constraints are listed above and below.

Response fields

Successful responses include requestId and scope. Use the actual business status or accepted field to determine the result. Optional fields are omitted when unavailable.

HTTP 200 · application/json

requestIduuidRequired

Server-generated HTTP request UUID. Include it when reporting a failed request.

scopeobjectRequired

The App and environment of this response. Headers only verify scope; they cannot switch key scope.

Show child fields
projectIdstringRequired

App ID bound to the credential.

minLength: 1

environmentenumRequired

Separate data scope: sandbox or live.

Show allowed values

"sandbox""live"

receiptsarrayRequired

The receipts value for this operation. Its accepted type and constraints are listed above and below.

minItems: 1

Show child fields
iduuidRequired

The id value for this operation. Its accepted type and constraints are listed above and below.

internal_feature_iduuidRequired

The internal_feature_id value for this operation. Its accepted type and constraints are listed above and below.

kindenumRequired

The kind value for this operation. Its accepted type and constraints are listed above and below.

Show allowed values

"consume""reserve""confirm""refund""release""expire"

originalIduuid | nullRequired

The originalId value for this operation. Its accepted type and constraints are listed above and below.

quantityobjectRequired

Use the declared field type for business quantity. Credit operations use decimal strings to avoid floating-point error. quote/reserve/confirm/refund require positive quantities; consume can record zero-cost events.

requestedQuantityobjectOptional

Original quantity for explicit cap/overflow. quantity is the quantity accepted or rejected by the operation.

overageBehaviorenumOptional

cap accepts the largest permitted quantity, possibly zero. overflow requests the full quantity subject to overage permission, usage caps and cash budgets. Omission keeps all-or-nothing behavior.

Show allowed values

"cap""overflow"

acceptedbooleanRequired

Whether business rules accepted the operation. HTTP 200 does not imply accepted is true.

reasonenum | nullRequired

Rejection reason or ledger operation description; interpret with accepted and status.

createdAtdate-timeRequired

ISO 8601 UTC time when the record was created.

reservationStatusenum | nullRequired

The reservationStatus value for this operation. Its accepted type and constraints are listed above and below.

expiresAtdate-time | nullRequired

ISO 8601 UTC expiry. Expired sessions and reservations cannot be reused.

allocationsarrayRequired

Balance allocations involved in this evaluation or ledger operation.

maxItems: 500

Show child fields
funding"balance" | "unbilled" | "prepaid" | "postpaid"Required

The funding value for this operation. Its accepted type and constraints are listed above and below.

sourceIduuid | uuidOptional

The sourceId value for this operation. Its accepted type and constraints are listed above and below.

rolloverIduuid | nullOptional

The rolloverId value for this operation. Its accepted type and constraints are listed above and below.

unitsstring | string | object | objectRequired

The units value for this operation. Its accepted type and constraints are listed above and below.

amountstring | stringOptional

Credit or ledger amount, using the field’s decimal-string or integer type.

pricingarrayOptional

The pricing value for this operation. Its accepted type and constraints are listed above and below.

minItems: 1 · maxItems: 12

Show child fields
internal_credit_feature_iduuid | nullRequired

The internal_credit_feature_id value for this operation. Its accepted type and constraints are listed above and below.

internal_metered_feature_iduuidRequired

The internal_metered_feature_id value for this operation. Its accepted type and constraints are listed above and below.

dimensionstringRequired

The dimension value for this operation. Its accepted type and constraints are listed above and below.

minLength: 1 · maxLength: 64

counterKeystringRequired

The counterKey value for this operation. Its accepted type and constraints are listed above and below.

minLength: 1 · maxLength: 240

cycleStartdate-timeRequired

The cycleStart value for this operation. Its accepted type and constraints are listed above and below.

unitCostobjectRequired

The unitCost value for this operation. Its accepted type and constraints are listed above and below.

unitsobjectRequired

The units value for this operation. Its accepted type and constraints are listed above and below.

amountstringRequired

Credit or ledger amount, using the field’s decimal-string or integer type.

pattern: ^(0|[1-9]\d{0,12})(\.\d{1,12})?$

tierinteger | nullRequired

The tier value for this operation. Its accepted type and constraints are listed above and below.

invoiceLineIduuid | nullOptional

The invoiceLineId value for this operation. Its accepted type and constraints are listed above and below.

authorizationIduuidOptional

The authorizationId value for this operation. Its accepted type and constraints are listed above and below.

Handle errors

Common failures
CodeRecovery
UNAUTHENTICATEDVerify the key or refresh the expired customer token once.
FORBIDDENCheck current key permissions and customer access.
INVALID_REQUESTCheck field types, UUIDs, decimal strings and mutually exclusive fields.
SCOPE_MISMATCHUse the App and environment bound to the credential.

Common failures

  • UNAUTHENTICATED

    Recovery
    Verify the key or refresh the expired customer token once.
  • FORBIDDEN

    Recovery
    Check current key permissions and customer access.
  • INVALID_REQUEST

    Recovery
    Check field types, UUIDs, decimal strings and mutually exclusive fields.
  • SCOPE_MISMATCH

    Recovery
    Use the App and environment bound to the credential.

Related:All request and error conventions·Back to endpoint index