# Authorize

Authorize is for merchants and card issuers. Check the signed approval an AI agent brings to a checkout or a payment, ask your own customer to approve a cart, and trade with other agents under signed terms.

Authorize is for merchants and card issuers. It checks the signed approval an AI agent brings with an order, so you know a person approved that exact cart.

Merchants also use it to ask their own customer to approve a cart, and to trade with other agents under signed terms. Issuers read the same approval when it arrives on an [agent payment](https://provenanceauth.com/docs/authorize/guides/agent-payments.md), and set their own rules for agent purchases with [issuer agent controls](https://provenanceauth.com/docs/authorize/guides/issuer-agent-controls.md).

## When to use it

- Accept an order from a shopping agent only when a person approved that exact cart.
- Ask your own customer to approve an agent's cart with a passkey before you ship it.
- Check, as a card issuer, that a person approved an agent's purchase before you authorize the payment.
- Sell to other companies' agents under a signed offer, or charge per call with a tab.

## How it works

1. A shopping agent sends its intent token with the order, bound to the cart's hash.
2. Your checkout checks the token: offline against the published keys, then with the free `POST /v1/verify` for revocation, or with your key on `POST /v1/authorize/verifications` for how the person approved.
3. You accept the order when the token is valid and binds your own record of the cart.

1. **The agent's order**: cart + intent token
2. **Your checkout**: keys, binding, revocation
3. **Your decision**: accept, ask, or send to bot rules

## Key objects

Each object links to its API reference.

| Object | What it is | Where you get it |
| --- | --- | --- |
| [Intent token](https://provenanceauth.com/docs/api/intent-tokens.md) | An ES256 JWT bound to the hash of the exact action a person approved ([how to verify one](https://provenanceauth.com/docs/authorize/guides/verify-tokens.md)) | The agent sends it with the order |
| [Verification result](https://provenanceauth.com/docs/api/verify.md) | The free check: signature, expiry, revocation and the token's free claims | [`POST /v1/verify`](https://provenanceauth.com/docs/api/verify.md#post-v1-verify) |
| [Verification](https://provenanceauth.com/docs/api/verifications.md) | The paid check: the same, your checkout rules, and how the person approved | [`POST /v1/authorize/verifications`](https://provenanceauth.com/docs/api/verifications.md#post-v1-authorize-verifications) |
| [Checkout approval](https://provenanceauth.com/docs/api/checkout-approvals.md) | A cart your customer approves with a passkey ([guide](https://provenanceauth.com/docs/authorize/guides/ask-your-own-customer.md)) | [`POST /v1/authorize/checkout_approvals`](https://provenanceauth.com/docs/api/checkout-approvals.md#post-v1-authorize-checkout-approvals) |
| [Deal](https://provenanceauth.com/docs/api/deals.md) | A signed offer accepted by another company's agent ([concept](https://provenanceauth.com/docs/authorize/concepts/agent-commerce.md)) | [`POST /v1/authorize/deals`](https://provenanceauth.com/docs/api/deals.md#post-v1-authorize-deals) |
| [Tab](https://provenanceauth.com/docs/api/tabs.md) | A running balance for pay-per-call usage ([guide](https://provenanceauth.com/docs/authorize/guides/pay-per-call-with-tabs.md)) | [`POST /v1/authorize/tabs`](https://provenanceauth.com/docs/api/tabs.md#post-v1-authorize-tabs) |

## Core endpoints

| Endpoint | Use it to |
| --- | --- |
| [`POST /v1/verify`](https://provenanceauth.com/docs/api/verify.md#post-v1-verify) | Check any token, grant or receipt for free, with no key. |
| [`POST /v1/authorize/verifications`](https://provenanceauth.com/docs/api/verifications.md#post-v1-authorize-verifications) | Check a token with your checkout rules and read how the person approved. |
| [`POST /v1/authorize/checkout_approvals`](https://provenanceauth.com/docs/api/checkout-approvals.md#post-v1-authorize-checkout-approvals) | Ask the shopper, or your own customer, to approve a cart. |
| [`POST /v1/authorize/deals`](https://provenanceauth.com/docs/api/deals.md#post-v1-authorize-deals) | Accept a signed offer from another agent. |
| [`POST /v1/authorize/tabs`](https://provenanceauth.com/docs/api/tabs.md#post-v1-authorize-tabs) | Open a tab for pay-per-call usage. |

## Your first call

Check a token with the free verify. It needs no key. In the sandbox, mint a test token first.

**curl**

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

INTENT_TOKEN=$(curl -s $PROVENANCE_API/v1/mandate/intents \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{"action_description":"Buy order ord_1042 at harborbean.example","action_payload":{"order_id":"ord_1042","total":2400,"currency":"usd"},"agent_session_id":"sess_overview_2","device_id":"dev_00000000000000000000000000000001"}' \
  | jq -r .intent_token)

curl -s -X POST $PROVENANCE_API/v1/verify \
  -H "Content-Type: application/json" \
  -d "{\"token\":\"$INTENT_TOKEN\"}"
```

**Node**

```ts
import { Provenance } from "@provenanceauth/sdk";

const prov = new Provenance({ baseUrl: process.env.PROVENANCE_API });
const result = await prov.verify({ token: intentToken });
console.log(result.valid, result.revoked);
```

**Python**

```python
import os
from provenanceauth import Provenance

prov = Provenance(base_url=os.environ["PROVENANCE_API"])
result = prov.verify(token=intent_token)
print(result["valid"], result["revoked"])
```

```json
{
  "object": "verification_result",
  "valid": true,
  "reason": null,
  "kind": "intent",
  "binding": "not_checked",
  "revoked": false
}
```

The [checkout guide](https://provenanceauth.com/docs/authorize/guides/verify-agent-checkout.md) checks the binding against your own record of the order.

## Next steps

- [Quickstart](https://provenanceauth.com/docs/authorize/quickstart.md): Verify an agent order, then ask the shopper for one.
- [Verify agent checkouts](https://provenanceauth.com/docs/authorize/guides/verify-agent-checkout.md): Check the approval on your own checkout before you accept the order.
- [API reference](https://provenanceauth.com/docs/api.md#resources-authorize): Every Authorize endpoint, with parameters and responses.
