# Checkout setup

Set up agent checkout: the setup's step state, and Muse, a test agent for your store.

Related guide: [Set up agent checkout](https://provenanceauth.com/docs/authorize/guides/five-minute-checkout.md)

## Endpoints

- `GET /v1/authorize/setup`: [Retrieve the checkout setup](#get-v1-authorize-setup)
- `POST /v1/authorize/setup/test_agent`: [Send a test agent](#post-v1-authorize-setup-test-agent)

## The checkout setup object

### Attributes

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `object` | enum | no | The type of object. One of `authorize_setup`. |
| `key_created` | boolean | no | The account has an active API key in this environment. |
| `decision_seen` | boolean | no | An assessment, or a decision your Identify middleware reported. |
| `webhook_delivered` | boolean | no | An `authorize.checkout_approval.*` event reached one of your endpoints. |
| `test_agent_run` | boolean | no | A test agent checked out with an approval. |
| `webhook_endpoint` | object \| null | no | The endpoint that gets checkout approval events, when there is one. |
| `webhook_endpoint.id` | string | no | The endpoint's ID. |
| `webhook_endpoint.url` | string | no | The endpoint's URL. |
| `latest_test_agent_run` | object \| any \| null | no | The newest test agent run. |
| `latest_test_agent_run.object` | enum | no | The type of object. One of `test_agent_run`. |
| `latest_test_agent_run.id` | string | no | Unique identifier for the object (`tar_…`). |
| `latest_test_agent_run.status` | enum | no | `running` while Muse waits for the approval. One of `running`, `done`. |
| `latest_test_agent_run.result` | enum | no | Once done: Muse checked out with the approval, the person declined, nobody approved within 60 seconds, or the run stopped. One of `approved`, `declined`, `expired`, `error`, `refused`. |
| `latest_test_agent_run.store_origin` | string | no | The store's origin. |
| `latest_test_agent_run.checkout_approval_id` | string \| null | no | The cart approval the store opened, when it's yours. |
| `latest_test_agent_run.steps` | array of objects | no | What Muse did, in order. |
| `latest_test_agent_run.steps.step` | enum | no | The step. One of `load_product`, `add_to_cart`, `checkout`, `relay`, `wait`, `retry`. |
| `latest_test_agent_run.steps.ok` | boolean | no | Whether it worked. |
| `latest_test_agent_run.steps.detail` | string | no | What happened, in a line. |
| `latest_test_agent_run.steps.at` | timestamp | no | When. |
| `latest_test_agent_run.created_at` | timestamp | no | When the run started. |
| `latest_test_agent_run.finished_at` | timestamp \| null | no | When it ended. |
| `latest_test_agent_run.approve_url` | string | no | On create: the approve link the store's 401 gave Muse. |
| `latest_test_agent_run.status_url` | string | no | On create: where Muse waits for the outcome. |
| `passkeys` | object | no | What a new passkey needs (your checkout rules' `passkeys`, or the default). |
| `passkeys.new_passkey` | enum | no | The setting. One of `step_up_contact`, `accept`, `require_existing`. |
| `passkeys.min_passkey_age` | integer | no | Seconds. |
| `passkeys.no_contact` | enum | no | With no customer contact. One of `accept`, `decline`. |

### Example

```json
{
  "object": "authorize_setup",
  "key_created": true,
  "decision_seen": true,
  "webhook_delivered": false,
  "test_agent_run": false,
  "webhook_endpoint": null,
  "latest_test_agent_run": null,
  "passkeys": {
    "new_passkey": "step_up_contact",
    "min_passkey_age": 86400,
    "no_contact": "accept"
  }
}
```

## Retrieve the checkout setup

`GET /v1/authorize/setup`

The four steps of "Set up agent checkout", each done or not done as the API has seen it: a key, a decision, a delivered confirmation and a test agent's checkout. Also your new-passkey setting. Free.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

No parameters.

### Returns

The setup state. See [the checkout setup object](#object).

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`insufficient_scope`](https://provenanceauth.com/docs/platform/errors.md#insufficient_scope)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x
curl "$PROVENANCE_API/v1/authorize/setup" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/authorize/setup`, {
  headers: { Authorization: "Bearer prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.get(f"{api}/v1/authorize/setup", headers={"Authorization": "Bearer prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x"}).json()
```

### Response 200

```json
{
  "object": "authorize_setup",
  "key_created": true,
  "decision_seen": true,
  "webhook_delivered": false,
  "test_agent_run": false,
  "webhook_endpoint": null,
  "latest_test_agent_run": null,
  "passkeys": {
    "new_passkey": "step_up_contact",
    "min_passkey_age": 86400,
    "no_contact": "accept"
  }
}
```

## Send a test agent

`POST /v1/authorize/setup/test_agent`

Runs Muse, a test agent with no Provenance support, against your store: it checks out, relays the 401's `approve_url` (here, and by text to `notify.phone`), waits up to 60 seconds and retries with the token. The result lands on `GET /v1/authorize/setup`. Sandbox keys only, 5 an hour; `store_url` must be https and public. Free.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `store_url` | body | string | yes | Your store's product page (https). |
| `notify` | body | object | no | Text the approve link to this phone as well. |
| `notify.phone` | body | string | no | E.164, for example `+14155550142`. |

### Returns

The run, with the link Muse relayed.

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`insufficient_scope`](https://provenanceauth.com/docs/platform/errors.md#insufficient_scope)
- [`invalid_json`](https://provenanceauth.com/docs/platform/errors.md#invalid_json)
- [`parameter_invalid`](https://provenanceauth.com/docs/platform/errors.md#parameter_invalid)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x
curl -X POST "$PROVENANCE_API/v1/authorize/setup/test_agent" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "store_url": "https://brightbox.example/" }'
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/authorize/setup/test_agent`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x", "Content-Type": "application/json" },
  body: JSON.stringify({ "store_url": "https://brightbox.example/" }),
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.post(f"{api}/v1/authorize/setup/test_agent", headers={"Authorization": "Bearer prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x"}, json={
    "store_url": "https://brightbox.example/"
}).json()
```

### Response 201

```json
{
  "object": "test_agent_run",
  "id": "tar_01M6T2Z8W3QK4N7V5B9X1Y2C3D",
  "status": "running",
  "result": null,
  "store_origin": "https://brightbox.example",
  "checkout_approval_id": "coap_01M6T2Z9A1B2C3D4E5F6G7H8J9",
  "steps": [
    {
      "step": "load_product",
      "ok": true,
      "detail": "Loaded /",
      "at": "2026-11-06T18:03:10.112Z"
    },
    {
      "step": "add_to_cart",
      "ok": true,
      "detail": "Added to cart",
      "at": "2026-11-06T18:03:10.240Z"
    },
    {
      "step": "checkout",
      "ok": true,
      "detail": "Ask the person you're shopping for to approve this order: https://app.provenanceauth.com/approve/c/Hq2vN8xK4tB7mW3sYd9cFj. Then retry this request.",
      "at": "2026-11-06T18:03:10.395Z"
    },
    {
      "step": "relay",
      "ok": true,
      "detail": "Relayed the link here",
      "at": "2026-11-06T18:03:10.401Z"
    }
  ],
  "created_at": "2026-11-06T18:03:10.020Z",
  "finished_at": null,
  "approve_url": "https://app.provenanceauth.com/approve/c/Hq2vN8xK4tB7mW3sYd9cFj",
  "status_url": "https://api.provenanceauth.com/v1/authorize/checkout_approvals/requests/status?token=Hq2vN8xK4tB7mW3sYd9cFj"
}
```
