Matterleaf API

Keep the trigger digital. Make the arrival physical.

Send letters, cards, and approved custom mailings from your own systems. Choose a standard format or work with us on a custom piece, then send as recipients and messages change. Minimum order: one.

Getting started

Tell us what you want to send.

Tell us what your software should send and when. We’ll confirm a supported format, arrange API credentials, and help you connect the first workflow.

Standard products and customer-specific approved products can both be used for ongoing sends. Product configuration is defined by the product you have access to, so inspect its schema before building an order.

Discuss API access or email hello@matterleaf.com. Existing API and order questions can go to support@matterleaf.com.

Authentication

Use your key from server-side code.

Customer API keys use the wl_ prefix. Keep the key in a server-side secret store; never expose it in browser code, public repositories, or client-side logs.

API credentials and setup are arranged with Matterleaf. Use the human-readable API reference for route, field, and scope details.

Request
curl https://api.matterleaf.com/v1/products \
  -H "Authorization: Bearer $MATTERLEAF_API_KEY"

The API accepts Bearer wl_live_… customer keys for customer operations. The key shown above is a placeholder, not a usable credential.

Products and configuration

Read the format before you send it.

Start with the products available to your customer account. The standard catalog currently includes handwritten; customer-specific approved products may also appear.

List products
curl https://api.matterleaf.com/v1/products \
  -H "Authorization: Bearer $MATTERLEAF_API_KEY"

Fetch the complete configuration schema for a product. Variable fields and insert choices depend on that response; a generic configuration object is not a valid order example.

Inspect one product
curl https://api.matterleaf.com/v1/products/handwritten \
  -H "Authorization: Bearer $MATTERLEAF_API_KEY"

The current standard handwritten product requires recipient and message. Its pen-written treatment is produced by an automated writing machine, not by a person writing each letter. Recipient fields include name, address, city, state, and ZIP; optional company and approved add-ons follow the returned schema.

Order metadata is your application's context; for example, metadata.source can identify your own source system. It does not set the API key's connection identity or Matterleaf's server-managed integration records.

Reusable mailings

Set the format up once. Personalize each send.

Create a reusable mailing from a product available to your account. Define typed input fields and bind them to product configuration or to content elements across the mailing’s pieces. A value such as a recipient name or message can be reused wherever the approved format allows it.

Product schemas define the physical piece types, options, and limits that can be used. A label or field in a mailing definition does not add a new physical capability or set its price. Unusual formats need to be agreed with Matterleaf and made available on the product before they can be submitted through the API.

Use POST /v1/mailings to create a definition, PUT /v1/mailings/{mailingId} to append a version, and POST /v1/mailings/{mailingId}/orders to submit recipient-specific values. Previous order snapshots keep the version used when they were accepted. The API reference includes request and response examples for each step.

First order

Quote it, then submit the same shape.

Save the configuration below as order.json. It uses the standard handwritten product shape and fictional recipient data. Customer-specific products can require different fields, so inspect the product schema before sending.

order.json
{
  "items": [
    {
      "product_id": "handwritten",
      "configuration": {
        "recipient": {
          "name": "Ada Lovelace",
          "address": "1 Main St",
          "city": "Denver",
          "state": "CO",
          "zip": "80202"
        },
        "message": "Thank you for being part of this work."
      }
    }
  ],
  "metadata": { "source": "crm_sync", "program": "welcome" }
}

Quotes are optional and return a temporary price without creating an order or debiting credits. Use the expires_at value returned by the quote response. When attached to an order, the API requires the exact quoted items and uses the saved item pricing and total. Rate-card changes do not alter a valid quote; expired quotes are rejected.

Get a quote
curl https://api.matterleaf.com/v1/quotes \
  -X POST \
  -H "Authorization: Bearer $MATTERLEAF_API_KEY" \
  -H "Content-Type: application/json" \
  --data @order.json

Replace the valid UUID in the example with the quote response’s id, save the quoted payload below as quoted-order.json, and submit it before the returned expires_at timestamp. An accepted order is recorded with Matterleaf; the response does not mean it has been printed or mailed.

quoted-order.json
{
      "quote_id": "00000000-0000-0000-0000-000000000000",
  "items": [
    {
      "product_id": "handwritten",
      "configuration": {
        "recipient": {
          "name": "Ada Lovelace",
          "address": "1 Main St",
          "city": "Denver",
          "state": "CO",
          "zip": "80202"
        },
        "message": "Thank you for being part of this work."
      }
    }
  ],
  "metadata": { "source": "crm_sync", "program": "welcome" }
}
Create a quoted order
curl https://api.matterleaf.com/v1/orders \
  -X POST \
  -H "Authorization: Bearer $MATTERLEAF_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $MATTERLEAF_EVENT_KEY" \
  --data @quoted-order.json

Keep credentials server-side. A successful HTTP response means the API accepted the request; it is not proof of dispatch or delivery. Use the simulated test-order endpoint below to validate request handling without a live order, credit debit, Stripe charge, or production work.

Testing

Try the order flow without a live send.

Use a key with the orders:test scope and without live order-creation permission. Simulated orders use the product schema and price rules, but are stored separately: they do not debit wallet credits, charge Stripe, create live order events, or enter physical production. Their status changes stay in the test event history and are not delivered to customer webhooks.

Use fictional recipient data and mark the message as simulation-only. The same idempotency guidance applies: reuse the key and identical request body when retrying the same simulated event.

test-order.json
{
  "items": [{
    "product_id": "handwritten",
    "configuration": {
      "recipient": { "name": "Synthetic Recipient", "address": "1 Test Way", "city": "Denver", "state": "CO", "zip": "80202" },
      "message": "Simulation only; do not print or mail."
    }
  }]
}
Create a simulated order
curl https://api.matterleaf.com/v1/test/orders \
  -X POST \
  -H "Authorization: Bearer $MATTERLEAF_TEST_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: test-welcome-event:123:v1" \
  --data @test-order.json

Use GET /v1/test/orders/{orderId} to retrieve the simulated order, and GET /v1/test/orders/{orderId}/events to read its test-only event history. Ask Matterleaf to arrange test credentials with the appropriate scope.

Order status

Follow the returned order ID.

Order creation returns an order identifier. A funded order returns 200 with accepted; an order waiting for explicitly enabled automatic recharge may return 202 with pending_payment. Keep the order ID and check its current status before retrying or creating another send.

Retrieve an order
curl https://api.matterleaf.com/v1/orders/$ORDER_ID \
  -H "Authorization: Bearer $MATTERLEAF_API_KEY"
StatusMeaning and next step
pending_paymentThe order is durable while configured funding is completed. Poll it; do not create another order for the same event.
payment_failedFunding did not complete. Review the order and wallet, then use POST /v1/orders/{orderId}/retry-payment only when appropriate.
acceptedThe API accepted and funded the order. Poll for the production state.
scheduledThe order has a requested future mailing time and remains on hold until Matterleaf releases it.
queuedThe order is waiting in Matterleaf’s production queue.
in_productionProduction has started. Cancellation is no longer available.
shippedMatterleaf has dispatched the order. This does not confirm postal delivery.
completeMatterleaf’s fulfillment lifecycle is finished after shipment; it does not confirm postal delivery.
failedThe order did not complete. Keep the order ID and request ID, then contact support before retrying.
canceledThe order was canceled. Use a new idempotency key only for an intentional new send.
Batches and mailing dates

Send a group with per-recipient results.

Submit individual order bodies together with POST /v1/batches. Each child has its own recipient, request result, and order ID when accepted. The endpoint returns 202; the batch can still be processing, and one child can fail while others succeed. The default limit is 100 children per batch and a deployment may set a lower limit.

batch.json
{
  "items": [{
    "client_item_id": "welcome-123",
    "order": {
      "items": [{
        "product_id": "handwritten",
        "configuration": {
          "recipient": { "name": "Ada Lovelace", "address": "1 Main St", "city": "Denver", "state": "CO", "zip": "80202" },
          "message": "Thank you for being part of this work."
        }
      }],
      "metadata": { "source": "crm_sync", "program": "welcome" }
    }
  }]
}
Submit a batch
curl https://api.matterleaf.com/v1/batches \
  -X POST \
  -H "Authorization: Bearer $MATTERLEAF_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: welcome-batch:2026-10-21" \
  --data @batch.json

Use a stable Idempotency-Key for the same batch submission. Check GET /v1/batches/{batchId} for its summary and GET /v1/batches/{batchId}/items for paginated child results.

The assigned rate card's volume tier uses the total number of children in a batch. Each child keeps its own order and price snapshot. A 50-piece batch uses the configured 50+ rate; 50 separate one-off requests use the single-piece rate.

To request a mailing time, set scheduled_for to a future UTC timestamp ending in Z in the individual order body. This is a requested mailing/release time, not a delivery date. A scheduled order stays on hold until Matterleaf releases it; this field does not create a recurring schedule.

Before production

Update an order while it is still in the queue.

Before production starts, use POST /v1/orders/{orderId}/edit to send a complete replacement item list, or updated mailing_input_values for an order created from a reusable mailing. The API validates the new content and options and recalculates the price. Send an Idempotency-Key and reuse it with the same body if the request needs retrying.

Use POST /v1/orders/{orderId}/cancel to cancel an eligible order or POST /v1/orders/{orderId}/reschedule with a future UTC time to change its requested mailing time. Once production has started, the order cannot be edited, canceled, or rescheduled. Canceling an eligible funded order restores its unused wallet-credit allocation; it does not refund a Stripe card payment.

Retries and errors

Retry events carefully.

Send an Idempotency-Key with every order request. Reuse the same key with the exact same request body when retrying the same intended mailing. Reusing a key with a different body returns an idempotency_conflict error.

Derive a stable key from the source account, source event/object, and intended mailing action, such as welcome-event:EVENT_ID:send-letter:v1. Reuse it for network retries of that event. Use a new key only when you intentionally mean to send again.

Errors use an envelope with error.code, error.message, error.request_id, and optional details. Keep the request ID when contacting support. If funding does not complete, check the order and wallet resources, then contact support before creating another send. Automatic recharge is attempted only when it has been explicitly enabled with a usable saved payment method and remains within the saved recharge policy.

Server-side TypeScript
const response = await fetch('https://api.matterleaf.com/v1/orders', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.MATTERLEAF_API_KEY}`,
    'Content-Type': 'application/json',
    'Idempotency-Key': `welcome-event:${event.id}`
  },
  body: JSON.stringify({
    items: [{
      product_id: 'handwritten',
      configuration: {
        recipient: {
          name: recipient.name,
          address: recipient.address,
          city: recipient.city,
          state: recipient.state,
          zip: recipient.zip
        },
        message: message.text
      }
    }],
    metadata: { source: 'crm_sync', program: 'welcome' }
  })
});

const order = await response.json();
if (!response.ok) throw new Error(`Matterleaf request failed: ${order.error?.code}`);

List responses use the pagination fields shown in the live reference. Pass an opaque next_cursor back as cursor; do not construct cursors yourself. Poll the order resource when you need an updated fulfillment state.

shipped means Matterleaf recorded dispatch. Configured USPS mail tracking can add a tracking code and in_transit, delivery_estimated, delivered, or delivery_exception webhook. A logical delivery estimate emits delivery_estimated; delivered requires an observed delivery scan. First-Class letters use IMb data through USPS Informed Visibility when the mailer has eligible barcodes and access; this is not the same as a public USPS package tracking number. complete is a fulfillment state, not proof of postal delivery.

PDF and artwork assets

Attach one approved file to each order.

POST /v1/assets creates an upload and returns a signed Storage URL. Upload the raw PDF bytes to that URL, then reference its ID as pdf_asset_id on the order. Matterleaf verifies the uploaded size and file type when the file is first used. For a fresh URL while an asset is still pending, call POST /v1/assets/{assetId}/upload-url. Signed uploads are temporary; keep the API key server-side and do not send the file as JSON or base64.

Each order item can attach one PDF through pdf_asset_id, without a product-specific asset slot. If an order references the PDF before its upload has finished, retry the same request after uploading the bytes. Order details return PDF metadata; GET /v1/orders/{orderId}/pdf returns a signed download URL that is valid for 15 minutes. Fetch that URL directly for the original PDF bytes; it does not require the Matterleaf API key. For a batch, upload each recipient's file and put that file's ID in that recipient's child order:

Personalized certificate order
{
  "items": [{
    "product_id": "handwritten",
    "pdf_asset_id": "PDF_ASSET_ID",
    "configuration": {
      "recipient": { "name": "Ada Lovelace", "address": "1 Main St", "city": "Denver", "state": "CO", "zip": "80202" },
      "message": "Gift certificate"
    }
  }]
}

Asset linkage preserves which file belongs to each order. Matterleaf retrieves stored PDFs for manual fulfillment.

See the full upload and API reference.

Webhooks

Receive order and batch status changes.

Register an HTTPS endpoint and choose supported order or batch events. The signing secret is returned when the endpoint is created or its secret is rotated; store it securely. Use GET /v1/webhook-endpoints/{endpointId}/deliveries to inspect delivery status and POST /v1/webhook-endpoints/{endpointId}/deliveries/{deliveryId}/replay to request a replay.

webhook-endpoint.json
{
  "url": "https://example.com/webhooks/matterleaf",
  "events": ["order.created", "order.payment_failed", "order.queued", "batch.completed"],
  "description": "Order and mailing status updates",
  "enabled": true
}

Verify X-Webhook-Signature as HMAC-SHA256 over <timestamp>.<raw request body> using your endpoint secret. The header carries t= and v1= values. A 2xx response completes a delivery; timeouts and non-2xx responses may be retried, so handle duplicate deliveries safely. Use the order or batch resource as the current source of truth; webhook receipt is not guaranteed.

Postal event webhooks include the mail tracking service/code and distinguish observed scans from USPS logical delivery estimates. USPS IMb tracking for letters requires a mailer with eligible barcodes and IV-MTR data access; it is not consumer-facing USPS package tracking. Do not treat order.complete as delivery confirmation.

Billing

Have credits available before the send.

Orders use account credits in integer US cents. Stripe top-ups and subscription grants fund the wallet; order acceptance allocates wallet credits transactionally. Eligible durable pending_payment orders are automatically funded oldest first as credits become available. If funding is needed and automatic recharge is explicitly enabled, with a usable saved payment method, the API may create a durable pending_payment order while the saved recharge policy completes. The saved top_up_amount_cents and monthly_limit_cents remain subject to per-charge and monthly guardrails; a saved card or retry request alone is not consent to charge. If recharge is disabled or one configured top-up remains insufficient, no unbounded loop starts; the order remains recoverable or a payment-required error is returned.

Canceling an eligible funded order restores its exact unused wallet-credit allocation once. It does not refund the Stripe top-up to the original card. A pending or failed payment has no order credit to restore. Use the returned order and wallet values as authoritative.

Billing setup and recharge arrangements are handled during onboarding. This guide does not publish subscription plans or browser payment flows as part of the customer API quickstart. Ask Matterleaf how credits and recharge should be configured for your workflow.

Help

We’ll help connect the first workflow.

Existing API or order questions: support@matterleaf.com. Access requests and custom mailing discussions: hello@matterleaf.com.

The interactive API reference is the canonical technical reference.

Discuss API setup