Public
Fax API for AI agents — paid per fax over x402 (USDC)
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

agentfax

A fax API for AI agents — paid per page over Tempo/MPP (USDC.e). No signup, no API key, no dashboard. An agent calls one endpoint, gets a 402 Payment Required with an MPP Payment challenge, pays in USDC.e on Tempo, and the fax goes out. It's "AgentMail, but for faxes."

Pay it in one line with the Tempo CLI:

tempo request -X POST --json '{"to":"+14155550123","file_url":"https://example.com/doc.pdf"}' \ https://agentfax.val.run/v1/fax

Why it's interesting

  • Permissionless monetization. No marketplace to apply to. You stand up an HTTP endpoint that returns a 402 WWW-Authenticate: Payment challenge pointing at your wallet; any MPP client pays it.
  • No facilitator, no keys to babysit. mppx verifies and settles the payment directly against the Tempo chain — there's no payment processor in the middle.
  • Per-page pricing. On the unpaid request we count the PDF's pages and price the charge as pages × rate, so the 402 tells the agent the exact cost up front.
  • Documents are never stored. The file is forwarded to the fax network and dropped — it never touches our database. We keep only a minimal send-metadata log (destination, pages, amount, payer).
  • Pluggable fax backend. Real faxing via the Sinch Fax API v3 when keys are set; otherwise a sandbox that simulates sending, so the whole pay→fax loop works with no fax account.

Endpoints

MethodPathPaidDescription
POST/v1/fax✅ MPPSend a fax. Returns 402 (MPP Payment challenge) until paid, then a job id.
GET/v1/fax/{id}freeLive delivery status (proxied from the carrier).
GET/v1/infofreeMachine-readable manifest (price, network, recipient, schema, example).
GET/openapi.jsonfreeMPP discovery document (for registries like MPPScan).
GET/llms.txtfreePointer file so an agent can self-onboard.
GET/og.pngfreeSocial card image.

Send a fax

to is required (E.164). Provide the document as either file_url (a public PDF URL) or content_base64 (+ optional file_name). metadata is optional and echoed back.

Unpaid, POST /v1/fax returns 402 with a WWW-Authenticate: Payment header. The Tempo CLI (or any MPP client) reads it, signs the USDC.e payment, and retries automatically.

Payments

  • Rail: MPP (the open Payment HTTP-auth scheme) on Tempo mainnet (chain id 4217).
  • Asset: USDC.e — 0x20C000000000000000000000b9537d11c60E8b50 (6 decimals).
  • Price: per page (FAX_PRICE_PER_PAGE, default $0.20).
  • Settlement: verified directly against the Tempo RPC by mppx — no facilitator.
  • You get paid at TEMPO_RECIPIENT (your Tempo wallet).
  • x402 (Coinbase / Circle) is parked in the codebase (payment.ts); re-enable it with a valid CDP facilitator key to also accept Base USDC agents.

What we store

The document itself is never stored. We keep a minimal SQLite metadata log (db.ts) — destination, page count, amount, paying wallet, status, timestamp — for a running total. No document content, ever.

Configuration

Sensible defaults; for production set your Sinch keys and Tempo recipient.

Env varDefaultPurpose
TEMPO_RECIPIENTa demo walletTempo address that receives the USDC.e.
MPP_SECRET_KEY(set)Server HMAC secret binding challenges to credentials.
MPP_SIGNER_KEY(set)Server signer mppx requires (session settlement; unused by one-shot charge).
FAX_PRICE_PER_PAGE0.20Price per page, in USD.
SINCH_KEY_ID / SINCH_KEY_SECRETunset → sandboxSinch Fax access key (OAuth2) for real faxing.
SINCH_PROJECT_IDunset → sandboxSinch project the Fax API is scoped to.
SINCH_FROMunsetOptional sender fax number.

Go live (real faxes)

  1. Fund your Tempo wallet with a little USDC.e (tempo wallet fund).

  2. Add your Sinch Fax credentials (from dashboard.sinch.com — Access Keys + Project ID):

    👉 Add SINCH_KEY_ID here: https://www.val.town/x/stevekrouse/agentfax/environment-variables?key=SINCH_KEY_ID

    👉 Add SINCH_KEY_SECRET here: https://www.val.town/x/stevekrouse/agentfax/environment-variables?key=SINCH_KEY_SECRET

    👉 Add SINCH_PROJECT_ID here: https://www.val.town/x/stevekrouse/agentfax/environment-variables?key=SINCH_PROJECT_ID

Files

  • main.ts — Hono server: routes, MPP payment gate, SSR landing page, metadata logging.
  • mpp.ts — Tempo/MPP rail via mppx (mainnet, USDC.e), per-page pricing, paymentInfo().
  • fax.ts — fax backend (Sinch Fax v3 + sandbox), job-id codec, live status.
  • db.ts — minimal metadata log (never the document content).
  • og.ts — Open Graph / Twitter card image.
  • payment.ts — parked x402 rail (re-enable with a CDP key).
  • frontend/ — SSR React + Twind landing page.

Built on Val Town. Faxes via Sinch. Payments via Tempo/MPP.