# Verify a Provenance token

Verify a Provenance token offline against the published keys, with the free keyless POST /v1/verify, or with the paid check that says how the person approved.

Use offline verification when you receive an intent token from someone else, such as a merchant, a bank or another agent, and want to check it without a Provenance API key. Tokens are signed with ES256 and the public keys are published, so you check the signature and expiry yourself. [Intent tokens and receipts](https://provenanceauth.com/docs/concepts/tokens-and-receipts.md) explains what each token and receipt holds.

Three guides cover agent orders. Pick the one that matches your job:

| You want to | Guide |
| --- | --- |
| Check one intent token or receipt you received, offline against the published keys or with `POST /v1/verify` | [Verify a token](https://provenanceauth.com/docs/authorize/guides/verify-tokens.md) |
| Get one outcome per agent order (approved, challenged or rejected) from your own checkout rules, shaped like a 3-D Secure result | [Assess an agent checkout](https://provenanceauth.com/docs/authorize/guides/assess-checkouts.md) |
| Check the cart-bound token and grant a shopping agent presents at your own checkout, with the `verifyAgentCheckout` helper | [Verify agent checkouts](https://provenanceauth.com/docs/authorize/guides/verify-agent-checkout.md) |

**Before you begin:** export the full-access sandbox key to get a token to check. Steps 2 to 4 need no key.

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

| Check | Offline | With the API |
| --- | --- | --- |
| Signed by Provenance and not expired | Yes | Yes |
| Not revoked | Keyless status check (step 4) | [`POST /v1/mandate/assessments`](https://provenanceauth.com/docs/api/intent-tokens.md#post-v1-mandate-assessments) |
| Description and payload match what was approved | No | [`POST /v1/mandate/assessments`](https://provenanceauth.com/docs/api/intent-tokens.md#post-v1-mandate-assessments) |
| Policy and approvals | No | [`POST /v1/mandate/assessments`](https://provenanceauth.com/docs/api/intent-tokens.md#post-v1-mandate-assessments) |

## 1. Get a token to check

In production the token arrives with the request you're about to honor. Here you mint one:

**curl**

```bash
curl -s $PROVENANCE_API/v1/mandate/intents \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "action_description": "Pay invoice INV-2041: $1,850.00 to Brindlecote Supplies",
    "agent_session_id": "sess_offline_1",
    "device_id": "dev_00000000000000000000000000000001"
  }' | tee authorization.json
export INTENT_TOKEN=$(jq -r .intent_token authorization.json)
export JTI=$(jq -r .attestation_id authorization.json)
```

**Node**

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

const prov = new Provenance({ apiKey: process.env.PROVENANCE_KEY!, baseUrl: process.env.PROVENANCE_API });
const auth = await prov.mandate.intents.create({
  actionDescription: "Pay invoice INV-2041: $1,850.00 to Brindlecote Supplies",
  agentSessionId: "sess_offline_1",
  deviceId: "dev_00000000000000000000000000000001",
});
const token = auth.intentToken;
```

**Python**

```python
import os
from provenanceauth import Provenance

prov = Provenance(os.environ["PROVENANCE_KEY"], base_url=os.environ["PROVENANCE_API"])
auth = prov.mandate.intents.create(
    action_description="Pay invoice INV-2041: $1,850.00 to Brindlecote Supplies",
    agent_session_id="sess_offline_1",
    device_id="dev_00000000000000000000000000000001",
)
token = auth["intent_token"]
```

```json
{
  "object": "intent_authorization",
  "intent_token": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ijc1MjY5NmZmMGY1ZTRmNTMifQ.eyJpc3MiOiJwcm92ZW5hbmNlLWF1dGhvcml6ZSJ9.dUvSg20-l4xn1dRTrhQTU8F0W9tRDWpE1INz793rICt-daFn5wVgd0SndvqNIquHFUih1aFMJ24rCoZCMq3AOA",
  "expires_at": "2026-10-24T17:36:45.000Z",
  "attestation_id": "7f79a885-5fc7-4946-a27e-6d5c5dc412d0",
  "biometric_bound": false
}
```

The token's `jti` claim is the `attestation_id`.

## 2. Fetch the published keys

[`GET /.well-known/jwks.json`](https://provenanceauth.com/docs/api/public-keys.md#get-well-known-jwks-json) is public and can be cached for an hour. During a key rotation it lists both keys, and each token's header names its key in `kid`.

**curl**

```bash
curl $PROVENANCE_API/.well-known/jwks.json
```

**Node**

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

const jwks = await fetchJwks(process.env.PROVENANCE_API!);
```

**Python**

```python
from provenanceauth import fetch_jwks

jwks = fetch_jwks(os.environ["PROVENANCE_API"])
```

```json
{
  "keys": [
    { "kty": "EC", "crv": "P-256", "x": "BK6V-uOw7SR4VDlKGwHj2eQpv5ZC5PwMnsrJhLoGVLQ", "y": "w7xDNaHuUjpEnYwC9u5p1Mosjw6ChXISYi7ojgjsUTc", "kid": "752696ff0f5e4f53", "use": "sig", "alg": "ES256" }
  ]
}
```

## 3. Verify the signature and expiry

The SDK verifiers use the platform's own crypto, so they run in Node, the browser and Python with no API key:

**Node**

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

const result = await verifyIntentTokenOffline(token, jwks);
if (result.valid) console.log("authorized for subject", result.payload?.sub, "in session", result.payload?.session);
```

**Python**

```python
from provenanceauth import verify_intent_token_offline

result = verify_intent_token_offline(token, jwks)
if result.valid:
    print("authorized for subject", result.payload["sub"], "in session", result.payload["session"])
```

The result has `valid`, `expired`, the token's claims in `payload`, and a `reason` when it fails. Any standard JOSE library works too, for example `jwtVerify` from `jose` with `algorithms: ["ES256"]`. To check without code, paste the token into the console's [Verify a proof](https://provenanceauth.com/docs/integrate/verify-a-proof.md) page.

Only ES256 is accepted. Pin the algorithm to ES256 and pick the key by the header `kid` before you check the signature. The API does the same: a token with any other `alg`, including `HS256` or `none`, fails [`POST /v1/mandate/assessments`](https://provenanceauth.com/docs/api/intent-tokens.md#post-v1-mandate-assessments) with reason `invalid_token`.

The claims you'll use most:

- `jti` (string): The token's ID, used for revocation checks.
- `sub` (string): An opaque subject for the person who approved, never their device id. A token minted with an `audience` carries a pairwise subject (`psub_…`): the same for one device at your site and unrelated at every other site, so you can count or block repeat approvals without linking the person elsewhere. A token minted without one carries a per-token subject (`anon_…`). Tokens minted before October 2026 carry the device's UUID until they expire.
- `aud` (string): The one site the token is for, when the agent named one. Accept the token only when it names your origin or merchant id.
- `action_hash` (string): SHA-256 of the approved `action_description`. Hash the description you received and compare.
- `payload_hash` (string): SHA-256 of the canonical JSON of the approved payload, when one was bound.
- `confirmed` (object): When a person approved the action (`at`) and how it reached them (`via`). Present only when a person approved. How they approved (the method, the biometric, the device tier) is in the paid check, [`POST /v1/authorize/verifications`](https://provenanceauth.com/docs/api/verifications.md#post-v1-authorize-verifications).
- `agent` (object): The registered agent's display name (`name`). Present when a registered agent asked.
- `risk` (object): A coarse risk read at mint: `score` (0 to 100) and `action` (`allow`, `review` or `block`).
- `exp` (integer): Expiry, four hours after issue.

## 4. Check revocation before a high-value action

A token can be revoked before it expires, and an offline check can't see that. The free [`POST /v1/verify`](https://provenanceauth.com/docs/api/verify.md#post-v1-verify) needs no key: it checks the signature, the issuer, the expiry and revocation, and answers with the token's free claims:

**curl**

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

**Node**

```ts
const res = await fetch(`${process.env.PROVENANCE_API}/v1/verify`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ token }),
});
const { valid, revoked } = await res.json();
```

**Python**

```python
import httpx

revoked = httpx.post(f"{os.environ['PROVENANCE_API']}/v1/verify", json={"token": token}).json()["revoked"]
```

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

### Approval holds

A token is signed when the agent asks for it, before anyone approves it. When the issuer's rules ask a person (`require.approval`), the agent's first decision opens the approval. Until the person approves, every check of the token answers `valid: false`: the free [`POST /v1/verify`](https://provenanceauth.com/docs/api/verify.md#post-v1-verify), the paid [`POST /v1/authorize/verifications`](https://provenanceauth.com/docs/api/verifications.md#post-v1-authorize-verifications), checkout assessments and the `@provenanceauth/rails` verifiers.

| `reason` | What happened | What to do |
| --- | --- | --- |
| `approval_pending` | The person hasn't answered yet. | Hold the order and check again after they answer. |
| `approval_denied` | The person declined it. | Don't run the action or ship the order. |
| `approval_expired` | Nobody answered before the approval expired. | Ask the agent to authorize again. |
| `approval_changes_requested` | The person asked for a change. | Wait for the agent's revised token. |
| `option_not_chosen` | The person chose a different option of the same request. | Run only the chosen option. |

A hold is a status, like revocation. The free check names the reason only, never the method, the biometric, the device tier or who approved. The paid check also names the approval (`approval.id`). Once the person approves, the token verifies, and `confirmed` says when they said yes (`via: "approval"`), even when they approved after the token was minted. `confirmed` is null when a rule alone allowed the action.

An agent that never calls its own decision has no approval to report, so its token verifies when nothing asked a person. To require a person's yes on every order, read `confirmed`, or pass `require.confirmed` to [`verifyAgentCheckout`](https://provenanceauth.com/docs/authorize/guides/verify-agent-checkout.md#require-a-persons-yes).

If you hold a key for the issuing account, [`POST /v1/mandate/assessments`](https://provenanceauth.com/docs/api/intent-tokens.md#post-v1-mandate-assessments) runs every check at once, including the description and payload binding.

## 5. Choose the free check or the paid one

[`POST /v1/verify`](https://provenanceauth.com/docs/api/verify.md#post-v1-verify) verifies any Provenance token for free: an intent token, a grant token or a signed receipt. Send `expected.action_payload` to have it compare the payload too; `binding` then says `match` or `mismatch`. It answers with the token's free claims only (the ones listed in step 3) and never the approval detail. It allows 120 requests a minute per IP address; past that it answers `429`.

A merchant that needs to know how the person approved calls [`POST /v1/authorize/verifications`](https://provenanceauth.com/docs/api/verifications.md#post-v1-authorize-verifications) with its own key. It runs the same checks, applies your checkout rules, and adds the approval detail Provenance keeps on its side: the method, whether it was biometric, the device's trust tier and the agent's registration. Each call is metered as one Authorize check.

| Check | Key | Answers with |
| --- | --- | --- |
| Offline (steps 2 and 3) | None | Signature and expiry |
| [`POST /v1/verify`](https://provenanceauth.com/docs/api/verify.md#post-v1-verify) | None | Signature, expiry, revocation, approval holds, binding and the free claims |
| [`POST /v1/authorize/verifications`](https://provenanceauth.com/docs/api/verifications.md#post-v1-authorize-verifications) | Your account key | All of that, your checkout rules and how the person approved |

## Errors you might see

| Symptom | Cause | Fix |
| --- | --- | --- |
| `valid: false`, reason `unknown kid` | Your cached keys predate a rotation | Fetch the keys again. |
| `valid: false`, `expired: true` | Tokens last four hours | Ask the sender to authorize again. |
| `valid: false`, reason `unsupported alg` | The token isn't an ES256 intent token | Check you were sent an intent token, not a receipt or another JWT. |
| `valid: false`, reason `approval_pending` | The issuer's rules asked a person, who hasn't answered | Hold the order; see [approval holds](#approval-holds). |
| `429` on the status check | The keyless status check is rate-limited per IP | Cache results for the token's lifetime, or verify with a key. |

## See also

- [Execution binding](https://provenanceauth.com/docs/mandate/guides/execution-binding.md)
- [Verify page](https://provenanceauth.com/docs/integrate/verify-a-proof.md)
- [Decision ledger](https://provenanceauth.com/docs/mandate/concepts/decision-ledger.md), for receipts that verify the same way
