Resolver API reference
The resolver is a compact HTTP boundary for offer discovery, readiness, invoice creation, resolution records, receipts, reconciliation, and webhook operations.
Authentication
The payment path is open: offer fetches, Fiber Address lookup, QR codes, readiness, invoice requests, and a single resolution or receipt addressed by its resolution ID. Everything on the merchant's side needs a resolver key with the right scope: offer registration and inventory, the offer switch, the list of an offer's resolutions, reconciliation exports, settlement writes, webhooks, diagnostics, and topology. The key is RESOLVER_API_KEY or a named key, sent as a bearer token or x-api-key. A browser uses a session opened with a key instead.
An offer ID is printed in every payment link, so it never grants access to more than the offer itself. Routes under /demo exist only when the resolver runs with RESOLVER_DEMO_MODE=true.
Authorization: Bearer change-me
# or
x-api-key: change-me
# a named key is sent the same way
Authorization: Bearer fok_...
A missing credential, or one that does not check out, gets 401 UNAUTHORIZED. A valid one with too low a scope gets 403 INSUFFICIENT_SCOPE, with required_scope and scope in details. When the resolver cannot check a credential it grants nothing, and an operator route answers 503 AUTH_UNAVAILABLE, which can be retried. A client address that presents more than 20 different bad credentials within one rate-limit window gets 429 RATE_LIMITED for new credentials until that window ends; keys and sessions already seen working are still served, and a dead session cookie is cleared.
Browser sessions
POST /operator/session with { "api_key": "..." } opens a session with that key's scope. It answers 204 and sets an HttpOnly, SameSite=Strict cookie, named __Host-fiber_offers_operator and marked Secure on HTTPS. The resolver stores the session and keeps only a hash of its secret. A session lasts RESOLVER_ADMIN_SESSION_TTL_SECONDS, 8 hours by default. It ends sooner when its key is revoked or expires, and a session opened with RESOLVER_API_KEY ends when that value changes.
A change made with the cookie must come from the resolver's own pages, or it gets 403 CROSS_SITE_REQUEST. A key sent in a header is not affected. GET /operator/session returns authenticated, scope, and the key's id and name. DELETE /operator/session ends the caller's own session on the resolver, so a copied cookie stops working too. DELETE /operator/sessions ends every open session.
Keys and scopes
RESOLVER_API_KEY is the root key. It has the admin scope, is never stored, and is checked in memory, so it works while the database is down. An admin key makes named keys, each with one scope. A higher scope includes everything a lower one covers.
| Scope | Covers | Give it to |
|---|---|---|
read | Every operator read: offer list, resolutions, reconciliation, webhooks and their events, the recurrence summary, diagnostics, and topology. | Accounting and monitoring. |
manage | Read, plus every operator change: offers, Fiber Addresses, the offer switch, syncs, status writes, and webhooks. | The shop's backend. |
admin | Manage, plus keys and sessions, and saying by hand that a live invoice was received or paid. | The people who manage keys. |
POST /operator/keys
Authorization: Bearer change-me
content-type: application/json
{
"name": "shop backend",
"scope": "manage",
"expires_at": "2027-06-01T00:00:00Z"
}
The answer is 201 with key and token. The token starts with fok_ and appears in this answer only: the resolver stores a SHA-256 hash of it. expires_at is optional. GET /operator/keys lists RESOLVER_API_KEY first, then every named key, revoked ones included, with last_used_at and usable. It never returns a token or a hash.
DELETE /operator/keys/:key_id revokes a named key. It stops working on every replica at its next request, and so do the sessions opened with it. An expired key stops the same way. RESOLVER_API_KEY cannot be revoked here (409 ENV_KEY_NOT_REVOCABLE): change it on every replica instead. Without RESOLVER_API_KEY the resolver is open for local development, every caller is the operator, and POST /operator/keys answers 409 AUTH_NOT_CONFIGURED.
Endpoint map
| Method and path | Purpose | Scope when configured |
|---|---|---|
GET /health | Whether the resolver is up, and its invoice mode. Dependency detail is added for operators. | No |
GET|POST /operator/session | Inspect the caller's key and scope, or open a browser session with a key. | No; POST checks the key |
DELETE /operator/session | End the caller's own session and clear the cookie. | read |
DELETE /operator/sessions | End every open session. | admin |
GET|POST /operator/keys | List keys, or create a named key with a scope. | admin |
DELETE /operator/keys/:key_id | Revoke a named key and the sessions opened with it. | admin |
GET /diagnostics, GET /topology | Resolver, Fiber RPC, worker, and topology health. | read |
GET /offers | List compact offer summaries for an operator console. | read |
POST /offers | Register an offer the merchant signed. | manage |
POST /demo/offers | Create a sample offer signed with a key the resolver generates. Demo mode only. | manage |
GET /offers/:offer_id | Offer, encoded payload, links, QR URLs, and metadata. | No |
POST /offers/:offer_id/disable, POST /offers/:offer_id/enable | Switch the offer off, or back on. Needs no signature from the offer's key. | manage |
DELETE /offers/:offer_id | Revoke the offer for good, with a revocation signed by the offer's key. | No; the signature authorizes it |
POST /offers/:offer_id/check | Validate a payment request without creating an invoice. | No |
POST /offers/:offer_id/invoice | Create or replay an invoice resolution. | No |
GET /offers/:offer_id/resolutions | List the offer's resolution records. | read |
GET /offers/:offer_id/resolutions/:resolution_id | One resolution, for whoever holds its ID. | No |
GET /offers/:offer_id/recurrence-status | With approval_id: one subscription, for its payer. Without: the summary across subscribers. | read, only without approval_id |
GET|POST /offers/:offer_id/webhooks | List or register webhook endpoints. | read to list, manage to register |
PATCH|DELETE /offers/:offer_id/webhooks/:webhook_id | Pause, resume, update, or remove an endpoint. | manage |
POST /offers/:offer_id/webhooks/:webhook_id/test | Send a signed test event to one endpoint. | manage |
POST /offers/:offer_id/webhooks/:webhook_id/rotate-secret | Rotate and reveal a replacement signing secret once. | manage |
GET /offers/:offer_id/webhook-events | Inspect event and delivery attempt history. | read |
GET /.well-known/fiberoffer/:username | Resolve a Fiber Address. | No |
Create or register an offer
The demo endpoint generates a key pair and signed offer for local development, and is served only when the resolver runs with RESOLVER_DEMO_MODE=true. Merchants create and sign the offer with the CLI, SDK, or protocol package, so the key never leaves their side, then send the encoded offer to POST /offers.
curl -X POST http://localhost:8787/demo/offers \
-H 'content-type: application/json' \
-H 'Authorization: Bearer change-me' \
-d '{
"username": "coffee",
"description": "Coffee checkout",
"pricing_type": "fixed",
"amount": "1000",
"assets": [{ "asset_type": "ckb", "symbol": "CKB" }]
}'
curl -X POST https://resolver.example/offers \
-H 'content-type: application/json' \
-H 'Authorization: Bearer change-me' \
-d '{
"username": "coffee",
"encoded_offer": "fbroffer1..."
}'
The registered response contains offer_id, payment_link, encoded_offer, qr_link_url, qr_offer_url, and the optional fiber_address.
Switch an offer off or revoke it
An offer can be stopped in two ways. Revocation is signed by the offer's own key and is permanent. The operator's switch needs a key or session with the manage scope and no signature, so it also stops an offer whose lifecycle key is lost, and it can be undone.
POST /offers/:offer_id/disable
Authorization: Bearer fok_...
content-type: application/json
{ "reason": "Sold out" }
POST /offers/:offer_id/enable
Authorization: Bearer fok_...
reason is optional, at most 200 characters. The resolver records the switch as operator_disabled, with disabled_at, the key's ID and name, and the reason. Only callers with a key or session see that record. Switching off an offer that is already off keeps the first record. A revoked offer can be switched neither off nor on (409 OFFER_REVOKED), but the offer's key can still revoke an offer that is switched off.
| What the payer calls | Switched off | Revoked |
|---|---|---|
POST /offers/:offer_id/invoice | 410 OFFER_DISABLED | 410 OFFER_REVOKED |
POST /offers/:offer_id/check | The offer_state check fails with OFFER_DISABLED. | The offer_state check fails with OFFER_REVOKED. |
GET /offers/:offer_id | disabled: true, no revoked_at | disabled: true and revoked_at |
GET /offers/:offer_id/recurrence-status | disabled: true, revoked: false | disabled: true, revoked: true |
Invoices issued before the switch stay payable until they expire. The switch stops new ones.
Readiness before invoice creation
Call check whenever the user has selected an amount and asset. It validates signature, pricing rules, assets, single-use state, and merchant invoice availability. Payer route payability remains unknown until the payer wallet dry-runs the fresh invoice using its own node.
POST /offers/:offer_id/check
{
"amount": "1200",
"asset": { "asset_type": "ckb", "symbol": "CKB" }
}
{
"ready": true,
"confidence": "medium",
"next_action": "request_invoice",
"summary": "Request is valid; a fresh Fiber invoice can be created.",
"checks": [],
"blockers": [],
"warnings": []
}
payable is omitted when the payer route is unknown. After invoice creation, the payer wallet calls FiberPaymentClient.checkPaymentRoute(); a successful dry-run returns payable: true and high confidence. A controlled pair fixture may perform this check through the resolver, but it is not required for merchant operation.
Invoice resolution and idempotency
Invoice creation is intentionally separate from readiness. The resolver creates a fresh invoice only after it accepts the request.
POST /offers/:offer_id/invoice
Idempotency-Key: checkout-order-42
content-type: application/json
{
"amount": "1200",
"asset": { "asset_type": "ckb", "symbol": "CKB" }
}
The first successful request returns 201. Retrying exactly the same request and idempotency key returns 200 with idempotent_replay: true. Reusing the key with a different amount or asset returns 409 IDEMPOTENCY_KEY_REUSED.
Scenario: mobile retry after a network timeout
The wallet sends an invoice request but loses the response. It retries with the same idempotency key. The resolver returns the original resolution and invoice, so the user never receives a second invoice for the same checkout attempt.
Records, receipts, and exports
GET /offers/:offer_id/resolutions
GET /offers/:offer_id/resolutions/:resolution_id
POST /offers/:offer_id/resolutions/:resolution_id/status
POST /offers/:offer_id/resolutions/:resolution_id/sync
POST /offers/:offer_id/resolutions/sync
GET /offers/:offer_id/resolutions/:resolution_id/receipt.json
GET /offers/:offer_id/reconciliation.json
GET /offers/:offer_id/reconciliation.csv
A single resolution and its receipt are readable by whoever holds the resolution ID. The resolution list and reconciliation files need the read scope; status writes and syncs need manage. Setting invoice_received or invoice_paid by hand needs admin, unless the invoice is a mock, because either status sends a signed webhook, such as invoice.paid, that the shop acts on. Every change made through the status route is recorded in status_history with source manual; a source the caller sends is kept as details.reported_source. Reconciliation files are read-only views intended for merchant systems, support workflows, and accounting exports.