# Approvals API

> Actions the assistant staged for a person to review before they go out. The API calls a batch of staged actions a cart. Show the approval to the user, then approve it with its `contentHash` so exactly what they saw is sent.

Part of the AGNT API reference. AGNT (https://agnt.ai) is the developer platform behind OpenAssistant (https://openassistant.us). Docs index: https://agnt.ai/llms.txt. Web page: https://agnt.ai/reference/api/approvals

Base URL: `https://api.agnt.ai`. Auth: `Authorization: Bearer ak_live_...`.

## GET /portal/carts

List approvals

Returns the approvals waiting on the user, newest first, up to 50. Filter with `status`.

Acts as one user: send `X-User-Email`.

**Query parameters**

- `status` (string): Comma-separated subset of pending_approval, time_boxed. Default: both.

**Responses**

- `200`: Approvals
  - `ok` (boolean, required)
  - `carts` (object[], required)
    - `id` (string, required): The approval (cart) id.
    - `taskId` (string | null)
    - `taskTitle` (string)
    - `assistantName` (string | null)
    - `status` (enum, required): open: the assistant is still adding actions. submitted: handed over, approval mode being decided. pending_approval: waiting for the user. time_boxed: runs when the window ends unless stopped. approved: approved and queued. executing: being sent. executed: done. cancelled: cancelled by a person with the cancel endpoint or by a time-boxed window set to cancel. rejected: declined from an approval link, such as the Reject link in an approval email. failed: could not be sent. One of: `open`, `submitted`, `pending_approval`, `time_boxed`, `approved`, `executing`, `executed`, `cancelled`, `rejected`, `failed`.
    - `resolvedApprovalMode` (enum) One of: `auto`, `time-boxed`, `manual`.
    - `timeBoxedExpiresAt` (string | null): For time_boxed: when the window ends.
    - `timeBoxedExpiry` (enum): What happens when a time-boxed window ends. One of: `execute`, `cancel`.
    - `dispatches` (object[], required)
      - `index` (integer): Position in the approval; use it in the dispatch paths.
      - `type` (string): Kind of action, such as a message sent as the assistant or a calendar change.
      - `platform` (string | null): Channel, such as email or sms.
      - `from` (string)
      - `to` (string[])
      - `cc` (string[])
      - `bcc` (string[])
      - `subject` (string)
      - `body` (string)
      - `description` (string): Plain description of the action.
      - `payload` (object | null): Action-specific detail, such as the full event for a calendar change.
      - `files` (object[]): Attachments that go out with the action.
        - `filename` (string | null)
        - `mimeType` (string | null)
        - `size` (number | null)
        - `fileId` (string | null)
      - `editedByUser` (boolean): True when the text shown is the user's own edit; it is sent exactly as written.
      - `currentVersionId` (string | null)
      - `validUntil` (string | null): When the content stops being true; null with evergreen false means none declared.
      - `evergreen` (boolean)
    - `contentHash` (string, required): Hash of exactly the content shown. Send it back on approve.
    - `createdAt` (string)
    - `updatedAt` (string)
- `400`: status names no valid value.
- `403`: The caller is not acting as a user: send X-User-Email with an account key, or use a user-scoped key. Certificate tokens and AGNT console sessions are refused.

```bash
curl 'https://api.agnt.ai/portal/carts' \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com"
```

Example response:

```json
{
  "ok": true,
  "carts": [
    {
      "id": "6660c4a1f2e3b7d8a9c01234",
      "status": "pending_approval",
      "dispatches": [
        {
          "index": null,
          "type": null,
          "platform": null,
          "from": null
        }
      ],
      "contentHash": "9f2c1b7e4a"
    }
  ]
}
```

## GET /portal/carts/{cartId}

Retrieve an approval

Retrieves an approval with its staged actions and the `contentHash` to approve it with.

Acts as one user: send `X-User-Email`.

**Path parameters**

- `cartId` (string, required)

**Responses**

- `200`: Approval
  - `ok` (boolean, required)
  - `cart` (object, required)
    - `id` (string, required): The approval (cart) id.
    - `taskId` (string | null)
    - `taskTitle` (string)
    - `assistantName` (string | null)
    - `status` (enum, required): open: the assistant is still adding actions. submitted: handed over, approval mode being decided. pending_approval: waiting for the user. time_boxed: runs when the window ends unless stopped. approved: approved and queued. executing: being sent. executed: done. cancelled: cancelled by a person with the cancel endpoint or by a time-boxed window set to cancel. rejected: declined from an approval link, such as the Reject link in an approval email. failed: could not be sent. One of: `open`, `submitted`, `pending_approval`, `time_boxed`, `approved`, `executing`, `executed`, `cancelled`, `rejected`, `failed`.
    - `resolvedApprovalMode` (enum) One of: `auto`, `time-boxed`, `manual`.
    - `timeBoxedExpiresAt` (string | null): For time_boxed: when the window ends.
    - `timeBoxedExpiry` (enum): What happens when a time-boxed window ends. One of: `execute`, `cancel`.
    - `dispatches` (object[], required)
      - `index` (integer): Position in the approval; use it in the dispatch paths.
      - `type` (string): Kind of action, such as a message sent as the assistant or a calendar change.
      - `platform` (string | null): Channel, such as email or sms.
      - `from` (string)
      - `to` (string[])
      - `cc` (string[])
      - `bcc` (string[])
      - `subject` (string)
      - `body` (string)
      - `description` (string): Plain description of the action.
      - `payload` (object | null): Action-specific detail, such as the full event for a calendar change.
      - `files` (object[]): Attachments that go out with the action.
        - `filename` (string | null)
        - `mimeType` (string | null)
        - `size` (number | null)
        - `fileId` (string | null)
      - `editedByUser` (boolean): True when the text shown is the user's own edit; it is sent exactly as written.
      - `currentVersionId` (string | null)
      - `validUntil` (string | null): When the content stops being true; null with evergreen false means none declared.
      - `evergreen` (boolean)
    - `contentHash` (string, required): Hash of exactly the content shown. Send it back on approve.
    - `createdAt` (string)
    - `updatedAt` (string)
- `403`: The caller is not acting as a user: send X-User-Email with an account key, or use a user-scoped key. Certificate tokens and AGNT console sessions are refused.
- `404`: No such approval for this user.

```bash
curl 'https://api.agnt.ai/portal/carts/<cartId>' \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com"
```

Example response:

```json
{
  "ok": true,
  "cart": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "status": "pending_approval",
    "dispatches": [
      {
        "index": 1,
        "type": "type",
        "platform": "platform",
        "from": "from"
      }
    ],
    "contentHash": "9f2c1b7e4a"
  }
}
```

## POST /portal/carts/{cartId}/approve

Approve an approval

Approves the staged actions exactly as the user saw them and queues them to run, with no further model step. Pass the `contentHash` from the read you showed the user. If the content changed since then, the call returns `409` and nothing is sent. Call it only on the user's explicit decision.

Acts as one user: send `X-User-Email`.

**Path parameters**

- `cartId` (string, required)

**Request body** (JSON)

- `contentHash` (string, required): The contentHash from the latest read of this approval.
- `reason` (string): Optional note.

**Responses**

- `200`: Approved and queued
  - `ok` (boolean)
  - `cartId` (string)
  - `status` (enum) One of: `approved`.
- `400`: content_hash_required, cart_already_resolved (not awaiting approval) or cart_task_closed (the task closed and the draft was withdrawn).
- `403`: The caller is not acting as a user: send X-User-Email with an account key, or use a user-scoped key. Certificate tokens and AGNT console sessions are refused.
- `404`: No such approval for this user.
- `409`: cart_content_changed: the content changed since it was read. Read it again and show the user before approving.
- `500`: Queuing failed; the approval is left as it was. Retry.

```bash
curl 'https://api.agnt.ai/portal/carts/<cartId>/approve' \
  -X POST \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com" \
  -H "Content-Type: application/json" \
  -d '{
  "contentHash": "9f2c1b7e4a"
}'
```

Example response:

```json
{
  "ok": true,
  "cartId": "6660c4a1f2e3b7d8a9c01234",
  "status": "approved"
}
```

## POST /portal/carts/{cartId}/cancel

Cancel an approval

Cancels the staged actions and sets the status to `cancelled`. Nothing is sent. The assistant receives the optional `reason` and adjusts.

Acts as one user: send `X-User-Email`.

**Path parameters**

- `cartId` (string, required)

**Request body** (JSON)

- `reason` (string): Optional reason passed to the assistant.

**Responses**

- `200`: Cancelled
  - `ok` (boolean)
  - `cartId` (string)
  - `status` (enum) One of: `cancelled`.
- `400`: Already executed, cancelled or rejected.
- `403`: The caller is not acting as a user: send X-User-Email with an account key, or use a user-scoped key. Certificate tokens and AGNT console sessions are refused.
- `404`: No such approval for this user.

```bash
curl 'https://api.agnt.ai/portal/carts/<cartId>/cancel' \
  -X POST \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com" \
  -H "Content-Type: application/json" \
  -d '{
  "reason": "Approved by Jane"
}'
```

Example response:

```json
{
  "ok": true,
  "cartId": "6660c4a1f2e3b7d8a9c01234",
  "status": "cancelled"
}
```

## PATCH /portal/carts/{cartId}/dispatches/{index}/edit

Edit a staged action

Changes the subject or body of one staged action, or how long its content stays valid. The edit is kept as a new version and changes the `contentHash`. Recipients and payload cannot be changed with this call.

Acts as one user: send `X-User-Email`.

**Path parameters**

- `cartId` (string, required)
- `index` (string, required)

**Request body** (JSON)

- `subject` (string)
- `body` (string)
- `validUntil` (string): ISO 8601 time with offset, in the future. Replaces the declared validity.
- `evergreen` (boolean): true: the content never goes stale. Replaces the declared validity.

**Responses**

- `200`: Updated approval
  - `ok` (boolean, required)
  - `cart` (object, required)
    - `id` (string, required): The approval (cart) id.
    - `taskId` (string | null)
    - `taskTitle` (string)
    - `assistantName` (string | null)
    - `status` (enum, required) One of: `open`, `pending_approval`, `time_boxed`, `approved`, `executing`, `executed`, `cancelled`, `rejected`, `failed`.
    - `resolvedApprovalMode` (enum) One of: `auto`, `time-boxed`, `manual`.
    - `timeBoxedExpiresAt` (string | null): For time_boxed: when the window ends.
    - `timeBoxedExpiry` (enum): What happens when a time-boxed window ends. One of: `execute`, `cancel`.
    - `dispatches` (object[], required)
      - `index` (integer): Position in the approval; use it in the dispatch paths.
      - `type` (string): Kind of action, such as a message sent as the assistant or a calendar change.
      - `platform` (string | null): Channel, such as email or sms.
      - `from` (string)
      - `to` (string[])
      - `cc` (string[])
      - `bcc` (string[])
      - `subject` (string)
      - `body` (string)
      - `description` (string): Plain description of the action.
      - `payload` (object | null): Action-specific detail, such as the full event for a calendar change.
      - `files` (object[]): Attachments that go out with the action.
        - `filename` (string | null)
        - `mimeType` (string | null)
        - `size` (number | null)
        - `fileId` (string | null)
      - `editedByUser` (boolean): True when the text shown is the user's own edit; it is sent exactly as written.
      - `currentVersionId` (string | null)
      - `validUntil` (string | null): When the content stops being true; null with evergreen false means none declared.
      - `evergreen` (boolean)
    - `contentHash` (string, required): Hash of exactly the content shown. Send it back on approve.
    - `createdAt` (string)
    - `updatedAt` (string)
- `400`: Invalid or empty edit, a change to to, cc, bcc or payload, or an action type that cannot be edited (edit_not_supported)
- `403`: The caller is not acting as a user: send X-User-Email with an account key, or use a user-scoped key. Certificate tokens and AGNT console sessions are refused.
- `404`: Approval or action not found.
- `409`: cart_not_editable: the approval is no longer pending_approval or time_boxed.

```bash
curl 'https://api.agnt.ai/portal/carts/<cartId>/dispatches/<index>/edit' \
  -X PATCH \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com" \
  -H "Content-Type: application/json" \
  -d '{
  "subject": "subject",
  "body": "Prefers morning meetings.",
  "validUntil": "2026-10-15T14:30:00Z",
  "evergreen": true
}'
```

Example response:

```json
{
  "ok": true,
  "cart": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "status": "pending_approval",
    "dispatches": [
      {
        "index": 1,
        "type": "type",
        "platform": "platform",
        "from": "from"
      }
    ],
    "contentHash": "9f2c1b7e4a"
  }
}
```

## PATCH /portal/carts/{cartId}/dispatches/{index}

Update a staged action

Updates one staged action, including its recipients and payload. Only the fields you send change, and the `contentHash` changes.

Acts as one user: send `X-User-Email`.

**Path parameters**

- `cartId` (string, required)
- `index` (string, required)

**Request body** (JSON)

- `subject` (string)
- `body` (string)
- `to` (string[])
- `cc` (string[])
- `bcc` (string[])
- `payload` (object): Action-specific fields to change.

**Responses**

- `200`: Updated approval
  - Same fields as the `200` response of `PATCH /portal/carts/{cartId}/dispatches/{index}/edit`.
- `400`: Invalid or empty patch.
- `403`: The caller is not acting as a user: send X-User-Email with an account key, or use a user-scoped key. Certificate tokens and AGNT console sessions are refused.
- `404`: Approval or action not found.
- `409`: cart_not_editable: the approval is no longer pending_approval or time_boxed.

```bash
curl 'https://api.agnt.ai/portal/carts/<cartId>/dispatches/<index>' \
  -X PATCH \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com" \
  -H "Content-Type: application/json" \
  -d '{
  "subject": "subject",
  "body": "Prefers morning meetings.",
  "to": [
    "to"
  ],
  "cc": [
    "cc"
  ]
}'
```

Example response:

```json
{
  "ok": true,
  "cart": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "status": "pending_approval",
    "dispatches": [
      {
        "index": 1,
        "type": "type",
        "platform": "platform",
        "from": "from"
      }
    ],
    "contentHash": "9f2c1b7e4a"
  }
}
```

## DELETE /portal/carts/{cartId}/dispatches/{index}

Remove a staged action

Removes one action from a pending approval. An approval with no actions left stays pending until you cancel it.

Acts as one user: send `X-User-Email`.

**Path parameters**

- `cartId` (string, required)
- `index` (string, required)

**Responses**

- `200`: Updated approval
  - Same fields as the `200` response of `PATCH /portal/carts/{cartId}/dispatches/{index}/edit`.
- `403`: The caller is not acting as a user: send X-User-Email with an account key, or use a user-scoped key. Certificate tokens and AGNT console sessions are refused.
- `404`: Approval or action not found.
- `409`: cart_not_editable: the approval is no longer pending_approval or time_boxed.

```bash
curl 'https://api.agnt.ai/portal/carts/<cartId>/dispatches/<index>' \
  -X DELETE \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com"
```

Example response:

```json
{
  "ok": true,
  "cart": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "status": "pending_approval",
    "dispatches": [
      {
        "index": 1,
        "type": "type",
        "platform": "platform",
        "from": "from"
      }
    ],
    "contentHash": "9f2c1b7e4a"
  }
}
```

## GET /portal/carts/{cartId}/snapshots

List undoable actions

Returns one entry per action that ran, with whether it can still be undone and until when.

Acts as one user: send `X-User-Email`.

**Path parameters**

- `cartId` (string, required)

**Responses**

- `200`: Snapshots
  - `cartId` (string)
  - `count` (integer)
  - `snapshots` (object[])
    - `dispatchIndex` (integer)
    - `dispatchType` (string)
    - `resourceType` (string)
    - `reversible` (boolean): Whether the action can be reverted after it ran. A non-reversible action can only be stopped while it waits to send.
    - `undoStatus` (enum) One of: `available`, `undone`, `expired`, `not_applicable`.
    - `undoExpiresAt` (string | null)
    - `undoneAt` (string | null)
    - `undoAvailable` (boolean)
- `403`: The caller is not acting as a user: send X-User-Email with an account key, or use a user-scoped key. Certificate tokens and AGNT console sessions are refused.
- `404`: No such approval for this user.

```bash
curl 'https://api.agnt.ai/portal/carts/<cartId>/snapshots' \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com"
```

Example response:

```json
{
  "cartId": "6660c4a1f2e3b7d8a9c01234",
  "count": 42,
  "snapshots": [
    {
      "dispatchIndex": 1,
      "dispatchType": "dispatchtype",
      "resourceType": "resourcetype",
      "reversible": true
    }
  ]
}
```

## POST /portal/carts/{cartId}/dispatches/{index}/undo

Undo an action

Reverts one action that ran, or stops one that is still waiting to send. Available until the action's undo window closes.

Acts as one user: send `X-User-Email`.

**Path parameters**

- `cartId` (string, required)
- `index` (string, required)

**Responses**

- `200`: Undone
  - `ok` (boolean)
  - `undone` (boolean)
  - `type` (enum) One of: `reversed`, `cancelled_during_delay`.
  - `dispatchType` (string)
  - `result` (object)
- `400`: Not available to undo, window expired, or undo_not_supported for this action type.
- `403`: The caller is not acting as a user: send X-User-Email with an account key, or use a user-scoped key. Certificate tokens and AGNT console sessions are refused.
- `404`: Approval or snapshot not found.
- `409`: The target changed since and cannot be reverted safely.
- `410`: The target no longer exists.

```bash
curl 'https://api.agnt.ai/portal/carts/<cartId>/dispatches/<index>/undo' \
  -X POST \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com"
```

Example response:

```json
{
  "ok": true,
  "undone": true,
  "type": "reversed",
  "dispatchType": "dispatchtype"
}
```

## POST /portal/carts/{cartId}/undo

Undo all actions

Reverts every reversible action in the approval, in reverse order, and reports the result for each.

Acts as one user: send `X-User-Email`.

**Path parameters**

- `cartId` (string, required)

**Responses**

- `200`: Result per action
  - `ok` (boolean)
  - `cartId` (string)
  - `undone` (integer)
  - `skipped` (integer)
  - `expired` (integer)
  - `failed` (integer)
  - `details` (object[])
- `403`: The caller is not acting as a user: send X-User-Email with an account key, or use a user-scoped key. Certificate tokens and AGNT console sessions are refused.
- `404`: No such approval for this user.

```bash
curl 'https://api.agnt.ai/portal/carts/<cartId>/undo' \
  -X POST \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com"
```

Example response:

```json
{
  "ok": true,
  "cartId": "6660c4a1f2e3b7d8a9c01234",
  "undone": 1,
  "skipped": 1
}
```

## GET /portal/account/kill-switch

Retrieve the kill switch

Returns whether outbound actions are frozen for the whole account. While the account is frozen, creating and running tasks returns `423` with `error_code: "KILL_SWITCH_ENGAGED"`. Only a person signed in to your hosted app can freeze or release the account; API keys and tokens cannot. To stop one task, stop the task instead.

**Responses**

- `200`: State
  - `state` (enum): frozen blocks every outbound action, reply and inbound processing for the account; active is normal operation. One of: `active`, `frozen`.
  - `engagedAt` (string | null): When the current freeze started; null while active
  - `engagedBy` (object | null): Who engaged the current freeze: actor is their email
    - `actor` (string | null)
    - `source` (string | null)
  - `reason` (string | null)

```bash
curl 'https://api.agnt.ai/portal/account/kill-switch' \
  -H "Authorization: Bearer ak_live_..."
```

Example response:

```json
{
  "state": "active",
  "engagedAt": "2026-10-15T14:30:00Z",
  "engagedBy": {
    "actor": "actor",
    "source": "source"
  },
  "reason": "Approved by Jane"
}
```
