Skip to content

Print & Mail API ​

Product overview: Passport photo print and mailing.

Send us a photo and a mailing address in any country. The photo can be a photoUuid from the Passport Photo API or your own finished image. We print the photo on 4×6 inch photo paper and mail it to your customer. You get the tracking number through the API or a webhook, and pass it on to your customer.

text
1. Create the photo with POST /v2/makeIdPhoto, or use your own image
2. POST /api/print/create-order    → paid from your prepaid balance
3. We print and mail the photos    → IN_PRODUCTION, then SHIPPED
4. Get the tracking number         → webhook, or query-order

Access ​

The Print & Mail API is available on every account with an API key. You can start right away: sandbox orders are free and never printed.

Real orders are paid from a prepaid print balance on your account. New accounts start with a balance of $0.00, so a real order returns 402 INSUFFICIENT_BALANCE until you add funds by contacting support@idphoto.ai. Check it with POST /api/print/query-balance, or see the balance and every transaction on the Print & Mail page of the Dashboard.

Before you start ​

You use the same API key and API secret as the Passport Photo API. Send requests from your server. Keep both credentials out of browser code, mobile applications, source control, and logs.

ItemValue
Base URLhttps://saas-api.idphotoapp.com
Test environmentA separate base URL and key, available on request from support@idphoto.ai. Test environment orders are never printed. Most integrations only need sandbox orders.
MethodPOST for every endpoint, Content-Type: application/json
AuthenticationapiKey and apiSecret in the JSON body
TimesISO 8601 in UTC, for example 2026-11-17T15:20:00Z
AmountsUS dollars, as numbers with 2 decimal places
Request size8 MB at most, to allow a Base64 photo
Rate limit10 requests per second per key. 200 sandbox orders per day per account.
DestinationsAddresses in any country, including US APO/FPO addresses

The production and test environments are fully separate. A key, balance, order, or webhook address from one does not work in the other.

Endpoints ​

EndpointUse
POST /api/print/create-orderCreate a print order
POST /api/print/query-orderGet one order by orderId or externalOrderId
POST /api/print/query-order-pagingList your orders, page by page, filtered by creation time or status
POST /api/print/cancel-orderCancel an order before printing starts
POST /api/print/query-balanceGet your print balance

Create an order ​

http
POST /api/print/create-order

Send exactly one photo source: photoUuid or photoImage.

Request ​

FieldTypeRequiredDescription
apiKeystringYesYour API key.
apiSecretstringYesYour API secret.
idempotencyKeystringYesUp to 64 characters, unique for each order you place. Sending the same key again returns the first order and does not charge twice.
externalOrderIdstringNoUp to 64 characters. Your own order number. It is returned in every response and webhook.
photoUuidstringOne photo sourceThe photoUuid returned by POST /v2/makeIdPhoto for this account, any specification. The print size is taken from the photo's spec code, so do not send printSize.
photoImagestringOne photo sourceYour own finished photo, Base64 without a data: prefix. JPEG or PNG, 5 MB at most.
printSizeobjectWith photoImageThe printed size of one photo: width, height and unit (inch or mm). Example: {"width": 2, "height": 2, "unit": "inch"} or {"width": 35, "height": 45, "unit": "mm"}. Must match the image's aspect ratio within 2%.
photoPairsintegerNoNumber of pairs of photos, 1 to 5. One pair is 2 photos. Defaults to 1.
shippingMethodstringYesSTANDARD, TRACKED, or EXPRESS. See Shipping methods. STANDARD has no tracking number.
recipientobjectYesMailing address. See Recipient.
notifyRecipientbooleanNoDefaults to false. When true, we email the recipient a plain, unbranded shipping notice with the tracking number. Requires recipient.email.
isSandboxbooleanNoDefaults to false. true creates a test order that is never charged, printed, or mailed. See Sandbox orders.
testScenariostringNoSandbox orders only. DELIVERED (default), FAILED, RETURNED, or UNTRACKED.

Recipient ​

FieldTypeRequiredDescription
namestringYesUp to 40 characters.
companystringNoCompany name.
address1stringYesStreet address.
address2stringNoApartment, suite, or unit.
citystringYesCity.
statestringDepends on countryState, province, or region. Required for US addresses: a two-letter state code, or AA, AE, or AP for APO/FPO addresses. Send it for other countries when the address uses one.
zipstringDepends on countryPostal code. Required when the country uses postal codes. For US addresses: a 5-digit ZIP code or ZIP+4, for example 95112 or 95112-1234.
countrystringYesTwo-letter ISO 3166-1 country code, for example US, GB, CA, or AU.
phonestringNoPhone number. Recommended for addresses outside the US.
emailstringNoRequired when notifyRecipient is true.

Example request ​

json
{
  "apiKey": "your-api-key",
  "apiSecret": "your-api-secret",
  "idempotencyKey": "order-10023",
  "externalOrderId": "10023",
  "photoUuid": "b1c2d3e4-5f60-4a7b-8c9d-0e1f2a3b4c5d",
  "photoPairs": 1,
  "shippingMethod": "TRACKED",
  "recipient": {
    "name": "Jane Doe",
    "address1": "123 Main St",
    "address2": "Apt 4",
    "city": "San Jose",
    "state": "CA",
    "zip": "95112",
    "country": "US"
  },
  "notifyRecipient": false
}

Response ​

json
{
  "orderId": "po_01JD8X5Q7R2M3N4P5S6T7V8W9X",
  "externalOrderId": "10023",
  "isSandbox": false,
  "status": "PENDING",
  "photoSource": "PHOTO_UUID",
  "photoPairs": 1,
  "shippingMethod": "TRACKED",
  "trackingAvailable": true,
  "price": { "total": 10.00, "currency": "USD" },
  "balanceAfter": 490.00,
  "printSize": { "width": 2, "height": 2, "unit": "inch" },
  "sheetCount": 1,
  "createdAt": "2026-11-17T02:00:00Z"
}

Amounts in the examples on this page are illustrative only.

FieldDescription
orderIdOur order ID. Use it with every other endpoint.
statusAlways PENDING for a new order. See Order status.
photoSourcePHOTO_UUID or UPLOADED.
trackingAvailablefalse for STANDARD, which has no tracking number.
price.totalThe amount charged for this order. A sandbox order shows the amount but is not charged.
balanceAfterYour print balance after this order.
printSizeThe printed size of each photo.
sheetCountNumber of 4×6 inch sheets we will print. See Print sizes.

If you send the same idempotencyKey again with the same fields, you get the first order back with HTTP 200 and "idempotentReplay": true. With different fields, you get 409 IDEMPOTENCY_CONFLICT.

What we check ​

An order that fails a check is not created and not charged.

CheckError
Key and secret are valid and the account is active403 AUTH_FAILED
Printing has not been turned off for the account403 PRINT_NOT_ENABLED
Exactly one of photoUuid and photoImage is sent400 INVALID_PHOTO_INPUT
The photoUuid exists, belongs to this account, and has a final (unwatermarked) photo404 PHOTO_NOT_FOUND
photoImage is a readable JPEG or PNG of 5 MB or less400 INVALID_PHOTO_IMAGE
printSize is sent with photoImage only, and matches the image's aspect ratio400 INVALID_PRINT_SIZE
The photo is at least 200 DPI at the printed size400 PHOTO_RESOLUTION_TOO_LOW
The photo fits on a 4×6 inch sheet400 PHOTO_SIZE_NOT_PRINTABLE
The address has the required fields for its country400 INVALID_ADDRESS
The balance covers the order (not checked for sandbox orders)402 INSUFFICIENT_BALANCE

We check the photo's format, size, and resolution. We do not check whether the photo meets a government's photo rules. Check it first with Photo Compliance Check. US passport photos must not be digitally altered: see that page before you print one.

We check the address format, not whether the address can receive mail. If we find a problem before printing, the order becomes FAILED and the amount goes back to your balance.

Get an order ​

http
POST /api/print/query-order
FieldTypeRequiredDescription
apiKeystringYesYour API key.
apiSecretstringYesYour API secret.
orderIdstringOne of the twoOur order ID.
externalOrderIdstringOne of the twoYour order number. If several orders share it, the newest is returned.
json
{
  "orderId": "po_01JD8X5Q7R2M3N4P5S6T7V8W9X",
  "externalOrderId": "10023",
  "isSandbox": false,
  "status": "SHIPPED",
  "statusReason": null,
  "photoSource": "PHOTO_UUID",
  "photoPairs": 1,
  "printSize": { "width": 2, "height": 2, "unit": "inch" },
  "sheetCount": 1,
  "shippingMethod": "TRACKED",
  "trackingAvailable": true,
  "price": { "total": 10.00, "currency": "USD" },
  "refund": null,
  "recipient": { "name": "Jane Doe", "city": "San Jose", "state": "CA", "zip": "95112", "country": "US" },
  "trackingNumber": "LX123456789US",
  "trackingUrl": "https://tracking.example.com/LX123456789US",
  "createdAt": "2026-11-17T02:00:00Z",
  "inProductionAt": "2026-11-17T18:05:00Z",
  "shippedAt": "2026-11-17T23:20:00Z",
  "deliveredAt": null,
  "history": [
    { "status": "PENDING", "at": "2026-11-17T02:00:00Z" },
    { "status": "IN_PRODUCTION", "at": "2026-11-17T18:05:00Z" },
    { "status": "SHIPPED", "at": "2026-11-17T23:20:00Z" }
  ]
}
FieldDescription
statusReasonWhy an order is FAILED, RETURNED, or CANCELED, for example ADDRESS_UNDELIVERABLE. Otherwise null.
refundnull, or { "amount", "refundedAt" } after an amount goes back to your balance.
recipientPart of the address only, for privacy.
trackingNumber, trackingUrlSet when the order is SHIPPED. Always null for STANDARD.
historyEvery status change, oldest first.

An unknown order, or an order of another account, returns 404 ORDER_NOT_FOUND.

List orders ​

http
POST /api/print/query-order-paging
FieldTypeRequiredDescription
apiKey, apiSecretstringYesYour credentials.
statusstring[]NoOnly these statuses, for example ["SHIPPED", "DELIVERED"].
createdFromstringNoOrders created at or after this time.
createdTostringNoOrders created at or before this time.
includeSandboxbooleanNoDefaults to false.
limitintegerNo1 to 100. Defaults to 50.
cursorstringNoThe nextCursor from the previous page.
json
{
  "items": [
    { "orderId": "po_01JD8X5Q7R2M3N4P5S6T7V8W9X", "status": "SHIPPED", "...": "..." }
  ],
  "nextCursor": "eyJjcmVhdGVkQXQiOi..."
}

Each item has the same fields as Get an order, without history. nextCursor is null on the last page.

Cancel an order ​

http
POST /api/print/cancel-order
FieldTypeRequiredDescription
apiKey, apiSecretstringYesYour credentials.
orderIdstringYesOur order ID.
reasonstringNoUp to 200 characters.

Only a PENDING order can be canceled. The full amount goes back to your balance.

json
{ "orderId": "po_01JD8X5Q7R2M3N4P5S6T7V8W9X", "status": "CANCELED", "refund": { "amount": 10.00, "refundedAt": "2026-11-17T03:10:00Z" }, "balanceAfter": 500.00 }

Once printing starts, you get 409 ORDER_NOT_CANCELABLE. Canceling an order that is already canceled returns the same result again and does not refund twice.

Get your balance ​

http
POST /api/print/query-balance
json
{ "apiKey": "your-api-key", "apiSecret": "your-api-secret" }
json
{ "balance": 490.00, "currency": "USD", "lowBalanceThreshold": 100.00 }

When the balance falls below lowBalanceThreshold, we email you and send a PRINT_BALANCE_LOW webhook.

Add funds ​

Email support@idphoto.ai with the amount (minimum $1,000). We send you an invoice that you can pay by card or US bank account (ACH), or you can pay by wire transfer. We add the funds to your balance once the payment arrives, and the top-up appears in your transactions on the Dashboard.

Shipping methods ​

We mail to addresses in any country and choose the carrier and service for each order.

shippingMethodTracking numberUse
STANDARDNoLowest cost
TRACKEDYesTracking number and link when the order ships
EXPRESSYesFaster delivery, with tracking

Prices depend on the shipping method and are set for your account. Delivery time depends on the destination.

Order status ​

text
PENDING ──► IN_PRODUCTION ──► SHIPPED ──► DELIVERED
   │              │               └──► RETURNED
   └► CANCELED    └► FAILED
StatusMeaningCan cancelWebhook
PENDINGCharged, waiting to be printedYes, full refundNo. The create response already returns it.
IN_PRODUCTIONPrinting has startedNoYes
SHIPPEDMailed. Has a tracking number, except STANDARD.NoYes
DELIVEREDDelivered—Yes
FAILEDNot mailed because of a photo or address problem. Refunded.—Yes
RETURNEDReturned to us as undeliverable—Yes
CANCELEDCanceled. Refunded.—Yes

Sandbox orders ​

Set "isSandbox": true to test your integration in either environment. A sandbox order goes through the same checks as a real one, but it is never charged, printed, or mailed, and notifyRecipient is ignored.

A sandbox order moves to the next status about once a minute, so you receive the full set of webhooks within a few minutes. testScenario picks the path:

testScenarioStatus path
DELIVEREDPENDING → IN_PRODUCTION → SHIPPED → DELIVERED
FAILEDPENDING → IN_PRODUCTION → FAILED, with statusReason: "ADDRESS_UNDELIVERABLE"
RETURNEDPENDING → IN_PRODUCTION → SHIPPED → RETURNED
UNTRACKEDLike DELIVERED, but SHIPPED has no tracking number, as with STANDARD

Sandbox tracking numbers start with TEST, for example TEST0000000000000001, and trackingUrl is null. Webhooks carry "isSandbox": true. A sandbox order cannot be turned into a real order: create a new order with "isSandbox": false.

Webhooks ​

We send a POST to your webhook address each time an order changes status. Each account has one webhook address per environment. Set or change it on the Print & Mail page of the Dashboard, under Webhook. The address must use HTTPS. The same page has a Send test webhook button that sends a PRINT_WEBHOOK_TEST message and shows the HTTP status your server returned.

EventWhenWhat you usually do
PRINT_ORDER_IN_PRODUCTIONPrinting started. The order can no longer be canceled.Update the order status
PRINT_ORDER_SHIPPEDMailedSend trackingNumber and trackingUrl to your customer
PRINT_ORDER_DELIVEREDDeliveredClose the order
PRINT_ORDER_FAILEDPhoto or address problem. Refunded.Ask your customer to fix it and order again
PRINT_ORDER_RETURNEDReturned as undeliverableConfirm the address with your customer
PRINT_ORDER_CANCELEDCanceled. Refunded.Update the order status
PRINT_BALANCE_LOWBalance fell below the thresholdAdd funds
PRINT_WEBHOOK_TESTYou clicked Send test webhook on the DashboardCheck that your server receives and verifies it

Example ​

http
POST https://api.example.com/hooks/idphoto
Content-Type: application/json
X-IDP-Timestamp: 1763421600
X-IDP-Signature: 5f2b9c...e1
User-Agent: IDPhoto-Webhook/1.0
json
{
  "eventId": "evt_01JD9A2B3C4D5E6F7G8H9J0K1M",
  "event": "PRINT_ORDER_SHIPPED",
  "occurredAt": "2026-11-17T23:20:00Z",
  "attempt": 1,
  "isSandbox": false,
  "data": {
    "orderId": "po_01JD8X5Q7R2M3N4P5S6T7V8W9X",
    "externalOrderId": "10023",
    "status": "SHIPPED",
    "statusReason": null,
    "shippingMethod": "TRACKED",
    "trackingNumber": "LX123456789US",
    "trackingUrl": "https://tracking.example.com/LX123456789US",
    "shippedAt": "2026-11-17T23:20:00Z"
  }
}

data has the same fields as Get an order, without history. The example above is shortened. PRINT_BALANCE_LOW carries balance and lowBalanceThreshold instead of an order. PRINT_WEBHOOK_TEST has isSandbox: true and carries only a message. It is signed the same way as every other message.

Verify the signature ​

X-IDP-Signature is the lowercase hex HMAC-SHA256 of timestamp + "." + raw request body, keyed with your API secret. Reject a message when the signature does not match or the timestamp is more than 5 minutes from your clock.

js
import crypto from "node:crypto";

// rawBody must be the exact string received. Do not parse and re-serialize it.
function verify(rawBody, timestamp, signature, apiSecret) {
  if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;
  const expected = crypto
    .createHmac("sha256", apiSecret)
    .update(`${timestamp}.${rawBody}`)
    .digest("hex");
  return expected.length === signature.length &&
    crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(signature));
}
python
import hashlib, hmac, time

def verify(raw_body: bytes, timestamp: str, signature: str, api_secret: str) -> bool:
    if abs(time.time() - int(timestamp)) > 300:
        return False
    expected = hmac.new(api_secret.encode(), f"{timestamp}.".encode() + raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, signature)

Delivery rules ​

  • Return HTTP 2xx within 10 seconds, then process the message. If we do not get a 2xx, we retry up to 3 times: after 10 seconds, 30 seconds, and 60 seconds. Each retry has a new attempt number and its own signature.
  • A message can arrive twice. Deduplicate by eventId.
  • Messages can arrive out of order. Use the newer occurredAt, or call Get an order for the current status.
  • If you miss a message, call Get an order or List orders. You can also poll these endpoints instead of using webhooks.

We print on 4×6 inch photo paper at 300 DPI, with at least a 0.25 inch white border. Photos are placed edge to edge, centered, at their exact printed size. The number of photos per sheet depends on the size:

Photo sizePhotos per sheetSheets for 1 pairSheets for 5 pairs
2×2 in (US passport and visa)215
35×45 mm (Schengen, UK, and many others)612
33×48 mm (China visa)413
50×70 mm215
3×4 in1210

Any passport, visa, or ID photo size is accepted. A large photo that fits only once on a sheet is printed one per sheet. A size larger than the printable area of a 4×6 inch sheet (about 3.5×5.5 inches) returns 400 PHOTO_SIZE_NOT_PRINTABLE. The price depends only on the number of pairs, not on the number of sheets.

Error codes ​

Errors use this format:

json
{
  "statusCode": 402,
  "errorCode": "INSUFFICIENT_BALANCE",
  "message": "Your Print & Mail balance is $0.00, which is not enough for this order ($4.00). To add funds, contact support@idphoto.ai. Sandbox orders (isSandbox: true) are free."
}

Use errorCode in your code. message is for people and can change. For a field validation error, message is a list of the fields that failed.

HTTPerrorCodeMeaning
400INVALID_PARAMSA field is missing or has the wrong format
400INVALID_PHOTO_INPUTNeither or both of photoUuid and photoImage were sent
400INVALID_PHOTO_IMAGEThe image cannot be read, is not JPEG or PNG, or is over 5 MB
400INVALID_PRINT_SIZEprintSize is missing, not allowed, or does not match the image
400PHOTO_RESOLUTION_TOO_LOWBelow 200 DPI at the printed size
400PHOTO_SIZE_NOT_PRINTABLEThe photo is larger than a 4×6 inch sheet
400INVALID_ADDRESSA required address field is missing or has the wrong format for the country
402INSUFFICIENT_BALANCEThe balance does not cover the order. New accounts start at $0.00. To add funds, contact support@idphoto.ai.
403AUTH_FAILEDWrong key or secret, an inactive account, or a key from the other environment
403PRINT_NOT_ENABLEDPrinting has been turned off for this account. Contact support@idphoto.ai.
404PHOTO_NOT_FOUNDThe photo does not exist or belongs to another account
404ORDER_NOT_FOUNDThe order does not exist or belongs to another account
409IDEMPOTENCY_CONFLICTThe idempotencyKey was used with different fields
409ORDER_NOT_CANCELABLEPrinting has started
429RATE_LIMITEDToo many requests
429SANDBOX_LIMIT_REACHEDDaily sandbox order limit reached
500INTERNAL_ERROROur error. Retrying with the same idempotencyKey is safe.

Support ​

To add funds, get a test environment, or ask about an order, contact support@idphoto.ai.