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

# Export usage

> Pull your CodeCobra usage into your own reporting, for chargeback or cost tracking.

If you split costs across teams or clients, you'll want the usage figures in your own systems rather than reading them off a page.

## Your usage

```bash theme={null}
curl -H "Authorization: Bearer cc_your_key_here" \
  "https://codecobra.ai/api/usage"
```

Returns usage across every project you can see, grouped by day, for the last 30 days.

### Narrowing it

| Parameter    | What it does                                                   |
| ------------ | -------------------------------------------------------------- |
| `days`       | Rolling window, in days. Defaults to 30.                       |
| `since`      | An ISO-8601 timestamp. Returns everything from that moment on. |
| `project_id` | Restrict to a single project.                                  |

```bash theme={null}
# Last 7 days
curl -H "Authorization: Bearer $KEY" "https://codecobra.ai/api/usage?days=7"

# Everything since a fixed point
curl -H "Authorization: Bearer $KEY" \
  "https://codecobra.ai/api/usage?since=2026-05-01T00:00:00Z"
```

<Warning>If you send both `since` and `days`, **`since` wins** and `days` is ignored. The response tells you which was used: `since` comes back as the effective lower bound, and `days` comes back as `null` whenever `since` was applied. Check that field rather than assuming your `days` took effect.</Warning>

## Incremental exports

For a nightly job, keep the `since` value the last run returned and pass it back next time. That gives you exactly the rows you haven't seen, with no overlap to de-duplicate and no gap if a run is late.

```bash theme={null}
curl -H "Authorization: Bearer $KEY" \
  "https://codecobra.ai/api/public/usage?since=$LAST_RUN"
```

## One task's usage

```bash theme={null}
curl -H "Authorization: Bearer $KEY" \
  "https://codecobra.ai/api/public/usage/task/$TASK_ID"
```

Grouped by capability class — useful when you want to know what a specific piece of work cost.

## Organization usage

```bash theme={null}
curl -H "Authorization: Bearer $KEY" \
  "https://codecobra.ai/api/organizations/$ORG_ID/usage"
```

Every billed event attributable to the organization, one row per request, so you can attribute spend by member or project in your own reporting. Owners and admins only.
