# Account API

Everything the dashboard shows is available over HTTPS at `https://cdpfleet.com` with your API key in `x-api-key`. Creating and revoking keys is only possible from the [dashboard](https://cdpfleet.com/app), so a leaked key can't create more keys.

| Method | Path | Returns |
| --- | --- | --- |
| `GET` | `/v1/me` | Your account, active plan (threads, daily minutes, maximum session length, rate limits, expiry) and key list (prefixes only). |
| `GET` | `/v1/me/usage` | Today's usage: budget, used and remaining thread-seconds, active sessions and threads. `?day=YYYY-MM-DD` for a past day. |
| `GET` | `/v1/me/usage/history` | Daily thread-seconds and session counts; `?days=30` (up to 366). |
| `GET` | `/v1/me/sessions` | Session history with start, end, duration, browser, threads, end reason and bytes. `?from`, `?to` (ISO timestamps, default last 24 h), `?limit` (up to 1000). |
| `GET` | `/v1/me/bandwidth` | Proxy traffic: totals, per UTC day, and the top 50 destination hosts with bytes down/up, connections and `proxy` (`default` or `rule`). `?days` 1–31 (default 7). |
| `GET` | `/v1/me/bandwidth.csv` | The same period as CSV: one row per day, session, host and proxy (`day,session_id,host,proxy,bytes_down,bytes_up,connections`). |
| `GET` | `/v1/me/sessions/<id>/bandwidth` | One session's proxy traffic per destination host. |
| `GET` | `/v1/me/proxy-balance` | cdpfleet residential proxy: balance in USD, today's usage per tier (bytes and USD), whether launches are allowed, the price per GB of each tier, and the last 50 ledger entries (free credit, top-ups, daily usage per tier). |
| `GET` | `/v1/me/proxies` | Your saved proxies with their last check (exit IP, country, response time). Passwords are masked; add and edit proxies in the dashboard. |
| `GET` | `/v1/me/proxy-rules` | Your proxy-rule sets: default proxy and rules (hosts, proxy ids). |
| `GET` | `/v1/me/downloads` | Files kept from sessions launched with `"downloads": true` (2 days): id, session\_id, name, bytes, sha256, source url, created and expiry times. `?session_id=` for one session. |
| `GET` | `/v1/me/downloads/{id}/url` | A private link to one file, valid 15 minutes; it answers as an attachment (`application/octet-stream`). |
| `DELETE` | `/v1/me/downloads/{id}` | Delete a kept file now. |
| `GET` | `/v1/me/threads` | Your live sessions with running time and deadline. |
| `DELETE` | `/v1/me/threads/{sessionId}` | End one of your live sessions now. |

```sh
curl -s https://cdpfleet.com/v1/me/usage -H "x-api-key: $CDPFLEET_API_KEY"
```

## What it's for

-   **A usage dashboard or a budget check before a big job:** `GET /v1/me/usage` returns `remaining_thread_seconds` for the day and `hour_remaining_thread_seconds` for the rolling hour on shared plans; skip or slow a batch when they run low instead of collecting `429`s.
-   **Cost allocation per client or project:** `GET /v1/me/bandwidth.csv?days=30` gives one row per day, session, host and proxy — join `session_id` with your own job log to charge traffic to the team that caused it, or find the hosts worth moving to a cheaper proxy.
-   **Ending stuck sessions:** a watchdog lists `GET /v1/me/threads` and ends anything running past your own deadline with `DELETE /v1/me/threads/{sessionId}` — useful when a worker crashed with a browser still open.
-   **Balance alerts:** poll `GET /v1/me/proxy-balance` and alert when `balance_usd` falls below a threshold; when `allowed` turns false, launches with a `cdpfleet-resi` proxy are refused until you top up.
-   **Collecting results after the fact:** recordings (`/v1/me/recordings`) and kept downloads (`/v1/me/downloads`) can be fetched by a script once a session has ended.

```sh
# End every session that has been running for more than 30 minutes
curl -s https://cdpfleet.com/v1/me/threads -H "x-api-key: $CDPFLEET_API_KEY" |
  jq -r '.threads[] | select(.running_seconds > 1800) | .session_id' |
  xargs -I{} curl -s -X DELETE https://cdpfleet.com/v1/me/threads/{} -H "x-api-key: $CDPFLEET_API_KEY"
```

---
Source: https://cdpfleet.com/docs/api · Markdown: https://cdpfleet.com/docs/api.md · All docs for AI tools: https://cdpfleet.com/llms.txt
