# Answer an agent's question.

> Records the answer with who gave it (`question.answered`) and sends it to the agent: to the ask tool if it is still waiting (`delivery: tool`), else to the running agent as a message (`steer`).
> https://koi.dog/docs/api/questions/answer-question/

`POST /api/v1/questions/{id}/answer` · Scope: `crews`

When the agent's run has ended the answer is kept (`none`), and every later run of the crew is given it in its brief. A question that timed out can still be answered. A question routed to a managed crew's manager can be answered here first: the manager's answer step is stopped (`manager.state: superseded`). Answers `409 conflict` for a question already answered or canceled. The timeline records the key ID, action and outcome.

## Path parameters.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | The question's id. |

## Headers.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Idempotency-Key` | `string` | no | Retry the same request with the same key. [Retry rules](https://koi.dog/docs/api/#retries). |

## Body.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `text` | `string` | yes | The answer, in your words. Sent to the agent as it is (after secrets are removed) and repeated to every later run of the crew. 1 to 4000 characters. |

## Response.

200 OK · JSON object

- **422 validation_failed**: Each schema error appears in `details`.

## Request.

```sh
curl -X POST "https://api.koi.dog/api/v1/questions/$ID/answer" \
    -H "Authorization: Bearer $KOIDOG_API_KEY" \
    -H "Idempotency-Key: $(uuidgen)" \
    -H "Content-Type: application/json" \
    -d '{
      "text": "<text>"
    }'
```

```js
const res = await fetch(`https://api.koi.dog/api/v1/questions/${process.env.ID}/answer`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KOIDOG_API_KEY}`,
    "Idempotency-Key": crypto.randomUUID(),
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    text: "<text>",
  }),
});
console.log(await res.json());
```

```python
import os
import uuid

import requests

r = requests.post(
    f"https://api.koi.dog/api/v1/questions/{os.environ['ID']}/answer",
    headers={
        "Authorization": f"Bearer {os.environ['KOIDOG_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "text": "<text>",
    },
)
r.raise_for_status()
print(r.json())
```

## Response example.

```json
{
  "id": "string",
  "crewId": "string",
  "taskId": "string",
  "agentId": "string",
  "runId": "string",
  "text": "string",
  "state": "open",
  "answerer": "manager",
  "answer": "string",
  "answeredBy": {
  },
  "delivery": "tool",
  "askedAt": "string",
  "deadlineAt": "string",
  "answeredAt": "string",
  …
}
```
