Authorize · Guide
Buy from agents
Use this when your agent buys from another company's agent. Your agent checks who it's paying, accepts the seller's signed offer under your grant and policy, and confirms what arrived. Acceptance is free.
Before you begin: register your agent and, for spending limits, grant it a grant.
1. Check the seller
import { verifyCounterparty } from "@provenanceauth/rails/deals";
const seller = await verifyCounterparty({ kid: offerKid }, { apiBase: process.env.PROVENANCE_API! });
if (!seller.domain_verified || seller.key_status !== "active") throw new Error("unverified seller");
from provenanceauth_verify import verify_counterparty
seller = verify_counterparty(os.environ["PROVENANCE_API"], kid=offer_kid)
See Check who you're paying for the fields.
2. Accept the offer
curl -s -X POST $PROVENANCE_API/v1/authorize/deals \
-H "Authorization: Bearer $PROVENANCE_KEY" -H "Content-Type: application/json" \
-d "{ \"offer\": \"$OFFER\", \"agent_session_id\": \"sess_scout_7\", \"agent_id\": \"$AGENT_ID\", \"grant_id\": \"$MANDATE_ID\" }"
import { acceptOffer } from "@provenanceauth/rails/deals";
const deal = await acceptOffer(offer, { apiBase: process.env.PROVENANCE_API!, apiKey: process.env.PROVENANCE_KEY!, agent_session_id: "sess_scout_7", agent_id: agentId, grant_id: mandateId });
import os
import httpx
api, h = os.environ["PROVENANCE_API"], {"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}
deal = httpx.post(f"{api}/v1/authorize/deals", headers=h, json={"offer": offer, "agent_session_id": "sess_scout_7", "agent_id": agent_id}).json()
The acceptance runs your grant, budget and policy unchanged, with action_type: "deal.accept", the seller agent as counterparty and the total as transaction_amount. A policy that would deny the purchase leaves the deal declined with its reason. The same offer accepted again returns the first deal.
When status is accepted, intent_token is the acceptance; hand it to the seller (over x402, dealTokenGetter does it inside intentPaymentFetch).
3. When a person must approve
pending_approval means a person on your side is asked: your policy asked, or the seller's offer requires your person (requires.buyer_person). The approval page shows the seller with its record, the cart, the terms and refunds; the person approves with their passkey, which also signs the offer's terms. awaiting_seller means a person at the seller confirms next. Poll GET / or listen for authorize.deal.accepted.
To ask a person at the seller to confirm, send require_seller_person: true. If the seller's policy doesn't cover the order, the request is refused with seller_confirmation_not_offered and the policy, so a deal never waits on a confirmation the seller doesn't give.
4. Confirm the delivery
Hash what you received and send it:
curl -s -X POST $PROVENANCE_API/v1/authorize/deals/$DEAL_ID/confirm \
-H "Authorization: Bearer $PROVENANCE_KEY" -H "Content-Type: application/json" \
-d '{ "content_hash": "'"$(sha256sum report.pdf | cut -d" " -f1)"'" }'
import { contentHash } from "@provenanceauth/rails/deals";
await fetch(`${process.env.PROVENANCE_API}/v1/authorize/deals/${deal.id}/confirm`, {
method: "POST",
headers: { Authorization: `Bearer ${process.env.PROVENANCE_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({ content_hash: await contentHash(reportBytes) }),
});
import hashlib
httpx.post(f"{api}/v1/authorize/deals/{deal['id']}/confirm", headers=h, json={"content_hash": hashlib.sha256(report_bytes).hexdigest()})
A match completes the deal; anything else is delivery_mismatch. Then rate the seller once with POST /, and record the rail's reference with POST / if you like.
5. Set your seller rules
In Rules → Seller rules, or PUT /, turn on the templates you want; each is saved as a rule in your checkout policy and named on the approval it triggers:
| Template | Default | Rule |
|---|---|---|
| New sellers | Ask below 50 orders | counterparty. |
| Low rating | Ask below 4.5 | counterparty. |
| Late deliveries | Off; ask below 95% | counterparty. |
| Disputes | Never buy above 2% | counterparty. (a deny) |
| Large purchases | Ask above 1,000 (your currency) | transaction_ |
Ask sellers to confirm when they offer it adds the seller's confirmation on orders at or over an amount, and chooses what happens when the seller doesn't confirm that order: buy anyway, ask your person, or don't buy.
Every counterparty.* fact is available to your own rules on deal.accept; the policy facts table lists them.
Errors you might see
| Code | What to do |
|---|---|
offer_, offer_, offer_ | Ask the seller for a fresh offer. |
offer_ | The issuer isn't a selling agent; check it first. |
deal_ | Add an approver, or accept under a grant whose person has a device key. |
seller_ | Accept without require_, or ask your own person. |