Accounts

List accounts with usage for a time range.

Returns a page of accounts with usage aggregated by metric or currency. Metric sorting requires exactly one of metric_id or currency.

get/v2/accounts/usage

Query parameters

start_atinteger required

Unix timestamp in seconds.

Example:1767225600

Inclusive lower bound for event occurrence time.

end_atinteger required

Unix timestamp in seconds.

Example:1767225600

Exclusive upper bound for event occurrence time.

aggregation'sum' | 'min' | 'max' | 'avg' | 'latest' | 'count'

Aggregation applied to corrected usage events. latest returns the quantity from the event with the latest occurred_at; ties use accepted_at then event ID. count returns the number of events.

Example:sum
limitinteger

Maximum number of records to return. Defaults to 100.

starting_afterstring

Return the next records after this account id.

Cursor account id from the previous page.

sort'created_at' | 'customer_name' | 'metric_ascending' | 'metric_descending'

Account ordering. Metric ordering requires metric_id or currency.

metric_idstring

LedgerUp metric identifier.

Example:metric_0194f4e3a2b77c6aa91c4f6b4db2a980

Metric used for metric_ascending or metric_descending sorting.

currencystring
Example:usd

Currency used for metric_ascending or metric_descending sorting. Normalized to lowercase.

Response

Page of accounts and aggregated usage.

has_moreboolean required

True when additional records are available after the returned page.

Example response

{
  "data": [
    {
      "account": {
        "id": "account_0194f4e3a2b77c6aa91c4f6b4db2a980",
        "external_id": "crm_acme_001",
        "ledgerup_customer_id": "0194f4e3-a2b7-7c6a-a91c-4f6b4db2a980",
        "name": "Acme",
        "description": "Usage tracked for Acme.",
        "created_at": 1767225600,
        "updated_at": 1767225600,
        "archived_at": 1767225600
      },
      "events_consumed": [
        {
          "metric_id": "metric_0194f4e3a2b77c6aa91c4f6b4db2a980",
          "currency": "usd",
          "metric_name": "Tokens",
          "measurement_units": "m",
          "quantity": "1250.5"
        }
      ]
    }
  ]
}

Changes