# Autosheet API - **OpenAPI Version:** `3.1.0` - **API Version:** `1.0.0` > **Preview** — The Autosheet API is in preview and may change. If you run into issues, contact [Autosheet support](https://autosheet.com/support). Use the Autosheet API to run a **spreadsheet agent** programmatically — perform AI-driven enrichment, analysis, edits, and transformations across spreadsheets from your AI agent, workflow tool, or code. Autosheet is built on the same agent engine that powers the [Agent in GPT for Sheets – Autosheet](https://autosheet.com/docs/gpt-for-sheets/agent). ## Get started To start using the Autosheet API: 1. **Sign in to the [Autosheet dashboard](https://dashboard.autosheet.com) with your Google account.** > **Note** — Make sure your space has [credits remaining](https://autosheet.com/docs/api#description/credits). 2. **Authorize GPT for Sheets – Autosheet.** In the dashboard sidebar, select **Autosheet API > API keys**. If you see **Connect to Google**, click it and follow the on-screen prompts to authorize GPT for Sheets – Autosheet. 3. **Create an API key.** Enter a descriptive name for the key, click **Create**, and copy the generated key — it will not be shown again. 4. [**Make a copy of our sample spreadsheet.**](https://docs.google.com/spreadsheets/d/1mGKj92RmNEm_FeZudRs6ExBFMTdlvTWtwC38rhUMC0I/copy) Copy the spreadsheet ID — the text string between `/d/` and `/edit` in the URL. 5. **Run your first task.** Open your terminal and enter the following command — with your API key and spreadsheet ID filled in. ```curl curl https://api.autosheet.com/v1/sheets/agents \ --request POST \ --header 'Content-Type: application/json' \ --header 'X-API-Key: ' \ --data '{ "spreadsheet_id": "", "prompt": "Score these leads against our scoring rules." }' ``` In the API response, the top-level `id` field is the agent ID. Copy it for later. 6. **Watch the agent work.** Open the sample spreadsheet and wait for the agent to finish. 7. **(Optional) Check the agent's status.** If you want to poll the agent while it's working on your request, enter the following command in your terminal — with the agent ID and your API key filled in. ```curl curl https://api.autosheet.com/v1/sheets/agents/ \ --header 'X-API-Key: ' ``` The agent has finished when, in the response, the top-level `status` returns to `idle` and `error_message` is `null`. Read the agent's replies from the ordered `messages` array (the last `assistant_message` entry is its final answer). ## Use with a coding agent If you want a coding agent (such as Claude Code, Codex, or Cursor) to scaffold a small script against this API, paste the prompt below into your agent. The prompt primes the agent on the API and asks it to build a script that submits a task, polls for progress, and prints the result. ```markdown # Get started with the Autosheet API **What this is:** A starter prompt to drop into an AI coding agent (such as Claude Code, Codex, or Cursor) so it builds you a small script that runs an Autosheet task against your Google Sheet. **You'll need:** An Autosheet API key, the URL of a Google Sheet, and a prompt describing what you want done. The agent will ask for whatever's missing. ## Get your API key If `$AUTOSHEET_API_KEY` is already set in your environment, the agent will pick it up. Otherwise, get one from the Autosheet dashboard at https://dashboard.autosheet.com — sign in with Google, authorize Sheets access on the **Autosheet API** page, click **Create API key**, and copy the key (it's shown only once). ## What you can do Anything Autosheet can do on a sheet — enrich rows, fill columns, dedupe, translate, score. A few examples: - "Fill CEO, headcount, recent news and fit score for every company in column A." - "For each product, write a 50-word description and translate it to French." - "Dedupe these contacts by company; merge 'Acme Inc.' and 'ACME, Inc' into one row." - "Score these leads against our scoring rules." ## API reference - **Base URL:** `https://api.autosheet.com` - **Auth:** send your API key as the `X-API-Key` header on every request - **Verify key:** `GET /v1/auth/verify` - **Submit task:** `POST /v1/sheets/agents` with body `{"spreadsheet_id": "...", "prompt": "..."}` - **Poll status:** `GET /v1/sheets/agents/{id}` — done when `status` is `idle` (`error_message` is `null` on success); `messages` holds the latest turn's ordered messages, its last `assistant_message` entry being the agent's final answer - **Full history:** `GET /v1/sheets/agents/{id}/messages` — the whole conversation, cursor-paginated (`limit`, `after`) - **Cancel task:** `POST /v1/sheets/agents/{id}/stop` Full reference: - Interactive docs → https://autosheet.com/docs/api - OpenAPI spec → https://autosheet.com/docs/api/openapi.yaml --- **Now:** build a small script that submits a task, polls for progress until the agent finishes, and prints the link to the edited Google Sheet when it finishes. Ask me for the API key (only if it's not in the env), the Google Sheet URL, and the prompt. Use whatever language and HTTP client makes sense. ``` ## Authentication All endpoints require an API key in the `X-API-Key` header. API keys are scoped to your user account and inherit your Google Sheets authorization. - Keys can be created, disabled, and deleted from the [Autosheet dashboard](https://dashboard.autosheet.com). - A deleted or unrecognized key returns `401`. A disabled or revoked key returns `403`, on every endpoint including [Verify API Key](https://autosheet.com/docs/api#tag/authentication/GET/v1/auth/verify). - Use the [Verify API Key](https://autosheet.com/docs/api#tag/authentication/GET/v1/auth/verify) endpoint to test your key. ## Credits Agents consume credits from your [Autosheet space](https://autosheet.com/docs/resources/guides/concepts#space). To run an agent, your space must have credits remaining. Check your available credits in the **Remaining credits** section of the [Autosheet dashboard](https://dashboard.autosheet.com), and [buy credits](https://autosheet.com/docs/admin/billing/pay-as-you-go/buy-credits) whenever you need to top up. To see what a single task cost, read the `usage` field returned by [Get agent](https://autosheet.com/docs/api#tag/agents/GET/v1/{platform}/agents/{id}). The field reports the latest turn's usage in integer nano-dollars, split between the agent's own model calls and the tools it ran. It is a final figure — while a turn is still running it is `null`, and the running subtotal appears under `usage_so_far` instead. A turn that was cancelled or failed still reports the charges it accumulated before stopping. ## Polling Use [Get agent](https://autosheet.com/docs/api#tag/agents/GET/v1/{platform}/agents/{id}) to check an agent's progress and inspect its work. Pass the agent ID returned when you started the task: ```curl curl https://api.autosheet.com/v1/sheets/agents/ \ --header 'X-API-Key: ' ``` **Reading the result** — the response's `messages` field holds the latest turn's messages as one ordered, type-tagged array (`user_message`, `assistant_message`, `tool_call`), so you never have to merge or reorder anything. The full conversation across all turns is available from [Get agent messages](https://autosheet.com/docs/api#tag/agents/GET/v1/{platform}/agents/{id}/messages) (cursor-paginated). Each `tool_call` entry embeds its result summary (`status`, affected `range`, row counters, `completed_at`, and for web\_search the `query`/`number_of_searches`/`sources`) and updates in place as the call completes. **Done condition** — the agent has finished when the top-level `status` returns to `idle`. On success `error_message` and `error_code` are both `null`. When the turn failed or was interrupted, `error_message` carries the reason and, when available, `error_code` identifies the condition — branch on the code when present, since the message is generated copy that can change. When Stop agent cancels an active turn, it sets `error_message` to `Agent cancelled by user.` and returns `error_code: null`. **Cost while running** — `usage` is a final figure and stays `null` until the turn ends; the running subtotal is in `usage_so_far`, which is present only while the turn is active. Once the agent is `idle`, `usage_so_far` is gone and `usage` holds the total. For a turn that completed normally that total is durable; for one that failed, was interrupted, or was cancelled it comes from a short-lived accumulator and is only available for about two hours afterwards, so read it promptly rather than reconciling costs days later. **Polling frequency** — poll only as often as your workflow needs. API requests are limited to 500 requests per minute per API key. For longer-running tasks, provide a `webhook_url` when [running an agent](https://autosheet.com/docs/api#tag/agents/POST/v1/{platform}/agents) and let the webhook notify you on completion instead — see the *Webhooks* section. ## Limits and errors All three limits below return `429`, so branch on `error.code` rather than the status alone. Every `429` carries `X-RateLimit-Limit`, `X-RateLimit-Remaining`, and `X-RateLimit-Reset`; only a request-rate rejection also carries `Retry-After` and `X-RateLimit-Reset-After`. See the `429` response on [`POST /v1/{platform}/agents`](https://autosheet.com/docs/api#tag/agents/POST/v1/{platform}/agents) for the full breakdown. **Request rate limit** — 500 requests/minute per API key, code `RATE_LIMIT_EXCEEDED`. This is the one case that tells you how long to wait, via `Retry-After`. **Concurrency limit** — up to 100 active agents per API key, code `CONCURRENT_LIMIT_REACHED`. No `Retry-After`, so retry after an active agent finishes. A request rejected this way still spends one request from your per-minute budget. **Spending limits** — Agents consume credits from your [Autosheet space](https://autosheet.com/docs/resources/guides/concepts#space). You can set space-wide and user-specific spending limits in the [Autosheet dashboard](https://dashboard.autosheet.com). When a limit is reached, new agent requests are rejected with code `SPENDING_LIMIT_REACHED` and no `Retry-After` — retrying will not help until the limit is raised or the period rolls over. Every error response also carries a `request_id`, echoed as the `X-Request-Id` response header. Include it when you contact support. ## Servers - **URL:** `https://api.autosheet.com` - **Description:** Production ## Operations ### Verify API key - **Method:** `GET` - **Path:** `/v1/auth/verify` - **Tags:** Authentication Validates the provided API key and returns basic account information. Use this endpoint to confirm your key is active and your Google account is connected. #### Responses ##### Status: 200 API key is valid ###### Content-Type: application/json - **`google_connected` (required)** `boolean` Whether Google Sheets access has been authorized - **`space` (required)** `object` - **`id` (required)** `string`, format: `uuid` Space ID the key belongs to - **`name` (required)** `string | null` Space name, or `null` when the space has no name set - **`user` (required)** `object` - **`email` (required)** `string | null` Email associated with the API key owner, or `null` when no email is on record for the account. - **`valid` (required)** `boolean` Whether the API key is valid and active - **`webhook_secret` (required)** `string | null` HMAC signing secret for webhook callbacks, or `null` if this key has no secret. Use it to verify the `X-Webhook-Signature` header on incoming webhook requests — see the *Webhooks* section. **Example** ```json { "valid": true, "user": { "email": "user@example.com" }, "space": { "id": "11223344-5566-7788-99aa-bbccddeeff00", "name": "My Workspace" }, "google_connected": true, "webhook_secret": "whsec_a1b2c3d4e5f6..." } ``` ##### Status: 401 The API key is missing, malformed, or not recognized. A key that exists but has been disabled or revoked reports `403` instead — see the `403` response. ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example** ```json { "error": { "code": "INVALID_API_KEY", "message": "Invalid Autosheet API key. Create a new API key, then reconnect.", "error_code": "api-autosheet-apikey-invalid" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 403 The API key is recognized but the request cannot be served. Three families of cause, scoped to the operations documented here: - **Key state** — the key has been disabled or revoked in the dashboard. Possible on any operation. - **Google connection** — no Google account is connected to the key (possible on any operation), or the connection has expired and must be re-authorized (**[Start agent](https://autosheet.com/docs/api#tag/agents/POST/v1/{platform}/agents) only**). - **Spreadsheet access** — the connected Google account does not have editor access to the spreadsheet (**[Start agent](https://autosheet.com/docs/api#tag/agents/POST/v1/{platform}/agents) only**). The expired-connection and spreadsheet-access variants arise while resolving a spreadsheet, which only Start agent does among the operations documented here. The other documented operations can return only the key-state and not-connected causes. ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example — The key has been disabled in the dashboard** ```json { "error": { "code": "API_KEY_DISABLED", "message": "Disabled Autosheet API key. Enable a new API key at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/agent-api.", "error_code": "api-autosheet-apikey-disabled" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — The key has been revoked** ```json { "error": { "code": "API_KEY_REVOKED", "message": "Revoked Autosheet API key. Create a new API key at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/agent-api, then reconnect.", "error_code": "api-autosheet-apikey-revoked" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — No Google account has been connected yet** ```json { "error": { "code": "GOOGLE_AUTH_REQUIRED", "message": "Google account not connected. Please connect at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/agent-api", "error_code": "api-google-auth-required" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — A previously connected Google account must be reconnected (Start agent only)** ```json { "error": { "code": "GOOGLE_AUTH_REQUIRED", "message": "Google account connection expired. Reconnect at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/agent-api.", "error_code": "api-google-auth-expired" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — The connected account lacks editor access (Start agent only)** ```json { "error": { "code": "SPREADSHEET_ACCESS_DENIED", "message": "Cannot access this spreadsheet. Check that user@example.com has editor access to https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms", "error_code": "api-spreadsheet-access-denied" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 429 The request rate limit was exceeded. This endpoint skips the spending and concurrency checks, so `RATE_LIMIT_EXCEEDED` is the only `429` it can return. The limit is applied before the key is authenticated — 500 requests/minute, counted per key — so an unrecognized key is rate-limited too. **Response headers** **`X-RateLimit-Limit` (required)** — `integer` Request limit per minute **`X-RateLimit-Remaining` (required)** — `integer` Remaining requests in current window **`X-RateLimit-Reset` (required)** — `integer` Unix timestamp when the rate limit resets **`Retry-After` (required)** — `integer` Seconds to wait before retrying **`X-RateLimit-Reset-After` (required)** — `integer` Seconds until the rate-limit window resets; same value as `Retry-After` ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example** ```json { "error": { "code": "RATE_LIMIT_EXCEEDED", "message": "Rate limit exceeded. Retry after 60 seconds." }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ### Start agent - **Method:** `POST` - **Path:** `/v1/{platform}/agents` - **Tags:** Agents Creates a new agent or adds a follow-up prompt to an existing agent. **New agent** — provide `spreadsheet_id` and `prompt`. A new agent is created and starts processing automatically. **Follow-up** — also provide `agent_id` to continue a previous agent's conversation. The agent must be in `idle` status (all previous turns completed). **Webhook** — optionally provide a `webhook_url` to receive a `POST` callback when the turn completes. See the *Webhooks* section for the payload and signature contract. #### Parameters ##### `platform` required - **In:** `path` Target platform **Example** ```json "sheets" ``` `string`, possible values: `"sheets"` #### Request Body ##### Content-Type: application/json - **`prompt` (required)** `string` Natural language instruction for the agent to execute. Must be non-empty once surrounding whitespace is trimmed; an empty or whitespace-only prompt is rejected with `400 MISSING_REQUIRED_FIELD`. - **`agent_id`** `string`, format: `uuid` ID of an existing agent to continue. When provided, the prompt is added as a follow-up turn. The agent must be in `idle` status. If omitted, a new agent is created and `spreadsheet_id` becomes required. - **`agent_model`** `string` Override the default agent model. Use an `id` from the `models.agent_models` list in [List available models](https://autosheet.com/docs/api#tag/agents/GET/v1/{platform}/agents/configuration). If not specified, the space's default agent model is used. - **`bulk_model`** `string` Override the default bulk tool model. Use an `id` from the `models.bulk_models` list in [List available models](https://autosheet.com/docs/api#tag/agents/GET/v1/{platform}/agents/configuration). If not specified, the space's default bulk model is used. - **`bulk_search_model`** `string` Override the default web search model. Use an `id` from the `models.bulk_search_models` list in [List available models](https://autosheet.com/docs/api#tag/agents/GET/v1/{platform}/agents/configuration). If not specified, the space's default search model is used. - **`sheet_id`** `integer` Numeric tab id — the `gid` from a Google Sheets URL. Alternative to `sheet_name`; resolved server-side to the tab title. Rejected with `400 SPREADSHEET_TAB_NOT_FOUND` when no tab has this id — the error `message` lists the spreadsheet's tabs with their ids, so you can retry without a second round trip. When both `sheet_id` and `sheet_name` resolve but name *different* tabs, the rejection is `400 INVALID_REQUEST` instead. - **`sheet_name`** `string` Name of the sheet to operate on. Defaults to the first sheet (new agent) or the sheet from the previous turn (follow-up). - **`spreadsheet_id`** `string` Google Sheets spreadsheet ID (found in the spreadsheet URL between `/d/` and `/edit`), or the full spreadsheet URL. When a full URL carries a tab id (`#gid=N`) and neither `sheet_id` nor `sheet_name` is provided, that tab is targeted automatically. **Required** when creating a new agent (no `agent_id`). On a follow-up it does not change the agent's spreadsheet — the agent keeps the one it was created with — but it is still format-checked, so a malformed value is rejected with `400 INVALID_SPREADSHEET_ID`. - **`webhook_url`** `string`, format: `uri` Optional URL to receive a `POST` callback when the turn completes. See the *Webhooks* section for the payload and signature contract. `prompt` is always required. Alongside it, supply **either** `spreadsheet_id` (start a new agent) **or** `agent_id` (continue an existing one). Sending both is accepted — `agent_id` wins and the agent keeps its own spreadsheet. Sending neither returns `400 MISSING_REQUIRED_FIELD`. **Required alternatives (at least one must match):** - New agent (spreadsheet\_id): requires `spreadsheet_id` and `prompt`. Start a new agent on a spreadsheet — requires `spreadsheet_id`. - Follow-up (agent\_id): requires `agent_id` and `prompt`. Continue an existing agent's conversation — requires `agent_id`. **Example — Create a new agent** ```json { "spreadsheet_id": "", "prompt": "Score these leads against our scoring rules, and add a one-line explanation for each score." } ``` **Example — New agent with specific models** ```json { "spreadsheet_id": "", "prompt": "Translate all content in column B from French to English", "agent_model": "managed:agent:anthropic/claude-opus-4-6", "bulk_model": "managed:bulk:openai/gpt-4.1", "bulk_search_model": "managed:search:perplexity/sonar" } ``` **Example — Follow-up on an existing agent** ```json { "agent_id": "", "prompt": "Add a one-line explanation for each lead's score in a new 'score_reason' column." } ``` **Example — New agent with webhook callback** ```json { "spreadsheet_id": "", "prompt": "Translate all content in column B from French to English", "webhook_url": "https://example.com/webhooks/autosheet" } ``` #### Responses ##### Status: 201 Agent created or follow-up turn added ###### Content-Type: application/json - **`created_at` (required)** `string`, format: `date-time` When the agent was created - **`error_code` (required)** `string | null` Machine-readable code for the latest turn's failure, or `null` when it has not errored. Always returned. Branch on this rather than matching `error_message`, which is generated copy and can change. - **`error_message` (required)** `string | null` The latest turn's error message (failure reason), or `null` when it has not errored. `null` while the turn is still in progress (`status: active`). Always returned — errored turns produce no assistant message, so this is where failures surface. - **`error_params` (required)** `object | null` The values `error_message` was rendered with, or `null`. Always returned. Provided so you can re-render the failure in your own wording or locale instead of reusing ours. - **`id` (required)** `string`, format: `uuid` Unique agent identifier - **`last_activity_at` (required)** `string | null`, format: `date-time` When the agent last had activity - **`messages` (required)** `array` The latest turn's messages as a single ordered, type-tagged array. Always returned. The full conversation across all turns is served (paginated) by `GET /v1/{platform}/agents/{id}/messages`. **Items:** **One of:** - **`content` (required)** `string` - **`created_at` (required)** `string`, format: `date-time` - **`message_id` (required)** `string`, format: `uuid` - **`turn_id` (required)** `string`, format: `uuid` The turn this entry belongs to (groups entries by prompt execution). - **`type` (required)** `string`, possible values: `"user_message"` * **`content` (required)** `string` * **`created_at` (required)** `string`, format: `date-time` * **`message_id` (required)** `string`, format: `uuid` * **`turn_id` (required)** `string`, format: `uuid` * **`type` (required)** `string`, possible values: `"assistant_message"` **All of:** - **`turn_id` (required)** `string`, format: `uuid` The turn this entry belongs to (groups entries by prompt execution). - **`type` (required)** `string`, possible values: `"tool_call"` * **`created_at` (required)** `string`, format: `date-time` When the tool call started. * **`status` (required)** `string`, possible values: `"pending", "running", "succeeded", "failed", "cancelled"` Terminal outcomes are reported uniformly as `succeeded` or `failed` for every tool; for bulk tools, `succeeded` means the run finished with no row failures — which includes a run that wrote nothing because every target cell was already populated, so `rows.processed` can legitimately be `0`. A call the user cancelled mid-turn reports `cancelled`. * **`tool` (required)** `string` Name of the tool that was called * **`tool_call_id` (required)** `string`, format: `uuid` Tool-call identifier. * **`cells`** `integer` Number of cells the call touched: cells written for write\_range/write\_cells, and the source-range cell count for copy\_paste\_range (omitted when that range is unbounded). * **`column`** `string` add\_column\_header: the column the header was written to. Not returned for bulk tools, which report the written range as `updated_range`. * **`completed_at`** `string | null`, format: `date-time` When the tool call reached a terminal status. Omitted while the call is still `pending`/`running`. * **`fields`** `string` read\_spreadsheet\_fields: the requested field mask. * **`message`** `string` Result message from the tool call. Present **only** on a `failed` call, where it carries the failure reason; omitted for every other status. * **`number_of_searches`** `integer` web\_search: how many searches the tool ran. Each is a billed unit. * **`paste_type`** `string` copy\_paste\_range: the paste behaviour. * **`prompt_template`** `string` Bulk tools: the per-row prompt template (column refs as `{{A}}`). * **`query`** `string` web\_search: the query searched for (the tool's prompt). * **`range`** `string` Affected range. For read\_range/read\_cells/write\_range/write\_cells the sheet prefix is removed (see `sheet_name`); add\_column\_header can retain it. Not returned for bulk tools, which use `updated_range`, nor copy\_paste\_range, which uses `source_range`/`target_range`. * **`read`** `object` read\_range / read\_cells: the dimensions of the data returned — counts only, never cell contents. Totals span every sheet the read covered. `cells` counts the cells actually returned, so it is not necessarily `rows × columns` (the Sheets API omits trailing empties) — useful for spotting a silently truncated read. - **`cells` (required)** `integer` Cells actually returned. - **`columns` (required)** `integer` Distinct columns per sheet, summed across the sheets the read spanned. - **`rows` (required)** `integer` Distinct rows per sheet, summed across the sheets the read spanned. - **`sheets` (required)** `integer` Number of sheets the returned data spans. * **`rows`** `object` Bulk tools only: row counters. Absent for non-bulk tools. Includes whichever of `processed` (successful rows), `errors`, and `total` the tool reported. - **`errors`** `integer` Row error count, including AI errors and write errors. - **`processed`** `integer` Successfully processed rows. - **`total`** `integer` Total rows to process (successful + failed + never run). * **`sheet_name`** `string` Sheet the tool operated on (range tools, bulk tools, get\_sheet\_overview, read\_spreadsheet\_fields). For copy\_paste\_range this is the *destination* sheet — see `source_sheet`/`target_sheet`. * **`skill`** `string` load\_skill / create\_skill: the skill name(s). * **`source_range`** `string` copy\_paste\_range: the range copied from. * **`source_sheet`** `string` copy\_paste\_range: the sheet copied from, when the source range named one. On a cross-sheet copy this differs from `sheet_name`, which is the destination. * **`sources`** `array` web\_search: the pages the model opened and read, plus any URLs it cited, deduplicated. (Not the full set of links the searches surfaced.) **Items:** `string`, format: `uri` * **`target_range`** `string` copy\_paste\_range: the range pasted into. * **`target_sheet`** `string` copy\_paste\_range: the sheet pasted into, when the target range named one. * **`updated_range`** `string` Bulk tools: the reported written range, or an estimate from the row counters when no confirmed range is available. If writes failed and no range was confirmed, this field is omitted. - **`models` (required)** `object` The effective models for this agent (the most recent turn's), or `null`. Always returned. - **`number_of_turns` (required)** `integer` Total number of turns in this agent's conversation, including the one in progress when the agent is `active`. - **`spreadsheet_id` (required)** `string` Google Sheets spreadsheet ID - **`status` (required)** `string`, possible values: `"active", "idle"` Agent status: - `active`: A turn is currently in progress - `idle`: All turns are completed - **`usage` (required)** `object` The latest turn's **final** credit usage, or `null`. Always returned, and strictly the latest turn — unlike `models`, it does not fall back to an earlier turn, so an older turn's cost can never be mistaken for the latest one's. It is always terminal: `null` while a turn is still running (use `usage_so_far` for the running subtotal). A turn that ran to its natural end reports the figure the runtime settled on, and that figure is durable. A turn that **failed, was interrupted, or was cancelled** stores no figure of its own. For those, this field is supplemented from a short-lived accumulator — but **only on Get agent**: that endpoint reads it, while the `201` from Start agent and the `200` from Stop agent do not, so they report `null` for such a turn even when charges accumulated. The accumulator also expires roughly two hours after the turn ends. So `null` here means "no figure available" — nothing was charged, or the total has expired, or you are reading an endpoint that does not consult the accumulator — never "cost nothing". If you need it, read it from Get agent, promptly. - **`usage_so_far`** `object` The running credit subtotal of the turn currently in flight, in the same units as `usage`. **Present only while the latest turn is active** — the field is absent once the agent is `idle`, so summing `usage` never double-counts a subtotal that is still moving. Rises as the turn is charged. Only Get agent reads the accumulator; Start agent returns this field as `null` while its turn is active. On Get agent, `null` means no subtotal is available yet, or the accumulator is unavailable or has expired. **Example — New task accepted: no messages recorded yet** ```json { "id": "1f7b5f98-3906-40f4-b177-8bc2327df6f1", "spreadsheet_id": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms", "status": "active", "created_at": "2026-02-18T10:04:21.000Z", "last_activity_at": null, "number_of_turns": 1, "models": { "agent_model": "managed:agent:openai/gpt-5.1", "bulk_model": "managed:bulk:openai/gpt-4.1", "bulk_search_model": "managed:search:perplexity/sonar" }, "error_message": null, "error_code": null, "error_params": null, "usage": null, "messages": [], "usage_so_far": null } ``` ##### Status: 400 Invalid request parameters. These examples cover several documented operations; a cause applies only where the corresponding parameter or body field is accepted. ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example — Malformed ID or URL, or upstream reports the target is not a Google Sheet** ```json { "error": { "code": "INVALID_SPREADSHEET_ID", "message": "Invalid spreadsheet ID or URL", "error_code": "api-spreadsheet-invalid-id" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — prompt was present but empty or whitespace only** ```json { "error": { "code": "MISSING_REQUIRED_FIELD", "message": "Missing required field: prompt" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — Neither spreadsheet\_id nor agent\_id was provided** ```json { "error": { "code": "MISSING_REQUIRED_FIELD", "message": "Missing required field: spreadsheet_id" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — A model override names a model this space cannot use** ```json { "error": { "code": "INVALID_REQUEST", "message": "Invalid agent_model: \"unknown-model\". Use GET /v1/sheets/agents/configuration to list available models." }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — sheet\_name or sheet\_id does not match any tab on the spreadsheet** ```json { "error": { "code": "SPREADSHEET_TAB_NOT_FOUND", "message": "This spreadsheet has no tab called \"Summary\". Its tabs are: Sheet1, Data.", "error_code": "api-spreadsheet-tab-not-found" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — limit is outside the accepted range** ```json { "error": { "code": "INVALID_REQUEST", "message": "limit must be an integer between 1 and 100" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — webhook\_url is not a valid HTTP or HTTPS URL** ```json { "error": { "code": "INVALID_REQUEST", "message": "webhook_url must be a valid HTTP or HTTPS URL" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — sheet\_id and sheet\_name both resolve but name different tabs** ```json { "error": { "code": "INVALID_REQUEST", "message": "sheet_name \"Scoring rules\" and sheet_id 1030583424 reference different tabs — sheet_id 1030583424 is \"Leads\". Provide one, or make them match." }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — The request body is not valid JSON** ```json { "error": { "code": "INVALID_REQUEST", "message": "Malformed JSON in request body" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — The file is an Office file in Drive, not a native Google Sheet** ```json { "error": { "code": "SPREADSHEET_NOT_NATIVE", "message": "This operation is not supported for this spreadsheet. The spreadsheet must not be an Office file. Either convert it to a native Google Sheets spreadsheet or use another spreadsheet.", "error_code": "api-spreadsheet-not-native" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — The space has no default model for bulk operations** ```json { "error": { "code": "NO_DEFAULT_BULK_MODEL", "message": "No default model for bulk operations. Set a default at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/models.", "error_code": "api-agent-no-default-bulk-model" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — The path's platform segment is not a supported platform** ```json { "error": { "code": "INVALID_PLATFORM", "message": "Unsupported platform. Supported: sheets" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 401 The API key is missing, malformed, or not recognized. A key that exists but has been disabled or revoked reports `403` instead — see the `403` response. ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example** ```json { "error": { "code": "INVALID_API_KEY", "message": "Invalid Autosheet API key. Create a new API key, then reconnect.", "error_code": "api-autosheet-apikey-invalid" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 403 The API key is recognized but the request cannot be served. Three families of cause, scoped to the operations documented here: - **Key state** — the key has been disabled or revoked in the dashboard. Possible on any operation. - **Google connection** — no Google account is connected to the key (possible on any operation), or the connection has expired and must be re-authorized (**[Start agent](https://autosheet.com/docs/api#tag/agents/POST/v1/{platform}/agents) only**). - **Spreadsheet access** — the connected Google account does not have editor access to the spreadsheet (**[Start agent](https://autosheet.com/docs/api#tag/agents/POST/v1/{platform}/agents) only**). The expired-connection and spreadsheet-access variants arise while resolving a spreadsheet, which only Start agent does among the operations documented here. The other documented operations can return only the key-state and not-connected causes. ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example — The key has been disabled in the dashboard** ```json { "error": { "code": "API_KEY_DISABLED", "message": "Disabled Autosheet API key. Enable a new API key at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/agent-api.", "error_code": "api-autosheet-apikey-disabled" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — The key has been revoked** ```json { "error": { "code": "API_KEY_REVOKED", "message": "Revoked Autosheet API key. Create a new API key at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/agent-api, then reconnect.", "error_code": "api-autosheet-apikey-revoked" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — No Google account has been connected yet** ```json { "error": { "code": "GOOGLE_AUTH_REQUIRED", "message": "Google account not connected. Please connect at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/agent-api", "error_code": "api-google-auth-required" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — A previously connected Google account must be reconnected (Start agent only)** ```json { "error": { "code": "GOOGLE_AUTH_REQUIRED", "message": "Google account connection expired. Reconnect at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/agent-api.", "error_code": "api-google-auth-expired" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — The connected account lacks editor access (Start agent only)** ```json { "error": { "code": "SPREADSHEET_ACCESS_DENIED", "message": "Cannot access this spreadsheet. Check that user@example.com has editor access to https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms", "error_code": "api-spreadsheet-access-denied" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 404 The spreadsheet does not exist (well-formed but unknown ID). ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example** ```json { "error": { "code": "SPREADSHEET_NOT_FOUND", "message": "Spreadsheet not found. Check the URL and ensure it is shared with user@example.com with editor access.", "error_code": "api-spreadsheet-not-found" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 409 Agent is still processing a previous turn (follow-up only) ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example** ```json { "error": { "code": "AGENT_BUSY", "message": "This agent is currently working and cannot receive your follow-up. Wait for its status to become available before re-sending the follow-up.", "error_code": "api-agent-busy" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 422 The request failed request-schema validation before it reached the handler: a required body field was absent, or a body field or query parameter did not satisfy its declared schema — wrong type, or outside a declared bound such as `sheet_id`'s minimum of `0`. The `message` names the offending field, prefixed with its location (`body.` for request-body fields). The examples below are drawn from across the API, so not every one is reachable on every operation. This is distinct from `400`, which covers requests that are well-formed but semantically invalid (a blank `prompt`, a `limit` outside 1–100, a spreadsheet the agent cannot use). ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example — A required body field was omitted entirely (Start agent)** ```json { "error": { "code": "INVALID_REQUEST", "message": "body.prompt: 'prompt' is required" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — A body field had the wrong type (Start agent)** ```json { "error": { "code": "INVALID_REQUEST", "message": "body.sheet_id: sheet_id must be an integer" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — A boolean query parameter had a non-boolean value (Get agent)** ```json { "error": { "code": "INVALID_REQUEST", "message": "include_intermediate_tool_failures: invalid boolean value" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — A numeric query parameter had a non-numeric value (Get agent messages)** ```json { "error": { "code": "INVALID_REQUEST", "message": "limit: invalid float number" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — A body field fell outside its declared bound (Start agent)** ```json { "error": { "code": "INVALID_REQUEST", "message": "body.sheet_id: sheet_id must be a non-negative integer" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 429 A limit was reached. Branch on `error.code` — the four causes have different remedies. The operation-specific notes below refer to the operations documented in this reference: - **`RATE_LIMIT_EXCEEDED`** — the per-key request rate limit (500 requests/minute). Wait for the window to reset and retry. - **`RATE_LIMIT_EXCEEDED`** with a Google Sheets message — Google's own API quota. That quota is separate from your Autosheet rate limit, but the rejected request has already passed the Autosheet limiter, so it still counts against your per-minute budget. Retry later. Only [Start agent](https://autosheet.com/docs/api#tag/agents/POST/v1/{platform}/agents) can return this, among the operations documented here, since the others do not resolve a spreadsheet. - **`SPENDING_LIMIT_REACHED`** — a space-wide or user spending limit was hit. Retrying will not help until the limit is raised in the dashboard or the period rolls over. - **`CONCURRENT_LIMIT_REACHED`** — too many agents are running at once (100 per API key). Retry once one finishes. Only [Start agent](https://autosheet.com/docs/api#tag/agents/POST/v1/{platform}/agents) can return this. **Headers.** `X-RateLimit-Limit`, `X-RateLimit-Remaining`, and `X-RateLimit-Reset` are set on every `429` — the rate-limit middleware stamps them before the spending and concurrency checks run. `Retry-After` and `X-RateLimit-Reset-After` are set **only** when the per-key rate limit itself rejected the request; they are absent on spending, concurrency, and Google-quota rejections. Note that a request rejected for concurrency still spends one request from the per-minute budget. **Response headers** **`X-RateLimit-Limit` (required)** — `integer` Request limit per minute **`X-RateLimit-Remaining` (required)** — `integer` Remaining requests in current window **`X-RateLimit-Reset` (required)** — `integer` Unix timestamp when the rate limit resets **`Retry-After`** — `integer` Seconds to wait before retrying. Present only on a `RATE_LIMIT_EXCEEDED` rejection from the per-key rate limit. **`X-RateLimit-Reset-After`** — `integer` Seconds until the rate-limit window resets. Same scope as `Retry-After`, and carries the same value. ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example — Per-key request rate limit (500/minute)** ```json { "error": { "code": "RATE_LIMIT_EXCEEDED", "message": "Rate limit exceeded. Retry after 60 seconds." }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — Google Sheets API quota, upstream (Start agent only)** ```json { "error": { "code": "RATE_LIMIT_EXCEEDED", "message": "Google Sheets API quota exceeded. Please try again later." }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — A spending limit was reached — one variant; wording depends on scope, plan and role** ```json { "error": { "code": "SPENDING_LIMIT_REACHED", "message": "User limit reached. It will reset on September 1st. Increase it on https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/billing to continue.", "error_code": "api-billing-spending-limit-reached-user" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — Too many agents running at once (Start agent only)** ```json { "error": { "code": "CONCURRENT_LIMIT_REACHED", "message": "Maximum number of concurrent active agents reached" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 500 Internal server error ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example** ```json { "error": { "code": "INTERNAL_SERVER_ERROR", "message": "Internal server error" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 502 An upstream dependency returned an invalid response while serving the request. The API gateway is healthy; the fault is upstream. Safe to retry with backoff — no agent was created. ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example** ```json { "error": { "code": "BAD_GATEWAY", "message": "An upstream dependency returned an invalid response. Please retry shortly." }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 504 The request timed out waiting on an upstream dependency. Safe to retry with backoff — the agent may or may not have started, so prefer an idempotent retry or check status before re-issuing. ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example** ```json { "error": { "code": "GATEWAY_TIMEOUT", "message": "The request timed out waiting on an upstream dependency. Please retry shortly." }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ### Get agent - **Method:** `GET` - **Path:** `/v1/{platform}/agents/{id}` - **Tags:** Agents Retrieves the current status and conversation of an agent. The response always includes the effective `models`, the latest turn's `error_message`, the total `number_of_turns`, and the latest turn's messages as a single ordered, type-tagged `messages` array. Tool calls carry compact summary details (status, affected range, row counters, and other per-tool fields — see the `200` response schema below for the full list) rather than full payloads. For the full conversation across all turns, use [Get agent messages](https://autosheet.com/docs/api#tag/agents/GET/v1/{platform}/agents/{id}/messages). By default `messages` includes every tool call of the latest turn, including failed attempts the agent later recovered from. Pass `include_intermediate_tool_failures=false` to omit those recovered failures and keep only the calls that reflect the turn's outcome. To request the filtered view: ```bash curl 'https://api.autosheet.com/v1/sheets/agents/?include_intermediate_tool_failures=false' \ --header 'X-API-Key: ' ``` Compare the **Complete view** and **Filtered view** `200` examples: the first failed read disappears, while the final failed metadata call and the assistant reply remain. The running and copy-task examples use illustrative accounting amounts, not price estimates. #### Parameters ##### `platform` required - **In:** `path` Target platform **Example** ```json "sheets" ``` `string`, possible values: `"sheets"` ##### `id` required - **In:** `path` Agent ID (UUID) **Example** ```json "" ``` `string`, format: `uuid` ##### `include_intermediate_tool_failures` - **In:** `query` Set to `false` to omit a `failed` tool call from `messages` when a later tool call in the same turn `succeeded` — i.e. the agent recovered and the failure was only an intermediate attempt. Terminal failures (a failed call with no later success in its turn) and the turn's `error_message` always remain visible. Defaults to `true`, so existing consumers keep receiving failed attempts. Does not affect [Get agent messages](https://autosheet.com/docs/api#tag/agents/GET/v1/{platform}/agents/{id}/messages), which always returns the complete history. **Example** ```json false ``` `boolean`, default: `true` #### Responses ##### Status: 200 Agent details ###### Content-Type: application/json - **`created_at` (required)** `string`, format: `date-time` When the agent was created - **`error_code` (required)** `string | null` Machine-readable code for the latest turn's failure, or `null` when it has not errored. Always returned. Branch on this rather than matching `error_message`, which is generated copy and can change. - **`error_message` (required)** `string | null` The latest turn's error message (failure reason), or `null` when it has not errored. `null` while the turn is still in progress (`status: active`). Always returned — errored turns produce no assistant message, so this is where failures surface. - **`error_params` (required)** `object | null` The values `error_message` was rendered with, or `null`. Always returned. Provided so you can re-render the failure in your own wording or locale instead of reusing ours. - **`id` (required)** `string`, format: `uuid` Unique agent identifier - **`last_activity_at` (required)** `string | null`, format: `date-time` When the agent last had activity - **`messages` (required)** `array` The latest turn's messages as a single ordered, type-tagged array. Always returned. The full conversation across all turns is served (paginated) by `GET /v1/{platform}/agents/{id}/messages`. **Items:** **One of:** - **`content` (required)** `string` - **`created_at` (required)** `string`, format: `date-time` - **`message_id` (required)** `string`, format: `uuid` - **`turn_id` (required)** `string`, format: `uuid` The turn this entry belongs to (groups entries by prompt execution). - **`type` (required)** `string`, possible values: `"user_message"` * **`content` (required)** `string` * **`created_at` (required)** `string`, format: `date-time` * **`message_id` (required)** `string`, format: `uuid` * **`turn_id` (required)** `string`, format: `uuid` * **`type` (required)** `string`, possible values: `"assistant_message"` **All of:** - **`turn_id` (required)** `string`, format: `uuid` The turn this entry belongs to (groups entries by prompt execution). - **`type` (required)** `string`, possible values: `"tool_call"` * **`created_at` (required)** `string`, format: `date-time` When the tool call started. * **`status` (required)** `string`, possible values: `"pending", "running", "succeeded", "failed", "cancelled"` Terminal outcomes are reported uniformly as `succeeded` or `failed` for every tool; for bulk tools, `succeeded` means the run finished with no row failures — which includes a run that wrote nothing because every target cell was already populated, so `rows.processed` can legitimately be `0`. A call the user cancelled mid-turn reports `cancelled`. * **`tool` (required)** `string` Name of the tool that was called * **`tool_call_id` (required)** `string`, format: `uuid` Tool-call identifier. * **`cells`** `integer` Number of cells the call touched: cells written for write\_range/write\_cells, and the source-range cell count for copy\_paste\_range (omitted when that range is unbounded). * **`column`** `string` add\_column\_header: the column the header was written to. Not returned for bulk tools, which report the written range as `updated_range`. * **`completed_at`** `string | null`, format: `date-time` When the tool call reached a terminal status. Omitted while the call is still `pending`/`running`. * **`fields`** `string` read\_spreadsheet\_fields: the requested field mask. * **`message`** `string` Result message from the tool call. Present **only** on a `failed` call, where it carries the failure reason; omitted for every other status. * **`number_of_searches`** `integer` web\_search: how many searches the tool ran. Each is a billed unit. * **`paste_type`** `string` copy\_paste\_range: the paste behaviour. * **`prompt_template`** `string` Bulk tools: the per-row prompt template (column refs as `{{A}}`). * **`query`** `string` web\_search: the query searched for (the tool's prompt). * **`range`** `string` Affected range. For read\_range/read\_cells/write\_range/write\_cells the sheet prefix is removed (see `sheet_name`); add\_column\_header can retain it. Not returned for bulk tools, which use `updated_range`, nor copy\_paste\_range, which uses `source_range`/`target_range`. * **`read`** `object` read\_range / read\_cells: the dimensions of the data returned — counts only, never cell contents. Totals span every sheet the read covered. `cells` counts the cells actually returned, so it is not necessarily `rows × columns` (the Sheets API omits trailing empties) — useful for spotting a silently truncated read. - **`cells` (required)** `integer` Cells actually returned. - **`columns` (required)** `integer` Distinct columns per sheet, summed across the sheets the read spanned. - **`rows` (required)** `integer` Distinct rows per sheet, summed across the sheets the read spanned. - **`sheets` (required)** `integer` Number of sheets the returned data spans. * **`rows`** `object` Bulk tools only: row counters. Absent for non-bulk tools. Includes whichever of `processed` (successful rows), `errors`, and `total` the tool reported. - **`errors`** `integer` Row error count, including AI errors and write errors. - **`processed`** `integer` Successfully processed rows. - **`total`** `integer` Total rows to process (successful + failed + never run). * **`sheet_name`** `string` Sheet the tool operated on (range tools, bulk tools, get\_sheet\_overview, read\_spreadsheet\_fields). For copy\_paste\_range this is the *destination* sheet — see `source_sheet`/`target_sheet`. * **`skill`** `string` load\_skill / create\_skill: the skill name(s). * **`source_range`** `string` copy\_paste\_range: the range copied from. * **`source_sheet`** `string` copy\_paste\_range: the sheet copied from, when the source range named one. On a cross-sheet copy this differs from `sheet_name`, which is the destination. * **`sources`** `array` web\_search: the pages the model opened and read, plus any URLs it cited, deduplicated. (Not the full set of links the searches surfaced.) **Items:** `string`, format: `uri` * **`target_range`** `string` copy\_paste\_range: the range pasted into. * **`target_sheet`** `string` copy\_paste\_range: the sheet pasted into, when the target range named one. * **`updated_range`** `string` Bulk tools: the reported written range, or an estimate from the row counters when no confirmed range is available. If writes failed and no range was confirmed, this field is omitted. - **`models` (required)** `object` The effective models for this agent (the most recent turn's), or `null`. Always returned. - **`number_of_turns` (required)** `integer` Total number of turns in this agent's conversation, including the one in progress when the agent is `active`. - **`spreadsheet_id` (required)** `string` Google Sheets spreadsheet ID - **`status` (required)** `string`, possible values: `"active", "idle"` Agent status: - `active`: A turn is currently in progress - `idle`: All turns are completed - **`usage` (required)** `object` The latest turn's **final** credit usage, or `null`. Always returned, and strictly the latest turn — unlike `models`, it does not fall back to an earlier turn, so an older turn's cost can never be mistaken for the latest one's. It is always terminal: `null` while a turn is still running (use `usage_so_far` for the running subtotal). A turn that ran to its natural end reports the figure the runtime settled on, and that figure is durable. A turn that **failed, was interrupted, or was cancelled** stores no figure of its own. For those, this field is supplemented from a short-lived accumulator — but **only on Get agent**: that endpoint reads it, while the `201` from Start agent and the `200` from Stop agent do not, so they report `null` for such a turn even when charges accumulated. The accumulator also expires roughly two hours after the turn ends. So `null` here means "no figure available" — nothing was charged, or the total has expired, or you are reading an endpoint that does not consult the accumulator — never "cost nothing". If you need it, read it from Get agent, promptly. - **`usage_so_far`** `object` The running credit subtotal of the turn currently in flight, in the same units as `usage`. **Present only while the latest turn is active** — the field is absent once the agent is `idle`, so summing `usage` never double-counts a subtotal that is still moving. Rises as the turn is charged. Only Get agent reads the accumulator; Start agent returns this field as `null` while its turn is active. On Get agent, `null` means no subtotal is available yet, or the accumulator is unavailable or has expired. **Example — Completed task: 50 leads scored and explained** ```json { "id": "1f7b5f98-3906-40f4-b177-8bc2327df6f1", "spreadsheet_id": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms", "status": "idle", "created_at": "2026-02-18T10:04:21.000Z", "last_activity_at": "2026-02-18T10:05:09.000Z", "number_of_turns": 1, "models": { "agent_model": "managed:agent:openai/gpt-5.1", "bulk_model": "managed:bulk:openai/gpt-4.1", "bulk_search_model": "managed:search:perplexity/sonar" }, "error_message": null, "error_code": null, "error_params": null, "usage": { "agent_usage": 412000000, "tool_usage": 1071000000, "total_usage": 1483000000 }, "messages": [ { "type": "user_message", "turn_id": "bd13ff9a-3b45-4b48-9aed-d4084d71cb6a", "message_id": "32858a65-38c2-40f5-a5c9-bda44de8c1c5", "created_at": "2026-02-18T10:04:21.000Z", "content": "Score these leads against our scoring rules, and add a one-line explanation for each score." }, { "type": "tool_call", "turn_id": "bd13ff9a-3b45-4b48-9aed-d4084d71cb6a", "tool_call_id": "6dfa6386-c31f-4649-9fdf-4c899ae2e763", "created_at": "2026-02-18T10:04:35.000Z", "tool": "ai_bulk_process_rows", "status": "succeeded", "completed_at": "2026-02-18T10:04:58.000Z", "updated_range": "E2:E51", "sheet_name": "Leads", "prompt_template": "Score this lead against our scoring rules: {{A}}. Respond with one of: Hot, Warm, Cold.", "rows": { "processed": 50, "errors": 0, "total": 50 } }, { "type": "tool_call", "turn_id": "bd13ff9a-3b45-4b48-9aed-d4084d71cb6a", "tool_call_id": "773e2fd7-fedd-47eb-a991-f4f953b89344", "created_at": "2026-02-18T10:04:59.000Z", "tool": "ai_bulk_process_rows", "status": "succeeded", "completed_at": "2026-02-18T10:05:08.000Z", "updated_range": "F2:F51", "sheet_name": "Leads", "prompt_template": "In one short line, explain the score for this lead: {{A}}.", "rows": { "processed": 50, "errors": 0, "total": 50 } }, { "type": "assistant_message", "turn_id": "bd13ff9a-3b45-4b48-9aed-d4084d71cb6a", "message_id": "be42ee1a-966c-405f-bcd3-485d5c5ea5eb", "created_at": "2026-02-18T10:05:09.000Z", "content": "Scored all 50 leads against your scoring rules in column E and added a one-line explanation in column F (score_reason)." } ] } ``` **Example — Task in progress: final usage is null, running subtotal is available** Illustrative accumulated amounts, not a price estimate. Once this task is idle, usage\_so\_far is omitted. ```json { "id": "1f7b5f98-3906-40f4-b177-8bc2327df6f1", "spreadsheet_id": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms", "status": "active", "created_at": "2026-02-18T10:04:21.000Z", "last_activity_at": "2026-02-18T10:04:45.000Z", "number_of_turns": 1, "models": { "agent_model": "managed:agent:openai/gpt-5.1", "bulk_model": "managed:bulk:openai/gpt-4.1", "bulk_search_model": "managed:search:perplexity/sonar" }, "error_message": null, "error_code": null, "error_params": null, "usage": null, "messages": [ { "type": "user_message", "turn_id": "bd13ff9a-3b45-4b48-9aed-d4084d71cb6a", "message_id": "32858a65-38c2-40f5-a5c9-bda44de8c1c5", "created_at": "2026-02-18T10:04:21.000Z", "content": "Score these leads against our scoring rules, and add a one-line explanation for each score." }, { "type": "tool_call", "turn_id": "bd13ff9a-3b45-4b48-9aed-d4084d71cb6a", "tool_call_id": "6dfa6386-c31f-4649-9fdf-4c899ae2e763", "created_at": "2026-02-18T10:04:35.000Z", "tool": "ai_bulk_process_rows", "status": "running", "sheet_name": "Leads", "prompt_template": "Score this lead against our scoring rules: {{A}}. Respond with one of: Hot, Warm, Cold.", "rows": { "processed": 20, "errors": 0, "total": 50 } } ], "usage_so_far": { "agent_usage": 700, "tool_usage": 300, "total_usage": 1000 } } ``` **Example — Complete view: intermediate and terminal tool failures included** A separate copy task, requested with include\_intermediate\_tool\_failures=true (the default). The first read omitted its range; a later read succeeded. The final metadata call omitted fields and has no later success. The task finished with an assistant reply, so its top-level error remains null. Usage amounts are illustrative accounting values, not a price estimate. ```json { "id": "96b9e0e3-91e9-4de8-a05a-19741035e611", "spreadsheet_id": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms", "status": "idle", "created_at": "2026-02-18T11:00:00.000Z", "last_activity_at": "2026-02-18T11:00:20.000Z", "number_of_turns": 1, "models": { "agent_model": "managed:agent:openai/gpt-5.1", "bulk_model": "managed:bulk:openai/gpt-4.1", "bulk_search_model": "managed:search:perplexity/sonar" }, "error_message": null, "error_code": null, "error_params": null, "usage": { "agent_usage": 400, "tool_usage": 0, "total_usage": 400 }, "messages": [ { "type": "user_message", "turn_id": "8e031ff7-8058-4d0f-b2e1-0d88a4451121", "message_id": "d0ca2ac5-40dd-47e4-a97e-c52e1f68d741", "created_at": "2026-02-18T11:00:00.000Z", "content": "Read Input!A1:A2, add a header in Output!B1, and copy the two values to Output!B2:B3. Then check the spreadsheet metadata." }, { "type": "tool_call", "turn_id": "8e031ff7-8058-4d0f-b2e1-0d88a4451121", "tool_call_id": "893482ba-9877-46e1-a6f5-5f761eff4b91", "created_at": "2026-02-18T11:00:01.000Z", "tool": "read_range", "status": "failed", "completed_at": "2026-02-18T11:00:02.000Z", "sheet_name": "Input", "message": "Tool call failed: range content not retrieved. Error: Invalid parameters. 'range' and 'documentId' are required." }, { "type": "tool_call", "turn_id": "8e031ff7-8058-4d0f-b2e1-0d88a4451121", "tool_call_id": "231da889-19b4-4fb4-a911-9f96df5f3451", "created_at": "2026-02-18T11:00:03.000Z", "tool": "read_range", "status": "succeeded", "completed_at": "2026-02-18T11:00:05.000Z", "range": "A1:A2", "sheet_name": "Input", "read": { "sheets": 1, "rows": 2, "columns": 1, "cells": 2 } }, { "type": "tool_call", "turn_id": "8e031ff7-8058-4d0f-b2e1-0d88a4451121", "tool_call_id": "865f7081-9f5c-4aab-96fd-40f3852b8a91", "created_at": "2026-02-18T11:00:06.000Z", "tool": "add_column_header", "status": "succeeded", "completed_at": "2026-02-18T11:00:08.000Z", "column": "B", "range": "Output!B1" }, { "type": "tool_call", "turn_id": "8e031ff7-8058-4d0f-b2e1-0d88a4451121", "tool_call_id": "d9442576-8fe7-4590-8483-186948510741", "created_at": "2026-02-18T11:00:09.000Z", "tool": "copy_paste_range", "status": "succeeded", "completed_at": "2026-02-18T11:00:12.000Z", "cells": 2, "source_range": "A1:A2", "target_range": "B2:B3", "source_sheet": "Input", "target_sheet": "Output", "sheet_name": "Output", "paste_type": "PASTE_VALUES_ONLY" }, { "type": "tool_call", "turn_id": "8e031ff7-8058-4d0f-b2e1-0d88a4451121", "tool_call_id": "4a9122bf-28e7-41b7-a448-15863c3aec61", "created_at": "2026-02-18T11:00:13.000Z", "tool": "read_spreadsheet_fields", "status": "failed", "completed_at": "2026-02-18T11:00:14.000Z", "message": "Tool call failed: fields parameter is required." }, { "type": "assistant_message", "turn_id": "8e031ff7-8058-4d0f-b2e1-0d88a4451121", "message_id": "a7d8be31-139b-4448-9843-008b2d941a61", "created_at": "2026-02-18T11:00:20.000Z", "content": "Added the header and copied the two values to Output!B2:B3. The final metadata check failed because its fields parameter was missing." } ] } ``` **Example — Filtered view: intermediate failure omitted, terminal failure retained** The same copy task requested with include\_intermediate\_tool\_failures=false. Only the first failed read is removed. The final failed metadata call and the assistant reply remain. Usage amounts are illustrative accounting values, not a price estimate. ```json { "id": "96b9e0e3-91e9-4de8-a05a-19741035e611", "spreadsheet_id": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms", "status": "idle", "created_at": "2026-02-18T11:00:00.000Z", "last_activity_at": "2026-02-18T11:00:20.000Z", "number_of_turns": 1, "models": { "agent_model": "managed:agent:openai/gpt-5.1", "bulk_model": "managed:bulk:openai/gpt-4.1", "bulk_search_model": "managed:search:perplexity/sonar" }, "error_message": null, "error_code": null, "error_params": null, "usage": { "agent_usage": 400, "tool_usage": 0, "total_usage": 400 }, "messages": [ { "type": "user_message", "turn_id": "8e031ff7-8058-4d0f-b2e1-0d88a4451121", "message_id": "d0ca2ac5-40dd-47e4-a97e-c52e1f68d741", "created_at": "2026-02-18T11:00:00.000Z", "content": "Read Input!A1:A2, add a header in Output!B1, and copy the two values to Output!B2:B3. Then check the spreadsheet metadata." }, { "type": "tool_call", "turn_id": "8e031ff7-8058-4d0f-b2e1-0d88a4451121", "tool_call_id": "231da889-19b4-4fb4-a911-9f96df5f3451", "created_at": "2026-02-18T11:00:03.000Z", "tool": "read_range", "status": "succeeded", "completed_at": "2026-02-18T11:00:05.000Z", "range": "A1:A2", "sheet_name": "Input", "read": { "sheets": 1, "rows": 2, "columns": 1, "cells": 2 } }, { "type": "tool_call", "turn_id": "8e031ff7-8058-4d0f-b2e1-0d88a4451121", "tool_call_id": "865f7081-9f5c-4aab-96fd-40f3852b8a91", "created_at": "2026-02-18T11:00:06.000Z", "tool": "add_column_header", "status": "succeeded", "completed_at": "2026-02-18T11:00:08.000Z", "column": "B", "range": "Output!B1" }, { "type": "tool_call", "turn_id": "8e031ff7-8058-4d0f-b2e1-0d88a4451121", "tool_call_id": "d9442576-8fe7-4590-8483-186948510741", "created_at": "2026-02-18T11:00:09.000Z", "tool": "copy_paste_range", "status": "succeeded", "completed_at": "2026-02-18T11:00:12.000Z", "cells": 2, "source_range": "A1:A2", "target_range": "B2:B3", "source_sheet": "Input", "target_sheet": "Output", "sheet_name": "Output", "paste_type": "PASTE_VALUES_ONLY" }, { "type": "tool_call", "turn_id": "8e031ff7-8058-4d0f-b2e1-0d88a4451121", "tool_call_id": "4a9122bf-28e7-41b7-a448-15863c3aec61", "created_at": "2026-02-18T11:00:13.000Z", "tool": "read_spreadsheet_fields", "status": "failed", "completed_at": "2026-02-18T11:00:14.000Z", "message": "Tool call failed: fields parameter is required." }, { "type": "assistant_message", "turn_id": "8e031ff7-8058-4d0f-b2e1-0d88a4451121", "message_id": "a7d8be31-139b-4448-9843-008b2d941a61", "created_at": "2026-02-18T11:00:20.000Z", "content": "Added the header and copied the two values to Output!B2:B3. The final metadata check failed because its fields parameter was missing." } ] } ``` ##### Status: 401 The API key is missing, malformed, or not recognized. A key that exists but has been disabled or revoked reports `403` instead — see the `403` response. ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example** ```json { "error": { "code": "INVALID_API_KEY", "message": "Invalid Autosheet API key. Create a new API key, then reconnect.", "error_code": "api-autosheet-apikey-invalid" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 403 The API key is recognized but the request cannot be served. Three families of cause, scoped to the operations documented here: - **Key state** — the key has been disabled or revoked in the dashboard. Possible on any operation. - **Google connection** — no Google account is connected to the key (possible on any operation), or the connection has expired and must be re-authorized (**[Start agent](https://autosheet.com/docs/api#tag/agents/POST/v1/{platform}/agents) only**). - **Spreadsheet access** — the connected Google account does not have editor access to the spreadsheet (**[Start agent](https://autosheet.com/docs/api#tag/agents/POST/v1/{platform}/agents) only**). The expired-connection and spreadsheet-access variants arise while resolving a spreadsheet, which only Start agent does among the operations documented here. The other documented operations can return only the key-state and not-connected causes. ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example — The key has been disabled in the dashboard** ```json { "error": { "code": "API_KEY_DISABLED", "message": "Disabled Autosheet API key. Enable a new API key at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/agent-api.", "error_code": "api-autosheet-apikey-disabled" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — The key has been revoked** ```json { "error": { "code": "API_KEY_REVOKED", "message": "Revoked Autosheet API key. Create a new API key at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/agent-api, then reconnect.", "error_code": "api-autosheet-apikey-revoked" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — No Google account has been connected yet** ```json { "error": { "code": "GOOGLE_AUTH_REQUIRED", "message": "Google account not connected. Please connect at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/agent-api", "error_code": "api-google-auth-required" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — A previously connected Google account must be reconnected (Start agent only)** ```json { "error": { "code": "GOOGLE_AUTH_REQUIRED", "message": "Google account connection expired. Reconnect at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/agent-api.", "error_code": "api-google-auth-expired" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — The connected account lacks editor access (Start agent only)** ```json { "error": { "code": "SPREADSHEET_ACCESS_DENIED", "message": "Cannot access this spreadsheet. Check that user@example.com has editor access to https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms", "error_code": "api-spreadsheet-access-denied" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 404 Agent not found ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example** ```json { "error": { "code": "AGENT_NOT_FOUND", "message": "Agent not found", "error_code": "api-agent-not-found" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 422 The request failed request-schema validation before it reached the handler: a required body field was absent, or a body field or query parameter did not satisfy its declared schema — wrong type, or outside a declared bound such as `sheet_id`'s minimum of `0`. The `message` names the offending field, prefixed with its location (`body.` for request-body fields). The examples below are drawn from across the API, so not every one is reachable on every operation. This is distinct from `400`, which covers requests that are well-formed but semantically invalid (a blank `prompt`, a `limit` outside 1–100, a spreadsheet the agent cannot use). ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example — A required body field was omitted entirely (Start agent)** ```json { "error": { "code": "INVALID_REQUEST", "message": "body.prompt: 'prompt' is required" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — A body field had the wrong type (Start agent)** ```json { "error": { "code": "INVALID_REQUEST", "message": "body.sheet_id: sheet_id must be an integer" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — A boolean query parameter had a non-boolean value (Get agent)** ```json { "error": { "code": "INVALID_REQUEST", "message": "include_intermediate_tool_failures: invalid boolean value" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — A numeric query parameter had a non-numeric value (Get agent messages)** ```json { "error": { "code": "INVALID_REQUEST", "message": "limit: invalid float number" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — A body field fell outside its declared bound (Start agent)** ```json { "error": { "code": "INVALID_REQUEST", "message": "body.sheet_id: sheet_id must be a non-negative integer" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 429 A limit was reached. Branch on `error.code` — the four causes have different remedies. The operation-specific notes below refer to the operations documented in this reference: - **`RATE_LIMIT_EXCEEDED`** — the per-key request rate limit (500 requests/minute). Wait for the window to reset and retry. - **`RATE_LIMIT_EXCEEDED`** with a Google Sheets message — Google's own API quota. That quota is separate from your Autosheet rate limit, but the rejected request has already passed the Autosheet limiter, so it still counts against your per-minute budget. Retry later. Only [Start agent](https://autosheet.com/docs/api#tag/agents/POST/v1/{platform}/agents) can return this, among the operations documented here, since the others do not resolve a spreadsheet. - **`SPENDING_LIMIT_REACHED`** — a space-wide or user spending limit was hit. Retrying will not help until the limit is raised in the dashboard or the period rolls over. - **`CONCURRENT_LIMIT_REACHED`** — too many agents are running at once (100 per API key). Retry once one finishes. Only [Start agent](https://autosheet.com/docs/api#tag/agents/POST/v1/{platform}/agents) can return this. **Headers.** `X-RateLimit-Limit`, `X-RateLimit-Remaining`, and `X-RateLimit-Reset` are set on every `429` — the rate-limit middleware stamps them before the spending and concurrency checks run. `Retry-After` and `X-RateLimit-Reset-After` are set **only** when the per-key rate limit itself rejected the request; they are absent on spending, concurrency, and Google-quota rejections. Note that a request rejected for concurrency still spends one request from the per-minute budget. **Response headers** **`X-RateLimit-Limit` (required)** — `integer` Request limit per minute **`X-RateLimit-Remaining` (required)** — `integer` Remaining requests in current window **`X-RateLimit-Reset` (required)** — `integer` Unix timestamp when the rate limit resets **`Retry-After`** — `integer` Seconds to wait before retrying. Present only on a `RATE_LIMIT_EXCEEDED` rejection from the per-key rate limit. **`X-RateLimit-Reset-After`** — `integer` Seconds until the rate-limit window resets. Same scope as `Retry-After`, and carries the same value. ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example — Per-key request rate limit (500/minute)** ```json { "error": { "code": "RATE_LIMIT_EXCEEDED", "message": "Rate limit exceeded. Retry after 60 seconds." }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — Google Sheets API quota, upstream (Start agent only)** ```json { "error": { "code": "RATE_LIMIT_EXCEEDED", "message": "Google Sheets API quota exceeded. Please try again later." }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — A spending limit was reached — one variant; wording depends on scope, plan and role** ```json { "error": { "code": "SPENDING_LIMIT_REACHED", "message": "User limit reached. It will reset on September 1st. Increase it on https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/billing to continue.", "error_code": "api-billing-spending-limit-reached-user" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — Too many agents running at once (Start agent only)** ```json { "error": { "code": "CONCURRENT_LIMIT_REACHED", "message": "Maximum number of concurrent active agents reached" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 500 Internal server error ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example** ```json { "error": { "code": "INTERNAL_SERVER_ERROR", "message": "Internal server error" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ### Get agent messages - **Method:** `GET` - **Path:** `/v1/{platform}/agents/{id}/messages` - **Tags:** Agents Retrieves the full conversation across all of the agent's turns as a single ordered, type-tagged array, paginated with a cursor. Pass `limit` to control the page size and the returned `end_cursor` as `after` to fetch the next page; `has_next_page` tells you when to stop. Entries are returned oldest-first. The request and response examples show the second and final page of the completed Get agent example, continuing after its first two entries. #### Parameters ##### `platform` required - **In:** `path` Target platform **Example** ```json "sheets" ``` `string`, possible values: `"sheets"` ##### `id` required - **In:** `path` Agent ID (UUID) **Example** ```json "" ``` `string`, format: `uuid` ##### `limit` - **In:** `query` Page size, 1–100. **Example** ```json 2 ``` `integer`, default: `20` ##### `after` - **In:** `query` Cursor returned as `end_cursor` by a previous page; entries strictly after it are returned. Omit it to fetch the first page. The example cursor identifies the second entry of the completed Get agent example. **Example** ```json "wmOoAZkdaU3oV18j" ``` `string` #### Responses ##### Status: 200 One page of conversation entries ###### Content-Type: application/json - **`end_cursor` (required)** `string | null` Cursor of the last entry on this page — pass as `after` to fetch the next page. Populated on every non-empty page, including the last one (where `has_next_page` is `false`); `null` only when the page is empty. Use `has_next_page`, not this field, to decide whether to keep paginating. - **`has_next_page` (required)** `boolean` - **`messages` (required)** `array` **Items:** **One of:** - **`content` (required)** `string` - **`created_at` (required)** `string`, format: `date-time` - **`message_id` (required)** `string`, format: `uuid` - **`turn_id` (required)** `string`, format: `uuid` The turn this entry belongs to (groups entries by prompt execution). - **`type` (required)** `string`, possible values: `"user_message"` * **`content` (required)** `string` * **`created_at` (required)** `string`, format: `date-time` * **`message_id` (required)** `string`, format: `uuid` * **`turn_id` (required)** `string`, format: `uuid` * **`type` (required)** `string`, possible values: `"assistant_message"` **All of:** - **`turn_id` (required)** `string`, format: `uuid` The turn this entry belongs to (groups entries by prompt execution). - **`type` (required)** `string`, possible values: `"tool_call"` * **`created_at` (required)** `string`, format: `date-time` When the tool call started. * **`status` (required)** `string`, possible values: `"pending", "running", "succeeded", "failed", "cancelled"` Terminal outcomes are reported uniformly as `succeeded` or `failed` for every tool; for bulk tools, `succeeded` means the run finished with no row failures — which includes a run that wrote nothing because every target cell was already populated, so `rows.processed` can legitimately be `0`. A call the user cancelled mid-turn reports `cancelled`. * **`tool` (required)** `string` Name of the tool that was called * **`tool_call_id` (required)** `string`, format: `uuid` Tool-call identifier. * **`cells`** `integer` Number of cells the call touched: cells written for write\_range/write\_cells, and the source-range cell count for copy\_paste\_range (omitted when that range is unbounded). * **`column`** `string` add\_column\_header: the column the header was written to. Not returned for bulk tools, which report the written range as `updated_range`. * **`completed_at`** `string | null`, format: `date-time` When the tool call reached a terminal status. Omitted while the call is still `pending`/`running`. * **`fields`** `string` read\_spreadsheet\_fields: the requested field mask. * **`message`** `string` Result message from the tool call. Present **only** on a `failed` call, where it carries the failure reason; omitted for every other status. * **`number_of_searches`** `integer` web\_search: how many searches the tool ran. Each is a billed unit. * **`paste_type`** `string` copy\_paste\_range: the paste behaviour. * **`prompt_template`** `string` Bulk tools: the per-row prompt template (column refs as `{{A}}`). * **`query`** `string` web\_search: the query searched for (the tool's prompt). * **`range`** `string` Affected range. For read\_range/read\_cells/write\_range/write\_cells the sheet prefix is removed (see `sheet_name`); add\_column\_header can retain it. Not returned for bulk tools, which use `updated_range`, nor copy\_paste\_range, which uses `source_range`/`target_range`. * **`read`** `object` read\_range / read\_cells: the dimensions of the data returned — counts only, never cell contents. Totals span every sheet the read covered. `cells` counts the cells actually returned, so it is not necessarily `rows × columns` (the Sheets API omits trailing empties) — useful for spotting a silently truncated read. - **`cells` (required)** `integer` Cells actually returned. - **`columns` (required)** `integer` Distinct columns per sheet, summed across the sheets the read spanned. - **`rows` (required)** `integer` Distinct rows per sheet, summed across the sheets the read spanned. - **`sheets` (required)** `integer` Number of sheets the returned data spans. * **`rows`** `object` Bulk tools only: row counters. Absent for non-bulk tools. Includes whichever of `processed` (successful rows), `errors`, and `total` the tool reported. - **`errors`** `integer` Row error count, including AI errors and write errors. - **`processed`** `integer` Successfully processed rows. - **`total`** `integer` Total rows to process (successful + failed + never run). * **`sheet_name`** `string` Sheet the tool operated on (range tools, bulk tools, get\_sheet\_overview, read\_spreadsheet\_fields). For copy\_paste\_range this is the *destination* sheet — see `source_sheet`/`target_sheet`. * **`skill`** `string` load\_skill / create\_skill: the skill name(s). * **`source_range`** `string` copy\_paste\_range: the range copied from. * **`source_sheet`** `string` copy\_paste\_range: the sheet copied from, when the source range named one. On a cross-sheet copy this differs from `sheet_name`, which is the destination. * **`sources`** `array` web\_search: the pages the model opened and read, plus any URLs it cited, deduplicated. (Not the full set of links the searches surfaced.) **Items:** `string`, format: `uri` * **`target_range`** `string` copy\_paste\_range: the range pasted into. * **`target_sheet`** `string` copy\_paste\_range: the sheet pasted into, when the target range named one. * **`updated_range`** `string` Bulk tools: the reported written range, or an estimate from the row counters when no confirmed range is available. If writes failed and no range was confirmed, this field is omitted. - **`total` (required)** `integer` Total number of entries in the full conversation. **Example:** ```json { "messages": [ { "type": "tool_call", "turn_id": "bd13ff9a-3b45-4b48-9aed-d4084d71cb6a", "tool_call_id": "773e2fd7-fedd-47eb-a991-f4f953b89344", "created_at": "2026-02-18T10:04:59.000Z", "tool": "ai_bulk_process_rows", "status": "succeeded", "completed_at": "2026-02-18T10:05:08.000Z", "updated_range": "F2:F51", "sheet_name": "Leads", "prompt_template": "In one short line, explain the score for this lead: {{A}}.", "rows": { "processed": 50, "errors": 0, "total": 50 } }, { "type": "assistant_message", "turn_id": "bd13ff9a-3b45-4b48-9aed-d4084d71cb6a", "message_id": "be42ee1a-966c-405f-bcd3-485d5c5ea5eb", "created_at": "2026-02-18T10:05:09.000Z", "content": "Scored all 50 leads against your scoring rules in column E and added a one-line explanation in column F (score_reason)." } ], "end_cursor": "mKsL7GAONWSi8sFx", "has_next_page": false, "total": 4 } ``` ##### Status: 400 Invalid request parameters. These examples cover several documented operations; a cause applies only where the corresponding parameter or body field is accepted. ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example — Malformed ID or URL, or upstream reports the target is not a Google Sheet** ```json { "error": { "code": "INVALID_SPREADSHEET_ID", "message": "Invalid spreadsheet ID or URL", "error_code": "api-spreadsheet-invalid-id" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — prompt was present but empty or whitespace only** ```json { "error": { "code": "MISSING_REQUIRED_FIELD", "message": "Missing required field: prompt" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — Neither spreadsheet\_id nor agent\_id was provided** ```json { "error": { "code": "MISSING_REQUIRED_FIELD", "message": "Missing required field: spreadsheet_id" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — A model override names a model this space cannot use** ```json { "error": { "code": "INVALID_REQUEST", "message": "Invalid agent_model: \"unknown-model\". Use GET /v1/sheets/agents/configuration to list available models." }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — sheet\_name or sheet\_id does not match any tab on the spreadsheet** ```json { "error": { "code": "SPREADSHEET_TAB_NOT_FOUND", "message": "This spreadsheet has no tab called \"Summary\". Its tabs are: Sheet1, Data.", "error_code": "api-spreadsheet-tab-not-found" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — limit is outside the accepted range** ```json { "error": { "code": "INVALID_REQUEST", "message": "limit must be an integer between 1 and 100" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — webhook\_url is not a valid HTTP or HTTPS URL** ```json { "error": { "code": "INVALID_REQUEST", "message": "webhook_url must be a valid HTTP or HTTPS URL" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — sheet\_id and sheet\_name both resolve but name different tabs** ```json { "error": { "code": "INVALID_REQUEST", "message": "sheet_name \"Scoring rules\" and sheet_id 1030583424 reference different tabs — sheet_id 1030583424 is \"Leads\". Provide one, or make them match." }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — The request body is not valid JSON** ```json { "error": { "code": "INVALID_REQUEST", "message": "Malformed JSON in request body" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — The file is an Office file in Drive, not a native Google Sheet** ```json { "error": { "code": "SPREADSHEET_NOT_NATIVE", "message": "This operation is not supported for this spreadsheet. The spreadsheet must not be an Office file. Either convert it to a native Google Sheets spreadsheet or use another spreadsheet.", "error_code": "api-spreadsheet-not-native" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — The space has no default model for bulk operations** ```json { "error": { "code": "NO_DEFAULT_BULK_MODEL", "message": "No default model for bulk operations. Set a default at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/models.", "error_code": "api-agent-no-default-bulk-model" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — The path's platform segment is not a supported platform** ```json { "error": { "code": "INVALID_PLATFORM", "message": "Unsupported platform. Supported: sheets" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 401 The API key is missing, malformed, or not recognized. A key that exists but has been disabled or revoked reports `403` instead — see the `403` response. ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example** ```json { "error": { "code": "INVALID_API_KEY", "message": "Invalid Autosheet API key. Create a new API key, then reconnect.", "error_code": "api-autosheet-apikey-invalid" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 403 The API key is recognized but the request cannot be served. Three families of cause, scoped to the operations documented here: - **Key state** — the key has been disabled or revoked in the dashboard. Possible on any operation. - **Google connection** — no Google account is connected to the key (possible on any operation), or the connection has expired and must be re-authorized (**[Start agent](https://autosheet.com/docs/api#tag/agents/POST/v1/{platform}/agents) only**). - **Spreadsheet access** — the connected Google account does not have editor access to the spreadsheet (**[Start agent](https://autosheet.com/docs/api#tag/agents/POST/v1/{platform}/agents) only**). The expired-connection and spreadsheet-access variants arise while resolving a spreadsheet, which only Start agent does among the operations documented here. The other documented operations can return only the key-state and not-connected causes. ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example — The key has been disabled in the dashboard** ```json { "error": { "code": "API_KEY_DISABLED", "message": "Disabled Autosheet API key. Enable a new API key at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/agent-api.", "error_code": "api-autosheet-apikey-disabled" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — The key has been revoked** ```json { "error": { "code": "API_KEY_REVOKED", "message": "Revoked Autosheet API key. Create a new API key at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/agent-api, then reconnect.", "error_code": "api-autosheet-apikey-revoked" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — No Google account has been connected yet** ```json { "error": { "code": "GOOGLE_AUTH_REQUIRED", "message": "Google account not connected. Please connect at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/agent-api", "error_code": "api-google-auth-required" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — A previously connected Google account must be reconnected (Start agent only)** ```json { "error": { "code": "GOOGLE_AUTH_REQUIRED", "message": "Google account connection expired. Reconnect at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/agent-api.", "error_code": "api-google-auth-expired" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — The connected account lacks editor access (Start agent only)** ```json { "error": { "code": "SPREADSHEET_ACCESS_DENIED", "message": "Cannot access this spreadsheet. Check that user@example.com has editor access to https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms", "error_code": "api-spreadsheet-access-denied" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 404 Agent not found ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example** ```json { "error": { "code": "AGENT_NOT_FOUND", "message": "Agent not found", "error_code": "api-agent-not-found" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 422 The request failed request-schema validation before it reached the handler: a required body field was absent, or a body field or query parameter did not satisfy its declared schema — wrong type, or outside a declared bound such as `sheet_id`'s minimum of `0`. The `message` names the offending field, prefixed with its location (`body.` for request-body fields). The examples below are drawn from across the API, so not every one is reachable on every operation. This is distinct from `400`, which covers requests that are well-formed but semantically invalid (a blank `prompt`, a `limit` outside 1–100, a spreadsheet the agent cannot use). ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example — A required body field was omitted entirely (Start agent)** ```json { "error": { "code": "INVALID_REQUEST", "message": "body.prompt: 'prompt' is required" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — A body field had the wrong type (Start agent)** ```json { "error": { "code": "INVALID_REQUEST", "message": "body.sheet_id: sheet_id must be an integer" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — A boolean query parameter had a non-boolean value (Get agent)** ```json { "error": { "code": "INVALID_REQUEST", "message": "include_intermediate_tool_failures: invalid boolean value" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — A numeric query parameter had a non-numeric value (Get agent messages)** ```json { "error": { "code": "INVALID_REQUEST", "message": "limit: invalid float number" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — A body field fell outside its declared bound (Start agent)** ```json { "error": { "code": "INVALID_REQUEST", "message": "body.sheet_id: sheet_id must be a non-negative integer" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 429 A limit was reached. Branch on `error.code` — the four causes have different remedies. The operation-specific notes below refer to the operations documented in this reference: - **`RATE_LIMIT_EXCEEDED`** — the per-key request rate limit (500 requests/minute). Wait for the window to reset and retry. - **`RATE_LIMIT_EXCEEDED`** with a Google Sheets message — Google's own API quota. That quota is separate from your Autosheet rate limit, but the rejected request has already passed the Autosheet limiter, so it still counts against your per-minute budget. Retry later. Only [Start agent](https://autosheet.com/docs/api#tag/agents/POST/v1/{platform}/agents) can return this, among the operations documented here, since the others do not resolve a spreadsheet. - **`SPENDING_LIMIT_REACHED`** — a space-wide or user spending limit was hit. Retrying will not help until the limit is raised in the dashboard or the period rolls over. - **`CONCURRENT_LIMIT_REACHED`** — too many agents are running at once (100 per API key). Retry once one finishes. Only [Start agent](https://autosheet.com/docs/api#tag/agents/POST/v1/{platform}/agents) can return this. **Headers.** `X-RateLimit-Limit`, `X-RateLimit-Remaining`, and `X-RateLimit-Reset` are set on every `429` — the rate-limit middleware stamps them before the spending and concurrency checks run. `Retry-After` and `X-RateLimit-Reset-After` are set **only** when the per-key rate limit itself rejected the request; they are absent on spending, concurrency, and Google-quota rejections. Note that a request rejected for concurrency still spends one request from the per-minute budget. **Response headers** **`X-RateLimit-Limit` (required)** — `integer` Request limit per minute **`X-RateLimit-Remaining` (required)** — `integer` Remaining requests in current window **`X-RateLimit-Reset` (required)** — `integer` Unix timestamp when the rate limit resets **`Retry-After`** — `integer` Seconds to wait before retrying. Present only on a `RATE_LIMIT_EXCEEDED` rejection from the per-key rate limit. **`X-RateLimit-Reset-After`** — `integer` Seconds until the rate-limit window resets. Same scope as `Retry-After`, and carries the same value. ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example — Per-key request rate limit (500/minute)** ```json { "error": { "code": "RATE_LIMIT_EXCEEDED", "message": "Rate limit exceeded. Retry after 60 seconds." }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — Google Sheets API quota, upstream (Start agent only)** ```json { "error": { "code": "RATE_LIMIT_EXCEEDED", "message": "Google Sheets API quota exceeded. Please try again later." }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — A spending limit was reached — one variant; wording depends on scope, plan and role** ```json { "error": { "code": "SPENDING_LIMIT_REACHED", "message": "User limit reached. It will reset on September 1st. Increase it on https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/billing to continue.", "error_code": "api-billing-spending-limit-reached-user" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — Too many agents running at once (Start agent only)** ```json { "error": { "code": "CONCURRENT_LIMIT_REACHED", "message": "Maximum number of concurrent active agents reached" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 500 Internal server error ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example** ```json { "error": { "code": "INTERNAL_SERVER_ERROR", "message": "Internal server error" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ### Stop agent - **Method:** `POST` - **Path:** `/v1/{platform}/agents/{id}/stop` - **Tags:** Agents Stops a running agent. If the agent has an active turn, it will be marked as cancelled. Completed turns are not affected. An already-idle agent is returned unchanged with `200`. The response is the snapshot at cancellation; a tool that was running may still appear as `running` until its update arrives. #### Parameters ##### `platform` required - **In:** `path` Target platform **Example** ```json "sheets" ``` `string`, possible values: `"sheets"` ##### `id` required - **In:** `path` Agent ID (UUID) **Example** ```json "" ``` `string`, format: `uuid` #### Responses ##### Status: 200 Agent snapshot after stopping, or the unchanged agent if already idle ###### Content-Type: application/json - **`created_at` (required)** `string`, format: `date-time` When the agent was created - **`error_code` (required)** `string | null` Machine-readable code for the latest turn's failure, or `null` when it has not errored. Always returned. Branch on this rather than matching `error_message`, which is generated copy and can change. - **`error_message` (required)** `string | null` The latest turn's error message (failure reason), or `null` when it has not errored. `null` while the turn is still in progress (`status: active`). Always returned — errored turns produce no assistant message, so this is where failures surface. - **`error_params` (required)** `object | null` The values `error_message` was rendered with, or `null`. Always returned. Provided so you can re-render the failure in your own wording or locale instead of reusing ours. - **`id` (required)** `string`, format: `uuid` Unique agent identifier - **`last_activity_at` (required)** `string | null`, format: `date-time` When the agent last had activity - **`messages` (required)** `array` The latest turn's messages as a single ordered, type-tagged array. Always returned. The full conversation across all turns is served (paginated) by `GET /v1/{platform}/agents/{id}/messages`. **Items:** **One of:** - **`content` (required)** `string` - **`created_at` (required)** `string`, format: `date-time` - **`message_id` (required)** `string`, format: `uuid` - **`turn_id` (required)** `string`, format: `uuid` The turn this entry belongs to (groups entries by prompt execution). - **`type` (required)** `string`, possible values: `"user_message"` * **`content` (required)** `string` * **`created_at` (required)** `string`, format: `date-time` * **`message_id` (required)** `string`, format: `uuid` * **`turn_id` (required)** `string`, format: `uuid` * **`type` (required)** `string`, possible values: `"assistant_message"` **All of:** - **`turn_id` (required)** `string`, format: `uuid` The turn this entry belongs to (groups entries by prompt execution). - **`type` (required)** `string`, possible values: `"tool_call"` * **`created_at` (required)** `string`, format: `date-time` When the tool call started. * **`status` (required)** `string`, possible values: `"pending", "running", "succeeded", "failed", "cancelled"` Terminal outcomes are reported uniformly as `succeeded` or `failed` for every tool; for bulk tools, `succeeded` means the run finished with no row failures — which includes a run that wrote nothing because every target cell was already populated, so `rows.processed` can legitimately be `0`. A call the user cancelled mid-turn reports `cancelled`. * **`tool` (required)** `string` Name of the tool that was called * **`tool_call_id` (required)** `string`, format: `uuid` Tool-call identifier. * **`cells`** `integer` Number of cells the call touched: cells written for write\_range/write\_cells, and the source-range cell count for copy\_paste\_range (omitted when that range is unbounded). * **`column`** `string` add\_column\_header: the column the header was written to. Not returned for bulk tools, which report the written range as `updated_range`. * **`completed_at`** `string | null`, format: `date-time` When the tool call reached a terminal status. Omitted while the call is still `pending`/`running`. * **`fields`** `string` read\_spreadsheet\_fields: the requested field mask. * **`message`** `string` Result message from the tool call. Present **only** on a `failed` call, where it carries the failure reason; omitted for every other status. * **`number_of_searches`** `integer` web\_search: how many searches the tool ran. Each is a billed unit. * **`paste_type`** `string` copy\_paste\_range: the paste behaviour. * **`prompt_template`** `string` Bulk tools: the per-row prompt template (column refs as `{{A}}`). * **`query`** `string` web\_search: the query searched for (the tool's prompt). * **`range`** `string` Affected range. For read\_range/read\_cells/write\_range/write\_cells the sheet prefix is removed (see `sheet_name`); add\_column\_header can retain it. Not returned for bulk tools, which use `updated_range`, nor copy\_paste\_range, which uses `source_range`/`target_range`. * **`read`** `object` read\_range / read\_cells: the dimensions of the data returned — counts only, never cell contents. Totals span every sheet the read covered. `cells` counts the cells actually returned, so it is not necessarily `rows × columns` (the Sheets API omits trailing empties) — useful for spotting a silently truncated read. - **`cells` (required)** `integer` Cells actually returned. - **`columns` (required)** `integer` Distinct columns per sheet, summed across the sheets the read spanned. - **`rows` (required)** `integer` Distinct rows per sheet, summed across the sheets the read spanned. - **`sheets` (required)** `integer` Number of sheets the returned data spans. * **`rows`** `object` Bulk tools only: row counters. Absent for non-bulk tools. Includes whichever of `processed` (successful rows), `errors`, and `total` the tool reported. - **`errors`** `integer` Row error count, including AI errors and write errors. - **`processed`** `integer` Successfully processed rows. - **`total`** `integer` Total rows to process (successful + failed + never run). * **`sheet_name`** `string` Sheet the tool operated on (range tools, bulk tools, get\_sheet\_overview, read\_spreadsheet\_fields). For copy\_paste\_range this is the *destination* sheet — see `source_sheet`/`target_sheet`. * **`skill`** `string` load\_skill / create\_skill: the skill name(s). * **`source_range`** `string` copy\_paste\_range: the range copied from. * **`source_sheet`** `string` copy\_paste\_range: the sheet copied from, when the source range named one. On a cross-sheet copy this differs from `sheet_name`, which is the destination. * **`sources`** `array` web\_search: the pages the model opened and read, plus any URLs it cited, deduplicated. (Not the full set of links the searches surfaced.) **Items:** `string`, format: `uri` * **`target_range`** `string` copy\_paste\_range: the range pasted into. * **`target_sheet`** `string` copy\_paste\_range: the sheet pasted into, when the target range named one. * **`updated_range`** `string` Bulk tools: the reported written range, or an estimate from the row counters when no confirmed range is available. If writes failed and no range was confirmed, this field is omitted. - **`models` (required)** `object` The effective models for this agent (the most recent turn's), or `null`. Always returned. - **`number_of_turns` (required)** `integer` Total number of turns in this agent's conversation, including the one in progress when the agent is `active`. - **`spreadsheet_id` (required)** `string` Google Sheets spreadsheet ID - **`status` (required)** `string`, possible values: `"active", "idle"` Agent status: - `active`: A turn is currently in progress - `idle`: All turns are completed - **`usage` (required)** `object` The latest turn's **final** credit usage, or `null`. Always returned, and strictly the latest turn — unlike `models`, it does not fall back to an earlier turn, so an older turn's cost can never be mistaken for the latest one's. It is always terminal: `null` while a turn is still running (use `usage_so_far` for the running subtotal). A turn that ran to its natural end reports the figure the runtime settled on, and that figure is durable. A turn that **failed, was interrupted, or was cancelled** stores no figure of its own. For those, this field is supplemented from a short-lived accumulator — but **only on Get agent**: that endpoint reads it, while the `201` from Start agent and the `200` from Stop agent do not, so they report `null` for such a turn even when charges accumulated. The accumulator also expires roughly two hours after the turn ends. So `null` here means "no figure available" — nothing was charged, or the total has expired, or you are reading an endpoint that does not consult the accumulator — never "cost nothing". If you need it, read it from Get agent, promptly. - **`usage_so_far`** `object` The running credit subtotal of the turn currently in flight, in the same units as `usage`. **Present only while the latest turn is active** — the field is absent once the agent is `idle`, so summing `usage` never double-counts a subtotal that is still moving. Rises as the turn is charged. Only Get agent reads the accumulator; Start agent returns this field as `null` while its turn is active. On Get agent, `null` means no subtotal is available yet, or the accumulator is unavailable or has expired. **Example — Cancellation snapshot: stopped before the first recorded message** ```json { "id": "7a5e5e10-cb40-4e49-a054-bf2212342701", "spreadsheet_id": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms", "status": "idle", "created_at": "2026-02-18T12:00:00.000Z", "last_activity_at": "2026-02-18T12:00:01.000Z", "number_of_turns": 1, "models": { "agent_model": "managed:agent:openai/gpt-5.1", "bulk_model": "managed:bulk:openai/gpt-4.1", "bulk_search_model": "managed:search:perplexity/sonar" }, "error_message": "Agent cancelled by user.", "error_code": null, "error_params": null, "usage": null, "messages": [] } ``` ##### Status: 401 The API key is missing, malformed, or not recognized. A key that exists but has been disabled or revoked reports `403` instead — see the `403` response. ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example** ```json { "error": { "code": "INVALID_API_KEY", "message": "Invalid Autosheet API key. Create a new API key, then reconnect.", "error_code": "api-autosheet-apikey-invalid" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 403 The API key is recognized but the request cannot be served. Three families of cause, scoped to the operations documented here: - **Key state** — the key has been disabled or revoked in the dashboard. Possible on any operation. - **Google connection** — no Google account is connected to the key (possible on any operation), or the connection has expired and must be re-authorized (**[Start agent](https://autosheet.com/docs/api#tag/agents/POST/v1/{platform}/agents) only**). - **Spreadsheet access** — the connected Google account does not have editor access to the spreadsheet (**[Start agent](https://autosheet.com/docs/api#tag/agents/POST/v1/{platform}/agents) only**). The expired-connection and spreadsheet-access variants arise while resolving a spreadsheet, which only Start agent does among the operations documented here. The other documented operations can return only the key-state and not-connected causes. ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example — The key has been disabled in the dashboard** ```json { "error": { "code": "API_KEY_DISABLED", "message": "Disabled Autosheet API key. Enable a new API key at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/agent-api.", "error_code": "api-autosheet-apikey-disabled" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — The key has been revoked** ```json { "error": { "code": "API_KEY_REVOKED", "message": "Revoked Autosheet API key. Create a new API key at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/agent-api, then reconnect.", "error_code": "api-autosheet-apikey-revoked" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — No Google account has been connected yet** ```json { "error": { "code": "GOOGLE_AUTH_REQUIRED", "message": "Google account not connected. Please connect at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/agent-api", "error_code": "api-google-auth-required" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — A previously connected Google account must be reconnected (Start agent only)** ```json { "error": { "code": "GOOGLE_AUTH_REQUIRED", "message": "Google account connection expired. Reconnect at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/agent-api.", "error_code": "api-google-auth-expired" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — The connected account lacks editor access (Start agent only)** ```json { "error": { "code": "SPREADSHEET_ACCESS_DENIED", "message": "Cannot access this spreadsheet. Check that user@example.com has editor access to https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms", "error_code": "api-spreadsheet-access-denied" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 404 Agent not found ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example** ```json { "error": { "code": "AGENT_NOT_FOUND", "message": "Agent not found", "error_code": "api-agent-not-found" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 429 A limit was reached. Branch on `error.code` — the four causes have different remedies. The operation-specific notes below refer to the operations documented in this reference: - **`RATE_LIMIT_EXCEEDED`** — the per-key request rate limit (500 requests/minute). Wait for the window to reset and retry. - **`RATE_LIMIT_EXCEEDED`** with a Google Sheets message — Google's own API quota. That quota is separate from your Autosheet rate limit, but the rejected request has already passed the Autosheet limiter, so it still counts against your per-minute budget. Retry later. Only [Start agent](https://autosheet.com/docs/api#tag/agents/POST/v1/{platform}/agents) can return this, among the operations documented here, since the others do not resolve a spreadsheet. - **`SPENDING_LIMIT_REACHED`** — a space-wide or user spending limit was hit. Retrying will not help until the limit is raised in the dashboard or the period rolls over. - **`CONCURRENT_LIMIT_REACHED`** — too many agents are running at once (100 per API key). Retry once one finishes. Only [Start agent](https://autosheet.com/docs/api#tag/agents/POST/v1/{platform}/agents) can return this. **Headers.** `X-RateLimit-Limit`, `X-RateLimit-Remaining`, and `X-RateLimit-Reset` are set on every `429` — the rate-limit middleware stamps them before the spending and concurrency checks run. `Retry-After` and `X-RateLimit-Reset-After` are set **only** when the per-key rate limit itself rejected the request; they are absent on spending, concurrency, and Google-quota rejections. Note that a request rejected for concurrency still spends one request from the per-minute budget. **Response headers** **`X-RateLimit-Limit` (required)** — `integer` Request limit per minute **`X-RateLimit-Remaining` (required)** — `integer` Remaining requests in current window **`X-RateLimit-Reset` (required)** — `integer` Unix timestamp when the rate limit resets **`Retry-After`** — `integer` Seconds to wait before retrying. Present only on a `RATE_LIMIT_EXCEEDED` rejection from the per-key rate limit. **`X-RateLimit-Reset-After`** — `integer` Seconds until the rate-limit window resets. Same scope as `Retry-After`, and carries the same value. ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example — Per-key request rate limit (500/minute)** ```json { "error": { "code": "RATE_LIMIT_EXCEEDED", "message": "Rate limit exceeded. Retry after 60 seconds." }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — Google Sheets API quota, upstream (Start agent only)** ```json { "error": { "code": "RATE_LIMIT_EXCEEDED", "message": "Google Sheets API quota exceeded. Please try again later." }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — A spending limit was reached — one variant; wording depends on scope, plan and role** ```json { "error": { "code": "SPENDING_LIMIT_REACHED", "message": "User limit reached. It will reset on September 1st. Increase it on https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/billing to continue.", "error_code": "api-billing-spending-limit-reached-user" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — Too many agents running at once (Start agent only)** ```json { "error": { "code": "CONCURRENT_LIMIT_REACHED", "message": "Maximum number of concurrent active agents reached" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 500 Internal server error ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example** ```json { "error": { "code": "INTERNAL_SERVER_ERROR", "message": "Internal server error" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ### List available models - **Method:** `GET` - **Path:** `/v1/{platform}/agents/configuration` - **Tags:** Agents Returns the available models for your space, grouped by purpose. If your space has custom model settings, those are returned. Otherwise, platform defaults are used. Use the model `id` values when creating an agent with a specific model override. #### Parameters ##### `platform` required - **In:** `path` Target platform **Example** ```json "sheets" ``` `string`, possible values: `"sheets"` #### Responses ##### Status: 200 Available configuration ###### Content-Type: application/json - **`models` (required)** `object` Available models and current defaults for this space - **`agent_models` (required)** `array` Models available for agent execution. Use the `id` in the `agent_model` field when running an agent. **Items:** - **`id` (required)** `string` Model identifier to use in API requests - **`is_default` (required)** `boolean` Whether this is the current default for its category - **`label` (required)** `string` Human-readable model name - **`provider` (required)** `string` Model provider - **`bulk_models` (required)** `array` Models available for bulk (standard) operations **Items:** - **`id` (required)** `string` Model identifier to use in API requests - **`is_default` (required)** `boolean` Whether this is the current default for its category - **`label` (required)** `string` Human-readable model name - **`provider` (required)** `string` Model provider - **`bulk_search_models` (required)** `array` Models available for web search operations **Items:** - **`id` (required)** `string` Model identifier to use in API requests - **`is_default` (required)** `boolean` Whether this is the current default for its category - **`label` (required)** `string` Human-readable model name - **`provider` (required)** `string` Model provider - **`defaults` (required)** `object` Current default model selections for this space. A category is omitted when the space has no model marked as its default. - **`agent_model`** `string` Default agent model ID - **`bulk_model`** `string` Default bulk model ID - **`bulk_search_model`** `string` Default web search model ID **Example:** ```json { "models": { "agent_models": [ { "id": "managed:agent:openai/gpt-5.1", "label": "gpt-5.1", "provider": "openai", "is_default": true }, { "id": "managed:agent:anthropic/claude-opus-4-6", "label": "claude-opus-4-6", "provider": "anthropic", "is_default": false } ], "bulk_models": [ { "id": "managed:bulk:openai/gpt-4.1", "label": "gpt-4.1", "provider": "openai", "is_default": true } ], "bulk_search_models": [ { "id": "managed:search:perplexity/sonar", "label": "sonar", "provider": "perplexity", "is_default": true } ], "defaults": { "agent_model": "managed:agent:openai/gpt-5.1", "bulk_model": "managed:bulk:openai/gpt-4.1", "bulk_search_model": "managed:search:perplexity/sonar" } } } ``` ##### Status: 401 The API key is missing, malformed, or not recognized. A key that exists but has been disabled or revoked reports `403` instead — see the `403` response. ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example** ```json { "error": { "code": "INVALID_API_KEY", "message": "Invalid Autosheet API key. Create a new API key, then reconnect.", "error_code": "api-autosheet-apikey-invalid" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 403 The API key is recognized but the request cannot be served. Three families of cause, scoped to the operations documented here: - **Key state** — the key has been disabled or revoked in the dashboard. Possible on any operation. - **Google connection** — no Google account is connected to the key (possible on any operation), or the connection has expired and must be re-authorized (**[Start agent](https://autosheet.com/docs/api#tag/agents/POST/v1/{platform}/agents) only**). - **Spreadsheet access** — the connected Google account does not have editor access to the spreadsheet (**[Start agent](https://autosheet.com/docs/api#tag/agents/POST/v1/{platform}/agents) only**). The expired-connection and spreadsheet-access variants arise while resolving a spreadsheet, which only Start agent does among the operations documented here. The other documented operations can return only the key-state and not-connected causes. ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example — The key has been disabled in the dashboard** ```json { "error": { "code": "API_KEY_DISABLED", "message": "Disabled Autosheet API key. Enable a new API key at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/agent-api.", "error_code": "api-autosheet-apikey-disabled" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — The key has been revoked** ```json { "error": { "code": "API_KEY_REVOKED", "message": "Revoked Autosheet API key. Create a new API key at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/agent-api, then reconnect.", "error_code": "api-autosheet-apikey-revoked" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — No Google account has been connected yet** ```json { "error": { "code": "GOOGLE_AUTH_REQUIRED", "message": "Google account not connected. Please connect at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/agent-api", "error_code": "api-google-auth-required" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — A previously connected Google account must be reconnected (Start agent only)** ```json { "error": { "code": "GOOGLE_AUTH_REQUIRED", "message": "Google account connection expired. Reconnect at https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/agent-api.", "error_code": "api-google-auth-expired" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — The connected account lacks editor access (Start agent only)** ```json { "error": { "code": "SPREADSHEET_ACCESS_DENIED", "message": "Cannot access this spreadsheet. Check that user@example.com has editor access to https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms", "error_code": "api-spreadsheet-access-denied" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 429 A limit was reached. Branch on `error.code` — the four causes have different remedies. The operation-specific notes below refer to the operations documented in this reference: - **`RATE_LIMIT_EXCEEDED`** — the per-key request rate limit (500 requests/minute). Wait for the window to reset and retry. - **`RATE_LIMIT_EXCEEDED`** with a Google Sheets message — Google's own API quota. That quota is separate from your Autosheet rate limit, but the rejected request has already passed the Autosheet limiter, so it still counts against your per-minute budget. Retry later. Only [Start agent](https://autosheet.com/docs/api#tag/agents/POST/v1/{platform}/agents) can return this, among the operations documented here, since the others do not resolve a spreadsheet. - **`SPENDING_LIMIT_REACHED`** — a space-wide or user spending limit was hit. Retrying will not help until the limit is raised in the dashboard or the period rolls over. - **`CONCURRENT_LIMIT_REACHED`** — too many agents are running at once (100 per API key). Retry once one finishes. Only [Start agent](https://autosheet.com/docs/api#tag/agents/POST/v1/{platform}/agents) can return this. **Headers.** `X-RateLimit-Limit`, `X-RateLimit-Remaining`, and `X-RateLimit-Reset` are set on every `429` — the rate-limit middleware stamps them before the spending and concurrency checks run. `Retry-After` and `X-RateLimit-Reset-After` are set **only** when the per-key rate limit itself rejected the request; they are absent on spending, concurrency, and Google-quota rejections. Note that a request rejected for concurrency still spends one request from the per-minute budget. **Response headers** **`X-RateLimit-Limit` (required)** — `integer` Request limit per minute **`X-RateLimit-Remaining` (required)** — `integer` Remaining requests in current window **`X-RateLimit-Reset` (required)** — `integer` Unix timestamp when the rate limit resets **`Retry-After`** — `integer` Seconds to wait before retrying. Present only on a `RATE_LIMIT_EXCEEDED` rejection from the per-key rate limit. **`X-RateLimit-Reset-After`** — `integer` Seconds until the rate-limit window resets. Same scope as `Retry-After`, and carries the same value. ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example — Per-key request rate limit (500/minute)** ```json { "error": { "code": "RATE_LIMIT_EXCEEDED", "message": "Rate limit exceeded. Retry after 60 seconds." }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — Google Sheets API quota, upstream (Start agent only)** ```json { "error": { "code": "RATE_LIMIT_EXCEEDED", "message": "Google Sheets API quota exceeded. Please try again later." }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — A spending limit was reached — one variant; wording depends on scope, plan and role** ```json { "error": { "code": "SPENDING_LIMIT_REACHED", "message": "User limit reached. It will reset on September 1st. Increase it on https://dashboard.autosheet.com/space/11223344-5566-7788-99aa-bbccddeeff00/settings/billing to continue.", "error_code": "api-billing-spending-limit-reached-user" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` **Example — Too many agents running at once (Start agent only)** ```json { "error": { "code": "CONCURRENT_LIMIT_REACHED", "message": "Maximum number of concurrent active agents reached" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ##### Status: 500 Internal server error ###### Content-Type: application/json - **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. - **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one. **Example** ```json { "error": { "code": "INTERNAL_SERVER_ERROR", "message": "Internal server error" }, "request_id": "b7c1a9f2-3d4e-4a51-8f60-2c9d5e7a1b83" } ``` ## Webhooks ### Turn completed - **Method:** `POST` - **Destination:** The `webhook_url` supplied for this task. - **Tags:** Webhooks Provide a `webhook_url` when [running an agent](https://autosheet.com/docs/api#tag/agents/POST/v1/{platform}/agents) and Autosheet sends this `POST` callback once the turn completes — so you don't have to poll. The callback fires for every outcome, with the `status` field set to `succeeded`, `failed`, `interrupted`, or `cancelled`. **Signature verification** — each request carries `X-Webhook-Signature: sha256=`, an HMAC-SHA256 of the **raw request body** keyed with your webhook secret. Fetch the secret from the [Verify API Key](https://autosheet.com/docs/api#tag/authentication/GET/v1/auth/verify) response (`webhook_secret` field), re-compute the HMAC over the raw body, and compare using a constant-time check (`crypto.timingSafeEqual` in Node, `hmac.compare_digest` in Python). Reject the request on mismatch. **Delivery** — respond with any `2xx` status to acknowledge. Non-`2xx` responses are not retried. #### Parameters ##### `X-Webhook-Signature` required - **In:** `header` HMAC-SHA256 of the raw request body, hex-encoded and prefixed with `sha256=`. Keyed with your webhook secret (see [Verify API Key](https://autosheet.com/docs/api#tag/authentication/GET/v1/auth/verify)). **Example** ```json "sha256=3f9a1c0b7d2e4f6a8b1c3d5e7f9a0b2c4d6e8f0a1b3c5d7e9f0a2b4c6d8e0f1a" ``` `string` #### Request Body ##### Content-Type: application/json - **`agent_id` (required)** `string`, format: `uuid` The agent that was running - **`error_code` (required)** `string | null` Machine-readable code for the failure behind `error_message`, or `null` when the turn carried none. Always present. Branch on this rather than on the message text. - **`error_message` (required)** `string | null` Error details when status is `failed` or `interrupted`, otherwise `null` - **`status` (required)** `string`, possible values: `"succeeded", "failed", "interrupted", "cancelled"` Turn outcome. `succeeded` means the turn reached its natural end — inspect the conversation for the result quality. - **`turn_id` (required)** `string`, format: `uuid` The specific turn that completed - **`usage` (required)** `object` The completed turn's credit usage, or `null`. Always present. This is only ever the figure the turn itself reported, which in practice means a turn that reached its natural end. A turn that failed, was interrupted, or was cancelled usually reports `null` here — its accumulated subtotal is available from [Get agent](https://autosheet.com/docs/api#tag/agents/GET/v1/{platform}/agents/{id}), which is the only endpoint that reads the accumulator. Body of the `POST` callback Autosheet sends to your `webhook_url` when a turn completes. **Example — Turn completed successfully** ```json { "agent_id": "1f7b5f98-3906-40f4-b177-8bc2327df6f1", "turn_id": "bd13ff9a-3b45-4b48-9aed-d4084d71cb6a", "status": "succeeded", "error_message": null, "error_code": null, "usage": { "agent_usage": 412000000, "tool_usage": 1071000000, "total_usage": 1483000000 } } ``` **Example — A separate task ended with a connection error** ```json { "agent_id": "6daec23d-42fa-4714-9ab5-53c4b1a337a0", "turn_id": "a3c2e8d1-4b56-4f89-9012-def456789abc", "status": "failed", "error_message": "The connection to Autosheet dropped before a final result was received. Check on the agent with autosheet_get_agent before doing anything else.", "error_code": "api-runtime-connection-lost", "usage": null } ``` #### Responses ##### Status: 2XX Return any `2xx` status to acknowledge receipt. Non-`2xx` responses are not retried. ## Schemas ### VerifyApiKeyResponse - **Type:**`object` * **`google_connected` (required)** `boolean` Whether Google Sheets access has been authorized * **`space` (required)** `object` - **`id` (required)** `string`, format: `uuid` Space ID the key belongs to - **`name` (required)** `string | null` Space name, or `null` when the space has no name set * **`user` (required)** `object` - **`email` (required)** `string | null` Email associated with the API key owner, or `null` when no email is on record for the account. * **`valid` (required)** `boolean` Whether the API key is valid and active * **`webhook_secret` (required)** `string | null` HMAC signing secret for webhook callbacks, or `null` if this key has no secret. Use it to verify the `X-Webhook-Signature` header on incoming webhook requests — see the *Webhooks* section. ### ConfigurationResponse - **Type:**`object` * **`models` (required)** `object` Available models and current defaults for this space - **`agent_models` (required)** `array` Models available for agent execution. Use the `id` in the `agent_model` field when running an agent. **Items:** - **`id` (required)** `string` Model identifier to use in API requests - **`is_default` (required)** `boolean` Whether this is the current default for its category - **`label` (required)** `string` Human-readable model name - **`provider` (required)** `string` Model provider - **`bulk_models` (required)** `array` Models available for bulk (standard) operations **Items:** - **`id` (required)** `string` Model identifier to use in API requests - **`is_default` (required)** `boolean` Whether this is the current default for its category - **`label` (required)** `string` Human-readable model name - **`provider` (required)** `string` Model provider - **`bulk_search_models` (required)** `array` Models available for web search operations **Items:** - **`id` (required)** `string` Model identifier to use in API requests - **`is_default` (required)** `boolean` Whether this is the current default for its category - **`label` (required)** `string` Human-readable model name - **`provider` (required)** `string` Model provider - **`defaults` (required)** `object` Current default model selections for this space. A category is omitted when the space has no model marked as its default. - **`agent_model`** `string` Default agent model ID - **`bulk_model`** `string` Default bulk model ID - **`bulk_search_model`** `string` Default web search model ID **Example:** ```json { "models": { "agent_models": [ { "id": "managed:agent:openai/gpt-5.1", "label": "gpt-5.1", "provider": "openai", "is_default": true }, { "id": "managed:agent:anthropic/claude-opus-4-6", "label": "claude-opus-4-6", "provider": "anthropic", "is_default": false } ], "bulk_models": [ { "id": "managed:bulk:openai/gpt-4.1", "label": "gpt-4.1", "provider": "openai", "is_default": true } ], "bulk_search_models": [ { "id": "managed:search:perplexity/sonar", "label": "sonar", "provider": "perplexity", "is_default": true } ], "defaults": { "agent_model": "managed:agent:openai/gpt-5.1", "bulk_model": "managed:bulk:openai/gpt-4.1", "bulk_search_model": "managed:search:perplexity/sonar" } } } ``` ### ModelOption - **Type:**`object` * **`id` (required)** `string` Model identifier to use in API requests * **`is_default` (required)** `boolean` Whether this is the current default for its category * **`label` (required)** `string` Human-readable model name * **`provider` (required)** `string` Model provider ### WebhookPayload - **Type:**`object` Body of the `POST` callback Autosheet sends to your `webhook_url` when a turn completes. - **`agent_id` (required)** `string`, format: `uuid` The agent that was running - **`error_code` (required)** `string | null` Machine-readable code for the failure behind `error_message`, or `null` when the turn carried none. Always present. Branch on this rather than on the message text. - **`error_message` (required)** `string | null` Error details when status is `failed` or `interrupted`, otherwise `null` - **`status` (required)** `string`, possible values: `"succeeded", "failed", "interrupted", "cancelled"` Turn outcome. `succeeded` means the turn reached its natural end — inspect the conversation for the result quality. - **`turn_id` (required)** `string`, format: `uuid` The specific turn that completed - **`usage` (required)** `object` The completed turn's credit usage, or `null`. Always present. This is only ever the figure the turn itself reported, which in practice means a turn that reached its natural end. A turn that failed, was interrupted, or was cancelled usually reports `null` here — its accumulated subtotal is available from [Get agent](https://autosheet.com/docs/api#tag/agents/GET/v1/{platform}/agents/{id}), which is the only endpoint that reads the accumulator. ### RunAgentRequest - **Type:**`object` `prompt` is always required. Alongside it, supply **either** `spreadsheet_id` (start a new agent) **or** `agent_id` (continue an existing one). Sending both is accepted — `agent_id` wins and the agent keeps its own spreadsheet. Sending neither returns `400 MISSING_REQUIRED_FIELD`. **Required alternatives (at least one must match):** - New agent (spreadsheet\_id): requires `spreadsheet_id` and `prompt`. Start a new agent on a spreadsheet — requires `spreadsheet_id`. - Follow-up (agent\_id): requires `agent_id` and `prompt`. Continue an existing agent's conversation — requires `agent_id`. * **`prompt` (required)** `string` Natural language instruction for the agent to execute. Must be non-empty once surrounding whitespace is trimmed; an empty or whitespace-only prompt is rejected with `400 MISSING_REQUIRED_FIELD`. * **`agent_id`** `string`, format: `uuid` ID of an existing agent to continue. When provided, the prompt is added as a follow-up turn. The agent must be in `idle` status. If omitted, a new agent is created and `spreadsheet_id` becomes required. * **`agent_model`** `string` Override the default agent model. Use an `id` from the `models.agent_models` list in [List available models](https://autosheet.com/docs/api#tag/agents/GET/v1/{platform}/agents/configuration). If not specified, the space's default agent model is used. * **`bulk_model`** `string` Override the default bulk tool model. Use an `id` from the `models.bulk_models` list in [List available models](https://autosheet.com/docs/api#tag/agents/GET/v1/{platform}/agents/configuration). If not specified, the space's default bulk model is used. * **`bulk_search_model`** `string` Override the default web search model. Use an `id` from the `models.bulk_search_models` list in [List available models](https://autosheet.com/docs/api#tag/agents/GET/v1/{platform}/agents/configuration). If not specified, the space's default search model is used. * **`sheet_id`** `integer` Numeric tab id — the `gid` from a Google Sheets URL. Alternative to `sheet_name`; resolved server-side to the tab title. Rejected with `400 SPREADSHEET_TAB_NOT_FOUND` when no tab has this id — the error `message` lists the spreadsheet's tabs with their ids, so you can retry without a second round trip. When both `sheet_id` and `sheet_name` resolve but name *different* tabs, the rejection is `400 INVALID_REQUEST` instead. * **`sheet_name`** `string` Name of the sheet to operate on. Defaults to the first sheet (new agent) or the sheet from the previous turn (follow-up). * **`spreadsheet_id`** `string` Google Sheets spreadsheet ID (found in the spreadsheet URL between `/d/` and `/edit`), or the full spreadsheet URL. When a full URL carries a tab id (`#gid=N`) and neither `sheet_id` nor `sheet_name` is provided, that tab is targeted automatically. **Required** when creating a new agent (no `agent_id`). On a follow-up it does not change the agent's spreadsheet — the agent keeps the one it was created with — but it is still format-checked, so a malformed value is rejected with `400 INVALID_SPREADSHEET_ID`. * **`webhook_url`** `string`, format: `uri` Optional URL to receive a `POST` callback when the turn completes. See the *Webhooks* section for the payload and signature contract. ### Agent - **Type:**`object` * **`created_at` (required)** `string`, format: `date-time` When the agent was created * **`error_code` (required)** `string | null` Machine-readable code for the latest turn's failure, or `null` when it has not errored. Always returned. Branch on this rather than matching `error_message`, which is generated copy and can change. * **`error_message` (required)** `string | null` The latest turn's error message (failure reason), or `null` when it has not errored. `null` while the turn is still in progress (`status: active`). Always returned — errored turns produce no assistant message, so this is where failures surface. * **`error_params` (required)** `object | null` The values `error_message` was rendered with, or `null`. Always returned. Provided so you can re-render the failure in your own wording or locale instead of reusing ours. * **`id` (required)** `string`, format: `uuid` Unique agent identifier * **`last_activity_at` (required)** `string | null`, format: `date-time` When the agent last had activity * **`messages` (required)** `array` The latest turn's messages as a single ordered, type-tagged array. Always returned. The full conversation across all turns is served (paginated) by `GET /v1/{platform}/agents/{id}/messages`. **Items:** **One of:** - **`content` (required)** `string` - **`created_at` (required)** `string`, format: `date-time` - **`message_id` (required)** `string`, format: `uuid` - **`turn_id` (required)** `string`, format: `uuid` The turn this entry belongs to (groups entries by prompt execution). - **`type` (required)** `string`, possible values: `"user_message"` * **`content` (required)** `string` * **`created_at` (required)** `string`, format: `date-time` * **`message_id` (required)** `string`, format: `uuid` * **`turn_id` (required)** `string`, format: `uuid` * **`type` (required)** `string`, possible values: `"assistant_message"` **All of:** - **`turn_id` (required)** `string`, format: `uuid` The turn this entry belongs to (groups entries by prompt execution). - **`type` (required)** `string`, possible values: `"tool_call"` * **`created_at` (required)** `string`, format: `date-time` When the tool call started. * **`status` (required)** `string`, possible values: `"pending", "running", "succeeded", "failed", "cancelled"` Terminal outcomes are reported uniformly as `succeeded` or `failed` for every tool; for bulk tools, `succeeded` means the run finished with no row failures — which includes a run that wrote nothing because every target cell was already populated, so `rows.processed` can legitimately be `0`. A call the user cancelled mid-turn reports `cancelled`. * **`tool` (required)** `string` Name of the tool that was called * **`tool_call_id` (required)** `string`, format: `uuid` Tool-call identifier. * **`cells`** `integer` Number of cells the call touched: cells written for write\_range/write\_cells, and the source-range cell count for copy\_paste\_range (omitted when that range is unbounded). * **`column`** `string` add\_column\_header: the column the header was written to. Not returned for bulk tools, which report the written range as `updated_range`. * **`completed_at`** `string | null`, format: `date-time` When the tool call reached a terminal status. Omitted while the call is still `pending`/`running`. * **`fields`** `string` read\_spreadsheet\_fields: the requested field mask. * **`message`** `string` Result message from the tool call. Present **only** on a `failed` call, where it carries the failure reason; omitted for every other status. * **`number_of_searches`** `integer` web\_search: how many searches the tool ran. Each is a billed unit. * **`paste_type`** `string` copy\_paste\_range: the paste behaviour. * **`prompt_template`** `string` Bulk tools: the per-row prompt template (column refs as `{{A}}`). * **`query`** `string` web\_search: the query searched for (the tool's prompt). * **`range`** `string` Affected range. For read\_range/read\_cells/write\_range/write\_cells the sheet prefix is removed (see `sheet_name`); add\_column\_header can retain it. Not returned for bulk tools, which use `updated_range`, nor copy\_paste\_range, which uses `source_range`/`target_range`. * **`read`** `object` read\_range / read\_cells: the dimensions of the data returned — counts only, never cell contents. Totals span every sheet the read covered. `cells` counts the cells actually returned, so it is not necessarily `rows × columns` (the Sheets API omits trailing empties) — useful for spotting a silently truncated read. - **`cells` (required)** `integer` Cells actually returned. - **`columns` (required)** `integer` Distinct columns per sheet, summed across the sheets the read spanned. - **`rows` (required)** `integer` Distinct rows per sheet, summed across the sheets the read spanned. - **`sheets` (required)** `integer` Number of sheets the returned data spans. * **`rows`** `object` Bulk tools only: row counters. Absent for non-bulk tools. Includes whichever of `processed` (successful rows), `errors`, and `total` the tool reported. - **`errors`** `integer` Row error count, including AI errors and write errors. - **`processed`** `integer` Successfully processed rows. - **`total`** `integer` Total rows to process (successful + failed + never run). * **`sheet_name`** `string` Sheet the tool operated on (range tools, bulk tools, get\_sheet\_overview, read\_spreadsheet\_fields). For copy\_paste\_range this is the *destination* sheet — see `source_sheet`/`target_sheet`. * **`skill`** `string` load\_skill / create\_skill: the skill name(s). * **`source_range`** `string` copy\_paste\_range: the range copied from. * **`source_sheet`** `string` copy\_paste\_range: the sheet copied from, when the source range named one. On a cross-sheet copy this differs from `sheet_name`, which is the destination. * **`sources`** `array` web\_search: the pages the model opened and read, plus any URLs it cited, deduplicated. (Not the full set of links the searches surfaced.) **Items:** `string`, format: `uri` * **`target_range`** `string` copy\_paste\_range: the range pasted into. * **`target_sheet`** `string` copy\_paste\_range: the sheet pasted into, when the target range named one. * **`updated_range`** `string` Bulk tools: the reported written range, or an estimate from the row counters when no confirmed range is available. If writes failed and no range was confirmed, this field is omitted. * **`models` (required)** `object` The effective models for this agent (the most recent turn's), or `null`. Always returned. * **`number_of_turns` (required)** `integer` Total number of turns in this agent's conversation, including the one in progress when the agent is `active`. * **`spreadsheet_id` (required)** `string` Google Sheets spreadsheet ID * **`status` (required)** `string`, possible values: `"active", "idle"` Agent status: - `active`: A turn is currently in progress - `idle`: All turns are completed * **`usage` (required)** `object` The latest turn's **final** credit usage, or `null`. Always returned, and strictly the latest turn — unlike `models`, it does not fall back to an earlier turn, so an older turn's cost can never be mistaken for the latest one's. It is always terminal: `null` while a turn is still running (use `usage_so_far` for the running subtotal). A turn that ran to its natural end reports the figure the runtime settled on, and that figure is durable. A turn that **failed, was interrupted, or was cancelled** stores no figure of its own. For those, this field is supplemented from a short-lived accumulator — but **only on Get agent**: that endpoint reads it, while the `201` from Start agent and the `200` from Stop agent do not, so they report `null` for such a turn even when charges accumulated. The accumulator also expires roughly two hours after the turn ends. So `null` here means "no figure available" — nothing was charged, or the total has expired, or you are reading an endpoint that does not consult the accumulator — never "cost nothing". If you need it, read it from Get agent, promptly. * **`usage_so_far`** `object` The running credit subtotal of the turn currently in flight, in the same units as `usage`. **Present only while the latest turn is active** — the field is absent once the agent is `idle`, so summing `usage` never double-counts a subtotal that is still moving. Rises as the turn is charged. Only Get agent reads the accumulator; Start agent returns this field as `null` while its turn is active. On Get agent, `null` means no subtotal is available yet, or the accumulator is unavailable or has expired. ### AgentModels - **Type:**`object` Models used by the agent. Each turn can use different models if overridden in the request. - **`agent_model` (required)** `string` Agent model in effect - **`bulk_model` (required)** `string` Bulk tool model in effect - **`bulk_search_model` (required)** `string` Web search model in effect ### TurnUsage - **Type:**`object` Credit usage for a single turn, in **integer nano-dollars** — divide by 1,000,000,000 for the dollar value (so `1483000000` is $1.483). - **`agent_usage` (required)** `integer` Usage attributable to the agent's own model calls. - **`tool_usage` (required)** `integer` Usage attributable to the tools the agent ran. - **`total_usage` (required)** `integer` Sum of `agent_usage` and `tool_usage`. ### AgentStatus - **Type:**`string` Agent status: - `active`: A turn is currently in progress - `idle`: All turns are completed ### AgentToolCall - **Type:**`object` * **`created_at` (required)** `string`, format: `date-time` When the tool call started. * **`status` (required)** `string`, possible values: `"pending", "running", "succeeded", "failed", "cancelled"` Terminal outcomes are reported uniformly as `succeeded` or `failed` for every tool; for bulk tools, `succeeded` means the run finished with no row failures — which includes a run that wrote nothing because every target cell was already populated, so `rows.processed` can legitimately be `0`. A call the user cancelled mid-turn reports `cancelled`. * **`tool` (required)** `string` Name of the tool that was called * **`tool_call_id` (required)** `string`, format: `uuid` Tool-call identifier. * **`cells`** `integer` Number of cells the call touched: cells written for write\_range/write\_cells, and the source-range cell count for copy\_paste\_range (omitted when that range is unbounded). * **`column`** `string` add\_column\_header: the column the header was written to. Not returned for bulk tools, which report the written range as `updated_range`. * **`completed_at`** `string | null`, format: `date-time` When the tool call reached a terminal status. Omitted while the call is still `pending`/`running`. * **`fields`** `string` read\_spreadsheet\_fields: the requested field mask. * **`message`** `string` Result message from the tool call. Present **only** on a `failed` call, where it carries the failure reason; omitted for every other status. * **`number_of_searches`** `integer` web\_search: how many searches the tool ran. Each is a billed unit. * **`paste_type`** `string` copy\_paste\_range: the paste behaviour. * **`prompt_template`** `string` Bulk tools: the per-row prompt template (column refs as `{{A}}`). * **`query`** `string` web\_search: the query searched for (the tool's prompt). * **`range`** `string` Affected range. For read\_range/read\_cells/write\_range/write\_cells the sheet prefix is removed (see `sheet_name`); add\_column\_header can retain it. Not returned for bulk tools, which use `updated_range`, nor copy\_paste\_range, which uses `source_range`/`target_range`. * **`read`** `object` read\_range / read\_cells: the dimensions of the data returned — counts only, never cell contents. Totals span every sheet the read covered. `cells` counts the cells actually returned, so it is not necessarily `rows × columns` (the Sheets API omits trailing empties) — useful for spotting a silently truncated read. - **`cells` (required)** `integer` Cells actually returned. - **`columns` (required)** `integer` Distinct columns per sheet, summed across the sheets the read spanned. - **`rows` (required)** `integer` Distinct rows per sheet, summed across the sheets the read spanned. - **`sheets` (required)** `integer` Number of sheets the returned data spans. * **`rows`** `object` Bulk tools only: row counters. Absent for non-bulk tools. Includes whichever of `processed` (successful rows), `errors`, and `total` the tool reported. - **`errors`** `integer` Row error count, including AI errors and write errors. - **`processed`** `integer` Successfully processed rows. - **`total`** `integer` Total rows to process (successful + failed + never run). * **`sheet_name`** `string` Sheet the tool operated on (range tools, bulk tools, get\_sheet\_overview, read\_spreadsheet\_fields). For copy\_paste\_range this is the *destination* sheet — see `source_sheet`/`target_sheet`. * **`skill`** `string` load\_skill / create\_skill: the skill name(s). * **`source_range`** `string` copy\_paste\_range: the range copied from. * **`source_sheet`** `string` copy\_paste\_range: the sheet copied from, when the source range named one. On a cross-sheet copy this differs from `sheet_name`, which is the destination. * **`sources`** `array` web\_search: the pages the model opened and read, plus any URLs it cited, deduplicated. (Not the full set of links the searches surfaced.) **Items:** `string`, format: `uri` * **`target_range`** `string` copy\_paste\_range: the range pasted into. * **`target_sheet`** `string` copy\_paste\_range: the sheet pasted into, when the target range named one. * **`updated_range`** `string` Bulk tools: the reported written range, or an estimate from the row counters when no confirmed range is available. If writes failed and no range was confirmed, this field is omitted. ### MessageEntry - **Type:**`object` One entry in the ordered conversation `messages` array. The `type` field discriminates between the variants. **One of:** - **`content` (required)** `string` - **`created_at` (required)** `string`, format: `date-time` - **`message_id` (required)** `string`, format: `uuid` - **`turn_id` (required)** `string`, format: `uuid` The turn this entry belongs to (groups entries by prompt execution). - **`type` (required)** `string`, possible values: `"user_message"` * **`content` (required)** `string` * **`created_at` (required)** `string`, format: `date-time` * **`message_id` (required)** `string`, format: `uuid` * **`turn_id` (required)** `string`, format: `uuid` * **`type` (required)** `string`, possible values: `"assistant_message"` **All of:** - **`turn_id` (required)** `string`, format: `uuid` The turn this entry belongs to (groups entries by prompt execution). - **`type` (required)** `string`, possible values: `"tool_call"` * **`created_at` (required)** `string`, format: `date-time` When the tool call started. * **`status` (required)** `string`, possible values: `"pending", "running", "succeeded", "failed", "cancelled"` Terminal outcomes are reported uniformly as `succeeded` or `failed` for every tool; for bulk tools, `succeeded` means the run finished with no row failures — which includes a run that wrote nothing because every target cell was already populated, so `rows.processed` can legitimately be `0`. A call the user cancelled mid-turn reports `cancelled`. * **`tool` (required)** `string` Name of the tool that was called * **`tool_call_id` (required)** `string`, format: `uuid` Tool-call identifier. * **`cells`** `integer` Number of cells the call touched: cells written for write\_range/write\_cells, and the source-range cell count for copy\_paste\_range (omitted when that range is unbounded). * **`column`** `string` add\_column\_header: the column the header was written to. Not returned for bulk tools, which report the written range as `updated_range`. * **`completed_at`** `string | null`, format: `date-time` When the tool call reached a terminal status. Omitted while the call is still `pending`/`running`. * **`fields`** `string` read\_spreadsheet\_fields: the requested field mask. * **`message`** `string` Result message from the tool call. Present **only** on a `failed` call, where it carries the failure reason; omitted for every other status. * **`number_of_searches`** `integer` web\_search: how many searches the tool ran. Each is a billed unit. * **`paste_type`** `string` copy\_paste\_range: the paste behaviour. * **`prompt_template`** `string` Bulk tools: the per-row prompt template (column refs as `{{A}}`). * **`query`** `string` web\_search: the query searched for (the tool's prompt). * **`range`** `string` Affected range. For read\_range/read\_cells/write\_range/write\_cells the sheet prefix is removed (see `sheet_name`); add\_column\_header can retain it. Not returned for bulk tools, which use `updated_range`, nor copy\_paste\_range, which uses `source_range`/`target_range`. * **`read`** `object` read\_range / read\_cells: the dimensions of the data returned — counts only, never cell contents. Totals span every sheet the read covered. `cells` counts the cells actually returned, so it is not necessarily `rows × columns` (the Sheets API omits trailing empties) — useful for spotting a silently truncated read. - **`cells` (required)** `integer` Cells actually returned. - **`columns` (required)** `integer` Distinct columns per sheet, summed across the sheets the read spanned. - **`rows` (required)** `integer` Distinct rows per sheet, summed across the sheets the read spanned. - **`sheets` (required)** `integer` Number of sheets the returned data spans. * **`rows`** `object` Bulk tools only: row counters. Absent for non-bulk tools. Includes whichever of `processed` (successful rows), `errors`, and `total` the tool reported. - **`errors`** `integer` Row error count, including AI errors and write errors. - **`processed`** `integer` Successfully processed rows. - **`total`** `integer` Total rows to process (successful + failed + never run). * **`sheet_name`** `string` Sheet the tool operated on (range tools, bulk tools, get\_sheet\_overview, read\_spreadsheet\_fields). For copy\_paste\_range this is the *destination* sheet — see `source_sheet`/`target_sheet`. * **`skill`** `string` load\_skill / create\_skill: the skill name(s). * **`source_range`** `string` copy\_paste\_range: the range copied from. * **`source_sheet`** `string` copy\_paste\_range: the sheet copied from, when the source range named one. On a cross-sheet copy this differs from `sheet_name`, which is the destination. * **`sources`** `array` web\_search: the pages the model opened and read, plus any URLs it cited, deduplicated. (Not the full set of links the searches surfaced.) **Items:** `string`, format: `uri` * **`target_range`** `string` copy\_paste\_range: the range pasted into. * **`target_sheet`** `string` copy\_paste\_range: the sheet pasted into, when the target range named one. * **`updated_range`** `string` Bulk tools: the reported written range, or an estimate from the row counters when no confirmed range is available. If writes failed and no range was confirmed, this field is omitted. ### AgentMessagesPage - **Type:**`object` One page of the full conversation, oldest-first. The example is the second and final page (`limit=2`, `after=wmOoAZkdaU3oV18j`) of the completed Get agent example. Its non-null `end_cursor` identifies the final entry; `has_next_page: false` indicates there are no more entries to fetch. - **`end_cursor` (required)** `string | null` Cursor of the last entry on this page — pass as `after` to fetch the next page. Populated on every non-empty page, including the last one (where `has_next_page` is `false`); `null` only when the page is empty. Use `has_next_page`, not this field, to decide whether to keep paginating. - **`has_next_page` (required)** `boolean` - **`messages` (required)** `array` **Items:** **One of:** - **`content` (required)** `string` - **`created_at` (required)** `string`, format: `date-time` - **`message_id` (required)** `string`, format: `uuid` - **`turn_id` (required)** `string`, format: `uuid` The turn this entry belongs to (groups entries by prompt execution). - **`type` (required)** `string`, possible values: `"user_message"` * **`content` (required)** `string` * **`created_at` (required)** `string`, format: `date-time` * **`message_id` (required)** `string`, format: `uuid` * **`turn_id` (required)** `string`, format: `uuid` * **`type` (required)** `string`, possible values: `"assistant_message"` **All of:** - **`turn_id` (required)** `string`, format: `uuid` The turn this entry belongs to (groups entries by prompt execution). - **`type` (required)** `string`, possible values: `"tool_call"` * **`created_at` (required)** `string`, format: `date-time` When the tool call started. * **`status` (required)** `string`, possible values: `"pending", "running", "succeeded", "failed", "cancelled"` Terminal outcomes are reported uniformly as `succeeded` or `failed` for every tool; for bulk tools, `succeeded` means the run finished with no row failures — which includes a run that wrote nothing because every target cell was already populated, so `rows.processed` can legitimately be `0`. A call the user cancelled mid-turn reports `cancelled`. * **`tool` (required)** `string` Name of the tool that was called * **`tool_call_id` (required)** `string`, format: `uuid` Tool-call identifier. * **`cells`** `integer` Number of cells the call touched: cells written for write\_range/write\_cells, and the source-range cell count for copy\_paste\_range (omitted when that range is unbounded). * **`column`** `string` add\_column\_header: the column the header was written to. Not returned for bulk tools, which report the written range as `updated_range`. * **`completed_at`** `string | null`, format: `date-time` When the tool call reached a terminal status. Omitted while the call is still `pending`/`running`. * **`fields`** `string` read\_spreadsheet\_fields: the requested field mask. * **`message`** `string` Result message from the tool call. Present **only** on a `failed` call, where it carries the failure reason; omitted for every other status. * **`number_of_searches`** `integer` web\_search: how many searches the tool ran. Each is a billed unit. * **`paste_type`** `string` copy\_paste\_range: the paste behaviour. * **`prompt_template`** `string` Bulk tools: the per-row prompt template (column refs as `{{A}}`). * **`query`** `string` web\_search: the query searched for (the tool's prompt). * **`range`** `string` Affected range. For read\_range/read\_cells/write\_range/write\_cells the sheet prefix is removed (see `sheet_name`); add\_column\_header can retain it. Not returned for bulk tools, which use `updated_range`, nor copy\_paste\_range, which uses `source_range`/`target_range`. * **`read`** `object` read\_range / read\_cells: the dimensions of the data returned — counts only, never cell contents. Totals span every sheet the read covered. `cells` counts the cells actually returned, so it is not necessarily `rows × columns` (the Sheets API omits trailing empties) — useful for spotting a silently truncated read. - **`cells` (required)** `integer` Cells actually returned. - **`columns` (required)** `integer` Distinct columns per sheet, summed across the sheets the read spanned. - **`rows` (required)** `integer` Distinct rows per sheet, summed across the sheets the read spanned. - **`sheets` (required)** `integer` Number of sheets the returned data spans. * **`rows`** `object` Bulk tools only: row counters. Absent for non-bulk tools. Includes whichever of `processed` (successful rows), `errors`, and `total` the tool reported. - **`errors`** `integer` Row error count, including AI errors and write errors. - **`processed`** `integer` Successfully processed rows. - **`total`** `integer` Total rows to process (successful + failed + never run). * **`sheet_name`** `string` Sheet the tool operated on (range tools, bulk tools, get\_sheet\_overview, read\_spreadsheet\_fields). For copy\_paste\_range this is the *destination* sheet — see `source_sheet`/`target_sheet`. * **`skill`** `string` load\_skill / create\_skill: the skill name(s). * **`source_range`** `string` copy\_paste\_range: the range copied from. * **`source_sheet`** `string` copy\_paste\_range: the sheet copied from, when the source range named one. On a cross-sheet copy this differs from `sheet_name`, which is the destination. * **`sources`** `array` web\_search: the pages the model opened and read, plus any URLs it cited, deduplicated. (Not the full set of links the searches surfaced.) **Items:** `string`, format: `uri` * **`target_range`** `string` copy\_paste\_range: the range pasted into. * **`target_sheet`** `string` copy\_paste\_range: the sheet pasted into, when the target range named one. * **`updated_range`** `string` Bulk tools: the reported written range, or an estimate from the row counters when no confirmed range is available. If writes failed and no range was confirmed, this field is omitted. - **`total` (required)** `integer` Total number of entries in the full conversation. **Example:** ```json { "messages": [ { "type": "tool_call", "turn_id": "bd13ff9a-3b45-4b48-9aed-d4084d71cb6a", "tool_call_id": "773e2fd7-fedd-47eb-a991-f4f953b89344", "created_at": "2026-02-18T10:04:59.000Z", "tool": "ai_bulk_process_rows", "status": "succeeded", "completed_at": "2026-02-18T10:05:08.000Z", "updated_range": "F2:F51", "sheet_name": "Leads", "prompt_template": "In one short line, explain the score for this lead: {{A}}.", "rows": { "processed": 50, "errors": 0, "total": 50 } }, { "type": "assistant_message", "turn_id": "bd13ff9a-3b45-4b48-9aed-d4084d71cb6a", "message_id": "be42ee1a-966c-405f-bcd3-485d5c5ea5eb", "created_at": "2026-02-18T10:05:09.000Z", "content": "Scored all 50 leads against your scoring rules in column E and added a one-line explanation in column F (score_reason)." } ], "end_cursor": "mKsL7GAONWSi8sFx", "has_next_page": false, "total": 4 } ``` ### UserMessageEntry - **Type:**`object` A user message in the conversation. - **`content` (required)** `string` - **`created_at` (required)** `string`, format: `date-time` - **`message_id` (required)** `string`, format: `uuid` - **`turn_id` (required)** `string`, format: `uuid` The turn this entry belongs to (groups entries by prompt execution). - **`type` (required)** `string`, possible values: `"user_message"` ### AssistantMessageEntry - **Type:**`object` An assistant message (reasoning or final response) in the conversation. - **`content` (required)** `string` - **`created_at` (required)** `string`, format: `date-time` - **`message_id` (required)** `string`, format: `uuid` - **`turn_id` (required)** `string`, format: `uuid` - **`type` (required)** `string`, possible values: `"assistant_message"` ### ToolCallEntry - **Type:**`object` A tool call in the conversation, with its result embedded: `status`, `completed_at` and the summary details update in place as the call completes. **All of:** - **`turn_id` (required)** `string`, format: `uuid` The turn this entry belongs to (groups entries by prompt execution). - **`type` (required)** `string`, possible values: `"tool_call"` * **`created_at` (required)** `string`, format: `date-time` When the tool call started. * **`status` (required)** `string`, possible values: `"pending", "running", "succeeded", "failed", "cancelled"` Terminal outcomes are reported uniformly as `succeeded` or `failed` for every tool; for bulk tools, `succeeded` means the run finished with no row failures — which includes a run that wrote nothing because every target cell was already populated, so `rows.processed` can legitimately be `0`. A call the user cancelled mid-turn reports `cancelled`. * **`tool` (required)** `string` Name of the tool that was called * **`tool_call_id` (required)** `string`, format: `uuid` Tool-call identifier. * **`cells`** `integer` Number of cells the call touched: cells written for write\_range/write\_cells, and the source-range cell count for copy\_paste\_range (omitted when that range is unbounded). * **`column`** `string` add\_column\_header: the column the header was written to. Not returned for bulk tools, which report the written range as `updated_range`. * **`completed_at`** `string | null`, format: `date-time` When the tool call reached a terminal status. Omitted while the call is still `pending`/`running`. * **`fields`** `string` read\_spreadsheet\_fields: the requested field mask. * **`message`** `string` Result message from the tool call. Present **only** on a `failed` call, where it carries the failure reason; omitted for every other status. * **`number_of_searches`** `integer` web\_search: how many searches the tool ran. Each is a billed unit. * **`paste_type`** `string` copy\_paste\_range: the paste behaviour. * **`prompt_template`** `string` Bulk tools: the per-row prompt template (column refs as `{{A}}`). * **`query`** `string` web\_search: the query searched for (the tool's prompt). * **`range`** `string` Affected range. For read\_range/read\_cells/write\_range/write\_cells the sheet prefix is removed (see `sheet_name`); add\_column\_header can retain it. Not returned for bulk tools, which use `updated_range`, nor copy\_paste\_range, which uses `source_range`/`target_range`. * **`read`** `object` read\_range / read\_cells: the dimensions of the data returned — counts only, never cell contents. Totals span every sheet the read covered. `cells` counts the cells actually returned, so it is not necessarily `rows × columns` (the Sheets API omits trailing empties) — useful for spotting a silently truncated read. - **`cells` (required)** `integer` Cells actually returned. - **`columns` (required)** `integer` Distinct columns per sheet, summed across the sheets the read spanned. - **`rows` (required)** `integer` Distinct rows per sheet, summed across the sheets the read spanned. - **`sheets` (required)** `integer` Number of sheets the returned data spans. * **`rows`** `object` Bulk tools only: row counters. Absent for non-bulk tools. Includes whichever of `processed` (successful rows), `errors`, and `total` the tool reported. - **`errors`** `integer` Row error count, including AI errors and write errors. - **`processed`** `integer` Successfully processed rows. - **`total`** `integer` Total rows to process (successful + failed + never run). * **`sheet_name`** `string` Sheet the tool operated on (range tools, bulk tools, get\_sheet\_overview, read\_spreadsheet\_fields). For copy\_paste\_range this is the *destination* sheet — see `source_sheet`/`target_sheet`. * **`skill`** `string` load\_skill / create\_skill: the skill name(s). * **`source_range`** `string` copy\_paste\_range: the range copied from. * **`source_sheet`** `string` copy\_paste\_range: the sheet copied from, when the source range named one. On a cross-sheet copy this differs from `sheet_name`, which is the destination. * **`sources`** `array` web\_search: the pages the model opened and read, plus any URLs it cited, deduplicated. (Not the full set of links the searches surfaced.) **Items:** `string`, format: `uri` * **`target_range`** `string` copy\_paste\_range: the range pasted into. * **`target_sheet`** `string` copy\_paste\_range: the sheet pasted into, when the target range named one. * **`updated_range`** `string` Bulk tools: the reported written range, or an estimate from the row counters when no confirmed range is available. If writes failed and no range was confirmed, this field is omitted. ### Error - **Type:**`object` * **`error` (required)** `object` - **`code` (required)** `string` Machine-readable error code - **`message` (required)** `string` Human-readable error message. This is generated copy — it is rendered per request and can vary with your account context, so branch on `code` (or `error_code`), never on this text. - **`error_code`** `string` Cross-service identifier for the underlying condition, more specific than `code`. Present only when the failure carries one, so its absence is meaningful. * **`request_id` (required)** `string` Identifier for this request, returned on every error response and echoed on every response as the `X-Request-Id` header. Quote it when contacting support. If you send your own `X-Request-Id` header it is used here; otherwise the API generates one.