> ## 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.

# Send your first approval with the API

> Create an approval with curl, answer it on your phone, and read the result.

## You'll need

* An **agent ID** and a **workspace API key**. The [Quickstart](https://docs.finalsay-hitl.com/guide/getting-started.md) creates both, or see
  [Workspace settings and API keys](https://docs.finalsay-hitl.com/guide/credentials.md).
* The FinalSay mobile app or the web dashboard open, so you can answer.

```bash theme={"theme":{"light":"github-light","dark":"vesper"}}
export FINALSAY_AGENT_ID="your-agent-uuid"
export FINALSAY_API_KEY="hitl_…"
```

## 1. Create the approval

```bash theme={"theme":{"light":"github-light","dark":"vesper"}}
curl -sS -X POST https://api.finalsay-hitl.com/v1/approvals \
  -H "Content-Type: application/json" \
  -H "X-Agent-Id: $FINALSAY_AGENT_ID" \
  -H "X-Api-Key: $FINALSAY_API_KEY" \
  -d '{
    "request_id": "my-first-approval",
    "question": "Deploy v2.4 to production?",
    "context_markdown": "**Change:** 12 commits since v2.3\n\nTests passed. Rollback plan: redeploy v2.3.",
    "notification_summary": "Deploy approval",
    "options": [
      { "label": "Approve", "value": "approve" },
      { "label": "Reject", "value": "reject" }
    ]
  }'
```

```json Response theme={"theme":{"light":"github-light","dark":"vesper"}}
{
  "approval_id": "1d7c…",
  "request_id": "my-first-approval",
  "status": "pending",
  "expires_at": "2026-11-21T10:10:00.000Z",
  "idempotent": false
}
```

`question`, `context_markdown` and `options` are required. Everything else is optional: leave out `request_id` and the
server generates one (returned in the response), and leave out `timeout` to use the agent's default (10 minutes for a
new agent). All fields: [The approval object](https://docs.finalsay-hitl.com/api-reference/approval-object.md).

## 2. Answer it

Your phone gets a push notification titled *Agent name: Deploy approval*. Open it, or open **Approvals** in the web
dashboard, then pick **Approve** or **Reject**, or tap **Write your own answer**. Only the first answer counts.

## 3. Read the result

Poll with the `request_id`:

```bash theme={"theme":{"light":"github-light","dark":"vesper"}}
curl -sS https://api.finalsay-hitl.com/v1/approvals/my-first-approval/result \
  -H "X-Agent-Id: $FINALSAY_AGENT_ID" \
  -H "X-Api-Key: $FINALSAY_API_KEY"
```

Before anyone answers you get `{ "request_id": "my-first-approval", "status": "pending" }`. Afterwards:

```json theme={"theme":{"light":"github-light","dark":"vesper"}}
{
  "request_id": "my-first-approval",
  "agent_id": "4f1c…",
  "correlation_id": null,
  "status": "selected_option",
  "selected_option_index": 0,
  "selected_option_label": "Approve",
  "selected_option_value": "approve",
  "custom_instruction": null,
  "fallback_applied": false,
  "answer": "approve",
  "resolved_by": { "user_id": "9b2e…", "name": "Ana" },
  "resolved_at": "2026-11-21T10:01:12.000Z"
}
```

Branch on `selected_option_value`. If `status` is `custom_instruction`, follow what they wrote; if it's `expired`,
don't proceed.

> [!TIP]
>
> Instead of polling, add `"callback": { "url": "https://…" }` and FinalSay POSTs this same object to your URL when the
> approval is answered or expires. See [Callbacks](https://docs.finalsay-hitl.com/best-practices/callbacks.md).

## Try it again

Run step 1 again with the same body: you get the same approval back with `"idempotent": true`, not a second approval.
Change the question but keep `request_id`, and you get `409 idempotency_conflict`. That's what makes retries safe; see
[Idempotency and retries](https://docs.finalsay-hitl.com/best-practices/idempotency.md).


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