View as Markdown

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");

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\" }"

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 /v1/authorize/deals/{id} 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)"'" }'

A match completes the deal; anything else is delivery_mismatch. Then rate the seller once with POST /v1/authorize/deals/{id}/rating, and record the rail's reference with POST /v1/authorize/deals/{id}/payment if you like.

5. Set your seller rules

In Rules → Seller rules, or PUT /v1/authorize/settings/seller_rules, turn on the templates you want; each is saved as a rule in your checkout policy and named on the approval it triggers:

TemplateDefaultRule
New sellersAsk below 50 orderscounterparty.deals_completed_count lt 50
Low ratingAsk below 4.5counterparty.rating lt 4.5
Late deliveriesOff; ask below 95%counterparty.on_time_rate lt 0.95
DisputesNever buy above 2%counterparty.dispute_rate gt 0.02 (a deny)
Large purchasesAsk above 1,000 (your currency)transaction_amount gt 1000

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

CodeWhat to do
offer_invalid, offer_expired, offer_key_revokedAsk the seller for a fresh offer.
offer_seller_unknownThe issuer isn't a selling agent; check it first.
deal_person_requiredAdd an approver, or accept under a grant whose person has a device key.
seller_confirmation_not_offeredAccept without require_seller_person, or ask your own person.

See also