Skip to main content
GET
/
api
/
v1
/
credits
/
usage
JavaScript
import Stigg from '@stigg/typescript';

const client = new Stigg({
  apiKey: process.env['STIGG_API_KEY'], // This is the default and can be omitted
});

const response = await client.v1.credits.getUsage({ customerId: 'customerId' });

console.log(response.data);
{
  "data": {
    "series": [
      {
        "featureId": "feature-tokens",
        "featureName": "API Tokens",
        "totalCredits": 1500,
        "points": [
          {
            "timestamp": "2024-01-01T00:00:00.000Z",
            "value": 500
          },
          {
            "timestamp": "2024-01-02T00:00:00.000Z",
            "value": 750
          },
          {
            "timestamp": "2024-01-03T00:00:00.000Z",
            "value": 250
          }
        ]
      }
    ],
    "currency": {
      "currencyId": "credits",
      "displayName": "Credits",
      "symbol": null,
      "singular": "credit",
      "plural": "credits"
    },
    "pagination": {
      "next": null,
      "prev": null
    }
  }
}

Authorizations

X-API-KEY
string
header
required

Server API Key

Headers

X-ACCOUNT-ID
string

Account ID — optional when authenticating with a user JWT (Bearer token); falls back to the user's first membership. Ignored for API-key auth.

X-ENVIRONMENT-ID
string

Environment ID — required when authenticating with a user JWT (Bearer token) on environment-scoped endpoints. Ignored for API-key auth (env is intrinsic to the key).

Query Parameters

limit
integer
default:20

Maximum number of items to return

Required range: 1 <= x <= 100
after
string

Return items that come after this cursor

Maximum string length: 255
before
string

Return items that come before this cursor

Maximum string length: 255
customerId
string
required

Filter by customer ID (required)

Required string length: 1 - 255
Pattern: ^[a-zA-Z0-9][a-zA-Z0-9_|.@-]*$
resourceId
string

Filter by resource ID

Required string length: 1 - 255
Pattern: ^[a-zA-Z0-9][a-zA-Z0-9_|.-]*$
currencyId
string

Filter by currency ID

Required string length: 1 - 255
Pattern: ^[a-zA-Z0-9][a-zA-Z0-9_|.-]*$
timeRange
enum<string>

Time range for usage data (LAST_DAY, LAST_WEEK, LAST_MONTH, LAST_YEAR). Defaults to LAST_MONTH

Available options:
LAST_DAY,
LAST_WEEK,
LAST_MONTH,
LAST_YEAR
startDate
string<date-time>

Start date for the credit usage time range (ISO 8601). Takes precedence over timeRange when provided

endDate
string<date-time>

End date for the credit usage time range (ISO 8601). Defaults to now when startDate is provided

groupBy
string

Comma-separated list of feature dimension keys to group usage series by (up to 3). Each key matches /^[a-zA-Z0-9_$-]+$/

Maximum string length: 255

Response

Credit usage data with time-series points per feature.

Response object

data
CreditUsage · object
required

Credit usage data grouped by feature with time-series points