# Answer a relayed tool call

`POST https://api.morevoice.ai/v1/cli/listen/{session_id}/tool_results`

Sends your local tool server's answer (status and body, as it responded) for a `tool_call` frame of your listen session. Only the key that opened the session can answer, within the call's `timeout_ms`.

Authenticate with a secret API key: `Authorization: Bearer $MOREVOICE_API_KEY`.

Operation ID: `cli_submit_tool_result`.

## Parameters

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `session_id` | `string` | yes | The session's ID (`clis_…`, from the `cli.session` frame). |

### Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `MoreVoice-Version` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `Idempotency-Key` | `string` | no | A unique key (for example a UUID) that makes this request safe to retry: for 24 hours, a retry with the same key and parameters returns the first response instead of acting twice. |

## Request body

Required, `application/json`.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | The `tool_call` frame's `id`. |
| `body` | `string` | no | Your local server's response body, as is (the tool's answer). |
| `error` | `string` | no | Your local server could not be reached: the tool call fails with this message. |
| `headers` | `Record<string, string>` | no | Your local server's response headers (informational). |
| `status` | `integer` | no | Your local server's HTTP status (default 200). |

Example:

```json
{
  "body": "{\"status\":\"shipped\"}",
  "id": "clitc_7cJ9kL4mP2qR5sT8uV1wXy",
  "status": 200
}
```

## Responses

### 200 OK

OK Returns `CliToolResult`.

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"cli_tool_result"` | — |
| `id` | `string` | `clitc_…` ID. |
| `session_id` | `string` | — |
| `accepted` | `true` | — |

Example:

```json
{
  "accepted": true,
  "id": "clitc_7cJ9kL4mP2qR5sT8uV1wXy",
  "object": "cli_tool_result",
  "session_id": "clis_5bH8jK3mN6pQ9rT2vW4xYz"
}
```

### 400 Bad Request

The request is invalid: a parameter is missing, malformed or unknown, or the version header is unknown. Returns `ErrorEnvelope`.

### 401 Unauthorized

No valid API key was sent. Returns `ErrorEnvelope`.

### 403 Forbidden

The key may not do this (a missing scope, a plan limit, or a compliance block). Returns `ErrorEnvelope`.

### 404 Not Found

No object with this ID exists in this organisation and mode. Returns `ErrorEnvelope`.

### 409 Conflict

The request conflicts with the object's state, or the Idempotency-Key was reused with other parameters. Returns `ErrorEnvelope`.

### 429 Too Many Requests

Too many requests, or no call capacity right now. Retry after the Retry-After delay. Returns `ErrorEnvelope`.

### 500 Internal Server Error

Something went wrong on MoreVoice's side. Retry with the same Idempotency-Key. Returns `ErrorEnvelope`.

## Code samples

**TypeScript**

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

const cliToolResult = await mv.cli.submitToolResult("clis_5bH8jK3mN6pQ9rT2vW4xYz", {
	body: "{\"status\":\"shipped\"}",
	id: "clitc_7cJ9kL4mP2qR5sT8uV1wXy",
	status: 200,
});
console.log(cliToolResult);
```

**Python**

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

cli_tool_result = client.cli.submit_tool_result("clis_5bH8jK3mN6pQ9rT2vW4xYz", {
    "body": "{\"status\":\"shipped\"}",
    "id": "clitc_7cJ9kL4mP2qR5sT8uV1wXy",
    "status": 200,
})
print(cli_tool_result)
```

**cURL**

```sh
curl -X POST https://api.morevoice.ai/v1/cli/listen/clis_5bH8jK3mN6pQ9rT2vW4xYz/tool_results \
  -H "Authorization: Bearer $MOREVOICE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
  "body": "{\"status\":\"shipped\"}",
  "id": "clitc_7cJ9kL4mP2qR5sT8uV1wXy",
  "status": 200
}'
```
