Guides
Usage history
See which billable calls were made, by which credential, how they ended and what they cost, replay a past search for free, and read daily totals.
This edition is written for AI agents: complete, explicit and ready to paste. Give it to your agent, or point the agent at its address and it reads the page itself.
# Usage history
> See which billable calls were made, by which credential, how they ended and what they cost, replay a past search for free, and read daily totals.
- Human-readable page: https://dashboard.sproutsdata.ai/docs/guides/usage-history
- This document: https://dashboard.sproutsdata.ai/docs/agents/guides/usage-history
- Index of every agent document: https://dashboard.sproutsdata.ai/llms.txt
- API base URL: https://api.sproutsdata.ai
## Summary
The usage history records every billable call: kind, time, credential type, outcome, cost. Three free routes, all needing `dsp.usage.read`: list runs (`GET /v1/usage/history`), one run's detail with a free replay of a search's first page (`GET /v1/usage/history/{run_id}`), and daily totals (`GET /v1/usage/metrics`).
## Rules
- Visibility: an API key sees only its own runs. A signed-in person or OAuth client sees the person's own runs plus runs of API keys the person created. A workspace admin sees every run of the workspace.
- Recorded calls (`action_type`): `dsp.search`, `dsp.similar`, `dsp.entities`, `dsp.relationships`, `dsp.org_chart`, `dsp.agents`, `dsp.enrichment`, `dsp.tools.run`. Free reads (lists, usage, credits, feedback, vocabularies) are not recorded.
- `GET /v1/usage/history` query: `action_type` (max 32 chars, exact match), `from` and `to` (ISO 8601 datetimes; default window = last 30 days ending now; max window 90 days; `from` must be before `to`), `limit` (1 to 100, default 25), `cursor` (max 200 chars, from `next_cursor`). Newest first. `next_cursor` is null on the last page. Retention 90 days; a window starting earlier: 422 `request.invalid`.
- Run summary fields: `id` (string; numeric for most runs, the Tools run id `run_<32 hex>` for `dsp.tools.run`), `occurred_at`, `action_type`, `actor_type`, `status` (`pending` | `ok` | `failed`), `error_code`, `query`, `result_count`, `credits_charged` (decimal string, or null when not metered), `latency_ms`. `environment` is deprecated and always `live`.
- Long-running work (agent runs, enrichment, Tools runs) is recorded `pending` at start and updated with outcome and cost when settled. A pending run that can no longer be running reads `status: "failed"`, `error_code: "unsettled"`.
- `GET /v1/usage/history/{run_id}`: `run_id` matches `^(?:[0-9]{1,19}|run_[0-9a-f]{32})$`. Adds `request` (as sent), `resolved_search` (as served), `snapshot`, `snapshot_state`: `present` (first page of a search: `snapshot.results` = that page's records looked up again, free and current, may differ slightly from what was served), `continuation` (a later page; no snapshot), `absent` (nothing to replay). Not visible or older than 90 days: 404 `history.not_found`.
- `GET /v1/usage/metrics` query: `from`, `to` (same rules). Returns `period_from`, `period_to`, `total_requests`, `total_ok`, `total_failed`, `total_pending`, `total_credits` (decimal string), `buckets[]` (`day`, `action_type`, `requests`, `ok`, `failed`, `pending`, `credits`). Same visibility as history.
- Use `meta.request_id` / run ids from history as `subject_ref` when reporting feedback.
## Operations
### GET /v1/usage/history
History
- URL: `GET https://api.sproutsdata.ai/v1/usage/history`
- Scopes (any one): `dsp.usage.read`
- Cost: free
Your recent runs, newest first.
Query parameters:
- `cursor` (string or null): Limits: at most 200 characters.
- `limit` (integer): Default `25`. Limits: 1 to 100.
- `action_type` (string or null): Limits: at most 32 characters.
- `from` (string (date-time) or null)
- `to` (string (date-time) or null)
Response 200 (application/json): Successful Response
Response fields:
- `next_cursor` (string or null, required)
- `results` (array of object, required)
- `action_type` (string, required)
- `actor_type` (string, required)
- `credits_charged` (string or null, required)
- `error_code` (string or null, required)
- `id` (string, required)
- `latency_ms` (integer or null, required)
- `occurred_at` (string (date-time), required)
- `query` (string or null, required)
- `result_count` (integer or null, required)
- `status` (string, required): One of: `"pending"`, `"ok"`, `"failed"`.
- `environment` (string): One of: `"live"`. Default `"live"`.
Errors:
- 401: No credential, or one that does not verify (`auth.unauthorized`).
- 403: The credential lacks the scope this route needs (`auth.insufficient_scope`), or the signed-in user has not chosen a workspace (`auth.workspace_required`).
- 404: No such resource for this workspace (`*.not_found`), or no such route (`route.not_found`).
- 422: The request is invalid (`request.invalid`), or its cursor is (`pagination.*`).
- 429: Too many requests for this key or workspace (`quota.burst_exceeded`). See `Retry-After`.
- 503: A service this request needs is unavailable, or the API is at capacity. See `Retry-After`.
Example request:
```bash
curl "https://api.sproutsdata.ai/v1/usage/history?limit=20" \
-H "X-API-Key: $SPROUTS_API_KEY"
```
### GET /v1/usage/metrics
Metrics
- URL: `GET https://api.sproutsdata.ai/v1/usage/metrics`
- Scopes (any one): `dsp.usage.read`
- Cost: free
Your run counts, outcomes and credits per day.
Query parameters:
- `from` (string (date-time) or null)
- `to` (string (date-time) or null)
Response 200 (application/json): Successful Response
Response fields:
- `buckets` (array of object, required)
- `action_type` (string, required)
- `credits` (string, required)
- `day` (string (date), required)
- `failed` (integer, required)
- `ok` (integer, required)
- `pending` (integer, required)
- `requests` (integer, required)
- `period_from` (string (date-time), required)
- `period_to` (string (date-time), required)
- `total_credits` (string, required)
- `total_failed` (integer, required)
- `total_ok` (integer, required)
- `total_pending` (integer, required)
- `total_requests` (integer, required)
Errors:
- 401: No credential, or one that does not verify (`auth.unauthorized`).
- 403: The credential lacks the scope this route needs (`auth.insufficient_scope`), or the signed-in user has not chosen a workspace (`auth.workspace_required`).
- 404: No such resource for this workspace (`*.not_found`), or no such route (`route.not_found`).
- 422: The request is invalid (`request.invalid`), or its cursor is (`pagination.*`).
- 429: Too many requests for this key or workspace (`quota.burst_exceeded`). See `Retry-After`.
- 503: A service this request needs is unavailable, or the API is at capacity. See `Retry-After`.
Example request:
```bash
curl "https://api.sproutsdata.ai/v1/usage/metrics" \
-H "X-API-Key: $SPROUTS_API_KEY"
```
The detail route `GET /v1/usage/history/{run_id}` is specified in full at https://dashboard.sproutsdata.ai/docs/agents/api-reference/usage-history
## Errors to handle
- 403 `auth.insufficient_scope`: the credential lacks `dsp.usage.read`.
- 404 `history.not_found`: not visible to this caller, or past retention.
- 422 `request.invalid`: bad window (`from` ≥ `to`, over 90 days, or before retention) or cursor.
- 429 `quota.burst_exceeded`: rate limit; wait `Retry-After`.
## See also
- https://dashboard.sproutsdata.ai/docs/agents/api-reference/usage-history
- https://dashboard.sproutsdata.ai/docs/agents/guides/credits
- https://dashboard.sproutsdata.ai/docs/agents/guides/feedback