# Approvals

> See which runs are waiting for a person's answer, and answer them from your own systems.

Web page: https://docs.lodol.com/docs/api/approvals

A workflow's [Ask a person](https://docs.lodol.com/docs/guides/approvals.md) step pauses its run until someone answers: presses one of its buttons (**Approve** or **Reject**, on an approval), with as much writing as it asks for, or, when the step asks for one, replies in writing. While it waits, the run's status is `awaiting_approval`. These endpoints let your own system, such as a practice-management tool or an ERP, do the answering. An answer sent with an API key is recorded as that key's, by name, and the run carries on straight away.

## The approval request object

```json
{
  "id": "6ae123ec738a4977fdb31728",
  "type": "approval",
  "status": "pending",
  "title": "Pay the Acme invoice",
  "details": "Invoice INV-7 for $1,200",
  "workflow_id": "665f1a2b3c4d5e6f7a8b9c0d",
  "version_id": "6683e1c4b2a9d7f0e5c3a1b2",
  "workflow_name": "Pay bills",
  "run_id": "683b2c3d4e5f6a7b8c9d0e1f",
  "step_index": 2,
  "created_at": "2026-10-27T09:00:00+00:00",
  "expires_at": "2026-10-30T09:00:00+00:00",
  "on_timeout": "reject",
  "buttons": ["Approve", "Reject"],
  "written_answer": "optional",
  "draft": "",
  "timeout_answer": "",
  "decision": null
}
```

<Fields title="Fields">
<Field id="id" type="string" description="The request's ID." />
<Field id="type" type="string" description="approval, answered with Approve or Reject; or reply, for every other request: one with buttons of its own, or one answered in writing alone." />
<Field id="status" type="string" description="pending while it waits for an answer; approved, rejected or replied once answered; expired when nobody answered in time and the step was set to fail; or cancelled when the run was stopped, or its workflow deleted, first." />
<Field id="title" type="string" description="What the step asks, as it wrote it." />
<Field id="details" type="string" description="More about what's being asked, as the step wrote it." />
<Field id="workflow_id" type="string" description="The ID of the workflow whose run asked. It stays the same when the workflow is edited." />
<Field id="version_id" type="string" description="The ID of the version of the workflow that ran." />
<Field id="workflow_name" type="string" description="The workflow's name." />
<Field id="run_id" type="string" description="The ID of the run that's waiting." />
<Field id="step_index" type="integer" description="Which step of the workflow asked." />
<Field id="created_at" type="string" description="When it asked, in ISO 8601." />
<Field id="expires_at" type="string or null" description="When the step stops waiting, in ISO 8601, or null if it waits as long as it takes." />
<Field id="on_timeout" type="string" description="What happens if nobody answers by then: the request is rejected or approved, or the run fails or carries on without a reply." />
<Field id="buttons" type="array of strings" description="What a person presses to answer, as labelled: Approve and Reject on an approval, the step's own otherwise. Empty for a request answered in writing alone." />
<Field id="written_answer" type="string" description="How much they write alongside: none, optional or required." />
<Field id="draft" type="string" description="Text the person can change before they answer, as the step gave it; empty when there is none." />
<Field id="timeout_answer" type="string" description="The button pressed for them if nobody answers in time; empty when there is none." />
<Field id="decision" type="object or null" description="How it was answered: answer (the button pressed; empty for a written reply), reply (what was written), draft (the text as left), decision (approved, rejected or replied), comment, decided_by (who answered, a person as described below), decided_at and via (app, email, api or timeout). Null until it's answered." />
</Fields>

A request also lists who may answer it in Lodol (`approvers`, `approver_group`), the member the run runs as (`requested_by`), and its history (`events`), each event with its `type`, when it `occurred_at`, and who it was `by`.

A person here, in `requested_by`, `approvers`, `decision.decided_by` and each event's `by`, is an object with their `id`, `name` and `email`. One who isn't a member, such as a role or an email list, also has a `type` saying which, and its `id` can be `null`. When Lodol has no name for someone, `name` is their email.

---

## List approval requests

<Endpoint method="GET" path="/api/v1/approvals" />

Returns approval requests, newest first, a page at a time. Requires the `executions:read` scope. Requests from workflows the key's member can't see are left out.

<Fields title="Query parameters">
<Field id="status" type="string" description="pending for the ones still waiting; decided for the ones answered, expired or withdrawn; or all." facts="Default: `pending`." />
<Field id="run_id" type="string" description="Only the requests one run made: the run's id." />
<Field id="workflow_id" type="string" description="Only requests from this workflow, from every version of it. Takes the workflow's id or the ID of any of its versions." />
<Field id="limit" type="integer" description="How many requests to read for the page, from 1 to 100." facts="Default: `50`." />
<Field id="cursor" type="string" description="For the next page: the next_cursor of the page you have." />
</Fields>

```bash tab="cURL" tab-group="lang"
# The request a run you started is waiting on
curl "https://api-prod.lodol.com/api/v1/approvals?run_id=683b2c3d4e5f6a7b8c9d0e1f" \
  -H "Authorization: Bearer $LODOL_API_KEY"
```

```js tab="JavaScript"
const params = new URLSearchParams({ run_id: '683b2c3d4e5f6a7b8c9d0e1f' });
const response = await fetch(`https://api-prod.lodol.com/api/v1/approvals?${params}`, {
  headers: { Authorization: `Bearer ${process.env.LODOL_API_KEY}` },
});
const { approvals } = await response.json();
```

```python tab="Python"
response = requests.get(
    "https://api-prod.lodol.com/api/v1/approvals",
    headers={"Authorization": f"Bearer {os.environ['LODOL_API_KEY']}"},
    params={"run_id": "683b2c3d4e5f6a7b8c9d0e1f"},
)
approvals = response.json()["approvals"]
```

**Response `200`:** a page of [approval requests](#the-approval-request-object), and `next_cursor`, for the next page, or `null` when there are no more. See [Paging through lists](https://docs.lodol.com/docs/api.md#paging-through-lists).

```json
{
  "approvals": [
    { "id": "6ae123ec738a4977fdb31728", "type": "approval", "status": "pending", "...": "..." }
  ],
  "next_cursor": null
}
```

A page can hold fewer requests than `limit`, even none, when some it read were from workflows the key's member can't see. Keep going while `next_cursor` isn't `null`.

---

## Get an approval request

<Endpoint method="GET" path="/api/v1/approvals/:id" />

Returns one [approval request](#the-approval-request-object). Requires the `executions:read` scope. A request from a workflow the key's member can't see returns `404`.

```bash
curl https://api-prod.lodol.com/api/v1/approvals/6ae123ec738a4977fdb31728 \
  -H "Authorization: Bearer $LODOL_API_KEY"
```

---

## Answer an approval request

<Endpoint method="POST" path="/api/v1/approvals/:id/decision" />

Presses one of a request's buttons, or replies to one answered in writing alone, so its run carries on. Requires the `workflows:execute` scope, and the member who created the key must be allowed to run workflows. An API key answers for the workspace, so it isn't held to the request's list of approvers. It is held to who may not answer: a key made by the member who prepared the item, or by the member the run runs as when the step needs someone else, gets `403`.

<Fields title="Headers">
<Field id="Idempotency-Key" type="string" description="Makes the request safe to retry: a repeat with the same key returns the first answer instead of a conflict with it. See Idempotency." />
</Fields>

<Fields title="Body">
<Field id="answer" type="string" description="The button to press, one of the request's buttons. Leave it out for a request answered in writing alone." />
<Field id="reply" type="string" description="What to write alongside: a comment on an approval, the answer to a request answered in writing alone. Required when written_answer is required; ignored when it is none." />
<Field id="draft" type="string" description="The request's text as changed, for a request that carries text to check. Left out, the text goes on as the step gave it." />
</Fields>

Requests answered before buttons were sent with `decision` (`approved` or `rejected`) and `comment`. That body still works for an approval.

```bash tab="cURL" tab-group="lang"
curl -X POST https://api-prod.lodol.com/api/v1/approvals/6ae123ec738a4977fdb31728/decision \
  -H "Authorization: Bearer $LODOL_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: approve-inv-7" \
  -d '{"answer": "Approve", "reply": "Matches the purchase order"}'
```

```js tab="JavaScript"
await fetch('https://api-prod.lodol.com/api/v1/approvals/6ae123ec738a4977fdb31728/decision', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.LODOL_API_KEY}`,
    'Content-Type': 'application/json',
    'Idempotency-Key': 'approve-inv-7',
  },
  body: JSON.stringify({ answer: 'Approve', reply: 'Matches the purchase order' }),
});
```

```python tab="Python"
requests.post(
    "https://api-prod.lodol.com/api/v1/approvals/6ae123ec738a4977fdb31728/decision",
    headers={
        "Authorization": f"Bearer {os.environ['LODOL_API_KEY']}",
        "Idempotency-Key": "approve-inv-7",
    },
    json={"answer": "Approve", "reply": "Matches the purchase order"},
)
```

**Response `200`:** the [approval request](#the-approval-request-object) as answered, with its `decision`.

A request that's no longer waiting returns `409`, with a code saying why:

| Code | Meaning |
| --- | --- |
| `approval_already_answered` | Someone answered it first. `decision` on [Get an approval request](#get-an-approval-request) says who and how |
| `approval_expired` | Nobody answered in time: it closed, or its time limit answered it as the step was set to |
| `approval_withdrawn` | The run was stopped, or its workflow deleted, before anyone answered |

None of them is worth retrying: the request is settled.
