# Submit a tool result > Send the result of a client action back to the agent so it can finish its answer When the agent calls a [client action](/docs/api-reference/v2/client-actions), your app runs it, not QwryAI. The answer stops with `finishReason: "tool-calls"` and a `tool-call` part holding a `toolCallId`. Run the action, send its result here with that `toolCallId`, then call [Chat with an agent](/docs/api-reference/v2/agents/chat-with-an-agent) again with the same `conversationId` so the agent can use the result. ```http POST https://api.qwryai.com/api/v2/agents/{agentId}/conversations/{conversationId}/tool-result ``` ## Authentication Send your API key as `Authorization: Bearer `. The key needs **Chat with agents**. See [Authentication](/docs/api-reference/v2/authentication). ## Path parameters | Name | Type | Required | Description | | - | - | - | - | | `agentId` | `string` | Yes | The agent's id, from `list_agents`. | | `conversationId` | `string` | Yes | The conversation the action was called in. | ## Body parameters | Name | Type | Required | Description | | - | - | - | - | | `toolCallId` | `string` | Yes | The `toolCallId` from the `tool-call` part, or from the stream's `tool-input-start` event. | | `output` | any JSON | No | What the action returned: an object, array, string, number or boolean. Up to 256 KB. Leave it out to send `null`. | Any other field is refused with `VALIDATION_INVALID_BODY`. ## Request example > [tab] cURL > > ```bash > curl -X POST 'https://api.qwryai.com/api/v2/agents/YOUR_AGENT_ID/conversations/fd5ae9e1-9b30-4503-b346-ccd4d7ef16a3/tool-result' \ > -H 'Authorization: Bearer YOUR_API_KEY' \ > -H 'Content-Type: application/json' \ > -d '{ > "toolCallId": "a7c4e9d2-3b1f-4a68-8e5c-0f9d2b6a1c37", > "output": { "items": 2, "total": "84.00", "currency": "NZD" } > }' > ``` > [tab] JavaScript > > ```javascript > const BASE = "https://api.qwryai.com/api/v2/agents/YOUR_AGENT_ID"; > const headers = { Authorization: "Bearer YOUR_API_KEY", "Content-Type": "application/json" }; > const conversationId = "fd5ae9e1-9b30-4503-b346-ccd4d7ef16a3"; > > await fetch(`${BASE}/conversations/${conversationId}/tool-result`, { > method: "POST", > headers, > body: JSON.stringify({ > toolCallId: "a7c4e9d2-3b1f-4a68-8e5c-0f9d2b6a1c37", > output: { items: 2, total: "84.00", currency: "NZD" }, > }), > }); > > // Let the agent continue from the result > await fetch(`${BASE}/chat`, { method: "POST", headers, body: JSON.stringify({ conversationId }) }); > ``` > [tab] Python > > ```python > import requests > > BASE = "https://api.qwryai.com/api/v2/agents/YOUR_AGENT_ID" > headers = {"Authorization": "Bearer YOUR_API_KEY"} > conversation_id = "fd5ae9e1-9b30-4503-b346-ccd4d7ef16a3" > > requests.post( > f"{BASE}/conversations/{conversation_id}/tool-result", > headers=headers, > json={ > "toolCallId": "a7c4e9d2-3b1f-4a68-8e5c-0f9d2b6a1c37", > "output": {"items": 2, "total": "84.00", "currency": "NZD"}, > }, > ) > > # Let the agent continue from the result > requests.post(f"{BASE}/chat", headers=headers, json={"conversationId": conversation_id}, stream=True) > ``` ## Response ```json { "data": { "success": true } } ``` The result is stored, and the agent uses it on your next chat request for this conversation. If the agent called several client actions in one answer, submit a result for each before you continue. > [!NOTE] > > Each `toolCallId` takes one result. A client action that waits too long expires, and its `toolCallId` is refused after that. ## Errors | HTTP status | Code | When | | - | - | - | | 400 | `VALIDATION_INVALID_BODY` | No `toolCallId`, an unknown field, or an `output` over 256 KB. | | 401 | `AUTH_MISSING_API_KEY` / `AUTH_INVALID_API_KEY` | No key, or an unknown, deleted or expired key. | | 403 | `SUBSCRIPTION_API_RESTRICTED_PLAN` | The workspace's plan doesn't include API access. | | 403 | `ACCESS_COUNTRY_BLOCKED` | The request comes from a country the agent blocks in **Guardrails**. | | 403 | `CHAT_CONVERSATION_MISMATCH` | The conversation doesn't exist or belongs to another agent. | | 404 | `AGENT_NOT_FOUND` | No agent with that id in your workspace. | | 404 | `RESOURCE_TOOL_CALL_NOT_FOUND` | No client action is waiting for this `toolCallId` in this conversation: it expired, or its result was already submitted. | | 409 | `CHAT_CONVERSATION_NOT_ONGOING` | The conversation ended, or a teammate took it over. | | 429 | `RATE_LIMIT_TOO_MANY_REQUESTS` | Too many requests. Wait for `Retry-After` seconds. | | 500 | `INTERNAL_SERVER_ERROR` | Something failed on our side. | See [Error Handling](/docs/api-reference/v2/error-handling) for every code.