> ## Documentation Index
> Fetch the complete documentation index at: https://docs.finalsay-hitl.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Callbacks

> Get the result pushed to your URL instead of polling, and check it really came from FinalSay.

Set `callback.url` when you create an approval, and FinalSay POSTs the result there as soon as someone answers or the
approval expires. No polling loop, and it suits long waits: n8n Wait nodes, Zapier catch hooks, serverless functions.

```json theme={"theme":{"light":"github-light","dark":"vesper"}}
{
  "question": "Send the refund of €240 to order #8812?",
  "context_markdown": "…",
  "options": [{ "label": "Refund", "value": "refund" }, { "label": "Decline", "value": "decline" }],
  "callback": { "url": "https://example.com/hooks/finalsay" }
}
```

## The request FinalSay sends

| | |
| - | - |
| **Method** | `POST` to your `callback.url` |
| **When** | When the approval leaves `pending`: an answer, or expiry. It's usually sent within a second or two. |
| **Body** | The [approval result](https://docs.finalsay-hitl.com/api-reference/approval-object.md#result), exactly what `GET /v1/approvals/{requestId}/result` returns |
| **Headers** | `Content-Type: application/json`, `User-Agent: FinalSay-Integration-API/1.0`, then your `callback.headers`, then the agent's callback security header |
| **Success** | Any `2xx` response. The body is ignored. |
| **Timeout** | 10 seconds per attempt. No response by then counts as a failed attempt. |
| **Retries** | Three attempts in total, waiting 1 second and then 2 seconds between them. Retries continue after a FinalSay restart. |

Each result is delivered **at least once**. In rare cases, such as a FinalSay restart in the middle of a send, the
same result can arrive twice. Use `request_id` to ignore a result you've already handled.

If every attempt fails, the approval's `result_delivery_status` becomes `failed` with the error in
`result_delivery_error` (see `GET /v1/approvals/{requestId}`), and the attempt shows up on **Delivery health**. The
result is still there to poll, so a missed callback never loses an answer.

> [!TIP]
>
> Reply `2xx` within 10 seconds and do slow work afterwards. If your endpoint might be down for a while, poll
> `GET …/result` as a backstop.

## Securing your endpoint

FinalSay doesn't sign callback bodies. Instead, give the agent a secret header and check it on every call:

**1. Generate a secret**

In the web dashboard, open the agent → **Callback security**. Keep the header name `X-FinalSay-Callback` (or set
your own) and click **Generate secret**. Copy it; it's shown once.

**2. Check it on your endpoint**

Reject any request where that header doesn't match, for example with `401`. In n8n, set the Wait node's
**Authentication** to **Header Auth** with the same name and value.

**3. Rotate when needed**

**Rotate secret…** issues a new one and the old one stops working at once, so update your endpoint right after.

FinalSay adds the header on the server when it delivers the result. The secret never appears in
`POST /v1/approvals`, MCP tool arguments, or n8n and Zapier exports. If `callback.headers` sets the same header name,
the agent's value wins, so a request can't strip it.

Also:

* **Use HTTPS** callback URLs.
* Put only **non-secret** values in `callback.headers`, such as a trace id. They're stored with the approval and are
  part of its idempotency check.
* Treat the body as data. Check `request_id` against approvals you created before acting on it.

## Recipes

> [card] [n8n Wait node](https://docs.finalsay-hitl.com/integrations/n8n.md#securing-the-wait-resume-url)
>
> `callback.url` = `{{ $execution.resumeUrl }}`, with Header Auth on the Wait node.

> [card] [Zapier catch hook](https://docs.finalsay-hitl.com/integrations/zapier.md#get-the-result)
>
> Post the result to a **Catch Hook** that starts a second Zap.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.