> ## Documentation Index
> Fetch the complete documentation index at: https://goldrush.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Get account usage

> Read your GoldRush account usage programmatically — daily usage, aggregate credit consumption against your plan, and a per-API-key breakdown.

> [card] Credential
>
> ServiceKey (account-scoped)

> [card] Processing
>
> Realtime

Returns the same three datasets the Platform **Usage** page renders — daily usage, aggregate credit consumption against your plan, and a per-API-key breakdown — as JSON, filterable by time range.

This endpoint is authenticated with a **ServiceKey**, an account-scoped credential distinct from your standard GoldRush API keys (`cqt_…`). See [Service Keys](https://goldrush.dev/docs/service-keys.md) for how to create, use, and rotate one.

> [!NOTE]
>
> Platform endpoints on `api.covalenthq.com` require a **trailing slash** — call `/platform/usage/`, not `/platform/usage`.

## Endpoint

```
GET https://api.covalenthq.com/platform/usage/
Authorization: Bearer <GOLDRUSH_SERVICE_KEY>
```

## Request

Filter with either a rolling `duration` or an explicit `from`/`to` window. Every section of the response is computed over that single window (`period`).

**duration** `integer` (default: 1)

Rolling window in months, counting back from today. One of `1`, `3`, `6`, or `12`. The default `1` is month-to-date. Ignored when `from`/`to` are supplied.

**from** `string`

Start of an explicit window (`YYYY-MM-DD`). Use together with `to` instead of `duration`.

**to** `string`

End of an explicit window (`YYYY-MM-DD`). Use together with `from` instead of `duration`.

### Example

```bash cURL theme={null}
curl "https://api.covalenthq.com/platform/usage/?duration=1" \
  -H "Authorization: Bearer $GOLDRUSH_SERVICE_KEY"
```

```typescript TypeScript theme={null}
const response = await fetch(
  "https://api.covalenthq.com/platform/usage/?duration=1",
  {
    headers: {
      Authorization: `Bearer ${process.env.GOLDRUSH_SERVICE_KEY}`,
    },
  },
);

const body = await response.json();
```

```python Python theme={null}
import os, requests

response = requests.get(
    "https://api.covalenthq.com/platform/usage/",
    params={"duration": 1},
    headers={"Authorization": f"Bearer {os.environ['GOLDRUSH_SERVICE_KEY']}"},
)
response.raise_for_status()

body = response.json()
```

The GoldRush CLI exposes the same data:

```bash theme={null}
goldrush usage --duration 1 --by-key
```

## Response

The response is a `{ "data": { … } }` envelope containing the window it was computed over (`period`) and the three datasets.

```json theme={null}
{
  "data": {
    "period": {
      "from": "2026-07-01",
      "to": "2026-07-26"
    },
    "aggregate": {
      "credits_consumed": 412000,
      "max_credits": 1000000,
      "premium_credits": 380000,
      "free_credits": 32000,
      "plan": "Advanced",
      "flex_credits": {
        "limit": 250000
      }
    },
    "by_day": [
      {
        "date": "2026-07-25",
        "premium_credits": 18400,
        "free_credits": 1200
      }
    ],
    "by_api_key": [
      {
        "apikey": "cqt_rQ…",
        "credits": 210000
      }
    ]
  }
}
```

### Field descriptions

**period** `object`

The single time window every section is computed over.

**period**

**from** `string`

Start of the window (`YYYY-MM-DD`).

**to** `string`

End of the window (`YYYY-MM-DD`).

**aggregate** `object`

Aggregate credit consumption for the window.

**aggregate**

**credits\_consumed** `integer`

Total credits used in the window.

**max\_credits** `integer`

Credit ceiling for your plan.

**premium\_credits** `integer`

Premium credits used in the window.

**free\_credits** `integer`

Free credits used in the window.

**plan** `string`

Name of your current plan.

**flex\_credits** `object`

Flex (overage) credit allowance, including its `limit`.

**by\_day** `object[]`

Per-day usage over the window.

**by\_day\[]**

**date** `string`

The day (`YYYY-MM-DD`).

**premium\_credits** `integer`

Premium credits used that day.

**free\_credits** `integer`

Free credits used that day.

**by\_api\_key** `object[]`

Credits attributed to each API key over the window.

**by\_api\_key\[]**

**apikey** `string`

The API key the credits are attributed to.

**credits** `integer`

Credits consumed by that key in the window.

## Common uses

* **Budget guardrails in code** — watch `aggregate.credits_consumed` against `max_credits` (and `flex_credits.limit`) to alert or throttle before you hit the ceiling.
* **Per-key cost attribution** — use `by_api_key` to split spend across projects, environments, or downstream customers for chargeback and show-back.
* **Usage trends** — feed `by_day` (premium vs. free) into your own BI or observability stack to forecast month-end spend and catch runaway jobs.

## Common errors

| Status | Cause | Fix |
| - | - | - |
| `401 Unauthorized` | Header missing or malformed, or the ServiceKey has been revoked. | Confirm `Authorization: Bearer <key>` and that the key is still active on the Platform. |
| `403 Forbidden` | A regular API key was supplied instead of a ServiceKey. | Create a [ServiceKey](https://goldrush.dev/docs/service-keys.md) and retry. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.