MailmanAPI

Developers

Let your agent send real mail.

One call makes a draft: the exact price, every page, and a link where your user approves and pays. Owners can turn on capped auto-send from balance. REST or MCP. Test mode is free.

Before you start

  • A draft costs nothing. Quotes, drafts, reads and cancels are free. A piece is charged only when approved.
  • A person approves by default. Share approval_url so they can review and pay. An account owner can enable a key to approve from prepaid balance up to a monthly cap.
  • Quotes show both prices. total_cents is the price from balance. card_total_cents includes payment_processing for Checkout. Once paid, payment.amount_cents is the amount collected.
  • Approval starts a 30-minute hold. Cancel before cancel_until for a full refund. After the hold the piece goes through screening before it can print.
  • Certified Mail needs a full return address. USPS returns undelivered Certified Mail to the sender, so from needs a street, city, state and ZIP.
  • Test keys never buy postage. In test mode every piece goes to a simulated print partner. Nothing is printed, mailed or charged.
Markdown

Quickstart.

No key needed for a draft. Send an Idempotency-Key, so a retry never makes a second piece.

Markdown
  1. POST the letter: to, from, the service, and text or a PDF.
  2. Show the person approval_url. They check the preview and price, and approve.
  3. GET the piece, or open mail_url, for its timeline, tracking and return receipt.
Create a draft
curl https://mailmanapi.com/v1/mail \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: demand-letter-okafor-0001" \
  -d '{
    "product": "letter",
    "service": "certified_err",
    "to":   { "name": "R. Okafor", "line1": "418 Alder Court",
              "line2": "Apt 2", "city": "Macon", "state": "GA", "zip": "31201" },
    "from": { "name": "Sam Rivera", "line1": "77 Pine St",
              "city": "Atlanta", "state": "GA", "zip": "30303" },
    "document": { "text": "Dear R. Okafor, ..." }
  }'

Endpoints.

Base URL https://mailmanapi.com. JSON in and out, PDFs for documents, money in integer US cents. Full schema: /openapi.json (OpenAPI 3.1). Owners add funds in Account.

Markdown
REST endpoints
CallAuthWhat it does
GET /v1/productsnoneWhat can be sent, with starting prices.
POST /v1/quotesoptionalItemized price: a letter by pages or PDF, a postcard by size.
POST /v1/mailoptionalCreate a draft: preview, price and approval link.
GET /v1/mail/{id}key or linkThe piece: timeline, any tracking, and the next step.
GET /v1/mailkeyYour key's mailpieces, newest first.
POST /v1/mail/{id}/cancelkey or linkCancels a draft, or cancels a paid piece during its hold for a full refund.
GET /v1/mail/{id}/previewkey or linkThe exact PDF that will be printed.
GET /v1/mail/{id}/receiptkey or linkThe electronic return receipt PDF, when ready.
POST /v1/addresses/verifyoptionalCheck a US address before you draft.
GET /v1/balancekeyRead the owner’s prepaid balance.
POST /v1/mail/{id}/approvekeyApprove from prepaid balance only with an enabled auto-send key. Pass approval_hash.
POST /v1/balance/top-upkeyReturn the account link where the owner can sign in and add funds.

MCP tools.

Streamable HTTP at https://mailmanapi.com/mcp. Use the private approval URL by default. Only an owner-enabled auto-send key can call approve_mail. The Claude directory endpoint at https://mailmanapi.com/mcp/claude has four tools for letter drafts and status.

Markdown
list_mail_types
What can be sent, the options, and starting prices.
quote_mail
An itemized price, without making a draft.
send_mail
Creates a draft with the preview, price and private approval link. It never charges or mails the draft.
get_mail
One piece's state, timeline, any tracking, and the next step.
list_mail
The pieces made with your key.
cancel_mail
Cancels a draft, or cancels a paid piece during its hold for a full refund.
verify_address
Checks a US address and returns the address it will use.
get_balance
Read the owner’s prepaid balance in US cents.
approve_mail
Spend from balance with the creating key when its owner enabled auto-send and set a cap. Pass id and approval_hash.

Errors say how to fix the call.

Every error has a code, a message, a fix your code or model can act on, and the field at fault when there is one.

Markdown

Approval is bound to what the person saw. The draft's approval_hash covers the document, both addresses, the service, the route and the total. Any change is a new draft.

Retries are safe. The same Idempotency-Key and body, with the same credentials, return the same piece. A different body with that key is refused.

422 address_undeliverable
{
  "error": {
    "code": "address_undeliverable",
    "message": "USPS doesn't recognize this address. The street was not found.",
    "fix": "Check the recipient's street and ZIP code, fix to, and try again.",
    "field": "to",
    "reason": { "code": "street_not_found", "fields": ["to.line1"] }
  }
}

Refusals, and what to tell the person.

Each code the API and MCP return, what it means, and what to tell the person. "Nothing" means fix the call; the person needn't hear about it.

Markdown
Error codes, what each means, and what to tell the person
CodeWhat happenedWhat to tell the person
invalid_request 422A field is missing or has the wrong value. field names it and fix says what to send.Nothing. Fix the call, or ask the person for the missing detail.
invalid_json 400The body is not valid JSON.Nothing. Fix the request and send it again.
idempotency_key_required 400A draft was sent without an idempotency key.Nothing. Add a key and send it again.
idempotency_key_invalid 400The key is not 16 to 255 letters, digits, underscores, periods, colons or hyphens.Nothing. Fix the key and send it again.
idempotency_mismatch 409The key was already used with a different body.Nothing. Resend the original body, or use a new key for a new draft.
address_undeliverable 422The recipient address could not be confirmed. reason says which part."I couldn't confirm that address. Can you check the street, unit and ZIP code?"
pdf_invalid 422The PDF can't be printed as sent: over 10 MB, password-protected, unreadable, or not portrait US Letter.Say which of those it is, and ask for a fixed PDF.
pages_out_of_range 422The letter has more pages than the service takes.Say how many pages it has and the limit, and ask whether to shorten or split it.
document_missing 422No document was sent.Nothing. Send exactly one of text, pdf_base64 or pdf_url.
document_ambiguous 422More than one document source was sent.Nothing. Send exactly one of text, pdf_base64 or pdf_url.
unsupported_combination 422An option was sent that this product doesn't take, such as pages on a postcard.Nothing. Remove the option and send it again.
approval_mismatch 409The approval hash differs from the draft's current one."The draft changed since you looked. Here is the current preview and price." Show them both again.
payment_unavailable 501Live approval needs payments, and payments are not open yet."Live mail isn't open yet, so nothing was mailed or charged."
too_late_to_cancel 409The piece was already submitted to the print partner."It already went to print, so it can't be canceled."
invalid_state 409The action doesn't fit the piece's state, such as approving a canceled draft.Read the piece and tell them where it stands, from its next_step.
auth_required 401The call needs the private link's token or the API key that made the piece.Nothing. Use the full mail_url with its t token, or the creating key.
invalid_api_key 401The Bearer key is not valid.Nothing. Remove the header to draft with an approval link, or use a valid key.
mail_not_found 404No piece with that ID is visible to this link or key.Ask them for the full private link.
provider_unavailable 502No print partner can take this piece right now."I can't send this kind of piece right now."
not_implemented 501That isn't available here, such as a top-up before payments open or a page image that can't be made.Nothing. Use the alternative in fix.
internal_error 500Something failed on our side.Retry once with the same idempotency key. If it fails again, say the mail service had an error, and give support the piece ID.

Named test recipients.

In test mode the recipient's name picks the outcome, in any case. In live mode they're ordinary names. Test controls, where enabled, win.

Markdown
Named test recipients and their outcomes
Recipient nameOutcome
Test DeliveredFrom submission: printed at 2 minutes, mailed at 5, in transit at 10, delivered at 20, return receipt at 25 (certified_err only). First-Class letters and postcards stop at mailed, like live mail. Any other name follows this clock.
Test ReturnedCertified: mailed after 5 minutes, then returned after 10.
Test Print FailureThe print partner rejects it at submit. The piece is failed, with the reason.
Test UndeliverableThe address check fails at draft, with address_undeliverable.
Test No ScansMailed after 5 minutes and never scans, so you can see the empty tracking state.

Mailpiece statuses.

Every state, from the same table behind next_step and the private pages. Cancel: the link or key can still cancel it.

Markdown
Mailpiece states, whether each can be canceled, and the next step
StateLabelCancelNext step for an assistant
draftDraftyesShow the person approval_url to review the preview and price and approve.
paidApprovedyesWait for the hold to end, or cancel before cancel_until.
screeningCheckingnoCheck the piece again shortly.
reviewIn reviewnoCheck again later for a decision.
submittedAt printnoCheck again for printing and mailing updates.
printedPrintednoCheck again for the USPS handoff.
mailedMailednoCheck again for USPS updates.
in_transitIn transitnoCheck again for delivery.
deliveredDeliverednoKeep the mail link for your records.
receipt_readyReceipt filednoDownload the electronic return receipt at receipt_url.
canceledCancelednoCreate a new draft with a new idempotency key if you still want to mail it.
failedFailednoReview the failure and create a corrected draft with a new idempotency key.
returnedReturnednoConfirm the full recipient address before creating a new draft.
refundedRefundednoReview the refund and create a new draft if you still want to mail it.

First-Class letters get no USPS scans after hand-off. Choose Certified Mail if you need proof. Postcards get no USPS scans after hand-off. USPS keeps Certified tracking for 2 years.

A sandbox run, start to finish.

A real test-mode run, captured 2026-11-27: the assistant drafts with send_mail, the person approves on the private page, the assistant reads the status, and a replay of the same idempotency key with a changed body is refused. Link tokens are shortened.

Markdown
send_mail → approval → get_mail → refused replay
// 1. Assistant: send_mail
{
  "product": "letter",
  "service": "certified_err",
  "idempotency_key": "transcript-38a230da5f00",
  "to": {
    "name": "R. Okafor",
    "line1": "418 Alder Court",
    "line2": "Apt 2",
    "city": "Macon",
    "state": "GA",
    "zip": "31201"
  },
  "from": {
    "name": "Sam Rivera",
    "line1": "77 Pine St",
    "city": "Atlanta",
    "state": "GA",
    "zip": "30303"
  },
  "document": {
    "text": "Dear R. Okafor, …"
  }
}
→ {
  "id": "mp_ht6os4qvuhlkkluiauxy",
  "state": "draft",
  "total_cents": 1031,
  "approval_url": "https://mailmanapi.com/l/mp_ht6os4qvuhlkkluiauxy/approve?t=…",
  "mail_url": "https://mailmanapi.com/l/mp_ht6os4qvuhlkkluiauxy?t=…",
  "next_step": "Show approval_url to the person so they can review the preview and price and approve the draft."
}

// 2. The person: Approve on approval_url
{
  "approval_hash": "ade6d3c563fd…"
}
→ {
  "http": 303
}

// 3. Assistant: get_mail
{
  "mail_url": "https://mailmanapi.com/l/mp_ht6os4qvuhlkkluiauxy?t=…"
}
→ {
  "id": "mp_ht6os4qvuhlkkluiauxy",
  "state": "paid",
  "cancel_until": "2026-11-27T20:08:36.415Z",
  "next_step": "Wait for the cancellation hold to end or cancel the piece before submission.",
  "approval": {
    "at": "2026-11-27T19:38:36.415Z",
    "via": "approval_page"
  }
}

// 4. Assistant: send_mail
{
  "idempotency_key": "transcript-38a230da5f00",
  "service": "first_class",
  "…": "the rest unchanged"
}
→ {
  "isError": true,
  "error": {
    "code": "idempotency_mismatch",
    "message": "This idempotency key was already used with a different request.",
    "fix": "Resend the original body unchanged, or use a new idempotency key for a new draft.",
    "field": "idempotency_key"
  }
}

Coming next.

  • WebhooksSigned events on every state change. Until then, poll GET /v1/mail/{id}.
  • SDKs and CLITypeScript and Python packages from the OpenAPI document. Until then, use REST or MCP.