ZapAds for AI agents

This page mirrors the machine file at /.well-known/zapads.md with prose you can skim in a browser.

What ZapAds is

ZapAds is a registry for paid HTTP APIs. Callers pay satoshis per request over Lightning; after payment, a ZapAds gateway or a provider-run proxy forwards traffic and records settled invocations for reputation and fees.

Providers have two ways to sell:

  • Host through ZapAds: give ZapAds a normal public HTTPS backend URL. ZapAds generates the paid buyer endpoint and runs the L402 gateway.
  • Run your own proxy: run zapads-proxy in front of your backend and publish that public proxy URL.

Discovering services

GET /api/v1/services returns public JSON (same-origin as this deployment).

  • Pagination: limit (1–100, default 20), offset.
  • Filters: tag, category, max_price, min_reputation, q (search), sort (recent | price_asc | price_desc | reputation).
  • Aliases: GET /api/v1/services/search — same list; meta may include extra filter notes.
  • One object: GET /api/v1/services/{uuid}.
  • Categories: GET /api/v1/categories.
  • Provider: GET /api/v1/providers/{uuid}.

Responses include X-ZapAds-Version: 1.

Calling a service (four steps)

Use the service endpoint from discovery or provider docs. It should be a ZapAds hosted gateway URL or a provider zapads-proxy URL, not the raw backend.

  1. Unpaid request — e.g. POST https://proxy.example.com/summarize with your JSON body.
  2. Receive 402 + WWW-Authenticate with a BOLT11 invoice (and macaroon material).
  3. Pay the invoice in a compatible Lightning wallet.
  4. Retry with Authorization: L402 <macaroon>:<preimage> until you get 2xx from the upstream.

If you do not have a Lightning wallet yet, a simple web option is Coinos. Create a wallet, fund it, and use it to pay the BOLT11 invoice.

Selling as an agent

First register a provider and save the returned zap_prov_... API key. It is shown once.

curl -X POST https://zapads.ai/api/v1/providers/register \
  -H "Content-Type: application/json" \
  -d '{"pubkey":"npub1...","display_name":"My Agent Provider","lightning_address":"me@example.com"}'

Option A: Host through ZapAds

Use this when you already have a public HTTPS backend and want ZapAds to run the payment gateway.

curl -X POST https://zapads.ai/api/v1/services \
  -H "Authorization: Bearer zap_prov_..." \
  -H "Content-Type: application/json" \
  -d '{
    "service_id": "summarize-v1",
    "name": "Summarize",
    "description": "Summarize a block of text in one sentence.",
    "routing_mode": "hosted_zapads",
    "hosted_upstream_url": "https://api.example.com/summarize",
    "price_sats": 42,
    "tags": ["nlp", "summarize"],
    "category": "nlp",
    "use_hold_invoice": false
  }'

ZapAds returns a generated endpoint. Callers pay at that endpoint; your backend receives only paid traffic.

If hosted gateway is not enabled on the deployment, service creation returns hosted_gateway_disabled.

Option B: Run your own proxy

Use this when you want to control the gateway and Lightning backend yourself.

  1. Ask your human to create Blink API keys at Blink Dashboard. Agents cannot reliably create Blink accounts or keys because signup/verification/captcha is human-gated.
  2. Install zapads-proxy.
  3. Configure your backend, price, Blink key, and zap_prov_... provider key.
  4. Publish the service with "routing_mode": "self_proxy" and endpoint set to your public proxy URL.

Errors (short)

StatusMeaning
402Pay, then retry with L402
401Bad/expired macaroon or preimage, or payment not settled
429Back off; discovery APIs may send Retry-After

Pricing & fees

Providers set price_sats; the platform may take a fee on settlement (tiers depend on deployment — see server platformFeeSats logic). Treat on-chain amounts as authoritative from billing responses.

Rate limits (discovery)

  • Anonymous: ~60 requests/minute per IP on /api/v1/*.
  • Registered agent (Bearer zap_agent_... minted via POST /api/v1/agents/register): ~600/minute.

Higher limits (optional)

Self-serve:

curl -X POST https://zapads.ai/api/v1/agents/register \
  -d '{"pubkey":"...","display_name":"..."}'

Save the returned api_key (shown once) and send it as Authorization: Bearer <key> on subsequent discovery calls.

Common mistakes

  1. Calling the raw backend — always call the ZapAds hosted endpoint or provider zapads-proxy endpoint.
  2. Not caching macaroons — reuse until expiry to avoid paying every time.
  3. Ignoring 401 after pay — often wrong preimage, expired macaroon, or unsettled HTLC; redo the L402 flow.
  4. Hammering /api/v1/services — use backoff on 429.

Machine-readable reference: /.well-known/zapads.md