# PostalForm Projects: agent quickstart PostalForm Projects sends real postal mail from code. Upload a PDF, quote it, create the order, and track it to the mailbox with signed webhooks. Test mode is free and simulated; live mode prints and mails real letters and postcards. ## Environment After `stripe projects add postalform/mail` (or `stripe projects env pull`), the project env contains: - POSTALFORM_TEST_API_KEY: pf_test_ key. Free, simulated fulfillment, fake credits. It never mails anything. - POSTALFORM_LIVE_API_KEY: pf_live_ key. Present only after live billing is enabled (see Going live). It creates real mail. - POSTALFORM_API_BASE: https://projects.postalform.com/api. Every path below starts with /v1, for example $POSTALFORM_API_BASE/v1/letters. - POSTALFORM_WORKSPACE_ID and POSTALFORM_DASHBOARD_URL. - POSTALFORM_WEBHOOK_ENDPOINT_ID and POSTALFORM_WEBHOOK_SECRET, only when the service configuration included webhook_url. Direct signups at https://projects.postalform.com/signup copy the same values from the dashboard API Keys page. ## Send a test letter Send `Authorization: Bearer $POSTALFORM_TEST_API_KEY` on every request. POST $POSTALFORM_API_BASE/v1/letters with an Idempotency-Key header and the PDF in the same request. PostalForm stores the PDF, counts its pages, quotes it and creates the order. This command mails the hosted sample letter: 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"}}' For your own PDF, set file_url to a public HTTPS link, or send multipart/form-data with -F file=@letter.pdf -F 'recipient={...}' -F 'sender={...}'. Every letter and postcard needs sender, the return address printed on it, with name or company, line1, city, state and postal_code. PDFs are limited to 25 MiB. Mail options such as mail_class, color, double_sided and certified go in the same request, and the countries come from the addresses. The response includes the order id, price_cents, page_count and "mode":"test". Retrying with the same Idempotency-Key returns that order instead of mailing twice. Track it with GET $POSTALFORM_API_BASE/v1/letters/{order_id}. To quote first, for example to confirm price_cents with the user before a live order, run the steps separately: 1. POST $POSTALFORM_API_BASE/v1/documents/upload-intent with {"content_type":"application/pdf","byte_size":,"page_count":}. It returns document_id and upload_url. PUT the PDF bytes to upload_url with Content-Type: application/pdf, then POST $POSTALFORM_API_BASE/v1/documents/{document_id}/complete with {"page_count":}. 2. POST $POSTALFORM_API_BASE/v1/letters/quotes with {"document_id":"doc_..."}. Optional: mail_class (standard, priority, express), color, double_sided, certified, certified_return_receipt, destination_country_code. It returns quote_id and price_cents. 3. POST $POSTALFORM_API_BASE/v1/letters with an Idempotency-Key header and {"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"}}. The response includes the order id and "mode":"test". 4. GET $POSTALFORM_API_BASE/v1/letters/{order_id} for status and timeline, and GET $POSTALFORM_API_BASE/v1/letters/{order_id}/document.pdf to show the user the prepared letter. Test letters stop before delivery on their own. To see the rest of the lifecycle, POST $POSTALFORM_API_BASE/v1/letters/{order_id}/simulate-delivery (postcards: /v1/postcards/{order_id}/simulate-delivery) with the test key. It moves the letter through accepted, in_transit and delivered, sends the signed webhook for each step, and returns the delivered letter. Repeating it is safe. Live keys get 403 test_mode_only. Tell the user that test orders are simulated and nothing was mailed. Postcards: POST $POSTALFORM_API_BASE/v1/postcards/prepare with front_image, message, recipient, and sender, or quote 2-page artwork with /v1/postcards/quotes and send it with /v1/postcards. ## Going live Ask the user before enabling live mail: live orders print, mail, and charge. - Stripe Projects: run `stripe projects upgrade postalform/mail` and choose pay-as-you-go (service configuration {"price":"payg"}). Stripe collects payment and bills each submitted mailpiece. Then run `stripe projects env pull` to receive POSTALFORM_LIVE_API_KEY. To refuse any single order priced above a limit, include "max_amount_cents" in the service configuration. - Direct signups: add prepaid credit on the dashboard Credits page, then create the live key on the API Keys page. Live requests are the same calls with POSTALFORM_LIVE_API_KEY. Quote first and confirm price_cents with the user before creating the order. ## Webhooks Configure endpoints in the dashboard or with POST $POSTALFORM_API_BASE/v1/webhook-endpoints. Deliveries are signed with the PostalForm-Signature header; verify them with the endpoint secret. To exercise a handler end to end, send a test letter and simulate its delivery (see Send a test letter). ## Errors - 404 with suggested_path: the request left out /v1. Retry at the suggested path. - 400 sender_required or invalid_sender_address: add the return address. missing_fields lists what is missing, such as sender.state. - 403 permission_denied or approval_required: the key or workspace policy needs a person to approve live mail. API keys cannot approve; use /v1/drafts and the dashboard. - 409 order_processing from simulate-delivery: the test letter is being prepared. Retry after the Retry-After seconds. - 429 rate_limited: wait retry_after_seconds. - Live orders without enough prepaid credit or an active Stripe Projects payment authorization are rejected before any mail is created. ## Pricing US letters from $1.80 plus $0.20 per black-and-white page or $0.40 per color page. Postcards from $1.50. USPS Certified Mail adds $8.00 and Electronic Return Receipt adds $3.00. The quote is always the exact price. ## Permissions API keys carry enforced operation permissions. Standard keys can send directly; live sends require mailings.submit_live and mailings.submit_without_approval. Each OpenAPI operation lists its x-workspace-permissions. The historical letters:write plus letters:read scope pair keeps broad access for compatibility, and key rotation preserves restrictions. /v1/drafts prepares, revises, requests approval for, and releases mail; /v1/approvals returns expense-only summaries. ## Provisioning protocol (called by Stripe Projects, not by agents) Stripe Projects calls the APP 0.1d surface at https://projects.postalform.com/agentic: POST /provisioning/account_requests, GET /provisioning/services, POST /provisioning/resources, GET /provisioning/resources/{id}, POST /provisioning/resources/{id}/rotate_credentials, POST /provisioning/resources/{id}/remove, POST /provisioning/resources/{id}/update_service, POST /provisioning/deep_links, and GET /provisioning/health. Credential rotations keep returning the Stripe-managed webhook variables. Live resources use usage-based billing when Stripe supplies payment_credentials.type=stripe_payment_token. ## Documentation - https://projects.postalform.com/docs (guide and API reference) - https://projects.postalform.com/openapi.yaml (OpenAPI 3.1 schema) - https://projects.postalform.com/pricing (pricing calculator)