# Sell to agents

Mark your agent as a seller, publish its well-known file, sign offers and delivery receipts with its Identify key, and set when a person on your team confirms.

Use this to let other companies' agents buy from your agent with a signed offer, and to get proof of who accepted it and what you delivered. Your agent signs offers and deliveries with its own Ed25519 key; it never calls Provenance to sign.

**Before you begin:** [register your agent](https://provenanceauth.com/docs/mandate/guides/execution-binding.md#1-register-the-agent) and [give it an Identify signing key](https://provenanceauth.com/docs/identify/guides/sign-agent-requests.md).

## 1. Mark the agent as a seller

**curl**

```bash norun
curl -s -X PATCH $PROVENANCE_API/v1/mandate/agents/$AGENT_ID \
  -H "Authorization: Bearer $PROVENANCE_KEY" -H "Content-Type: application/json" \
  -d '{ "selling": true, "seller_origin": "https://saltmarsh.example" }'
```

**Node**

```ts
await fetch(`${process.env.PROVENANCE_API}/v1/mandate/agents/${agentId}`, {
  method: "PATCH",
  headers: { Authorization: `Bearer ${process.env.PROVENANCE_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({ selling: true, seller_origin: "https://saltmarsh.example" }),
});
```

**Python**

```python
import os
import httpx

api, h = os.environ["PROVENANCE_API"], {"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}
httpx.patch(f"{api}/v1/mandate/agents/{agent_id}", headers=h, json={"selling": True, "seller_origin": "https://saltmarsh.example"})
```

## 2. Publish the well-known file

Serve this at `https://saltmarsh.example/.well-known/provenance-agent.json`, listing the agent and its key ids:

```json
{ "agents": [{ "id": "agt_01M67P48DDK4HRGG0BR457KQJN", "kids": ["poqkLGiymh_W0uP6PZFw-dvez3QJT5SolqXBCW38r0U"] }] }
```

Then run [`POST /v1/authorize/agents/{id}/seller_check`](https://provenanceauth.com/docs/api/deals.md#post-v1-authorize-agents-id-seller-check). The check runs daily too. While it passes, buyers see `domain_verified: true`; a failure clears it and sends `authorize.agent.seller_check_failed`. `domain_verified` means your origin lists the agent, nothing more.

## 3. Sign an offer

**Node**

```ts
import { signOffer } from "@provenanceauth/rails/deals";

const { offer, offer_hash } = await signOffer({
  iss: agentId,
  offer_id: "ofr_eu_storage_2026q4",
  items: [{ sku: "rpt-eu-storage", name: "EU storage market report", quantity: 1, unit_price: 40, description: "20 pages, PDF" }],
  total: 40,
  currency: "USD",
  delivery: { kind: "file", format: "application/pdf", deadline: "2026-11-02T00:00:00Z" },
  refund_terms: ["full_if_late"],
  terms: { summary: "PDF delivery. A full refund if it arrives late.", url: "https://saltmarsh.example/terms", hash: termsSha256 },
  seller_confirmation: { offered: "never", response_time: "1bd" },
}, privateJwk);
```

**Python**

```python
from provenanceauth_verify import sign_offer

signed = sign_offer({
    "iss": agent_id, "offer_id": "ofr_eu_storage_2026q4",
    "items": [{"sku": "rpt-eu-storage", "name": "EU storage market report", "quantity": 1, "unit_price": 40}],
    "total": 40, "currency": "USD",
    "delivery": {"kind": "file", "deadline": "2026-11-02T00:00:00Z"},
    "refund_terms": ["full_if_late"],
    "seller_confirmation": {"offered": "never", "response_time": "1bd"},
}, private_jwk)
offer = signed["offer"]
```

An offer expires within 7 days and is at most 8 KB. `total` must equal the items. To require a person at the buyer, add `requires: { buyer_person: true, buyer_method: "passkey", agree_terms: true }`; their passkey then signs your `terms.hash`. `seller_confirmation` must match your settings exactly (step 5), or the offer is refused.

To sell over x402 v2, put the offer in the 402 with `x402OfferRequired({ resource, accepts, offer })`. The buyer accepts it and pays with the acceptance token in the extension.

## 4. Check the acceptance

When the buyer pays, check its token offline against our JWKS and your own offer:

**Node**

```ts
import { verifyDealAcceptance, verifyX402DealPayment } from "@provenanceauth/rails/deals";

const r = await verifyDealAcceptance(token, offer, { jwks });
// over x402: await verifyX402DealPayment(req.headers["payment-signature"], offer, { jwks })
if (!r.valid) throw new Error(r.reason);
```

**Python**

```python
from provenanceauth_verify import verify_deal_acceptance

r = verify_deal_acceptance(token, offer, jwks)
assert r.valid, r.reason
```

**Go**

```go
r := provenanceverify.VerifyDealAcceptance(token, offer, jwks, "", nil, 0)
```

It checks our signature and expiry, that the token's `deal.offer_hash` is your offer's hash and you are the seller, the revocations you pass, and that every person the offer required approved with the method, tier and terms you asked for. `chain` is `not_checked`: agent-team chains aren't issued yet.

## 5. Set when your people confirm

In **Settings → Store → Selling → Confirmations**, or [`PUT /v1/authorize/settings/commerce`](https://provenanceauth.com/docs/api/deals.md#put-v1-authorize-settings-commerce), choose `never`, `on_request` (orders at or over `min_amount`, or with listed SKUs or categories) or `always`, and your usual response time. The policy goes into every offer and the counterparty check, beside the measured median over 30 days. Confirmations go to all of your approvers; with none, an order that needs one is refused at acceptance with `deal_person_required`.

To send some orders to particular people, add a rule on `action_type: "deal.sell"` with a [route](https://provenanceauth.com/docs/mandate/guides/route-approvals.md): the rule can read the order's `order.*` facts (amount, SKUs, categories, the buyer company and its rating), and the confirmation then follows the route's people, wait and escalation.

Your confirmation page shows the buyer, the agent it's buying with, a one-line summary, the delivery date and the total. **Show the buyer's record** (`show_buyer_record`) adds the buyer's two facts: `never` (the default), `new_or_low` (a new buyer, or one rated under the value you set, 4 by default) or `always`. The record is always in Details.

## 6. Deliver

Sign a delivery receipt and record it with your key:

```ts
import { signDelivery, contentHash } from "@provenanceauth/rails/deals";

const { receipt } = await signDelivery({ iss: agentId, deal_id: deal.id, offer_hash, content_hash: await contentHash(pdfBytes) }, privateJwk);
```

Then [`POST /v1/authorize/deals/{id}/delivery`](https://provenanceauth.com/docs/api/deals.md#post-v1-authorize-deals-id-delivery). The buyer confirms the hash; a silent buyer leaves the deal `completed_unconfirmed` after the confirm window. You pay per completed deal. You may cancel any time before delivery with [`POST /v1/authorize/deals/{id}/cancel`](https://provenanceauth.com/docs/api/deals.md#post-v1-authorize-deals-id-cancel).

## Errors you might see

| Code | What to do |
| --- | --- |
| `offer_invalid` | Re-sign the offer; check the totals and that `seller_confirmation` matches your settings. |
| `offer_key_revoked` | Sign with an active key. |
| `delivery_receipt_invalid` | Sign the receipt with this deal's `id` and `offer_hash`. |
| `deal_state_invalid` | Read the deal and act on its current status. |

## See also

- [Deals between agents](https://provenanceauth.com/docs/authorize/concepts/agent-commerce.md)
- [Pay per call with tabs](https://provenanceauth.com/docs/authorize/guides/pay-per-call-with-tabs.md): many small calls under one approval
- [When a deal goes wrong](https://provenanceauth.com/docs/authorize/guides/when-a-deal-goes-wrong.md): disputes, evidence and who decides
- [Act as an arbiter](https://provenanceauth.com/docs/authorize/guides/act-as-an-arbiter.md): decide disputes you are named in
- [Buy from agents](https://provenanceauth.com/docs/authorize/guides/buy-from-agents.md)
