Send real postal mail from code: mail a PDF with one request, then track it to the mailbox with signed webhooks. Free simulated test mode, prepaid credits for live mail, and Stripe Projects provisioning.
Every PostalForm Projects workspace has isolated test and live environments. Test keys (pf_test_…) run the entire flow — uploads, quotes, orders, status timelines, and webhooks — against simulated fulfillment, free of charge. Live keys (pf_live_…) create real mail and spend prepaid credits only after the mailpiece is accepted for fulfillment.
Dashboard: https://projects.postalform.com
API: https://projects.postalform.com/api/v1
Authenticate every API call with a bearer key. Fulfillment routing is automatic: you choose the mailpiece options (speed, color, proof mail, destination) and PostalForm selects an eligible production path.
Authorization: Bearer pf_test_...
Authorization: Bearer pf_live_...
API key permissions are checked on every operation. Standard keys include direct sending. Live sends require mailings.submit_live and mailings.submit_without_approval; test sends require mailings.submit_test. Each OpenAPI operation lists its test/live requirements in x-workspace-permissions.
Denied actions return HTTP 403 with permission_denied or approval_required. Key rotation preserves existing restrictions and cannot exceed the calling key's permissions. The historical letters:write plus letters:read pair retains broad access for compatibility. Team settings support separate preparation, sending, approval and billing roles. Use /api/v1/drafts to prepare and release reviewed mail; /api/v1/approvals returns private expense summaries. Independent human decisions happen in the dashboard. Approval does not charge or send mail.
| Capability | Test mode | Live mode |
|---|---|---|
| Fulfillment | Simulated end to end | Real print-and-mail fulfillment |
| Cost | Free (simulated test credits) | Prepaid credits, captured on acceptance |
| Webhooks | Delivered and signed normally | Delivered and signed normally |
| Tracking | Simulated: run a test letter to Delivered on request | Carrier tracking numbers where available |
One command provisions a free workspace — no signup flow — and Stripe syncs the env vars into your secret store.
stripe projects add postalform/mail
Create a workspace at projects.postalform.com/signup, then copy your key from the API Keys page.
POSTALFORM_TEST_API_KEY=pf_test_...
POSTALFORM_WORKSPACE_ID=pfws_...
POSTALFORM_API_BASE=https://projects.postalform.com/api
One request stores the PDF, counts its pages, prices it and creates the order. This one mails the hosted sample letter with a test key, so it runs end to end without printing or charging anything:
curl "$POSTALFORM_API_BASE/v1/letters" \
-H "Authorization: Bearer $POSTALFORM_TEST_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"file_url": "https://projects.postalform.com/samples/letter.pdf",
"recipient": {
"name": "Ada Lovelace", "line1": "1 Analytical Way",
"city": "San Francisco", "state": "CA", "postal_code": "94105"
},
"sender": {
"name": "Grace Hopper", "line1": "2 Compiler Ct",
"city": "Arlington", "state": "VA", "postal_code": "22201"
}
}'
The response is the order, including id, status, mode, price_cents and the counted page_count. To mail your own PDF, upload it as a multipart file part, or put a public HTTPS link to it in file_url:
curl "$POSTALFORM_API_BASE/v1/letters" \
-H "Authorization: Bearer $POSTALFORM_TEST_API_KEY" \
-H "Idempotency-Key: invoice-1042" \
-F file=@letter.pdf \
-F 'recipient[name]=Ada Lovelace' -F 'recipient[line1]=1 Analytical Way' \
-F 'recipient[city]=San Francisco' -F 'recipient[state]=CA' \
-F 'recipient[postal_code]=94105' \
-F 'sender[name]=Grace Hopper' -F 'sender[line1]=2 Compiler Ct' \
-F 'sender[city]=Arlington' -F 'sender[state]=VA' -F 'sender[postal_code]=22201'
Multipart addresses can also be JSON parts, such as -F 'recipient={"name":"Ada Lovelace",...}'. Mail options such as mail_class, color, double_sided and certified go in the same request, and the countries come from the addresses. Retrying with the same Idempotency-Key returns the original order with idempotent_replay=true instead of mailing it twice. Track it with GET $POSTALFORM_API_BASE/v1/letters/{order_id}.
Test letters are never printed, so on their own they stop before delivery. Run one through accepted, in_transit and delivered, with the signed webhook a live letter sends at each step:
curl -X POST "$POSTALFORM_API_BASE/v1/letters/<order_id>/simulate-delivery" \
-H "Authorization: Bearer $POSTALFORM_TEST_API_KEY"
The response is the delivered letter with its timeline and webhook events. See Test your webhook handler.
To show the price before committing, or to upload from your user's browser, run the steps separately.
PUT the PDF bytes to the returned URL, and mark the document complete.Idempotency-Key header.# Stripe Projects writes these to .env; direct signups copy them from API Keys.
export POSTALFORM_TEST_API_KEY="pf_test_..."
export POSTALFORM_API_BASE="https://projects.postalform.com/api"
# 1. Upload a PDF
curl -s "$POSTALFORM_API_BASE/v1/documents/upload-intent" \
-H "Authorization: Bearer $POSTALFORM_TEST_API_KEY" \
-H "Content-Type: application/json" \
-d '{"content_type":"application/pdf","byte_size":123456,"page_count":1}'
# → returns document_id + upload_url
curl -s -X PUT "<upload_url>" \
-H "Content-Type: application/pdf" \
--data-binary @letter.pdf
curl -s -X POST "$POSTALFORM_API_BASE/v1/documents/<document_id>/complete" \
-H "Authorization: Bearer $POSTALFORM_TEST_API_KEY" \
-H "Content-Type: application/json" \
-d '{"page_count":1}'
# 2. Quote it
curl -s "$POSTALFORM_API_BASE/v1/letters/quotes" \
-H "Authorization: Bearer $POSTALFORM_TEST_API_KEY" \
-H "Content-Type: application/json" \
-d '{"document_id":"doc_..."}'
# → returns quote_id + price_cents
# 3. Send it
curl -s "$POSTALFORM_API_BASE/v1/letters" \
-H "Authorization: Bearer $POSTALFORM_TEST_API_KEY" \
-H "Idempotency-Key: first-letter-2026-07-01" \
-H "Content-Type: application/json" \
-d '{"quote_id":"quote_...","recipient":{"name":"Ada Lovelace","line1":"1 Analytical Way","city":"San Francisco","state":"CA","postal_code":"94105"},"sender":{"name":"Grace Hopper","line1":"2 Compiler Ct","city":"Arlington","state":"VA","postal_code":"22201"}}'
# 4. Watch it move
curl -s "$POSTALFORM_API_BASE/v1/letters/<order_id>" \
-H "Authorization: Bearer $POSTALFORM_TEST_API_KEY"
# 5. Test mode: run it to Delivered and fire the webhooks
curl -s -X POST "$POSTALFORM_API_BASE/v1/letters/<order_id>/simulate-delivery" \
-H "Authorization: Bearer $POSTALFORM_TEST_API_KEY"
Prefer zero code first? The dashboard Send page runs this whole flow from a file picker. Use a pf_live_... key only when you intend to send real mail.
POST /api/v1/documents/upload-intent
PUT {upload_url}
POST /api/v1/documents/{document_id}/complete
POST /api/v1/letters/quotes
POST /api/v1/letters { "quote_id": "quote_...", "recipient": { ... }, "sender": { ... } }
GET /api/v1/letters/{order_id}
POST /api/v1/letters/{order_id}/simulate-delivery
GET /api/v1/letters/{order_id}/document.pdf
GET /api/v1/letters/{order_id}/return-receipt.pdf
GET /api/v1/return-receipts/export.zip
Create an upload intent for a PDF, PUT the bytes to the returned upload URL, then mark the document complete. page_count is optional but recommended because it makes quotes deterministic before the file is inspected.
POST /api/v1/documents/upload-intent
{
"content_type": "application/pdf",
"byte_size": 123456,
"page_count": 4
}
POST /api/v1/documents/{document_id}/complete
{
"page_count": 4
}
Upload URLs expire after 15 minutes — finish the PUT and the complete call promptly. Completed documents cannot be overwritten. A validated document can back multiple quotes.
By default, upload URLs allow cross-origin browser PUTs from any origin with Content-Type: application/pdf. Your server creates the intent with its API key and returns the upload instructions to your browser; your server also makes the completion call. Keep your API key on your server.
Origin restrictions are optional. Admins can configure an upload-origin allowlist for a workspace; an empty list allows any origin. Your server can also include upload_origin, such as https://app.example.com, to restrict one upload. When both are configured, the browser origin must satisfy both restrictions. Workspace changes apply to existing and new upload URLs.
// Your server: POST /api/v1/documents/upload-intent
// Authorization: Bearer <server-side API key>
{
"content_type": "application/pdf",
"byte_size": 123456
}
// Your browser: file is a PDF File selected by the user.
const result = await fetch(uploadIntent.upload_url, {
method: "PUT",
headers: { "Content-Type": "application/pdf" },
credentials: "omit",
body: file
});
if (!result.ok) throw new Error("Upload failed");
// Notify your server to POST /documents/{document_id}/complete.
Configured origins must use HTTPS; HTTP localhost or loopback is supported for development. An origin contains only the scheme, hostname, and optional port. Choose per-upload restrictions on your server from trusted configuration. Origin restrictions control browser requests carrying an Origin header; server-to-server uploads continue to work with the upload URL. CORS grants no cookie access or API-key headers. Other API calls still run on your server.
Quotes calculate the customer price and lock in the mail options for a later order. PostalForm automatically selects an eligible fulfillment path; API clients choose the mailpiece options, not the underlying production network.
POST /api/v1/letters/quotes
{
"document_id": "doc_...",
"mail_class": "usps_first_class",
"color": false,
"double_sided": true,
"certified": false,
"certified_return_receipt": false,
"return_receipt_format": "electronic",
"restricted_delivery": false,
"err_delivery": "manual",
"signature_required": false,
"destination_country_code": "US",
"origin_country_code": "US"
}
mail_class accepts standard/usps_first_class, priority/usps_priority, and express/usps_express. Priority and Express cannot be combined with certified or registered proof mail.
color controls black-and-white versus color printing. double_sided controls duplex printing when supported. Billing includes an inserted address page for letter mail. Set standalone_address_page to keep that page on its own sheet for duplex letters, or omit it to use your workspace default in Settings. Single-sided letters are unchanged.
Pricing is separate from the one-off PostalForm.com workflow: standard letters start with a $1.80 base fee plus $0.20 per billable black-and-white page or $0.40 per billable color page. Large packets and high-cost routes can use a provider-cost floor. Proof-mail add-ons are $8.00 for U.S. Certified Mail, $32.00 for Canada Post Registered Mail, and $3.00 for Electronic Return Receipt where eligible. The quote is always the final price — estimate combinations on the pricing calculator.
Set certified=true for proof-mail services on eligible standard letters. U.S. destinations request USPS Certified Mail. Canadian destinations request Canada Post Registered Mail. Belgium, Switzerland, Spain, and France destinations request the available registered-mail option for that destination.
certified_return_receipt=true applies only to eligible U.S. Certified Mail. return_receipt_format defaults to electronic; use physical for the mailed PS Form 3811 green card. restricted_delivery=true requests addressee-only USPS Restricted Delivery. Provider-managed variants can raise the quote only when their verified fulfillment cost exceeds the existing retail baseline.
err_delivery defaults to manual. In manual mode, use the returned tracking_url to track the article and request the electronic receipt from USPS. Set err_delivery=email to have PostalForm acquire, store, and email the signed USPS PDF; optionally set err_email, otherwise the Projects account email is used. Email delivery is not available for physical PS Form 3811.
The electronic USPS PDF includes delivery details plus the signature image or USPS-approved hand-stamp. Acquired PDFs are retained for three years by default and expose err_retention_until. Download one from /api/v1/letters/{order_id}/return-receipt.pdf, or export up to 500 at a time with a CSV manifest from /api/v1/return-receipts/export.zip.
For Canada Post Registered Mail, the return-receipt flag is ignored because the registered service already includes the available delivery proof.
signature_required=true applies to eligible U.S. Priority and Express letters. Postcards do not support certified, registered, return-receipt, or signature-required options.
Letter quotes accept destination_country_code and origin_country_code; both default to US. Supported first-party destination countries are US, CA, AT, BE, CH, DE, ES, FR, GB, IN, LU, and NL.
Fast international mail is available only for destinations with a distinct fast-mail product. If a requested option is unavailable for the destination, the quote request returns a validation error instead of silently changing the requested service.
For international letters, include a sender address. Some destinations require a sender country that is compatible with the selected mailpiece options.
Pass a cover image, a short message and both mailing addresses to POST /api/v1/postcards/prepare. PostalForm composes and stores the print artwork internally, so you do not need to create or upload a PDF. The image goes on the front; the note goes on the back alongside the mailing details.
POST /api/v1/postcards/prepare
{
"front_image": "data:image/jpeg;base64,...",
"message": "Thinking of you this holiday season!",
"signature": "Love, Alex",
"recipient": {
"name": "Maya Example", "line1": "185 Berry St",
"city": "San Francisco", "state": "CA",
"postal_code": "94107", "countryCode": "US"
},
"sender": {
"name": "Alex Example", "line1": "111 Townsend St",
"city": "San Francisco", "state": "CA",
"postal_code": "94107", "countryCode": "US"
}
}
The response includes quote_id, price_cents, expires_at, the mailing address objects and preview_pdf_base64. Decode the preview and show both sides, mailing details and price for review. Postage and mailing barcode contents are illustrative and are assigned during processing. Preparation does not create an order or reserve credits.
After confirmation, use POST /api/v1/postcards with the returned quote and unchanged recipient and sender objects, plus a stable Idempotency-Key. A mailing-detail change requires preparing and reviewing a fresh postcard. The order includes an authenticated preview_url for viewing the layout again.
The helper currently supports US-to-US postcards. back_image is optional decoration behind the note; signature, front_text, and front_text_color are optional. The default size is 4x6; 6x9 and 11x6 are also supported. PNG/JPEG input limits and text-overflow checks below also apply to preparation.
Use back_logo for an independent PNG/JPEG logo, with back_logo_position set to top_left, top_center, top_right (default), or bottom_left. back_logo_width and back_logo_height define a box in inches (defaults 1 × 0.75); the logo keeps its aspect ratio without cropping. It stays clear of postage, address and barcode areas. Left-side positions reserve room above or below the note; a combination that does not fit returns 422. Logos have a 1-million-pixel limit.
Set front_text_position to top, center, or bottom. Choose front_text_font (serif, sans, mono), front_text_weight (normal, bold), and front_text_style (normal, italic). Serif/normal/italic preserves the existing font. Enable front_text_shadow or front_text_outline for busy photos; the outline color defaults to black and accepts front_text_outline_color.
Front text accepts up to 500 characters, wraps at words and explicit newlines, and breaks long unspaced words. front_text_font_size starts at 32pt by default (16–72pt). Wrapping comes first; the renderer reduces the size only if the block is too tall, stops at 16pt, then returns 422 if it still cannot fit. Nothing is truncated. Text and effects stay at least 0.25 inch inside the final trimmed edges, or 0.375 inch from the full bleed artwork edges, on every postcard size.
{
"back_logo": "data:image/png;base64,...",
"back_logo_position": "top_right",
"back_logo_width": 1.25,
"back_logo_height": 0.75,
"front_text": "A holiday greeting for the whole family",
"front_text_position": "bottom",
"front_text_font": "sans",
"front_text_style": "normal",
"front_text_weight": "bold",
"front_text_color": "#ffffff",
"front_text_shadow": true,
"front_text_outline": true
}
Call POST /api/v1/addresses/autocomplete with {"query":"185 Berry", "country_code":"US"}. Results have an id, text, description, and type. For a container, repeat the search with its container_id. For an address, call POST /api/v1/addresses/retrieve with {"id":"the-selected-id", "country_code":"US"} to receive mailing fields. Add the recipient name and ask the user to confirm them.
These optional calls require drafts.create and share limits of 60 requests per minute and 1,000 per day per workspace. Keep keys on your server and debounce searches. Test keys return a clearly marked simulated example without calling the address provider. Live keys look up suggestions. Capture does not guarantee delivery or verify occupancy, and never sends mail or reserves credits.
Render a printable preview with POST /api/v1/postcards/render. Supply a PNG/JPEG data URL in front_image and a message; optional fields are back_image, signature, postcard_size, front_text, and front_text_color. It returns a two-page PDF without creating an order or spending credit. The back image is masked behind the note panel and blank mailing area. Images are limited to 4 MiB and 4 million pixels each, with 30 renders per minute per workspace. Unsupported text and overflow return 422 rather than truncating the greeting.
curl https://projects.postalform.com/api/v1/postcards/render -H "Authorization: Bearer $POSTALFORM_TEST_API_KEY" -H "Content-Type: application/json" --data-binary @artwork.json --output postcard.pdf
// artwork.json
{
"postcard_size": "4x6",
"front_image": "data:image/jpeg;base64,...",
"back_image": "data:image/png;base64,...",
"message": "Thinking of you this holiday season!",
"signature": "Love, Alex"
}
Only front_image and message are required. The PDF is printable artwork: page 1 is the cover, and page 2 is the note with a blank mailing area. Supply addresses when creating the order; PostalForm applies the address block, postage and barcode during fulfillment. Keep those elements out of the uploaded artwork.
Postcards use /api/v1/postcards/quotes and /api/v1/postcards. The uploaded PDF must already be a composed two-page postcard artwork file: page 1 is the front and page 2 is the back.
POST /api/v1/postcards/quotes
{
"document_id": "doc_...",
"postcard_size": "4x6",
"destination_country_code": "US",
"origin_country_code": "US"
}
postcard_size accepts 4x6, 6x9, or 11x6. Postcards are quoted as first-class, color, double-sided mail and do not support proof-mail add-ons.
Send the PDF with the order, as file_url or a multipart file part, or create the order from a quote. Both need an Idempotency-Key header. Reusing the same key returns the original order with idempotent_replay=true, so network retries never create duplicate physical mail.
POST /api/v1/letters
Idempotency-Key: unique-order-key
{
"file_url": "https://files.example.com/letter.pdf",
"recipient": { "name": "...", "line1": "...", "city": "...", "state": "...", "postal_code": "...", "countryCode": "US" },
"sender": { "name": "...", "line1": "...", "city": "...", "state": "...", "postal_code": "...", "countryCode": "US" },
"mail_class": "usps_first_class",
"color": false,
"metadata": { "customer_id": "..." }
}
A letter sent with its PDF takes the same mail options as a letter quote. PostalForm counts the pages and prices the letter for the recipient's and sender's countries; the response adds document_id, quote_id and page_count. PDFs are limited to 25 MiB. A file_url must be a public HTTPS URL that downloads within 30 seconds, and a retry returns its order even after a signed link has expired. Multipart requests take recipient, sender and metadata as JSON parts or as bracketed fields such as recipient[name]. to and from are accepted as aliases. Sending a file also requires the drafts.create permission, which standard keys include.
To create the order from a quote instead:
POST /api/v1/letters
Idempotency-Key: unique-order-key
{
"quote_id": "quote_...",
"recipient": { "name": "...", "line1": "...", "city": "...", "state": "...", "postal_code": "...", "countryCode": "US" },
"sender": { "name": "...", "line1": "...", "city": "...", "state": "...", "postal_code": "...", "countryCode": "US" },
"metadata": { "customer_id": "..." }
}
recipient and sender are required. sender is the return address printed on the mailpiece and needs a name or company, line1, city and postal_code, plus state in the U.S. and Canada. Without one, the order is rejected with 400 sender_required, or 400 invalid_sender_address whose missing_fields lists what is missing. metadata is stored on the order and returned in reads and webhooks.
Add target_delivery_date to POST /api/v1/letters or POST /api/v1/postcards after approving the quote and preview. Use a YYYY-MM-DD date within 180 days. Arrival targeting currently supports U.S. destinations; letters and postcards use the selected service's conservative end-to-end estimate, including production, cutoffs and holidays. Delivery is estimated and may be earlier or later than the target.
{
"quote_id": "quote_...",
"recipient": { "name": "...", "line1": "...", "city": "...", "state": "CA", "postal_code": "94107", "countryCode": "US" },
"sender": { "name": "...", "line1": "...", "city": "...", "state": "CA", "postal_code": "94107", "countryCode": "US" },
"target_delivery_date": "2026-12-24"
}
The response includes target_delivery_date, scheduled_release_at, estimated_delivery_start and estimated_delivery_end. A future order stays scheduled, with credits reserved and artwork retained. When due, the periodic worker begins ordinary preparation and submission, normally within 15 minutes. If the release time is already due and the target is still feasible, fulfillment begins immediately.
Use POST /api/v1/letters/{order_id}/cancel or POST /api/v1/postcards/{order_id}/cancel while the order is still scheduled to return reserved credits. Once released, cancellation returns 409 order_not_cancelable. Repeated cancellation is safe. Keep the same target and mailing details on idempotent order retries, including after the original quote expires.
A date too close to meet returns 422 target_delivery_date_too_soon with earliest_delivery_date, the earliest conservative target. Other destinations return 422 target_delivery_destination_unsupported. Omitting the field preserves immediate sending. If the original API key is revoked, sending permissions are removed, or live sending is disabled before release, the order fails safely and its reserved credits are returned. Existing approval and content checks still apply.
Order reads return the customer-facing mailpiece state, pricing, funds state, metadata, timeline, customer webhook events, and any tracking number that has been received.
GET /api/v1/letters/{order_id}
{
"id": "ord_123",
"object": "letter",
"mailpiece_type": "letter",
"status": "in_transit",
"mode": "live",
"price_cents": 220,
"currency": "usd",
"funds_status": "captured",
"billing_rail": "prepaid_credits",
"tracking_number": "9405500000000000000001",
"tracking_url": "https://tools.usps.com/go/TrackConfirmAction?tLabels=9405500000000000000001",
"tracking_status": "in_transit",
"return_receipt_format": "electronic",
"restricted_delivery": false,
"err_delivery": "email",
"err_status": "pending",
"return_receipt_available": false,
"return_receipt_url": null,
"metadata": { "customer_id": "..." },
"timeline": [],
"webhook_events": []
}
Status values include scheduled, queued, document_preparing, document_prepared, submitted, accepted, in_transit, delivered_estimated, delivered, returned, submission_pending, failed, and canceled. delivered_estimated means delivery is estimated from provider completion without carrier confirmation; later carrier evidence can replace it. delivered means a delivery confirmation was reported. Scheduled orders emit postalform.letter.scheduled or postalform.postcard.scheduled, then queued when released, or canceled when canceled before release. Test orders reach delivered only when you simulate delivery.
submission_pending is a safety marker: the fulfillment job entered a window where PostalForm will not blindly retry, because a blind retry could create duplicate physical mail. If a later status follows it, it was transient. If it remains the current status, the order is being reconciled before anything else is mailed.
Use /api/v1/webhook-endpoints (or the dashboard) to register HTTPS endpoints. Customer webhook events are emitted for fulfillment status changes with postalform.{letter|postcard}.{status} event names: accepted, in_transit, delivered_estimated, delivered, returned, failed, and canceled.
Signing secrets are endpoint-scoped, start with whsec_, and are shown once when the endpoint is created or rotated — list calls never expose them. One endpoint can receive both test and live events.
PostalForm-Signature: t=1777592400,v1=<hmac_sha256_hex>
{
"id": "evt_123",
"type": "postalform.letter.in_transit",
"data": {
"object": {
"id": "ord_123",
"object": "letter",
"status": "in_transit",
"mode": "live",
"price_cents": 220,
"currency": "usd",
"funds_status": "captured",
"billing_rail": "prepaid_credits",
"metadata": {}
}
},
"mailpiece": {
"status": "in_transit",
"tracking_number": "9405500000000000000001",
"tracking_status": "In Transit"
}
}
The signed payload is {timestamp}.{raw_json_body}, HMAC-SHA256 with your endpoint secret — the same shape as Stripe-style webhooks. Verify before trusting any delivery:
import { createHmac, timingSafeEqual } from 'node:crypto'
export function verifyPostalFormWebhook(rawBody, header, secret) {
const parts = Object.fromEntries(header.split(',').map((part) => part.trim().split('=')))
const timestamp = Number(parts.t)
if (!Number.isFinite(timestamp) || Math.abs(Math.floor(Date.now() / 1000) - timestamp) > 300)
return false
const expected = createHmac('sha256', secret).update(timestamp + '.' + rawBody).digest('hex')
const received = parts.v1 ?? ''
return (
received.length === expected.length &&
timingSafeEqual(Buffer.from(received), Buffer.from(expected))
)
}
Respond with a 2xx quickly. Failed mailing event deliveries retry up to six times with increasing backoff (about 1 minute, 5 minutes, 30 minutes, 2 hours, 12 hours, then 24 hours). Replay events on demand with POST /api/v1/webhook-events/{event_id}/replay, and inspect delivery attempts from the dashboard.
On your workspace’s Webhooks page, click Send test beside an endpoint. This sends a postalform.webhook.test event to that endpoint using its current signing secret. Verify the signature as usual, then return 2xx for this test event. The payload has data.object.mode set to test and includes the data.object.endpoint_id. The dashboard shows the HTTP result. Tests create no mailing or charge and do not retry automatically after a failed delivery.
Test letters are never printed, so on their own they stop before delivery and your endpoint never sees in_transit or delivered. Simulate delivery to run a test letter through accepted, in_transit and delivered. Each step creates the same signed event a live letter would, and deliveries to your endpoints start right after the call.
POST /api/v1/letters/{order_id}/simulate-delivery
POST /api/v1/postcards/{order_id}/simulate-delivery
The response is the delivered order with its timeline and webhook_events; delivery attempts can appear a moment later. Steps the order already reached are skipped, and repeating the call creates no new events, so no Idempotency-Key is needed. It needs a test key with mailings.submit_test: live keys get 403 test_mode_only. Scheduled, failed, canceled and returned orders get 409 order_not_simulatable, and an order PostalForm is preparing at that moment gets 409 order_processing with Retry-After. Test order pages in the dashboard have the same Simulate delivery button.
Live mail spends prepaid credits: funds are reserved when an order is created and captured when fulfillment accepts the mailpiece. Top-ups are the only card charge that happens before mail is sent.
GET /api/v1/credits/balance
POST /api/v1/credits/checkout-session
GET /api/v1/credits/payment-methods
POST /api/v1/credits/payment-methods/setup-session
GET /api/v1/credits/auto-refill
POST /api/v1/credits/auto-refill
GET /api/v1/credits/ledger
POST /api/v1/credits/checkout-session.POST /api/v1/api-keys/rotate with {"mode":"live"}.Live keys stay disabled until the workspace is live-enabled through billing setup, so a leaked test integration can never mail anything real.
Errors return a machine-readable code, with a 4xx status for request problems and 5xx for PostalForm-side failures.
{ "error": "idempotency_key_required" }
| Code | Status | Meaning |
|---|---|---|
unauthorized | 401 | Missing or invalid bearer key. |
forbidden | 403 | The key cannot act on this resource (for example, live action on a test-only workspace). |
not_found | 404 | Unknown route or a resource that does not belong to this workspace. |
idempotency_key_required | 400 | Order creation without an Idempotency-Key header. |
invalid_pdf | 400 | The uploaded or downloaded file is not a readable PDF. |
upload_too_large | 413 | The PDF exceeds 25 MiB; the response includes max_bytes. |
file_url_unreachable | 422 | The file_url returned an error, redirected somewhere unusable, or did not download in time. |
test_mode_only | 403 | A live key called a test-only operation, such as simulating delivery. |
order_not_simulatable | 409 | The test order is scheduled, failed, canceled or returned, so its delivery cannot be simulated. |
order_processing | 409 | The test order is being prepared right now; retry after Retry-After seconds. |
rate_limited | 429 | Too many requests; the response includes retry_after_seconds. |
Each API key is limited to 120 requests per 60 seconds. Batch large jobs client-side and honor retry_after_seconds on 429 responses. Validation failures (an ineligible option combination, an expired quote, a malformed address) return a descriptive error code instead of silently changing the request.
The hosted OpenAPI YAML is the customer API source of truth for SDK generation. It documents request bodies, response properties, enums, authentication, and webhook payloads.
GET /openapi.json
GET /openapi.public.json
GET /openapi.yaml
GET /openapi.public.yaml
Generated TypeScript (@postalform/projects-sdk) and Python (postalform-projects-sdk) clients are built from this schema. Until they are published to npm and PyPI, generate your own client from /openapi.public.yaml with any OpenAPI generator, or call the API directly — every endpoint works with plain HTTP.
Building with agents? Use the Projects mailing MCP or read the agent quickstart.
Connect a Streamable HTTP MCP client to https://projects.postalform.com/mcp. Set its Authorization bearer token from your workspace’s API Keys page using the client’s secret settings. Use a test key first. The key selects the workspace, mode and permissions. Supported clients can discover the postalform-projects-mail skill after connecting.
get_workspace. Use a separate client connection for each workspace or mode.create_upload_intent, PUT the file bytes to its temporary URL, then complete_upload. Use quote_mailing and save_mailing_draft. For letter text, use render_letter_document instead of uploading. For templates and handwritten mail, prepare the draft directly.release_mailing with the reviewed mode, revision, exact price cap and SEND_REVIEWED_MAILING. Live release sends real mail and can trigger configured auto-refill. Read the returned order with get_order.The tools also support address lookup, postcard artwork, scheduled letter and postcard delivery, and brochure drafts and release where enabled. Use stable idempotency keys on retries. Tool schemas describe the fields and confirmation for each operation.
This table is generated from the public OpenAPI schema served by /openapi.json and /openapi.yaml.
| Method | Path | Purpose | Request | Primary response |
|---|---|---|---|---|
POST | /api/v1/addresses/autocomplete | Suggest mailing addresses while collecting an address. | AddressAutocompleteRequest | AddressSuggestions |
POST | /api/v1/addresses/retrieve | Retrieve mailing fields for an autocomplete address ID. | AddressRetrieveRequest | CapturedAddress |
POST | /api/v1/documents/upload-intent | Create a PDF upload intent. | object | UploadIntent |
POST | /api/v1/documents/{document_id}/complete | Mark an uploaded document complete after the object is present. | object | object |
POST | /api/v1/letters/quotes | Quote a mailpiece. | CreateQuoteRequest | Quote |
POST | /api/v1/letters | Send a PDF as a letter in one call, or create a letter from a quote. | CreateLetterRequest | Letter |
GET | /api/v1/letters/{order_id} | Retrieve a mail order, timeline, tracking fields, and customer webhook events. | None | Letter + object |
GET | /api/v1/letters/{order_id}/document.pdf | Preview or download the PDF for a letter order. | None | PDF bytes |
POST | /api/v1/letters/{order_id}/cancel | Cancel a scheduled letter before release and return reserved credits. | None | Letter |
POST | /api/v1/letters/{order_id}/simulate-delivery | Run a test letter to delivered and send its webhooks. | None | Letter + object |
GET | /api/v1/letters/{order_id}/return-receipt.pdf | Download a stored USPS electronic return receipt. | None | PDF bytes |
GET | /api/v1/return-receipts/export.zip | Export stored electronic return receipts in bulk. | None | ZIP archive containing manifest.csv and the available receipt PDFs. |
POST | /api/v1/postcards/prepare | Prepare a postcard from an image, note and mailing addresses. | PreparePostcardRequest | PreparedPostcard |
POST | /api/v1/postcards/{order_id}/cancel | Cancel a scheduled postcard before release and return reserved credits. | None | Letter |
POST | /api/v1/postcards/{order_id}/simulate-delivery | Run a test postcard to delivered and send its webhooks. | None | Letter + object |
POST | /api/v1/postcards/render | Render postcard artwork from images and a note without sending mail. | RenderPostcardArtworkRequest | PDF bytes |
POST | /api/v1/postcards/quotes | Quote a postcard mailpiece. | CreatePostcardQuoteRequest | Quote |
POST | /api/v1/postcards | Create a test or live postcard order from a postcard quote. | CreateLetterRequest | Letter |
GET | /api/v1/postcards/{order_id} | Retrieve a postcard order, timeline, tracking fields, and customer webhook events. | None | Letter + object |
GET | /api/v1/postcards/{order_id}/preview.pdf | View a postcard order with its mailing details in place. | None | PDF bytes |
GET | /api/v1/postcards/{order_id}/document.pdf | Preview or download the PDF for a postcard order. | None | PDF bytes |
GET | /api/v1/templates | List active mail templates. | None | MailTemplate[] |
POST | /api/v1/templates | Create a reusable mail template. | MailTemplateRequest | MailTemplate |
GET | /api/v1/templates/{template_id} | Retrieve a mail template. | None | MailTemplate |
DELETE | /api/v1/templates/{template_id} | Archive a mail template. | None | MailTemplate |
PATCH | /api/v1/templates/{template_id} | Update a mail template. | MailTemplateRequest | MailTemplate |
POST | /api/v1/templates/{template_id}/send | Send one mailpiece from a template. | SendTemplateRequest | MailSendOrder |
POST | /api/v1/handwritten | Send a handwritten card or letter. | CreateHandwrittenRequest | MailSendOrder |
GET | /api/v1/handwritten/{order_id} | Retrieve a handwritten order, its message, timeline, and customer webhook events. | None | MailSendOrder + object |
GET | /api/v1/handwritten/{order_id}/document.pdf | Download the proof PDF for a handwritten order. | None | PDF bytes |
GET | /api/v1/webhook-endpoints | List customer webhook endpoints for the workspace. | None | WebhookEndpoint[] |
POST | /api/v1/webhook-endpoints | Configure a customer webhook endpoint for status events. | object | WebhookEndpointSecretResponse |
DELETE | /api/v1/webhook-endpoints/{endpoint_id} | Disable a customer webhook endpoint. | None | WebhookEndpoint |
POST | /api/v1/webhook-endpoints/{endpoint_id}/rotate-secret | Rotate a customer webhook endpoint signing secret. | None | WebhookEndpointSecretResponse |
GET | /api/v1/webhook-events | List customer webhook events for the workspace. | None | WebhookEvent[] |
POST | /api/v1/webhook-events/{event_id}/replay | Queue a customer webhook event for replay. | None | Replay queued. |
GET | /api/v1/credits/balance | Get prepaid credit balance. | None | CreditBalance |
GET | /api/v1/credits/payment-methods | List saved live billing payment methods. | None | BillingPaymentMethod[] |
POST | /api/v1/credits/payment-methods/setup-session | Create a Checkout setup session for live credit auto-refill. | None | PaymentMethodSetupSession |
GET | /api/v1/credits/auto-refill | Get credit auto-refill threshold policies. | None | CreditAutoRefillPolicies |
POST | /api/v1/credits/auto-refill | Configure the credit auto-refill threshold for the authenticated key mode. | CreditAutoRefillRequest | object |
GET | /api/v1/credits/ledger | List prepaid credit ledger entries. | None | CreditLedgerEntry[] |
GET | /api/v1/api-keys | List API key prefixes and status. | None | ApiKey[] |
POST | /api/v1/api-keys/rotate | Rotate a test or live API key. | object | ApiKeyRotation |
POST | /api/v1/credits/checkout-session | Create a prepaid credit top-up checkout session. | object | CreditCheckoutSession |
GET | /api/v1/drafts | List mailing drafts within the credential mode. | None | object |
POST | /api/v1/drafts | Save a mailing draft without spending or sending. | SaveMailingDraftRequest | object |
GET | /api/v1/drafts/{draft_id} | Read a mailing draft and its immutable revisions. | None | object |
PATCH | /api/v1/drafts/{draft_id} | Save a new draft revision and invalidate approval. | SaveMailingDraftRequest + object | object |
POST | /api/v1/drafts/{draft_id}/request-approval | Request independent expenditure approval. | DraftRevisionRequest | object |
POST | /api/v1/drafts/{draft_id}/withdraw | Withdraw an unused approval request. | DraftRevisionRequest | object |
POST | /api/v1/drafts/{draft_id}/discard | Discard an unreleased draft without erasing its history. | DraftRevisionRequest | object |
POST | /api/v1/drafts/{draft_id}/refresh | Refresh pricing and create a new unapproved revision. | DraftRevisionRequest | object |
POST | /api/v1/drafts/{draft_id}/release | Release the approved revision once; retries return the same order. | DraftRevisionRequest | object |
GET | /api/v1/approvals | Read an expense-only summary without documents, addresses, metadata, or tracking. | None | object |
GET | /api/v1/approvals/{draft_id} | Read an expense-only summary without documents, addresses, metadata, or tracking. | None | object |
POST | /api/v1/templates/{template_id}/drafts | Prepare a rendered mailing draft without spending or sending. | SendTemplateRequest | object |
POST | /api/v1/handwritten/drafts | Prepare a rendered mailing draft without spending or sending. | CreateHandwrittenRequest | object |
GET | /api/v1/brochures/catalog | Get the square roll-fold brochure specification. | None | object map |
GET | /api/v1/brochures | List brochure drafts in this workspace and API-key mode. | None | BrochureDraft[] |
POST | /api/v1/brochures | Save an unpaid brochure draft without printing, charging or sending email. | BrochureDraftInput | BrochureDraft |
GET | /api/v1/brochures/{brochure_id} | Get a brochure draft and its remaining preparation steps. | None | BrochureDraft |
PATCH | /api/v1/brochures/{brochure_id} | Replace brochure draft fields and invalidate its prices and proof status. | BrochureDraftInput + object | BrochureDraft |
POST | /api/v1/brochures/{brochure_id}/quote | Quote printing, folding, tracked shipping and tax for every delivery. | object | BrochureDraft |
GET | /api/v1/brochures/{brochure_id}/readiness | Check missing addresses, quotes and artwork review. | None | object |
POST | /api/v1/brochures/{brochure_id}/orders | Reserve prepaid credit and queue an approved brochure for printing. | object | BrochureOrder |
GET | /api/v1/brochure-orders | List brochure orders in this workspace and mode. | None | BrochureOrder[] |
GET | /api/v1/brochure-orders/{order_id} | Read brochure delivery, funds and tracking status. | None | BrochureOrder |
POST | /api/v1/brochure-orders/{order_id}/cancel | Cancel a brochure order before any delivery begins printing. | None | BrochureOrder |
These request-body tables come from the same OpenAPI schema used for SDK generation.
Letter quote request. API clients choose mailpiece options; PostalForm handles fulfillment automatically.
| Property | Type / values | Required | Default | Meaning |
|---|---|---|---|---|
document_id | string | Yes | None | Uploaded PDF to quote. |
page_count | integer; min 1 | No | None | Optional explicit PDF page count. Used for deterministic pricing when present. |
mail_class | string | No | usps_first_class | Standard/USPS First Class by default. Accepts standard/usps_first_class, priority/usps_priority, and express/usps_express. Priority/Express cannot be combined with certified or registered proof mail. |
color | boolean | No | false | Whether the letter is printed in color instead of black and white. |
double_sided | boolean | No | true | Whether eligible pages are printed duplex. |
standalone_address_page | boolean | No | None | Keep the address page on its own sheet with a blank reverse for double-sided letters, preserving the document page pairing. Omit to inherit the workspace setting (off by default); explicit true or false overrides it. Single-sided letters are unchanged. The resolved choice is fixed on the quote, and added pages or sheets are included in pricing and provider limits. |
certified | boolean | No | false | Proof-mail add-on for letters only. Eligible U.S. standard letters request USPS Certified Mail. Eligible Canada standard letters request Canada Post Registered Mail. Eligible Belgium, Switzerland, Spain, and France standard letters request the available registered-mail option for that destination. |
certified_return_receipt | boolean | No | false | Return receipt for eligible U.S. Certified Mail letters. Defaults to the electronic format when true. |
return_receipt_format | electronic, physical | No | electronic | Electronic selects the USPS signed proof-of-delivery PDF. Physical selects the mailed PS Form 3811 green card. Requires certified_return_receipt=true. |
restricted_delivery | boolean | No | false | Requests USPS Restricted Delivery for addressee-only delivery. Requires certified_return_receipt=true and uses the provider-managed restricted-delivery service. |
err_delivery | manual, email | No | manual | Manual leaves receipt retrieval to the customer through the USPS tracking link. Email makes PostalForm acquire, retain, and email the electronic receipt when available. |
err_email | string (email); max length 256 | No | None | Optional destination when err_delivery=email. If omitted, PostalForm uses the Projects account email. Not valid for a physical PS Form 3811. |
signature_required | boolean | No | false | Signature confirmation for eligible U.S. Priority and Express letters. |
destination_country_code | string; min length 2, max length 2 | No | US | ISO 3166-1 alpha-2 destination country code used for quote validation and pricing. Defaults to US. First-party Projects destinations are US, CA, AT, BE, CH, DE, ES, FR, GB, IN, LU, and NL. |
origin_country_code | string; min length 2, max length 2 | No | US | ISO 3166-1 alpha-2 sender/origin country code used for quote validation and pricing. Defaults to US. |
| Property | Type / values | Required | Default | Meaning |
|---|---|---|---|---|
postcard_size | 4x6, 6x9, 11x6 | No | 4x6 | See the schema type and endpoint context. |
front_image | string; max length 5592460 | Yes | None | PNG/JPEG base64 data URL for the cover; at most 4 MiB decoded and 4 million pixels. |
back_image | string; max length 5592460 | No | None | Optional PNG/JPEG data URL for message-side decoration. The message panel and mailing area are covered with opaque white. |
back_logo | string; max length 5592460 | No | None | Independent PNG/JPEG base64 logo. At most 4 MiB and 1 million pixels. Aspect ratio is preserved inside the logo box, outside mailing areas. |
back_logo_position | top_left, top_center, top_right, bottom_left | No | top_right | Safe preset on the back. Requires back_logo. Overlapping message space is reserved automatically; unsupported sizes return 422. |
back_logo_width | number; min 0.25, max 2 | No | 1 | Logo bounding-box width in inches. Requires back_logo. |
back_logo_height | number; min 0.25, max 1 | No | 0.75 | Logo bounding-box height in inches. Requires back_logo. Image is contained without stretching or cropping. |
message | string; min length 1, max length 2000 | Yes | None | Latin text and common punctuation. The renderer rejects layout overflow even below this input limit. |
signature | string; max length 120 | No | None | See the schema type and endpoint context. |
front_text | string; max length 500 | No | None | Center-aligned text. Wraps at words or explicit newlines, breaks overlong words, then reduces font size down to 16pt only if needed. Unfittable text returns 422; nothing is truncated. |
front_text_color | string; pattern ^#[0-9a-fA-F]{6}$ | No | #392b22 | See the schema type and endpoint context. |
front_text_position | top, center, bottom | No | None | Vertical alignment within the safe area. Omit to retain the original upper placement. All text and effects stay at least 0.25 inch inside final trimmed edges (0.375 inch inside the bleed artwork). |
front_text_font | serif, sans, mono | No | serif | Times, Helvetica, or Courier family. Latin text and common punctuation only. |
front_text_weight | normal, bold | No | normal | See the schema type and endpoint context. |
front_text_style | normal, italic | No | italic | See the schema type and endpoint context. |
front_text_font_size | number; min 16, max 72 | No | 32 | Starting font size in points. Wrapping is attempted first; reduces toward 16pt only to fit the safe height. |
front_text_shadow | boolean | No | false | Subtle translucent black shadow for readability over photos. |
front_text_outline | boolean | No | false | Thin outline for readability over photos. |
front_text_outline_color | string; pattern ^#[0-9a-fA-F]{6}$ | No | #000000 | See the schema type and endpoint context. |
recipient | MailingAddress | Yes | None | See the schema type and endpoint context. |
sender | MailingAddress | Yes | None | See the schema type and endpoint context. |
| Property | Type / values | Required | Default | Meaning |
|---|---|---|---|---|
standalone_address_page | boolean | No | None | Resolved standalone address page setting saved on this quote. Always false for postcards. |
quote_id | string | No | None | See the schema type and endpoint context. |
mailpiece_type | letter, postcard | No | None | See the schema type and endpoint context. |
postcard_size | 4x6, 6x9, 11x6, null | No | None | See the schema type and endpoint context. |
price_cents | integer | No | None | See the schema type and endpoint context. |
currency | usd | No | None | See the schema type and endpoint context. |
pricing_version | string | No | None | See the schema type and endpoint context. |
certified_return_receipt | boolean | No | None | See the schema type and endpoint context. |
return_receipt_format | electronic, physical | No | None | See the schema type and endpoint context. |
restricted_delivery | boolean | No | None | See the schema type and endpoint context. |
err_delivery | manual, email | No | None | See the schema type and endpoint context. |
err_email | string (email) | null | No | None | See the schema type and endpoint context. |
signature_required | boolean | No | None | See the schema type and endpoint context. |
expires_at | string (date-time) | No | None | See the schema type and endpoint context. |
document_id | string | Yes | None | Print artwork stored internally by PostalForm. |
recipient | MailingAddress | Yes | None | See the schema type and endpoint context. |
sender | MailingAddress | Yes | None | See the schema type and endpoint context. |
preview_kind | layout | Yes | None | See the schema type and endpoint context. |
preview_pdf_base64 | string (byte) | Yes | None | Base64-encoded two-page PDF showing the cover and note with mailing details. Postage and barcode are illustrative; display this for review and confirm using quote_id. |
| Property | Type / values | Required | Default | Meaning |
|---|---|---|---|---|
postcard_size | 4x6, 6x9, 11x6 | No | 4x6 | See the schema type and endpoint context. |
front_image | string; max length 5592460 | Yes | None | PNG/JPEG base64 data URL for the cover; at most 4 MiB decoded and 4 million pixels. |
back_image | string; max length 5592460 | No | None | Optional PNG/JPEG data URL for message-side decoration. The message panel and mailing area are covered with opaque white. |
back_logo | string; max length 5592460 | No | None | Independent PNG/JPEG base64 logo. At most 4 MiB and 1 million pixels. Aspect ratio is preserved inside the logo box, outside mailing areas. |
back_logo_position | top_left, top_center, top_right, bottom_left | No | top_right | Safe preset on the back. Requires back_logo. Overlapping message space is reserved automatically; unsupported sizes return 422. |
back_logo_width | number; min 0.25, max 2 | No | 1 | Logo bounding-box width in inches. Requires back_logo. |
back_logo_height | number; min 0.25, max 1 | No | 0.75 | Logo bounding-box height in inches. Requires back_logo. Image is contained without stretching or cropping. |
message | string; min length 1, max length 2000 | Yes | None | Latin text and common punctuation. The renderer rejects layout overflow even below this input limit. |
signature | string; max length 120 | No | None | See the schema type and endpoint context. |
front_text | string; max length 500 | No | None | Center-aligned text. Wraps at words or explicit newlines, breaks overlong words, then reduces font size down to 16pt only if needed. Unfittable text returns 422; nothing is truncated. |
front_text_color | string; pattern ^#[0-9a-fA-F]{6}$ | No | #392b22 | See the schema type and endpoint context. |
front_text_position | top, center, bottom | No | None | Vertical alignment within the safe area. Omit to retain the original upper placement. All text and effects stay at least 0.25 inch inside final trimmed edges (0.375 inch inside the bleed artwork). |
front_text_font | serif, sans, mono | No | serif | Times, Helvetica, or Courier family. Latin text and common punctuation only. |
front_text_weight | normal, bold | No | normal | See the schema type and endpoint context. |
front_text_style | normal, italic | No | italic | See the schema type and endpoint context. |
front_text_font_size | number; min 16, max 72 | No | 32 | Starting font size in points. Wrapping is attempted first; reduces toward 16pt only to fit the safe height. |
front_text_shadow | boolean | No | false | Subtle translucent black shadow for readability over photos. |
front_text_outline | boolean | No | false | Thin outline for readability over photos. |
front_text_outline_color | string; pattern ^#[0-9a-fA-F]{6}$ | No | #000000 | See the schema type and endpoint context. |
Postcard quote request. Postcards force first-class color double-sided mail and cannot use certified or registered mail.
| Property | Type / values | Required | Default | Meaning |
|---|---|---|---|---|
document_id | string | Yes | None | See the schema type and endpoint context. |
page_count | integer; min 1 | No | None | Optional explicit PDF page count. Postcard source PDFs should be fully composed. |
postcard_size | 4x6, 6x9, 11x6 | Yes | None | See the schema type and endpoint context. |
destination_country_code | string; min length 2, max length 2 | No | US | ISO 3166-1 alpha-2 destination country code used for quote validation and pricing. Defaults to US. |
origin_country_code | string; min length 2, max length 2 | No | US | ISO 3166-1 alpha-2 sender/origin country code used for quote validation and pricing. Defaults to US. |
Send the PDF at file_url with its mail options, or create the order from quote_id. Requires Idempotency-Key header. sender is the return address printed on the mailpiece and needs a name or company, line1, city and postal_code, plus state in the U.S. and Canada; without one the order is rejected with 400 sender_required or invalid_sender_address.
| Property | Type / values | Required | Default | Meaning |
|---|---|---|---|---|
file_url | string (uri) | No | None | Public HTTPS URL of the PDF to mail, instead of quote_id. PostalForm downloads it once, counts its pages and quotes it with the mail options in this request. |
quote_id | string | No | None | Quote from POST /api/v1/letters/quotes, instead of file_url. The quote fixes the mail options. |
target_delivery_date | string (date) | No | None | Optional YYYY-MM-DD arrival target for U.S. letters and postcards, at most 180 days ahead. PostalForm works backward from the conservative end-to-end estimate, including production, mailing speed, cutoffs and holidays. Arrival is estimated and may be early or late. A too-soon date returns 422 with earliest_delivery_date; unsupported destinations also return 422. The order reserves credits immediately and remains scheduled until scheduled_release_at. Cancel before release to return reserved credits. Omit to start normal fulfillment immediately. Use the same date on idempotent retries. |
recipient | MailingAddress | Yes | None | Destination mailing address. |
sender | MailingAddress | Yes | None | Required return address printed on the mailpiece: name or company, line1, city, state and postal_code. |
metadata | object map | No | None | Optional caller metadata stored on the order and surfaced in reads/webhook payloads. |
mail_class | string | No | usps_first_class | Standard/USPS First Class by default. Accepts standard/usps_first_class, priority/usps_priority, and express/usps_express. Priority/Express cannot be combined with certified or registered proof mail. |
color | boolean | No | false | See the schema type and endpoint context. |
double_sided | boolean | No | true | See the schema type and endpoint context. |
standalone_address_page | boolean | No | None | Keep the address page on its own sheet for double-sided letters. Omit to inherit the workspace setting. |
certified | boolean | No | false | Proof-mail add-on, as in POST /api/v1/letters/quotes. U.S. letters request USPS Certified Mail. |
certified_return_receipt | boolean | No | false | Return receipt for eligible U.S. Certified Mail letters. |
return_receipt_format | electronic, physical | No | electronic | Requires certified_return_receipt=true. |
restricted_delivery | boolean | No | false | USPS Restricted Delivery. Requires certified_return_receipt=true. |
err_delivery | manual, email | No | manual | Email makes PostalForm acquire, retain, and email the electronic receipt when available. |
err_email | string (email); max length 256 | No | None | Optional destination when err_delivery=email. Defaults to the Projects account email. |
signature_required | boolean | No | false | Signature confirmation for eligible U.S. Priority and Express letters. |
page_count | integer; min 1 | No | None | Optional expected page count. The request is rejected if the PDF has a different number of pages. |
destination_country_code | string; min length 2, max length 2 | No | None | Optional. Must match the recipient's country, which sets the destination. |
origin_country_code | string; min length 2, max length 2 | No | None | Optional. Must match the sender's country, which sets the origin. |
Flexible mailing address object. Pass countryCode, country_code, country, address_country, or addressCountry for international destinations; country defaults to US when omitted.
| Property | Type / values | Required | Default | Meaning |
|---|---|---|---|---|
name | string; min length 1, max length 255 | No | None | Name is preserved. The selected mailing route may require a lower limit of 40 or 45 characters. Validation errors identify the applicable limit. Overlong names are rejected before credits are reserved and are never silently shortened. |
company | string | No | None | Optional organization name. |
line1 | string | No | None | Also accepts street1, address_line1, or addressLine1. |
line2 | string | No | None | Also accepts street2, address_line2, or addressLine2. |
city | string | No | None | Also accepts address_city or addressCity. |
state | string | No | None | Also accepts province, provinceOrState, address_state, or addressState. |
postal_code | string | No | None | Also accepts postalCode, postalOrZip, zip, address_zip, or addressZip. |
countryCode | string; min length 2, max length 2 | No | US | ISO 3166-1 alpha-2 country code. Defaults to US when omitted. |
These response tables explain the IDs, prices, state fields, timeline entries, and tracking fields returned by order and credit reads.
| Property | Type / values | Required | Default | Meaning |
|---|---|---|---|---|
document_id | string | No | None | Stable document identifier used in quote requests. |
upload_url | string (uri) | No | None | Temporary URL that accepts the PDF bytes. |
upload_method | PUT | No | None | HTTP method to use when uploading to the temporary URL. |
expires_at | string (date-time) | No | None | When the temporary upload URL stops accepting uploads. |
| Property | Type / values | Required | Default | Meaning |
|---|---|---|---|---|
standalone_address_page | boolean | No | None | Resolved standalone address page setting saved on this quote. Always false for postcards. |
quote_id | string | No | None | Short-lived quote token used to create the order. |
mailpiece_type | letter, postcard | No | None | Whether the quote is for a letter or postcard. |
postcard_size | 4x6, 6x9, 11x6, null | No | None | Postcard size for postcard quotes; null for letters. |
price_cents | integer | No | None | Customer price in cents for the quoted mailpiece. |
currency | usd | No | None | Quote currency. |
pricing_version | string | No | None | Pricing table version used for this quote. |
certified_return_receipt | boolean | No | None | Whether a return receipt was accepted for the quote. |
return_receipt_format | electronic, physical | No | None | Electronic PDF or mailed physical PS Form 3811. |
restricted_delivery | boolean | No | None | Whether USPS Restricted Delivery was accepted for the quote. |
err_delivery | manual, email | No | None | Receipt delivery workflow selected for the order. |
err_email | string (email) | null | No | None | Resolved automatic-delivery email, when applicable. |
signature_required | boolean | No | None | Whether signature confirmation was accepted for the quote. |
expires_at | string (date-time) | No | None | When the quote can no longer be used to create an order. |
| Property | Type / values | Required | Default | Meaning |
|---|---|---|---|---|
target_delivery_date | string (date) | null | No | None | See the schema type and endpoint context. |
scheduled_release_at | string (date-time) | null | No | None | Planned start of fulfillment. A scheduled order is released by the periodic worker, normally within 15 minutes. This is not a guaranteed delivery time. |
estimated_delivery_start | string (date) | null | No | None | See the schema type and endpoint context. |
estimated_delivery_end | string (date) | null | No | None | See the schema type and endpoint context. |
preview_url | string | No | None | Authenticated PDF layout preview for a postcard order, including mailing details. Available for US-to-US postcards. |
id | string | No | None | PostalForm order ID. |
object | letter, postcard, handwritten | No | None | Object type returned by the API. |
mailpiece_type | letter, postcard, handwritten | No | None | Mailpiece family for the order. |
postcard_size | 4x6, 6x9, 11x6, null | No | None | Postcard size for postcard orders; null for letters. |
status | MailOrderStatus | No | None | Customer-facing order state. |
mode | Mode | No | None | Whether the order was created with a test or live key. |
price_cents | integer | No | None | Final customer price reserved or captured for the order. |
currency | string | No | None | Order currency. |
funds_status | string | No | None | Billing state for the order funds. |
billing_rail | string | No | None | Billing source used for the order. |
tracking_number | string | null | No | None | Carrier tracking number when available. |
tracking_url | string (uri) | null | No | None | Direct USPS tracking URL when a tracking number is available. Manual ERR customers can use it to request their receipt from USPS. |
tracking_status | string | null | No | None | Normalized tracking status when available. |
return_receipt_format | electronic, physical | No | None | Electronic PDF or mailed physical PS Form 3811. |
restricted_delivery | boolean | No | None | Whether USPS Restricted Delivery was requested. |
err_delivery | manual, email | No | None | Manual USPS retrieval or automatic PostalForm email delivery. |
err_email | string (email) | null | No | None | Resolved automatic-delivery email, when applicable. |
err_status | manual, pending, sent, failed, expired | No | None | Current return-receipt acquisition or delivery state. |
err_delivered_at | string (date-time) | null | No | None | When PostalForm successfully emailed the receipt. |
err_retention_until | string (date-time) | null | No | None | Last instant at which an acquired receipt remains retrievable. PostalForm's default ERR retention is three years. |
return_receipt_available | boolean | No | None | Whether a stored electronic receipt can currently be downloaded. |
return_receipt_url | string | null | No | None | Relative authenticated download URL when return_receipt_available is true. |
metadata | object map | No | None | Caller-defined metadata copied from the create-order request. |
created_at | string (date-time) | No | None | Order creation timestamp. |
updated_at | string (date-time) | No | None | Most recent order update timestamp. |
idempotent_replay | boolean | No | None | True when the response came from a repeated idempotency key. |
document_id | string | No | None | Stored PDF, returned when the PDF was sent with the order. |
quote_id | string | No | None | Quote PostalForm created for the PDF, returned when the PDF was sent with the order. |
page_count | integer | null | No | None | Pages counted in the PDF, returned when the PDF was sent with the order. |
Customer-facing order timeline event. Internal fulfillment identifiers are not exposed.
| Property | Type / values | Required | Default | Meaning |
|---|---|---|---|---|
id | string | No | None | Timeline event ID. |
event_type | string | No | None | Customer-facing event type. |
status_before | string | No | None | Order status before the event, when known. |
status_after | string | No | None | Order status after the event, when known. |
source | string | No | None | Public source category for the status update. |
created_at | string (date-time) | No | None | Timeline event timestamp. |
| Property | Type / values | Required | Default | Meaning |
|---|---|---|---|---|
mode | test, live | No | None | Key mode for the returned balance. |
billing_rail | mock_test_credits, prepaid_credits, future_projects_spt, future_metronome_streaming, future_mpp_tempo, manual_invoice | No | None | Billing source currently backing credits. |
available_cents | integer | No | None | Credit cents available for new live orders. |
reserved_cents | integer | No | None | Credit cents reserved for created orders that are not fully settled. |
currency | string | No | None | Balance currency. |
status | string | No | None | Credit account status. |
test | CreditBalanceSnapshot | No | None | Test-mode balance snapshot. |
live | CreditBalanceSnapshot | No | None | Live-mode balance snapshot. |
auto_refill | CreditAutoRefillPolicies | No | None | Configured auto-refill policies. |
Webhook payloads use customer-facing order states. Store webhook signing secrets when they are created or rotated because they are returned once.
| Property | Type / values | Required | Default | Meaning |
|---|---|---|---|---|
id | string | No | None | Webhook endpoint ID. |
url | string (uri); pattern ^https:// | No | None | HTTPS URL that receives signed status webhooks. |
status | string | No | None | Endpoint lifecycle status. |
created_at | string (date-time) | No | None | Endpoint creation timestamp. |
| Property | Type / values | Required | Default | Meaning |
|---|---|---|---|---|
id | string | No | None | See the schema type and endpoint context. |
url | string (uri); pattern ^https:// | No | None | See the schema type and endpoint context. |
status | string | No | None | See the schema type and endpoint context. |
created_at | string (date-time) | No | None | See the schema type and endpoint context. |
signing_secret | string | No | None | Returned only when the endpoint is created or its signing secret is rotated. |
JSON body POSTed to customer webhook endpoints.
| Property | Type / values | Required | Default | Meaning |
|---|---|---|---|---|
id | string | No | None | Webhook event ID. |
type | CustomerWebhookEventType | No | None | PostalForm event name. |
data | object | No | None | Webhook data wrapper. data.object is the current order object. |
mailpiece | object | No | None | Tracking and delivery-state snapshot for the physical mailpiece. |
| Property | Type / values | Required | Default | Meaning |
|---|---|---|---|---|
mode | Mode | No | None | Optional key mode override. Defaults to the authenticated key mode. |
enabled | boolean | No | true | Whether automatic refill is enabled. |
threshold_cents | integer; min 100, max 100000 | Yes | None | Trigger a refill when available credits fall below this amount. |
refill_amount_cents | integer; min 100, max 100000 | Yes | None | Credit amount to purchase when the threshold is crossed. |
| Property | Type / values | Required | Default | Meaning |
|---|---|---|---|---|
mode | Mode | No | None | Key mode that was rotated. |
api_key | string | No | None | Full API key secret. Returned once. |
api_key_prefix | string | No | None | Non-secret key prefix shown later in dashboards and list responses. |
Order timeline status. `delivered_estimated` means delivery is estimated from provider completion without carrier delivery confirmation; later carrier evidence can replace it. `delivered` means a delivery confirmation was reported. `submission_pending` means the fulfillment submit job entered a physical-mail safety window where PostalForm cannot blindly retry without risking duplicate mail; it requires reconciliation if it remains the current order status.
| Value | Meaning |
|---|---|
scheduled | Customer-facing order state. |
queued | Order accepted and waiting for document preparation. |
document_preparing | PostalForm is preparing the print-ready PDF. |
document_prepared | The print-ready PDF is ready for submission. |
submitted | The mailpiece has been submitted for production. |
accepted | The mailpiece was accepted for production or mailing. |
in_transit | The mailpiece is moving through the mail stream. |
delivered_estimated | Customer-facing order state. |
delivered | Delivery was reported. |
returned | The mailpiece was returned. |
submission_pending | Submission entered a safety window and needs reconciliation before blind retry. |
failed | The order failed and needs review or retry. |
canceled | The order was canceled. |
Customer webhook event names emitted for fulfillment status changes. Replace `letter` with `postcard` for postcard mailpieces or `handwritten` for handwritten cards and letters.
| Value | Meaning |
|---|---|
postalform.letter.scheduled | Letter scheduled for future release. Credits are reserved and artwork is retained until fulfillment begins or the order is canceled. |
postalform.letter.queued | Scheduled letter released into ordinary preparation and fulfillment. |
postalform.postcard.scheduled | Postcard scheduled for future release. Credits are reserved and artwork is retained until fulfillment begins or the order is canceled. |
postalform.postcard.queued | Scheduled postcard released into ordinary preparation and fulfillment. |
postalform.letter.accepted | Letter accepted for production or mailing after the order leaves PostalForm's preparation queue. |
postalform.letter.in_transit | Letter entered the mail stream. The payload may include or update `mailpiece.tracking_number` when tracking is available. |
postalform.letter.delivered_estimated | Delivery is estimated from provider completion without carrier confirmation. Carrier polling continues; this is not proof of receipt. |
postalform.letter.delivered | Letter reported delivered by the carrier or delivery network. |
postalform.letter.returned | Letter returned or otherwise marked undeliverable. |
postalform.letter.failed | Letter could not be produced or mailed. Inspect the order timeline and retry with a corrected request when appropriate. |
postalform.letter.canceled | Letter canceled before delivery completion. |
postalform.postcard.accepted | Postcard accepted for production or mailing after the order leaves PostalForm's preparation queue. |
postalform.postcard.in_transit | Postcard entered the mail stream. The payload may include or update `mailpiece.tracking_number` when tracking is available. |
postalform.postcard.delivered_estimated | Delivery is estimated from provider completion without carrier confirmation. Carrier polling continues; this is not proof of receipt. |
postalform.postcard.delivered | Postcard reported delivered by the carrier or delivery network. |
postalform.postcard.returned | Postcard returned or otherwise marked undeliverable. |
postalform.postcard.failed | Postcard could not be produced or mailed. Inspect the order timeline and retry with a corrected request when appropriate. |
postalform.postcard.canceled | Postcard canceled before delivery completion. |
postalform.handwritten.accepted | Handwritten card or letter accepted for writing. |
postalform.handwritten.in_transit | Handwritten card or letter was sealed, stamped, and handed to the carrier. Handwritten mail has no carrier tracking, so this is usually the last status. |
postalform.handwritten.delivered | Handwritten card or letter reported delivered. |
postalform.handwritten.failed | Handwritten card or letter could not be written or mailed, for example because of an invalid address. |
postalform.handwritten.canceled | Handwritten card or letter canceled before it was mailed. |
| Value | Meaning |
|---|---|
test | Test mode. |
live | Real mail and live billing. |