Skip to content
Longplay
Docs
Browse docs / Read credit analytics
On this page

Read credit analytics

Operation
readCreditAnalytics
Server SDK
readCreditAnalytics
Python
read_credit_analytics
Go
ReadCreditAnalytics
POST/api/v1/credits/analytics

Read credit analytics derived from balance and financial records.

Markdown
API v1Updated

Request#

Credential
Server Key with credits:read. Call from your backend only.
SDK
JavaScript createLongplayServer().readCreditAnalytics · Python read_credit_analytics · Go ReadCreditAnalytics
Success
HTTP 200
request.shShell
curl -X POST "$LONGPLAY_API_URL/api/v1/credits/analytics" \  -H "Authorization: Bearer $LONGPLAY_SERVER_KEY" \  -H "X-Indiana-Protocol: 0.10" \  -H "Content-Type: application/json" \  -d '{  "customerId": null,  "query": {    "range": {      "kind": "absolute",      "from": "2026-10-01T00:00:00.000Z",      "to": "2026-10-03T12:00:00.000Z"    },    "timezone": "UTC",    "filterBy": [],    "interval": "day",    "internal_feature_id": null,    "groupBy": "customer",    "entityId": null,    "topN": null,    "after": null,    "limit": 50  }}'

The response shows example data.

Body parameters#

application/json

customerIduuid | nullRequired

The Customer UUID. Required with a Server Key; omit it with a Customer Token.

queryobjectRequired

Query.

Show child fields
rangeobject | object | objectRequired

Time range.

Show child fields
kind"absolute" | "last_days" | "billing_cycles"Required

Kind; see the allowed values.

fromdate-timeOptional

Range start (ISO 8601).

todate-timeOptional

Range end (ISO 8601).

days1 | 7 | 30 | 90Optional

Number of days.

membershipIduuidOptional

membership ID.

countintegerOptional

For a billing_cycles range, how many of the membership's most recent billing cycles to cover (1–12); with includeCurrent: false, only completed cycles count.

min: 1 · max: 12

includeCurrentbooleanOptional

Whether to include the current period.

timezonestringRequired

Time zone.

maxLength: 100

filterByarrayRequired

Filter.

maxItems: 5

Show child fields
keystringRequired

Name of an event property to filter on (lowercase letters, digits and underscores); only events whose property equals one of values are included.

pattern: ^[a-z][a-z0-9_]{0,63}$

valuesarrayRequired

Values.

minItems: 1 · maxItems: 20

intervalenumRequired

Interval; see the allowed values.

Show allowed values

"hour""day""week""month"

internal_feature_iduuid | nullRequired

Feature ID.

entityIduuid | nullRequired

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

topNinteger | nullRequired

Number of top items to return.

groupByenum | stringRequired

Group-by dimension.

afterobject | nullRequired

Pagination cursor: pass the value from the previous page; null for the first page.

Show child fields
bucketdate-timeRequired

Aggregation bucket.

groupstringRequired

Group.

maxLength: 240

isOtherbooleanRequired

Whether this row aggregates the remaining items.

internal_feature_iduuidRequired

Feature ID.

resourceIduuidRequired

Cursor field: the resourceId from the previous page's nextCursor. Pass that cursor object unchanged.

limitintegerRequired

Maximum records per page, subject to the contract limit.

min: 1 · max: 100

Response fields#

Every successful response includes requestId (this request's ID, for support) and scope (App and environment).

HTTP 200 · application/json

requestIduuidRequired

UUID the server generated for this HTTP request; include it when reporting a problem. It is not your business requestId.

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"

analyticsobjectRequired

The report page: the resolved from/to range, interval and timezone, the aggregated rows and nextCursor for the next page.

Show child fields
fromdate-timeRequired

Range start (ISO 8601).

todate-timeRequired

Range end (ISO 8601).

intervalenumRequired

Interval; see the allowed values.

Show allowed values

"hour""day""week""month"

timezonestringRequired

Time zone.

maxLength: 100

rowsarrayRequired

Data rows.

maxItems: 100

Show child fields
bucketdate-timeRequired

Aggregation bucket.

groupstringRequired

Group.

maxLength: 240

isOtherbooleanRequired

Whether this row aggregates the remaining items.

internal_feature_iduuidRequired

Feature ID.

resourceIduuidRequired

UUID of the Feature whose balance funded the usage: the credit Feature when usage is paid with credits, otherwise the same as internal_feature_id.

consumedUnitsstringRequired

Quantity consumed in this bucket, including confirmed reservations, in units of the tracked Feature (internal_feature_id); decimal string.

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

refundedUnitsstringRequired

Quantity refunded, in units of the tracked Feature; decimal string. Refunds count in the bucket of the original usage.

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

reservedUnitsstringRequired

Quantity currently held by pending, unexpired reservations, in units of the tracked Feature; decimal string.

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

chargedstringRequired

Amount deducted from the resourceId balance by consumption, in that balance's units (credits for a credit Feature); decimal string.

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

refundedstringRequired

Refunded portion.

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

reservedstringRequired

Reserved quantity.

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

netUnitsstringRequired

consumedUnits minus refundedUnits; decimal string. Reservations are not included.

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

netChargedstringRequired

charged minus refunded: the net amount deducted from the resourceId balance; decimal string.

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

nextCursorobject | nullRequired

Next-page cursor; null means end. Pass unchanged and clear when filters change.

Show child fields
bucketdate-timeRequired

Aggregation bucket.

groupstringRequired

Group.

maxLength: 240

isOtherbooleanRequired

Whether this row aggregates the remaining items.

internal_feature_iduuidRequired

Feature ID.

resourceIduuidRequired

resourceId of the last row on this page; part of the cursor to pass unchanged as query.after.

Errors#

Failures return an error object; handle them by error.code and error.recovery. The table lists the errors that follow from this operation's credential, scope and idempotency fields; depending on the request it can also return NOT_FOUND (a referenced resource doesn't exist), NOT_CONFIGURED (a required integration isn't connected) or PAYLOAD_TOO_LARGE. Some refusals, such as insufficient balance, are not errors but a reason in a successful response.

Possible errors
codeHTTPWhenrecovery
INVALID_REQUEST400The request doesn't match this page's parameters. A missing or malformed protocol header returns UNSUPPORTED_PROTOCOL_VERSION or INVALID_PROTOCOL_VERSION instead.fix_request
UNAUTHENTICATED401The credential is missing, invalid, expired or revoked.authenticate
FORBIDDEN403The credential lacks credits:read.check_permissions
SCOPE_MISMATCH403X-Indiana-Project or X-Indiana-Environment doesn't match the credential's App and environment.check_scope
RATE_LIMITED429Too many requests; wait for Retry-After and retry the same request.retry_same_request
SERVICE_UNAVAILABLE503The service is temporarily unavailable; retry the same request.retry_same_request
INTERNAL_ERROR500The outcome is unknown; retry later.recover_operation

Possible errors

  • INVALID_REQUEST

    HTTP
    400
    When
    The request doesn't match this page's parameters. A missing or malformed protocol header returns UNSUPPORTED_PROTOCOL_VERSION or INVALID_PROTOCOL_VERSION instead.
    recovery
    fix_request
  • UNAUTHENTICATED

    HTTP
    401
    When
    The credential is missing, invalid, expired or revoked.
    recovery
    authenticate
  • FORBIDDEN

    HTTP
    403
    When
    The credential lacks credits:read.
    recovery
    check_permissions
  • SCOPE_MISMATCH

    HTTP
    403
    When
    X-Indiana-Project or X-Indiana-Environment doesn't match the credential's App and environment.
    recovery
    check_scope
  • RATE_LIMITED

    HTTP
    429
    When
    Too many requests; wait for Retry-After and retry the same request.
    recovery
    retry_same_request
  • SERVICE_UNAVAILABLE

    HTTP
    503
    When
    The service is temporarily unavailable; retry the same request.
    recovery
    retry_same_request
  • INTERNAL_ERROR

    HTTP
    500
    When
    The outcome is unknown; retry later.
    recovery
    recover_operation

Related: Error codes and recovery·Request conventions·All operations