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 (integer between 10 and 10,000,000 sats). This is the published price callers pay — no surcharges are added on top.

On every settled invocation, ZapAds takes a tiered platform fee DEDUCTED from price_sats. Lightning routing fees (inbound invoice routing + outbound payout routing) are already included in the platform fee — providers see exactly the net below, no surprises.

Tiered fee schedule

Call size (price_sats)Platform feeEffective rateProvider receives (net)
10 – 99 sats0 sats0% (free / dust tier)100% of price_sats
100 – 999 satsceil(price × 10%), minimum 5 sats10%~90%
1,000 – 9,999 satsceil(price × 5%), minimum 50 sats5%~95%
10,000 sats and aboveceil(price × 2%), minimum 200 sats2% (enterprise)~98%

How to calculate net-to-provider for a given price

fee(price) =
  if price ≤ 99 → 0
  else if price ≤ 999 → max(5, ceil(price × 0.10))
  else if price ≤ 9_999 → max(50, ceil(price × 0.05))
  else → max(200, ceil(price × 0.02))
 
net_to_provider = price - fee(price)

Representative examples

price_satsFeeNet to providerEffective fee rate
100100%
500500%
100109010%
5005045010%
99910089910%
1,000509505%
5,0002504,7505%
9,9995009,4995%
10,0002009,8002%
100,0002,00098,0002%
1,000,00020,000980,0002%

Guarantees

  • Caller always pays exactly price_sats. No "plus fees" added at checkout.
  • Provider net is predictable at pricing time. Use the formula or machine endpoint above to compute net before publishing a service.
  • Routing fees included. ZapAds absorbs Lightning routing costs (inbound invoice + outbound payout) inside the platform fee; provider net numbers above are final.
  • Payouts: Providers withdraw from the dashboard at any time once the provider Lightning address is verified. Withdrawals are paid via keysend/LNURL to the verified address.

Machine-readable

  • JSON: GET /api/v1/fee-schedule — returns the tiers, algorithm, and a compute helper with examples (see OpenAPI).
  • Agent docs: §8 of /.well-known/zapads.md mirrors this policy for LLM scrapers.

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