MailmanAPI

Developers

Let your agent send real mail.

One API call makes a draft. You get the exact price, a preview of every page and a link your user can open to approve and pay. Account owners can also enable capped auto-send from balance. REST or MCP, same service. Test mode is free.

Things worth knowing first

  • A draft costs nothing. Quoting, drafting, reading and canceling are free. A piece is charged only once it is 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 how much each payment method costs. 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 is needed for a draft. The POST needs an Idempotency-Key, so a retry with the same body never makes a second piece.

Markdown
  1. POST the letter: who it goes to, who it is from, the service, and text or a PDF.
  2. Show the person approval_url. They see the exact preview and itemized price, and approve.
  3. Follow mail_url, or GET the piece, for its timeline, Certified Mail tracking and the 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, PDF for documents, money in integer US cents. The full schema is at /openapi.json (OpenAPI 3.1). A person can add funds in Account.

Markdown
REST endpoints
CallAuthWhat it does
GET /v1/productsnoneWhat can be sent, with starting prices.
POST /v1/quotesoptionalAn itemized price for a letter by page count or PDF, or a postcard by size.
POST /v1/mailoptionalCreate a draft: preview, price and approval link.
GET /v1/mail/{id}key or linkA mailpiece, its timeline, any Certified 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
State, timeline, any Certified tracking and the next step for one piece.
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 REST error has the same shape: a code, a message, a fix your code or your 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. Within the same credential scope, the same Idempotency-Key and body return the same piece. A different body with the same key is refused.

Test mode never mails. In test mode every piece goes to a simulated print partner, and its page says so.

422 address_undeliverable
{
  "error": {
    "code": "address_undeliverable",
    "message": "The recipient address could not be confirmed. The street was not found.",
    "fix": "Confirm the recipient's street and ZIP code, then correct 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 can return, what it means, and what an assistant should say. "Nothing" means the fix is in the call, not for the person.

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 yet. Fix the call, or ask the person for the one 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 in the current mode."I can't send this kind of piece right now."
not_implemented 501Balance top-ups arrive with payments.Nothing. There is no balance to top up yet.
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 to rehearse, matched without regard to case. In live mode these are ordinary names. Test controls, where enabled, take precedence.

Markdown
Named test recipients and their outcomes
Recipient nameOutcome
Test DeliveredThe test clock, from submission: printed after 2 minutes, mailed after 5, in transit after 10, delivered after 20, and the return receipt after 25 (Certified with return receipt only). First-Class letters and postcards stop at mailed, as live mail does. Any other name follows this clock too.
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 a piece can be in, from the same table the API's next_step and the private pages use. Cancel means the private 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 approval_url to the person so they can review the preview and price and approve the draft.
paidApprovedyesWait for the cancellation hold to end or cancel the piece before submission.
screeningCheckingnoCheck the mailpiece again after the next processing tick.
reviewIn reviewnoCheck the mailpiece again for a decision.
submittedAt printnoCheck the mailpiece again for printing and postal updates.
printedPrintednoCheck the mailpiece again for the USPS mailing update.
mailedMailednoCheck the mailpiece for updates as it travels through USPS.
in_transitIn transitnoCheck the mailpiece again for the delivery update.
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 generated from the OpenAPI document. Until then, use the REST or MCP examples above.