Guides
Tools API
Run tools that fetch live data from websites and public sources, such as an Amazon product's current listing, priced before every run.
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.
# Tools API
> Run tools that fetch live data from websites and public sources, such as an Amazon product's current listing, priced before every run.
- Human-readable page: https://dashboard.sproutsdata.ai/docs/guides/tools
- This document: https://dashboard.sproutsdata.ai/docs/agents/guides/tools
- Index of every agent document: https://dashboard.sproutsdata.ai/llms.txt
- API base URL: https://api.sproutsdata.ai
## Summary
The Tools API (`/tools/v1`, versioned apart from `/v1`, same API key) is a catalog of tools that each fetch live data from one public source and return a structured record, e.g. `amazon/product` (an Amazon product's current listing by `asin` or `url`). Find a tool, read its `input_schema`, quote it, run it, read the output. Billed per 10 records returned, rounded up (a single-response tool: per call), only for `succeeded` runs. Tools have no paging; a run returns all its records in one answer (up to its `limit` input, max 5,000 for a list tool).
## Rules
- Scopes: `dsp.tools.read` for categories, groups, tools, tool detail, quotes, and reading/listing runs and events. `dsp.tools.write` for starting, cancelling and deleting runs.
- Tool id: `<group>/<name>` (each a lowercase slug, whole id max 80 chars), two path segments, e.g. `GET /tools/v1/tools/amazon/product`.
- Catalog (free): `GET /tools/v1/categories` → `items[{slug, name, tool_count}]`. `GET /tools/v1/groups?category=&q=` → `count`, `items[{slug, name, summary, logo, category, tool_count, min_credits}]`. `GET /tools/v1/groups/{slug}` → group plus `tools`. `GET /tools/v1/tools?category=&group=&q=&limit=` → `count`, `items[ToolSummary]`; with `q` (plain-language need, max 500 chars) ranked by relevance (best 50 by default); without it every listed tool ordered by category, group, name; `limit` 1 to 500.
- Tool detail `GET /tools/v1/tools/{tool_id}`: `id`, `name`, `summary`, `description`, `category`, `group`, `tags`, `input_schema` (JSON Schema for `input`), `output_schema`, `example_output`, `price` (`basis` `per_10_records` or `per_call`, `credits` per 10 records or per call, `record_block`, `max_credits`, `charged`), `latency` (`typical_seconds`, `max_seconds`), `mode` (`sync` | `async`), `status` (`enabled` | `hidden` | `paused` | `retired`), `available` (can run now), `personal_data`, `alternatives` (other tool ids in the group). Retired, paused and hidden tools still answer by id.
- `amazon/product` input: exactly one of `url` (string, uri, `^https://(www\.)?amazon\.com/[^\s]*$`, max 2,000) or `asin` (string, `^[A-Z0-9]{10}$`); no other properties.
- Quote `POST /tools/v1/tools/{tool_id}/quote` body `{"input": {...}}` → `tool`, `price`, `max_credits` (the most this input can cost = what a run holds), `available`. Free; runs nothing.
- Run `POST /tools/v1/runs` body `{"tool": "<id>", "input": {...}, "wait_seconds": N}`. Waits up to `wait_seconds` (default 10; capped at 20). 200 = finished within the wait (any final status). 202 = still going; `Location: /tools/v1/runs/{run_id}`, `Retry-After: 2`; poll `GET /tools/v1/runs/{run_id}`.
- Run `Idempotency-Key`: optional, 1 to 120 chars `[A-Za-z0-9._:-]` (else 422). Live 24 hours: a repeat returns the first run (`replayed: true`), no new run, no new charge. After 24 h the key starts a new run. Same key for another tool or another credential: 409 `tools.idempotency_key_reused`. Same key with a different input: 409 `tools.idempotency_conflict`.
- Run statuses: `queued`, `running` (in progress); final: `succeeded` (output present), `no_match`, `rejected`, `failed` (`error: {code, message}`), `cancelled`, `expired`, `unresolved` (outcome could not be confirmed; reviewed by hand).
- Run fields: `run_id` (`run_<32 hex>`), `tool`, `status`, `input`, `output` (once succeeded), `error`, `units`, `units_bound`, `billable_units`, `cost` (`credits_charged`: 0 until settled; `price_credits`: null until settled), `created_at`, `deadline_at`, `completed_at`, `latency_ms`, `queue_position`, `queue_reason` (`capacity` | `paused`), `estimated_start_seconds`, `replayed`, `payload_expires_at`, `payload_deleted`. `meta.credits_charged` appears once settled.
- Billing: the quote's maximum (ceil(units bound / 10) × `price.credits`) is HELD before the run is queued; 402 `credits.insufficient` if not covered. Only `succeeded` is charged: ceil(`billable_units` / 10) × `price.credits` (10 records = 1×, 11 = 2×, 50 = 5×), never more than held. All other outcomes: nothing charged, hold released. Recorded in usage history as `action_type` `dsp.tools.run` (history `id` = the run id).
- Input not matching `input_schema`: 422 `tools.input_invalid`, nothing runs, nothing charged.
- Events `GET /tools/v1/runs/{run_id}/events` (JSON, not a stream) → `run_id`, `items[{type, status, at}]`; `type` ∈ `queued`, `starting`, `running`, `retry_scheduled`, `waiting`, `cancel_requested`, `finished`.
- Cancel `POST /tools/v1/runs/{run_id}/cancel` → run, now `cancelled`, costs nothing. Already finished: 409 `tools.run_finished`.
- Delete `DELETE /tools/v1/runs/{run_id}` → 204; removes input and output; the run stays listed with status and cost and `payload_deleted: true`. Queued or running: 409 `tools.run_in_flight` (cancel first). `unresolved`: 409 `tools.run_unresolved`. Repeat delete: no-op.
- List `GET /tools/v1/runs?tool=&status=&limit=&cursor=`: newest first, without output; `limit` 1 to 100, default 20; `cursor` = `next_cursor` (a run id). Visibility: a key sees its own runs; a signed-in person their own and their keys'; a workspace admin every run of the workspace.
- Input and output are deleted automatically at `payload_expires_at`.
- 504 `upstream.timeout` on a start: the run may still be queued. Retry with the same `Idempotency-Key` or list runs before starting another.
- Body limit 64 KiB: 413 `request.too_large`.
## Steps
1. `GET /tools/v1/tools?q=<need>`; pick an `id`.
2. `GET /tools/v1/tools/{id}`; build `input` from `input_schema`; check `available`.
3. `POST /tools/v1/tools/{id}/quote` with `{"input": ...}`; check `max_credits`.
4. `POST /tools/v1/runs` with `Idempotency-Key`, `{"tool": id, "input": ..., "wait_seconds": 20}`.
5. If 202 or `status` in (`queued`, `running`): poll `GET /tools/v1/runs/{run_id}` every 2 s until final.
6. `succeeded` → read `output`; otherwise read `status` and `error`.
## Examples
```json
{
"tool": "amazon/product",
"input": { "asin": "B0CP9YB3Q4" },
"wait_seconds": 20
}
```
## Operations
### GET /tools/v1/tools
List Tools
- URL: `GET https://api.sproutsdata.ai/tools/v1/tools`
- Scopes (any one): `dsp.tools.read`
- Cost: free
Listed tools. With `q`, ranked by relevance to a plain-language need;
without it, ordered by category, group and name. This is what an agent uses
to find a tool.
Query parameters:
- `category` (string or null): Limits: at most 40 characters.
- `group` (string or null): Limits: at most 40 characters.
- `q` (string or null): Limits: 1 to 500 characters.
- `limit` (integer): Default `50`. Limits: 1 to 500.
Response 200 (application/json): Successful Response
Response fields:
- `count` (integer, required)
- `items` (array of object, required)
- `available` (boolean, required)
- `category` (string, required)
- `group` (string, required)
- `id` (string, required)
- `latency` (object, required)
- `max_seconds` (integer, required)
- `typical_seconds` (integer, required)
- `name` (string, required)
- `personal_data` (boolean, required)
- `price` (object, required): What a run costs, before it is made.
- `basis` (string, required): `per_10_records`: `credits` is the price of `record_block` (10) records the tool returns; a run is charged per 10 records returned, rounded up (11 records cost it twice). `per_call`: a tool that answers with one record, `credits` a call. `max_credits` is the most a run can be charged. One of: `"per_10_records"`, `"per_call"`.
- `charged` (boolean, required)
- `credits` (number, required)
- `max_credits` (number, required)
- `record_block` (integer): Records one price buys: 10.
- `summary` (string, required)
- `tags` (array of string, required)
Errors:
- 401: No usable credential (`auth.unauthorized`).
- 403: Not allowed: the workspace (`auth.tenant_not_allowed`) or the key's scope.
- 422: Validation Error
- 429: Too many requests (`rate_limit.exceeded`), runs in flight (`tools.too_many_runs`) or today's spend (`tools.spend_cap_exceeded`).
- 501: Tools are not served by this deployment (`not_implemented`).
- 503: Tools could not be reached (`upstream.unavailable`), or a tool is switched off (`tools.tool_disabled`, `service.unavailable`).
- 504: Tools did not answer in time (`upstream.timeout`). A run may still finish.
Example request:
```bash
curl "https://api.sproutsdata.ai/tools/v1/tools?group=amazon" \
-H "X-API-Key: $SPROUTS_API_KEY"
```
### POST /tools/v1/runs
Start Run
- URL: `POST https://api.sproutsdata.ai/tools/v1/runs`
- Scopes (any one): `dsp.tools.write`
- Cost: billed: an answer with results spends credits, an empty one is free
- Idempotency-Key header: optional
Run one tool once.
Answers 200 when the run finished within `wait_seconds` (any final status:
`succeeded`, `no_match`, `failed` and so on), else 202 with the run so far
and a `Location` to poll. Refusals before the run is queued (bad input, a
switched-off tool, the spend cap, too many runs in flight) are RFC 9457
errors.
Send `Idempotency-Key` to make a retry safe: a repeated key returns the
first run and never runs the tool again.
Headers:
- `Idempotency-Key` (string): Send one to make a retry safe: a retry with the same key on the same UTC day is charged once.
Request body (JSON, required):
- `tool` (string, required): Limits: at most 80 characters.
- `input` (object)
- `wait_seconds` (number or null): Limits: at least 0.
Response 200 (application/json): Successful Response
Response fields:
- `cost` (object, required)
- `credits_charged` (number, required)
- `price_credits` (number or null, required)
- `created_at` (string (date-time), required)
- `deadline_at` (string (date-time), required)
- `run_id` (string, required)
- `status` (string, required): One of: `"queued"`, `"running"`, `"succeeded"`, `"no_match"`, `"rejected"`, `"failed"`, `"unresolved"`, `"cancelled"`, `"expired"`.
- `tool` (string, required)
- `units` (integer, required)
- `billable_units` (integer or null)
- `completed_at` (string (date-time) or null)
- `error` (object or null)
- `code` (string, required)
- `message` (string, required)
- `estimated_start_seconds` (integer or null)
- `input` (object or null)
- `latency_ms` (integer or null)
- `output` (any)
- `payload_deleted` (boolean): Default `false`.
- `payload_expires_at` (string (date-time) or null)
- `queue_position` (integer or null)
- `queue_reason` (string or null): One of: `"capacity"`, `"paused"`.
- `replayed` (boolean): Default `false`.
- `synthetic` (boolean): Default `false`.
- `units_bound` (integer or null)
Errors:
- 401: No usable credential (`auth.unauthorized`).
- 403: Not allowed: the workspace (`auth.tenant_not_allowed`) or the key's scope.
- 404: No such tool, group or run for this workspace (`tools.*_not_found`).
- 409: A finished run (`tools.run_finished`), or an Idempotency-Key reused for another input (`tools.idempotency_conflict`).
- 410: A retired tool (`tools.tool_disabled`).
- 413: The body is too large (`request.too_large`).
- 422: Validation Error
- 429: Too many requests (`rate_limit.exceeded`), runs in flight (`tools.too_many_runs`) or today's spend (`tools.spend_cap_exceeded`).
- 501: Tools are not served by this deployment (`not_implemented`).
- 503: Tools could not be reached (`upstream.unavailable`), or a tool is switched off (`tools.tool_disabled`, `service.unavailable`).
- 504: Tools did not answer in time (`upstream.timeout`). A run may still finish.
Example request:
```bash
curl -X POST "https://api.sproutsdata.ai/tools/v1/runs" \
-H "X-API-Key: $SPROUTS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"tool": "amazon/product",
"input": {
"asin": "B0CP9YB3Q4"
},
"wait_seconds": 20
}'
```
### GET /tools/v1/runs
List Runs
- URL: `GET https://api.sproutsdata.ai/tools/v1/runs`
- Scopes (any one): `dsp.tools.read`
- Cost: free
The caller's own runs, newest first, without their output. Only the credential that started a run can see it, as with usage history.
Query parameters:
- `tool` (string or null): Limits: at most 80 characters.
- `status` (string or null): Limits: at most 16 characters.
- `limit` (integer): Default `20`. Limits: 1 to 100.
- `cursor` (string or null): Limits: at most 40 characters.
Response 200 (application/json): Successful Response
Response fields:
- `items` (array of object, required)
- `cost` (object, required)
- `credits_charged` (number, required)
- `price_credits` (number or null, required)
- `created_at` (string (date-time), required)
- `deadline_at` (string (date-time), required)
- `run_id` (string, required)
- `status` (string, required): One of: `"queued"`, `"running"`, `"succeeded"`, `"no_match"`, `"rejected"`, `"failed"`, `"unresolved"`, `"cancelled"`, `"expired"`.
- `tool` (string, required)
- `units` (integer, required)
- `billable_units` (integer or null)
- `completed_at` (string (date-time) or null)
- `error` (object or null)
- `code` (string, required)
- `message` (string, required)
- `estimated_start_seconds` (integer or null)
- `input` (object or null)
- `latency_ms` (integer or null)
- `output` (any)
- `payload_deleted` (boolean): Default `false`.
- `payload_expires_at` (string (date-time) or null)
- `queue_position` (integer or null)
- `queue_reason` (string or null): One of: `"capacity"`, `"paused"`.
- `replayed` (boolean): Default `false`.
- `synthetic` (boolean): Default `false`.
- `units_bound` (integer or null)
- `next_cursor` (string or null)
Errors:
- 401: No usable credential (`auth.unauthorized`).
- 403: Not allowed: the workspace (`auth.tenant_not_allowed`) or the key's scope.
- 422: Validation Error
- 429: Too many requests (`rate_limit.exceeded`), runs in flight (`tools.too_many_runs`) or today's spend (`tools.spend_cap_exceeded`).
- 501: Tools are not served by this deployment (`not_implemented`).
- 503: Tools could not be reached (`upstream.unavailable`), or a tool is switched off (`tools.tool_disabled`, `service.unavailable`).
- 504: Tools did not answer in time (`upstream.timeout`). A run may still finish.
Example request:
```bash
curl "https://api.sproutsdata.ai/tools/v1/runs?limit=20" \
-H "X-API-Key: $SPROUTS_API_KEY"
```
### GET /tools/v1/categories
List Categories
- URL: `GET https://api.sproutsdata.ai/tools/v1/categories`
- Scopes (any one): `dsp.tools.read`
- Cost: free
Categories with at least one listed tool, for the sidebar.
Response 200 (application/json): Successful Response
Response fields:
- `items` (array of object, required)
- `name` (string, required)
- `slug` (string, required)
- `tool_count` (integer, required)
Errors:
- 401: No usable credential (`auth.unauthorized`).
- 403: Not allowed: the workspace (`auth.tenant_not_allowed`) or the key's scope.
- 429: Too many requests (`rate_limit.exceeded`), runs in flight (`tools.too_many_runs`) or today's spend (`tools.spend_cap_exceeded`).
- 501: Tools are not served by this deployment (`not_implemented`).
- 503: Tools could not be reached (`upstream.unavailable`), or a tool is switched off (`tools.tool_disabled`, `service.unavailable`).
- 504: Tools did not answer in time (`upstream.timeout`). A run may still finish.
Example request:
```bash
curl "https://api.sproutsdata.ai/tools/v1/categories" \
-H "X-API-Key: $SPROUTS_API_KEY"
```
### GET /tools/v1/groups
List Groups
- URL: `GET https://api.sproutsdata.ai/tools/v1/groups`
- Scopes (any one): `dsp.tools.read`
- Cost: free
The cards on the Tools page. `q` keeps groups whose name or tools match.
Query parameters:
- `category` (string or null): Limits: at most 40 characters.
- `q` (string or null): Limits: 1 to 200 characters.
Response 200 (application/json): Successful Response
Response fields:
- `count` (integer, required)
- `items` (array of object, required)
- `category` (string, required)
- `min_credits` (number, required)
- `name` (string, required)
- `slug` (string, required)
- `summary` (string, required)
- `tool_count` (integer, required)
- `logo` (string or null)
Errors:
- 401: No usable credential (`auth.unauthorized`).
- 403: Not allowed: the workspace (`auth.tenant_not_allowed`) or the key's scope.
- 422: Validation Error
- 429: Too many requests (`rate_limit.exceeded`), runs in flight (`tools.too_many_runs`) or today's spend (`tools.spend_cap_exceeded`).
- 501: Tools are not served by this deployment (`not_implemented`).
- 503: Tools could not be reached (`upstream.unavailable`), or a tool is switched off (`tools.tool_disabled`, `service.unavailable`).
- 504: Tools did not answer in time (`upstream.timeout`). A run may still finish.
Example request:
```bash
curl "https://api.sproutsdata.ai/tools/v1/groups?category=e-commerce" \
-H "X-API-Key: $SPROUTS_API_KEY"
```
The routes with a path parameter (tool detail, quote, run read, events, cancel, delete, group detail) are specified in full at https://dashboard.sproutsdata.ai/docs/agents/api-reference/tools-catalog and https://dashboard.sproutsdata.ai/docs/agents/api-reference/tools-runs
## Errors to handle
- 402 `credits.insufficient`: the hold is not covered.
- 404 `tools.tool_not_found`, `tools.group_not_found`, `tools.run_not_found`.
- 409 `tools.idempotency_key_reused`, `tools.idempotency_conflict`, `tools.run_finished`, `tools.run_in_flight`, `tools.run_unresolved`.
- 410 `tools.tool_disabled`: the tool is retired.
- 413 `request.too_large`: body over 64 KiB.
- 422 `tools.input_invalid` (input vs `input_schema`), `request.invalid`.
- 429 `tools.too_many_runs` (workspace runs in flight; wait for one to end), `tools.spend_cap_exceeded` (the day's Tools spending limit; `Retry-After` = until reset), `quota.burst_exceeded` (rate limit).
- 503 `tools.tool_disabled` (paused), `tools.not_priced` (no price: cannot run), `upstream.unavailable`.
- 504 `upstream.timeout`: a run may still finish; do not start a duplicate.
## See also
- https://dashboard.sproutsdata.ai/docs/agents/api-reference/tools-catalog
- https://dashboard.sproutsdata.ai/docs/agents/api-reference/tools-runs
- https://dashboard.sproutsdata.ai/docs/agents/guides/usage-history
- https://dashboard.sproutsdata.ai/docs/agents/guides/credits