Authorize · Quickstart
Verify an agent order
This quickstart gets your store accepting only the agent orders a person approved. Start with the middleware in a few lines, or follow the API step by step under the hood.
Use the middleware
The fastest path to a store that accepts approved agent orders is the Identify middleware with hosted approvals and one webhook handler:
- An agent that checks out gets the approve link.
- The shopper approves the cart.
- Your store hears back on the webhook and checks the order.
The console's Set up agent checkout (from Get started, or /authorize/setup) fills in your key. The five-minute checkout guide has Express and FastAPI too.
This package isn't on npm yet. Until then, every request in these docs runs over HTTP against the sandbox.
With access to the private Provenance repository, which your Provenance contact grants, install from it:
git clone https://github.com/michaelnbane-jpg/provenance.git provenance
cd provenance && pnpm install && pnpm build
node scripts/check-publishable.mjs --out ../provenance-packs
cd ../your-project
npm install ../provenance-packs/provenanceauth-sdk-1.0.0.tgz ../provenance-packs/provenanceauth-rails-1.0.0.tgz ../provenance-packs/provenanceauth-identify-1.0.0.tgz// middleware.ts: agents that check out get the approve link; people never see a change.
import { Identify } from "@provenanceauth/identify";
import { identifyNext } from "@provenanceauth/identify/next";
import { orderFor } from "./lib/orders";
export const identify = new Identify({ apiKey: "prv_test_…", baseUrl: "https://api.provenanceauth.com" });
export const middleware = identifyNext(identify, { approvals: "hosted", orderFor });
// app/api/provenance/webhook/route.ts: the confirmation, checked against your own order.
import { nextWebhook } from "@provenanceauth/identify/webhooks";
import { identify } from "../../../../middleware";
import { findOrder, markApproved } from "../../../../lib/orders";
export const POST = nextWebhook(
identify.onApproved((a) => markApproved(a.order_id, a.approval_context), { secret: "whsec_…", orderFor: findOrder }),
);
Under the hood
In this quickstart a shopping agent sends your store an order with a Provenance token. You verify it for free, see a changed total fail, and read how the person approved. Then an order arrives with no token, and you ask the shopper to approve it.
You use curl with jq, or Node, or Python, and published sandbox keys, so you don't need an account.
1. Get an order token
In production the shopper's agent sends this token with its order. Here you mint one in the sandbox with the published full-access key, standing in for that agent.
The token binds the order: its id, the total in minor units, the currency, your merchant id and your store's origin.
export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x
curl -s $PROVENANCE_API/v1/mandate/intents \
-H "Authorization: Bearer prv_test_full_K7mN3xQp9RbT2vWm8sYd4cFjLhXn6gAe" \
-H "Content-Type: application/json" \
-d '{
"action_description": "Buy a desk lamp at Brindlecote Home",
"action_payload": { "order_id": "ord_1042", "total": 4800, "currency": "usd", "merchant_id": "brindlecote-home", "origin": "https://brindlecote-home.example" },
"agent_session_id": "sess_shopper_1",
"device_id": "dev_00000000000000000000000000000001"
}' | tee order-token.json
import { Provenance } from "@provenanceauth/sdk";
const order = { order_id: "ord_1042", total: 4800, currency: "usd", merchant_id: "brindlecote-home", origin: "https://brindlecote-home.example" };
const shopperAgent = new Provenance({ apiKey: "prv_test_full_K7mN3xQp9RbT2vWm8sYd4cFjLhXn6gAe", baseUrl: process.env.PROVENANCE_API });
const { intentToken } = await shopperAgent.mandate.intents.create({
actionDescription: "Buy a desk lamp at Brindlecote Home",
actionPayload: order,
agentSessionId: "sess_shopper_1",
deviceId: "dev_00000000000000000000000000000001",
});
import os
from provenanceauth import Provenance
order = {"order_id": "ord_1042", "total": 4800, "currency": "usd", "merchant_id": "brindlecote-home", "origin": "https://brindlecote-home.example"}
shopper_agent = Provenance("prv_test_full_K7mN3xQp9RbT2vWm8sYd4cFjLhXn6gAe", base_url=os.environ["PROVENANCE_API"])
intent_token = shopper_agent.mandate.intents.create(
action_description="Buy a desk lamp at Brindlecote Home",
action_payload=order,
agent_session_id="sess_shopper_1",
device_id="dev_00000000000000000000000000000001",
)["intent_token"]
{
"object": "intent_authorization",
"biometric_bound": false
}
export INTENT_TOKEN=$(jq -r .intent_token order-token.json)
PROVENANCE_KEY is now the Enterprise account key, which stands for your store in the next steps.
2. Verify the token for free
POST / needs no key. Send the token and the order as your own record has it. Build the order from your database, never from the request.
curl -s -X POST $PROVENANCE_API/v1/verify \
-H "Content-Type: application/json" \
-d '{ "token": "'"$INTENT_TOKEN"'", "expected": { "action_payload": { "order_id": "ord_1042", "total": 4800, "currency": "usd", "merchant_id": "brindlecote-home", "origin": "https://brindlecote-home.example" } } }'
const prov = new Provenance({ apiKey: process.env.PROVENANCE_KEY!, baseUrl: process.env.PROVENANCE_API });
const free = await prov.verify({ token: intentToken, expected: { actionPayload: order } });
prov = Provenance(os.environ["PROVENANCE_KEY"], base_url=os.environ["PROVENANCE_API"])
free = prov.verify(token=intent_token, expected={"action_payload": order})
{
"object": "verification_result",
"valid": true,
"kind": "intent",
"binding": "match",
"revoked": false
}
valid: true checks the signature, the issuer, the expiry and revocation. binding: "match" means the token was issued for this exact order. The response carries the token's free claims and a coarse risk.
3. Change the total
Suppose the agent was steered after the approval and the order total went up. Verify the new total with the same token.
curl -s -X POST $PROVENANCE_API/v1/verify \
-H "Content-Type: application/json" \
-d '{ "token": "'"$INTENT_TOKEN"'", "expected": { "action_payload": { "order_id": "ord_1042", "total": 9800, "currency": "usd", "merchant_id": "brindlecote-home", "origin": "https://brindlecote-home.example" } } }'
const changed = await prov.verify({ token: intentToken, expected: { actionPayload: { ...order, total: 9800 } } });
changed = prov.verify(token=intent_token, expected={"action_payload": {**order, "total": 9800}})
{
"object": "verification_result",
"valid": false,
"reason": "binding_mismatch",
"binding": "mismatch"
}
Refuse the order: the person approved the first total, not this one.
4. Read how the person approved
The free check says the approval is real. POST / with your Authorize key also says how the person approved: the method, whether it was biometric, the device's trust tier and the agent's registration.
It applies your checkout rules, and each call is one Authorize check on your bill.
curl -s -X POST $PROVENANCE_API/v1/authorize/verifications \
-H "Authorization: Bearer $PROVENANCE_KEY" \
-H "Content-Type: application/json" \
-d '{ "intent_token": "'"$INTENT_TOKEN"'", "action_payload": { "order_id": "ord_1042", "total": 4800, "currency": "usd", "merchant_id": "brindlecote-home", "origin": "https://brindlecote-home.example" } }'
const paid = await prov.authorize.verifications.create({ intentToken, actionPayload: order });
paid = prov.authorize.verifications.create(intent_token=intent_token, action_payload=order)
{
"object": "verification",
"valid": true,
"approval": {
"biometric_bound": false,
"hardware_attested": false,
"device_trust_tier": "simulated"
}
}
The sandbox token came from a simulated device with no person present, so approval.method is null. A token a person approved with a passkey says passkey, with approved_at and the approval's id.
5. Ask the shopper when there's no token
Another agent checks out with no token. Ask the shopper to approve this exact cart with POST /. By default the agent shows the approval link to its person, so Provenance sends nothing and nobody needs an account.
curl -s -X POST $PROVENANCE_API/v1/authorize/checkout_approvals \
-H "Authorization: Bearer $PROVENANCE_KEY" \
-H "Content-Type: application/json" \
-d '{
"cart": { "order_id": "ord_1043", "total": 4800, "currency": "USD", "merchant_id": "brindlecote-home", "origin": "https://brindlecote-home.example",
"items": [{ "sku": "lamp-desk", "name": "Desk lamp", "quantity": 1, "unit_amount": 4800 }] },
"display": { "merchant_name": "Brindlecote Home" },
"retry_url": "https://brindlecote-home.example/checkout",
"expires_in": 900
}' | tee checkout-approval.json
const approval = await prov.authorize.checkoutApprovals.create({
cart: { ...order, order_id: "ord_1043", items: [{ sku: "lamp-desk", name: "Desk lamp", quantity: 1, unit_amount: 4800 }] },
display: { merchantName: "Brindlecote Home" },
retryUrl: "https://brindlecote-home.example/checkout",
expiresIn: 900,
});
console.log(approval.approveUrl);
approval = prov.authorize.checkout_approvals.create(
cart={**order, "order_id": "ord_1043", "items": [{"sku": "lamp-desk", "name": "Desk lamp", "quantity": 1, "unit_amount": 4800}]},
display={"merchant_name": "Brindlecote Home"},
retry_url="https://brindlecote-home.example/checkout",
expires_in=900,
)
print(approval["approve_url"])
{
"object": "checkout_approval",
"status": "pending",
"route": "agent_relay",
"order_id": "ord_1043"
}
The response carries approve_url, the page the shopper opens, and challenge, the 401 your checkout returns to the agent. Read the approval back with GET /:
export APPROVAL_ID=$(jq -r .id checkout-approval.json)
curl -s $PROVENANCE_API/v1/authorize/checkout_approvals/$APPROVAL_ID \
-H "Authorization: Bearer $PROVENANCE_KEY"
const pending = await prov.authorize.checkoutApprovals.get(approval.id);
pending = prov.authorize.checkout_approvals.get(approval["id"])
{
"object": "checkout_approval",
"status": "pending",
"decided_at": null
}
Open approve_url in a browser to approve it as the shopper: the page shows your store, the items and the total, and approves with a passkey on that device.
Once approved, the approval carries an intent token bound to this order, and the agent retries your checkout with it:
{
"object": "checkout_approval",
"status": "approved",
"decided_at": "2026-11-04T21:19:02.000Z",
"intent_token": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6..."
}
The approved response also carries approval_context: how the person approved, with the passkey, the device and the network. See approval context.
Verify that token exactly as in step 2, with the cart as your order: valid: true and binding: "match".
Try it
The Authorize explorer verifies a token in your browser against the sandbox. To check a token without any call, verify it offline against the published keys: verify a token.
Next steps
- Verify agent checkouts:
verifyAgentCheckouton your own checkout, with the grant's limits. - Ask your own customer: send the approval link to your signed-in customer instead.
- Assess an agent checkout: one call that returns approved, challenged or rejected.
- Example apps: small working apps that use this product end to end.