Core concepts
Idempotency
Make retries safe with the Idempotency-Key header: where it is required or optional, the key format, how long a key lasts, and what a reused key returns.
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.
# Idempotency
> Make retries safe with the Idempotency-Key header: where it is required or optional, the key format, how long a key lasts, and what a reused key returns.
- Human-readable page: https://dashboard.sproutsdata.ai/docs/guides/idempotency
- This document: https://dashboard.sproutsdata.ai/docs/agents/guides/idempotency
- Index of every agent document: https://dashboard.sproutsdata.ai/llms.txt
- API base URL: https://api.sproutsdata.ai
## Summary
`Idempotency-Key` request header: a client-chosen value, resent unchanged on retries, so a retried request returns the first result instead of repeating (and re-charging) the work.
## Where it applies
| Route | Header | Retry with the same key |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `POST /v1/enrichment/jobs` | required (400 `request.invalid` if missing) | Returns the job the key started. Same key with a different job body: 409 `enrichment.idempotency_key_reused`. |
| `POST /v1/enrichment/lookups` | optional | Returns the first answer; charged once. |
| `POST /tools/v1/runs` | optional | Returns the first run (with output) for 24 hours; after 24 hours the key starts a new run. |
| `POST /v1/search`, `POST /v1/similar`, `POST /v1/entities/*`, `POST /v1/relationships`, `/reach`, `/institutions`, `/ask`, `POST /v1/org-chart`, `/departments`, `/locations`, `/people` | optional | Charged once when key, method, path, body, credential and UTC day all match; the retry reports `meta.credits_charged: 0`. Same key, same credential, same UTC day, different method, path or body: 409 `idempotency.conflict`, nothing run or charged. |
| `POST /v1/feedback` | optional | Returns the existing feedback with 200 instead of 201. |
| All other routes | ignored | Not applicable. `GET` routes are safe to retry. |
`POST /v1/agents/runs` reads no key: every start is a new run. After no answer, 500 or 504 on a start, `GET /v1/agents/runs` before starting again.
The header also appears on the free `POST /v1/relationships/institutions/lookup` and `GET /v1/org-chart/taxonomy`; it has no effect there.
## Key format
| Routes | Allowed |
| --------------------------------------------- | ------------------------------------------ |
| Tool runs, billed reads | 1 to 120 characters from `[A-Za-z0-9._:-]` |
| Enrichment jobs, enrichment lookups, feedback | at most 255 characters |
- Invalid key: `request.invalid`, 422 (400 on `POST /v1/enrichment/jobs`). Nothing runs.
- Keys are never truncated.
- Use a UUID v4 per intent.
## Conflicts
| Status | Code | Cause |
| ------ | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| 409 | `idempotency.conflict` | Billed read: key already used today, by this credential, for a different request (method, path or body). A failed request does not keep its key. |
| 409 | `enrichment.idempotency_key_reused` | Key already started a different enrichment job. |
| 409 | `tools.idempotency_key_reused` | Key started another tool's run, or another caller's, in the last 24 hours. |
| 409 | `tools.idempotency_conflict` | Key already used for a different tool or input, or by another key or person in the workspace. |
Action for all: generate a new key for new work; reuse a key only to retry the identical request.
## Rules
- Create the key when deciding to do the work; persist it with that work; reuse it on every retry, including after a restart.
- Never reuse a key for different work. A new key on a retry is a new request and may be charged again.
- Billed-read retries are free only on the same UTC day.
- If `POST /tools/v1/runs` times out (504 `upstream.timeout`), check `GET /tools/v1/runs` before starting another, or retry with the same key.
## See also
- `https://dashboard.sproutsdata.ai/docs/agents/guides/errors`
- `https://dashboard.sproutsdata.ai/docs/agents/guides/rate-limits`
- `https://dashboard.sproutsdata.ai/docs/agents/guides/agent-runs`
- `https://dashboard.sproutsdata.ai/docs/agents/guides/enrichment`
- `https://dashboard.sproutsdata.ai/docs/agents/guides/tools`