# Approve requests in a batch

Let an approver approve up to 25 waiting requests with one passkey prompt. Each request still gets its own ledger row, and anything risky stays out of the batch for its own review.

*Available on Pro, Growth and Enterprise.*

Use batch approval when one approver has many routine requests waiting, such as 30 invoices from the same company. The approver portal lists everything waiting for them, newest first. **Approve selected** approves up to 25 with one passkey prompt, and each request still gets its own ledger row and its own `mandate.approval.approved` webhook.

**Before you begin:** route approvals to an [approver link](https://provenanceauth.com/docs/mandate/guides/approver-network.md). Batch approval is for the requests your approvers decide; decide your own in the console.

```bash
export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
```

1. **Approver selects**: up to 25 in the portal
2. **One passkey prompt**: signs the whole list
3. **Each request approved**: one ledger row each

## 1. Set the batch limit

Any request above `batch_max_amount` stays out of a batch. It's 1,000 by default; change it with [`PUT /v1/mandate/settings/approvals`](https://provenanceauth.com/docs/api/account.md#put-v1-mandate-settings-approvals):

**curl**

```bash
curl -s -X PUT $PROVENANCE_API/v1/mandate/settings/approvals \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "batch_max_amount": 500 }'
```

**Node**

```ts
const res = await fetch(`${process.env.PROVENANCE_API}/v1/mandate/settings/approvals`, {
  method: "PUT",
  headers: { Authorization: `Bearer ${process.env.PROVENANCE_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({ batch_max_amount: 500 }),
});
const settings = await res.json();
```

**Python**

```python
import os
import httpx

settings = httpx.put(f"{os.environ['PROVENANCE_API']}/v1/mandate/settings/approvals",
                     headers={"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}, json={"batch_max_amount": 500}).json()
```

```json
{
  "object": "approval_settings",
  "batch_max_amount": 500
}
```

## What can't be batched

These stay in the list with **Review on its own**, and each `batch_reason` says why:

| `batch_reason` | The request |
| --- | --- |
| `over_batch_max_amount` | Is above your `batch_max_amount` |
| `option_group` | Has options to choose from |
| `first_time_payee` | Is the first approved payment to this payee |
| `individual_required` | Matched a rule with `require: { individual: true }` |
| `plan_below_growth` | Came from a company on Free |

Mark the requests that always need their own review in your policy:

```json
{ "id": "board-approves-each", "when": [{ "fact": "action_type", "op": "eq", "value": "board_payment" }], "require": { "approval": true, "individual": true } }
```

## 2. The approver selects requests

The portal reads `GET /v1/mandate/approver/approvals` with the approver's session. Each request carries `batchable`:

```json
{
  "object": "list",
  "data": [
    { "id": "appr_01M5R0C09DQ4X7N2W8K5T3VB6M", "object": "approval", "action_description": "Pay invoice INV-2041: $850.00 to Brindlecote Supplies", "batchable": true },
    { "id": "appr_01M5R0E6T1V3X5Z7B9D2F4H6J8", "object": "approval", "action_description": "Pay invoice INV-2043: $4,800.00 to Brindlecote Supplies", "batchable": false, "batch_reason": "over_batch_max_amount" }
  ]
}
```

**Approve selected** calls `POST /v1/mandate/approver/approvals/batch_link`, which returns a single-use link (15 minutes) to the approval page:

**curl**

```bash norun
curl -s $PROVENANCE_API/v1/mandate/approver/approvals/batch_link \
  -H "Authorization: Bearer $APPROVER_SESSION" \
  -H "Content-Type: application/json" \
  -d '{ "approval_ids": ["appr_01M5R0C09DQ4X7N2W8K5T3VB6M", "appr_01M5R0D2K7W9ZQ3V5X8N4T6YBA"] }'
```

**Node**

```ts
const link = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/approver/approvals/batch_link`, {
  method: "POST",
  headers: { Authorization: `Bearer ${approverSession}`, "Content-Type": "application/json" },
  body: JSON.stringify({ approval_ids: ["appr_01M5R0C09DQ4X7N2W8K5T3VB6M", "appr_01M5R0D2K7W9ZQ3V5X8N4T6YBA"] }),
})).json();
```

**Python**

```python
link = httpx.post(f"{os.environ['PROVENANCE_API']}/v1/mandate/approver/approvals/batch_link",
                  headers={"Authorization": f"Bearer {approver_session}"},
                  json={"approval_ids": ["appr_01M5R0C09DQ4X7N2W8K5T3VB6M", "appr_01M5R0D2K7W9ZQ3V5X8N4T6YBA"]}).json()
```

```json
{
  "object": "approval_batch_link",
  "approve_url": "https://app.provenanceauth.com/approve/batch/Zq4vB2nX8kR1tL6pW3sY9dF0hJ5mC7aE2gU4iO8eQ1w",
  "count": 2
}
```

## 3. One passkey prompt approves the list

The batch page reads `GET /v1/mandate/approval_batches`: each request, whether it can go in the batch, and one challenge. The challenge carries sha256 of the sorted list of `(approval_id, action_hash)`, so the approver's assertion signs exactly the requests they see. An approver who unticks a request gets a challenge for the rest.

`POST /v1/mandate/approval_batches/respond` verifies the assertion once and approves each request:

```json
{
  "object": "approval_batch",
  "id": "abat_01M5R0F4Q8H2J6K9M3N7P1R5T8",
  "status": "decided",
  "decided_count": 2,
  "results": [
    { "approval_id": "appr_01M5R0C09DQ4X7N2W8K5T3VB6M", "status": "approved" },
    { "approval_id": "appr_01M5R0D2K7W9ZQ3V5X8N4T6YBA", "status": "approved" }
  ]
}
```

Each request records the `batch_id`, gets its own ledger row, and meters as one decision. A list that doesn't match the challenge fails, and a request that can't be batched refuses the whole batch with `batch_not_allowed`, deciding nothing.

At verify, a batched approval adds the fact `approval.batched`, so a rule can treat it differently.

## Approve selected in your product

[`<provenance-approvals>`](https://provenanceauth.com/docs/embeds.md#9-an-approvers-inbox-in-your-product) puts the same inbox in your own app for the approver who's signed in, with a token you mint for one of your approver links. It lists only your company's requests. The approver ticks the ones to approve and confirms once with their passkey:

- `POST /v1/embed/approvals/batch_challenge` returns the challenge for exactly the ticked requests, or `batch_not_allowed` for one that needs its own review.
- `POST /v1/embed/approvals/batch` verifies the one assertion and approves each request, with the same `batch_id`, ledger rows and metering as the batch page.

The component calls both for you and fires `pv:batch_approved { batch_id, count, approval_ids }`.

## Errors you might see

| Code | Status | What to do |
| --- | --- | --- |
| `batch_not_allowed` | 409 | Leave the listed requests out and approve them one at a time. |
| `parameter_invalid` | 400 | Send the list the page showed, with its challenge; list each request once and only your own. |
| `approver_enrollment_failed` | 400 | The assertion isn't from this approver's passkey. |
| `resource_missing` | 404 | The batch link expired or was used. |

## See also

- [Route to an approver](https://provenanceauth.com/docs/mandate/guides/approver-network.md)
- [Use group sign-off](https://provenanceauth.com/docs/mandate/guides/group-approvals.md)
- [Policies](https://provenanceauth.com/docs/concepts/policies.md)
