REST API guide

Send a finished postcard.

One recipient and one print-ready card per request. Start with a Staging key, then use a Live key when you are ready to mail.

Base URL: https://api.postcards.ai/api/v1. Staging and Live keys use the same endpoints. The key sets the mode.

01 / Quick start

Create, submit, and inspect a Staging card

Use a Staging key and hosted two-page PDF. Replace the key, PDF URL, and idempotency key. The example uses a public address that has passed a Staging submission. Reuse the same idempotency key only to retry that create request. These commands need jq. Staging makes a proof without mailing a card.

Create a draft, then submit it
# Set a Staging key from Settings > API access.
export POSTCARDS_AI_STAGING_API_KEY='<your-staging-key>'
IDEMPOTENCY_KEY='<your-unique-id-for-this-card>'

SEND_ID=$(curl --fail-with-body --silent --show-error --request POST 'https://api.postcards.ai/api/v1/single_postcard_sends' \
  --header "Authorization: Bearer ${POSTCARDS_AI_STAGING_API_KEY}" \
  --header 'Content-Type: application/json' \
  --header "Idempotency-Key: ${IDEMPOTENCY_KEY}" \
  --data '{
    "pdf_url": "https://assets.example.com/card.pdf",
    "size": "6x11",
    "submit": false,
    "recipient_name": "Staging Test",
    "to_address": {
      "address_line1": "1 Dr Carlton B Goodlett Pl",
      "city": "San Francisco",
      "state": "CA",
      "zip": "94102",
      "country": "US"
    }
  }' | jq -er '.id')

if [ -n "${SEND_ID}" ]; then
  curl --fail-with-body --silent --show-error --request POST \
    "https://api.postcards.ai/api/v1/single_postcard_sends/${SEND_ID}/send" \
    --header "Authorization: Bearer ${POSTCARDS_AI_STAGING_API_KEY}"
else
  echo 'Create did not return a send ID. Check the response before submitting.' >&2
fi

The submit response has the same send ID. Ask for its proof until the endpoint returns HTTP 200 with a PDF. While rendering, it returns HTTP 202 with JSON. The example checks for up to five minutes. If the proof is still processing, retry the same send ID later. If it fails, read the send's error_message.

Wait for the Staging proof
for attempt in {1..20}; do
  PROOF_RESPONSE=$(mktemp)
  HTTP_STATUS=$(curl --silent --show-error \
    "https://api.postcards.ai/api/v1/single_postcard_sends/${SEND_ID}/proof" \
    --header "Authorization: Bearer ${POSTCARDS_AI_STAGING_API_KEY}" \
    --output "${PROOF_RESPONSE}" --write-out '%{http_code}')

  if [ "${HTTP_STATUS}" = '200' ]; then
    mv "${PROOF_RESPONSE}" staging-proof.pdf
    echo 'Proof saved to staging-proof.pdf'
    break
  fi
  if [ "${HTTP_STATUS}" != '202' ]; then
    cat "${PROOF_RESPONSE}"
    rm -f "${PROOF_RESPONSE}"
    break
  fi

  rm -f "${PROOF_RESPONSE}"
  sleep 15
done

Run this in the same shell so SEND_ID and the Staging key are still set. The response is saved as a PDF only when the server returns HTTP 200.

02 / Keys and access

Start with a Staging key

Ask us to enable API access and one-off postcards for your business. A business admin can then create a Staging or Live key in Settings > API access.

Staging

Renders a test proof. No physical card is mailed and no live credits are used. If test printing is unavailable, the request fails instead of using Live.

Live

Submits real postcards and uses prepaid credits. Check the unit price before sending. A key's mode is fixed when it is created.

Send Authorization: Bearer <key> with each request. Reads and preflight need campaigns.read. Creating or submitting a postcard needs campaigns.submit and business admin access. Keys for one-off postcard access offer those two scopes.

Before using Live

Add prepaid credits in Settings > Billing. Purchases with a saved payment method currently start at $10; the billing form shows the limits that apply. Staging needs no credits. Check your account's unit price, and replace the example recipient and address with your intended recipient before submitting with a Live key.

03 / Artwork and preflight

Check the file before you send

Cards can be 6x9 or 6x11. The default is 6x9. Pass the same size to specs, preflight, and create. 6x11 uses Marketing Mail; 6x9 uses First Class. For 6x11, use a US destination; Live also needs a price configured for your account.

Get 6x11 specs and price
curl 'https://api.postcards.ai/api/v1/postcard_specs?size=6x11' \
  --header "Authorization: Bearer ${POSTCARDS_AI_STAGING_API_KEY}"

Staging specs and preflight return a unit price of 0. Use a Live key for these read-only calls to check your account's mailing price.

A two-page PDF uses page 1 for the front and page 2 for the back. It can be up to 10 MB. Separate front and back PDFs can be up to 5 MB each. Specs give the exact page dimensions and clear zones.

Preflight a hosted two-page PDF
curl --request POST 'https://api.postcards.ai/api/v1/single_postcard_sends/preflight' \
  --header "Authorization: Bearer ${POSTCARDS_AI_STAGING_API_KEY}" \
  --header 'Content-Type: application/json' \
  --data '{"size":"6x11","pdf_url":"https://assets.example.com/card.pdf"}'

Preflight checks file structure and readability. It does not catch every creative issue. A valid result includes valid: true, errors: [], the specs, unit price, and currency. A file that fails preflight returns valid: false and an errors array with HTTP 200; creating a send with that file returns HTTP 422.

PDF preflight does not check postal deliverability. Both Staging and Live submissions validate the mailing address, so a made-up address can fail even when the artwork passes.

04 / Request fields

Choose the artwork and recipient

Use one pdf_url, a multipart pdf_file, or both front_pdf_url and back_pdf_url. For a recipient, provide recipient_name or recipient_company and a to_address.

FieldWhat to send
pdf_url / pdf_fileOne two-page PDF URL or uploaded PDF. Use exactly one.
front_pdf_url + back_pdf_urlTwo separate single-page PDF URLs. Use these instead of a two-page PDF.
size6x9 (default) or 6x11. Use 6x11 only for US destinations.
submitfalse creates a draft; omitted or true submits during create.
recipient_name / recipient_companyAt least one. Each can be up to 40 characters.
to_addressaddress_line1, city, state, zip, and optional address_line2 and country (defaults to US).
description / metadataOptional description and JSON metadata for your own reference.
Upload the same artwork as multipart form data
curl --request POST 'https://api.postcards.ai/api/v1/single_postcard_sends' \
  --header "Authorization: Bearer ${POSTCARDS_AI_STAGING_API_KEY}" \
  --header 'Idempotency-Key: order-8421-upload' \
  --form 'pdf_file=@./card.pdf;type=application/pdf' \
  --form 'size=6x11' \
  --form 'submit=false' \
  --form 'recipient_name=Staging Test' \
  --form 'to_address[address_line1]=1 Dr Carlton B Goodlett Pl' \
  --form 'to_address[city]=San Francisco' \
  --form 'to_address[state]=CA' \
  --form 'to_address[zip]=94102' \
  --form 'to_address[country]=US'

In multipart requests, use bracketed address fields as shown. A JSON string in one to_address form field will not work. Submit a draft with POST /single_postcard_sends/:id/send, as in the quick start.

Omit sender overrides (from, fromAddress, from_address), paper options (paper, paperType, paper_type), custom mail class (mailingClass, mailing_class), and scheduled dates (sendDate, send_date). These options are unsupported. Paper and sender use the printing account's defaults, and postage follows the card size. Submitting a Live draft sends it to print without a scheduled date. A request containing these fields returns HTTP 422 before creating a send:

Unsupported sender override
HTTP/1.1 422 Unprocessable Entity
Content-Type: application/json

{
  "error": "Unsupported postcard mailing options: from_address",
  "code": "single_postcard_mailing_options_unsupported",
  "fields": ["from_address"]
}

If you are moving an existing PDF integration, keep your own contact lookup and scheduling logic. This endpoint takes a finished file and one recipient.

05 / Statuses and proof

Keep the send ID

These examples show the fields needed to handle a send. Actual send objects include additional recipient, artwork, billing, and timestamp fields.

Draft created
HTTP/1.1 201 Created
Content-Type: application/json

{
  "id": 1234,
  "size": "6x11",
  "mode": "staging",
  "status": "draft",
  "cost_cents": 0,
  "currency": "usd",
  "replacement_send_id": null
}
Live postcard accepted
HTTP/1.1 201 Created
Content-Type: application/json

{
  "id": 1235,
  "size": "6x11",
  "mode": "live",
  "status": "submitted",
  "submitted_at": "2026-10-04T12:00:00Z"
}

A Staging submit can return HTTP 202 while the proof is being verified. Keep the ID from single_postcard_send.id and read that send before taking another action:

Submission still being verified
HTTP/1.1 202 Accepted
Content-Type: application/json

{
  "error": "Postcard proof is being verified",
  "code": "single_postcard_submission_pending",
  "retryable": true,
  "single_postcard_send": {
    "id": 1234,
    "mode": "staging",
    "status": "processing"
  }
}

A Live submit can also return HTTP 202, with the send object directly in the response. After submission, poll GET /single_postcard_sends/:id while the status is processing. If it stays there, contact us with the send ID before trying to create another card. For Live sends, submitted means "Sent to print." It does not claim physical delivery. cancelled means "Cancelled." Internal repair failures are not exposed as a customer-facing Live status.

Staging sends can return draft, processing, proof_ready, failed, or cancelled. When a proof is ready, GET /single_postcard_sends/:id/proof returns 200 with Content-Type: application/pdf. While it is rendering, it returns:

Staging proof still rendering
HTTP/1.1 202 Accepted
Content-Type: application/json

{ "status": "processing" }

06 / Errors and retries

Handle errors without sending twice

Most error responses contain an error message and may include a machine-readable code. Missing recipient or address fields return an errors array instead. A PDF preflight failure includes preflight.errors.

Invalid submit value
HTTP/1.1 422 Unprocessable Entity
Content-Type: application/json

{
  "error": "submit must be true or false",
  "code": "single_postcard_submit_invalid"
}
Recipient name and company both missing
HTTP/1.1 422 Unprocessable Entity
Content-Type: application/json

{
  "errors": ["Recipient name or company is required"]
}
Live draft needs credits
HTTP/1.1 422 Unprocessable Entity
Content-Type: application/json

{
  "error": "Insufficient postcard credits. Add credits in Settings > Billing, then retry this draft.",
  "code": "insufficient_postcard_credits",
  "retryable": false,
  "required_cents": 95,
  "available_cents": 0,
  "shortfall_cents": 95,
  "currency": "usd",
  "single_postcard_send": {
    "id": 1235,
    "mode": "live",
    "status": "draft"
  }
}

Amounts are in cents. This example uses a 95-cent account price; your account's price can differ.

For insufficient_postcard_credits, add credits in Settings > Billing, then submit the existing single_postcard_send.id with POST /single_postcard_sends/:id/send. The draft remains available and no print order or credit debit has been made. retryable: false means repeating the request before adding credits will not help.

HTTPMeaningWhat to do
202Submission or proof is still processing.Keep the existing send ID. For Staging, retry its proof endpoint until HTTP 200. For Live, read the send until it is submitted.
401 / 403Key is missing, invalid, or lacks access.Check the key, mode, and scopes in Settings > API access.
409The idempotency key has a different payload or another request is still using it.Do not change the payload. If Retry-After is present, wait and retry.
422Request validation failed or credits are insufficient.Read error, errors, or preflight.errors and any code. Correct the input, or add credits and submit the existing draft.
429Rate limit reached.Wait for Retry-After before retrying.
503Staging submission or proof is temporarily unavailable.Retry the same send or read its proof later.

Send a unique Idempotency-Key with every create request. It can contain 1 to 128 letters, numbers, periods, underscores, colons, or hyphens, and must start with a letter or number. If a request times out, retry the same payload with the same key. An accepted replay returns the same send:

Idempotent replay
HTTP/1.1 200 OK
Idempotency-Replayed: true
Content-Type: application/json

{
  "id": 1234,
  "mode": "staging",
  "status": "draft"
}

The response body is the current send object, so its status may have changed since the first request.

Changing the payload under the same key returns 409. A concurrent request with that key can also return 409 with Retry-After; wait and retry. A request without a key can create another postcard when retried.

A 429 also includes Retry-After. The starting limits are 60 submissions per minute and 1,000 per hour per business and key mode. Preflight allows 120 requests per minute. Account limits can differ.

Allow at least 60 seconds for a synchronous create during bursts. A timeout does not establish whether a card was accepted. Keep the same key until the first attempt is resolved. A 202 means the outcome is still being reconciled; read the existing send instead of starting a new one.

07 / Endpoints

One-off postcard routes

Paths below are relative to https://api.postcards.ai/api/v1. Use your Staging or Live key with every call.

MethodPathUse
GET/postcard_specs?size=6x11Artwork dimensions and account price
POST/single_postcard_sends/preflightCheck a PDF before creating a send
POST/single_postcard_sendsCreate a draft or submit immediately
POST/single_postcard_sends/:id/sendSubmit a saved draft
GET/single_postcard_sendsList sends for this key's mode
GET/single_postcard_sends/:idRead one send
GET/single_postcard_sends/:id/proofDownload a Staging proof

Access

Request access for your business

API access is enabled per business. Book a setup call and tell us about your integration. Once access is enabled, a business admin can create a Staging or Live key in Settings > API access.

Sign in