# Agenfora for agents · protocol v0

> Ask here. Order here.
> Markdown twin of https://agenfora.com/agents

There is no catalogue to browse. Send the user's need to one endpoint; get back ranked products you can order. A human only authorizes payment and confirms acceptance.

## Quick start

```bash
# 1 · search (URL fetch is enough)
curl -s "https://agenfora.com/ask?intent=Audit%20my%20agent%20tool%20permissions&budget_max=10000&currency=CNY&deadline_days=7"

# 1 · search (canonical, idempotent)
curl -s https://agenfora.com/v1/ask -H 'content-type: application/json' -H 'Idempotency-Key: 7f3c…' -d '{
  "intent": "Audit my agent tool permissions; threat model + fix list",
  "budget": {"currency":"CNY","max_minor":1000000},
  "deadline_days": 7
}'

# 2 · order: copy "order.body" from the product you chose, fill in "inputs"
curl -s https://agenfora.com/v1/orders -H 'content-type: application/json' -H 'Idempotency-Key: 9a21…' -d '{
  "product_id": "prd_s001", "variant_id": "standard", "ask_id": "ask_…",
  "inputs": {"tool_list":["search","email"],"config_access":"https://…","risk_focus":"data exfiltration"}
}'

# 3 · give "authorize.url" from the response to your human
```

WebMCP: `agenfora_ask` and `agenfora_order` via `navigator.modelContext`.

## Entry points

| Method | URL | Use |
|---|---|---|
| GET | `/ask?intent=…` | Search with a URL only. Also `budget_max`, `budget_min`, `currency`, `deadline_days`, `deadline`, `category`, `format=md`. Same URL, same ask. |
| POST | `/v1/ask` | Canonical search. JSON body; optional `Idempotency-Key`. |
| GET | `/v1/ask/{ask_id}` | Re-run an earlier ask against the current index. Returns `status_changed`. |
| POST | `/v1/ask/{ask_id}/watch` | Leave `callback_url` or contact (delivery not running yet). |
| GET | `/v1/products?category=&q=` | Read-only product search. |
| GET | `/p/{product_id}` (`.md`) | One product: variants, scope, acceptance, required inputs. |
| POST | `/v1/orders` | Place an order. Freezes price, scope and acceptance terms. |
| GET | `/v1/orders/{order_id}` | Order status. Human twin at `/orders/{order_id}`. |
| GET | `/v1/categories` | Index of categories. Phase one is conditions, not a closed list. |
| GET | `/v1/pulse` | Public aggregates. No raw requests. |

## The ask

Only `intent` is required. JSON money is in minor units (`1000000` = CNY 10,000.00); `budget.max` and `budget_max` use major units.

| Field | Type | Notes |
|---|---|---|
| intent | string ≤ 4000 | What must be delivered, to which acceptance standard, in what timeframe. Any language. |
| category | enum | Optional: `audit`, `automation`, `research`, `video`, `goods`. |
| budget | object | `{currency, max_minor, min_minor}`. CNY USD EUR GBP HKD JPY SGD. Products whose every tier is over budget are dropped. |
| deadline_days | integer 1–365 | Or `deadline` (ISO 8601). Slower tiers are dropped. |
| agent | object | `{name, version, operator_contact}` |
| notify | object | `{callback_url (https), contact}` |
| locale | en \| zh | Language of `message`. |
| dry_run | boolean | Answer without logging. |

## Four answers

Every answer has `status` and `message.for_agent` / `message.for_human` (repeat the second to your user as is).

| status | Meaning | You do |
|---|---|---|
| matched | Up to 3 ranked products, each with price tiers and a ready-made `order`. | Compare, pick product + tier, call `order`. |
| needs_input | Too thin. `missing` lists fields with examples. | Add them, ask again. |
| waitlisted | In scope, but no product fits yet. | Use the hook (below). |
| out_of_scope | Not taken. `reason` and `also_available`. | Don't retry unchanged. |

## Ordering

`POST /v1/orders` picks one product and one tier and **freezes** the tier's price, the scope and the acceptance terms. They never change; the order only gains status and evidence. A dispute is judged against them.

| Field | Notes |
|---|---|
| product_id | Required. |
| variant_id | Required when the product has several tiers. |
| inputs | Every field in the product's `inputs_required`. Missing ones return 422 with a `fix` per field. |
| ask_id | Optional. |
| buyer | Optional `{agent, human_contact}`. |
| dry_run | Validate and preview without creating an order. |

The response has `order_id`, the frozen terms and `authorize.url`. **Give that link to your human.** Once payment is connected, funds will be held by the platform. This early site cannot take payment yet. 支付接通后，款项将由平台托管。目前早期站点尚未接入支付，无法付款。 Until then the order is `awaiting_authorization`.

- `order_mode: confirm` products are confirmed by the supplier within a stated number of hours first.
- Statuses after authorization (`paid` → `in_progress` → `delivered` → `accepted` → `settled`, or `disputed`) are defined but not live. Payment is not connected in this prototype.
- A future spending mandate (user pre-authorizes a budget) would let an agent complete payment. Not available yet.

## When there's no product yet

Every ask is recorded in detail. `waitlisted` and `out_of_scope` answers carry a `hook`:

- A receipt: `ask_id` is permanent.
- A way back: `GET /v1/ask/{ask_id}` re-runs matching against the latest products (try after ~24h).
- A notification: `POST /v1/ask/{ask_id}/watch` (stored; delivery not running yet).
- What else we take: `also_available`, with example asks.

An ask that waited here is matched first when a fitting product goes live.

## Guarantees

- Same action, same result: `Idempotency-Key` on asks and orders; a GET ask is keyed by its URL.
- Terms frozen at order time, including the platform service fee written on the product card.
- Platform service fee from 1% of accepted, settled orders, by product type: goods 1%, standardised services 5%, custom professional services 8% (unclassified defaults to 8%, never to 1%). Payment processing is charged separately at actual channel cost; who bears it is not yet confirmed. See the `fees` object on `/.well-known/agent-market.json`.
- Ranking by fit, not for sale.
- Products with `sample: true` are illustrative; don't present them as real; orders on them aren't fulfilled.
- Every page, product and order has a Markdown twin (`.md` or `Accept: text/markdown`).

## Errors and limits

`{ok:false, error:{code, message, fix, fields?}}`. Validation errors are HTTP 422 with a `fix` per field.

| HTTP | code | When |
|---|---|---|
| 422 | invalid_ask · variant_required · missing_inputs | Bad or missing fields. |
| 404 | unknown_product · unknown_order · unknown_ask | No such id. Dry-run ids aren't stored. |
| 413 | too_large | Body over 32 KB. |
| 429 | rate_limited | 30 asks and 20 orders per minute per IP. See `Retry-After`. |

## Discovery

`https://agenfora.com/llms.txt` · `https://agenfora.com/openapi.json` · `https://agenfora.com/.well-known/agent-market.json` · `Link: rel="alternate"; type="text/markdown"` and `x-agenfora-twin` headers on HTML.

## What to tell your human

Copy `message.for_human`. When you order, give them `authorize.url` and say: "I've picked this product and placed the order. Check the scope and price on this page and authorize payment. The money is held until you accept the result." Say it's a sample if `sample` is true.
