REST · CLI · MCP
Postbot API for developers
REST API, CLI, and MCP server for mailing physical letters in the Czech Republic — three interfaces, one core.
Get an API key
Self-serve, no sign-up form and no email to anyone. The CLI login opens your browser, you sign in and approve access, and the backend mints an API key bound to your account.
npm i -g @postbotcz/cli posta auth # the key is saved as apiKey in ~/.config/postbot/credentials.json
- Send it on every call as Authorization: Bearer pb_…
- Running posta auth again rotates the key. The old key stops working.
- Sending spends prepaid credit: fund the account with posta topup or POST /api/v1/topup.
- An agent with no human at the keyboard can register itself instead: see /auth.md.
Quickstart
Preview first, then send the same body. The hosted API has no Sandbox: /api/v1/preview is the free dry run, and every /api/v1/send mails a real letter. To run a whole send without mail, use the Sandbox below.
cat > letter.json <<'EOF'
{"to": {"name": "Jan Novák", "street": "Dlouhá", "houseNumber": "5", "zip": "110 00", "city": "Praha"},
"document": {"text": "Dear Mr. Novák, ..."},
"service": "obycejne"}
EOF
# 1. Preview: exact PDF + firm price. No charge, nothing mailed.
curl -X POST https://postbot.cz/api/v1/preview \
-H "content-type: application/json" -d @letter.json
# 2. Send: charged from prepaid credit, mailed by Česká pošta.
curl -X POST https://postbot.cz/api/v1/send \
-H "authorization: Bearer $POSTBOT_API_KEY" \
-H "content-type: application/json" -d @letter.json- service is obycejne (ordinary) or doporucene (registered, with a tracking number).
- document also accepts markdown or a PDF as pdfBase64.
Sandbox
The hosted API at postbot.cz has no Sandbox. Its free dry run is POST /api/v1/preview: it returns the exact PDF and the firm price, charges nothing, and mails nothing. To run a whole send without mail, self-host the @postbotcz/mcp server against the Česká pošta Sandbox.
claude mcp add postbot \ -e POSTBOT_TEST=1 -e POSTBOT_CP_USER=dreplech -e POSTBOT_CP_PASSWD=dreplech \ -- npx -y @postbotcz/mcp
- The Sandbox is Česká pošta's test endpoint, online.test.postservis.cz. POSTBOT_TEST=1 selects it.
- dreplech / dreplech are the Sandbox's public credentials. The Sandbox accepts real API calls and discards the data after transfer.
- A Sandbox send returns a Česká pošta order code, but nothing is printed or mailed.
- With POSTBOT_TEST=0 and your own DopisOnline account, real letters go out and Česká pošta bills you for them. Postbot charges nothing for them.
REST API
JSON endpoints under https://postbot.cz/api/v1. The request body for sending and previewing is the same as the MCP send_letter_cz tool's input.
POST /api/v1/send
Send a letter
Prints, envelopes, and mails a letter via Česká pošta. Charged against the account's prepaid CZK credit; the price is computed from the rendered PDF (postage band + print).
POST /api/v1/preview
Preview + firm price
Renders the exact PDF that would be printed and returns it with the firm price. No side effects — use before /api/v1/send or /api/v1/oneoff to show a human what will mail.
POST /api/v1/topup
Top up credit
Funds the account's prepaid CZK balance via Stripe. Returns a Stripe Checkout URL.
POST /api/v1/oneoff
Pay for one letter, no account
One-off card payment for a single letter. Prices the rendered PDF and returns a pay URL.
GET /api/v1/balance
Prepaid balance
The CZK balance /api/v1/send draws from. Needs an API key. The CLI equivalent is posta balance.
GET /api/v1/orders
List your letters
Your letters, newest first, one page at a time: limit (1–100, default 20) and cursor. The answer carries data, next_cursor and has_more. For the next page, send next_cursor back unchanged as cursor. It never returns the letter content. Needs an API key. On the hosted /mcp, the list_letters tool does the same (OAuth with the letters:read scope).
GET /api/v1/orders/{orderId}Letter status
Status, Česká pošta order code, and tracking number of one of your letters. Needs an API key. The CLI equivalent is posta status.
Authentication and payment (401 / 402)
- A missing or invalid API key on an invalid letter returns 401.
- A valid but unfunded letter (no key, or insufficient credit) returns 402 with a body carrying both funding rails: rails.oneoff.payUrl (a ready pay-link for that exact letter) and rails.credit.topupUrl (prepaid-credit top-up).
- /api/v1/preview never charges or sends anything — it only renders the PDF and computes the firm price.
Versioning
The API version is in the path. The versioned base URL is https://postbot.cz/api/v1. Unversioned /api/* paths serve the same v1 surface, so existing clients keep working.
POST https://postbot.cz/api/v1/send POST https://postbot.cz/api/send # same endpoint, same v1 contract
- A breaking change ships under a new path version, not in /api/v1.
- A version that is about to retire announces it first in its responses, with a Deprecation header (RFC 9745) and a Sunset header (RFC 8594). Both carry the dates.
- Watch for these headers in your client. Their dates are the notice.
Errors
Every error is JSON: a stable error code, a message that says what to fix, and the matching HTTP status. openapi.json types it as the Error schema.
{"error": "invalid_letter", "message": "to: Invalid input"}- 400 invalid_letter: fix the field that message (or issues[].field) names, then retry.
- 401 unauthorized: send Authorization: Bearer pb_…
- 402 payment_required or insufficient_credit: pay rails.oneoff.payUrl, or top up at rails.credit.topupUrl.
- 409 duplicate_send: this letter is already paid. Do not retry; check its status.
- 404 not_found: no endpoint answers that method and path. Check openapi.json.
- 429 rate_limited: wait the number of seconds in Retry-After, then retry.
Rate limits
The three public endpoints below are limited per client IP in a fixed one-minute window. The counters run per edge instance, best effort: treat them as a backstop, not as a quota to plan against.
RateLimit-Limit: <requests allowed in the window> RateLimit-Remaining: <requests left in the window> RateLimit-Reset: <seconds until the window resets> Retry-After: <seconds to wait> # on 429 only
- POST /api/v1/preview: 30 requests per minute.
- POST /api/v1/oneoff: 10 requests per minute.
- GET /api/v1/order-status: 60 requests per minute.
- Over the limit, the endpoint answers 429 rate_limited with a Retry-After header.
CLI
The @postbotcz/cli terminal client calls the same core as REST and MCP.
Install
npm i -g @postbotcz/cli # or: bun add -g @postbotcz/cli
Usage
posta send letter.md --to-name "Jan Novák" --to-street "Dlouhá" --to-house "5" --to-city "Praha" --to-zip "110 00" posta status 3f9a2b7c-1d4e-4a8b-9c2f-6e5d0a1b2c3d
MCP self-host
Hosted server (no install)
Add https://postbot.cz/mcp to your agent as a remote MCP server (Streamable HTTP) — nothing to install.
Self-host (stdio)
npx -y @postbotcz/mcp
For the full 3-step agent-connection recipe (install, first letter, credit), see For agents.
Agent discovery
Machine-readable entry points for agents that discover Postbot on their own.
Pricing
Current live minimums and the price formula live on the Pricing.