FourBySix Partner API
FourBySix prints photos. You send us an order over one REST endpoint; we pull the
images out of your storage and print them. That is the entire integration. There is
no SDK to embed, no payment flow to wire up, and no library to install.
If you want to show your customer their card before they order, one more endpoint
renders its back exactly as we will print it:
POST /v1/previews/back. It is optional.
Read this part first
Every item in an order carries a source.url pointing at an image in your storage,
normally a presigned URL. We start downloading within seconds of your request.
If a URL has already expired when we reach it, that item is dead and so is the order.
There is no retry, no callback asking you for a fresh URL, and no endpoint to push one
to. The order stops in blocked and your only option is to submit a new order under a
new order_ref.
This is the one thing integrations get wrong, so:
- Mint presigned URLs immediately before you POST, not when the customer starts
their session. A URL minted at checkout and submitted after a twenty-minute review
step is the classic failure.
- Give them a TTL of at least 15 minutes. There is no upper bound we care about.
- If you queue orders internally, mint the URLs at the point of sending, not the point
of queueing.
- Make sure the URLs are reachable from the public internet. VPC-only endpoints,
IP allowlists and URLs that require your own auth headers will all fail.
Everything else in this document is ordinary REST.
Quickstart
curl -X POST https://api.fourbysix.co/v1/orders \
-H "Authorization: Bearer sk_fourbysix_…" \
-H "Content-Type: application/json" \
-d '{
"spec_version": "1.0",
"order_ref": "YOUR-ORDER-1",
"order_type": "photo_print",
"items": [
{
"item_ref": "p1",
"role": "print",
"source": { "url": "https://your-bucket.example/photo.jpg?X-Amz-Signature=…" },
"print": { "size": "4x6" }
}
]
}'
{
"order_id": "01m2qt7q87qrm9axn9gjp3xf2h",
"order_ref": "YOUR-ORDER-1",
"state": "received",
"items": [
{ "item_id": "01m2qt7q879m7p7bqqbxzf27y3", "item_ref": "p1",
"role": "print", "state": "pending_fetch" }
],
"status_url": "https://api.fourbysix.co/v1/orders/01m2qt7q87qrm9axn9gjp3xf2h"
}
202 means we have durably recorded the order and queued its images for download. It
does not mean the images arrived; poll status_url for that.
Authentication
Authorization: Bearer sk_fourbysix_…
We issue your key and show it once; we store only a hash, so we cannot recover it for
you. Keep it server-side: it is a secret key, and there is no browser-safe variant.
| Situation |
Status |
| Missing, unknown, revoked or expired key |
401 unauthorized |
| Valid key, suspended account |
403 partner_suspended |
You can hold several live keys at once, which is how you rotate without downtime: ask
us for a new one, deploy it, then ask us to revoke the old one.
POST /v1/orders
Envelope
| Field |
Required |
Notes |
spec_version |
yes |
"1.0". We accept any 1.x and reject everything else. |
order_ref |
yes |
Your own order id. This is the idempotency key (see below). Unique per partner, max 200 chars. |
order_type |
yes |
photo_print or postcard |
items |
yes |
1–200 items (your account limit is in GET /v1/me) |
submitted_at |
no |
ISO 8601. Defaults to when we received it. |
priority |
no |
standard (default) or rush |
customer_ref |
no |
Opaque. Stored with the submitted order, never interpreted, and not returned in GET /v1/orders/{id}. |
shipping |
no |
Where the package goes. Stored verbatim. Required on a postcard, in the shape given under Postcards. |
metadata |
no |
Free-form object, 4096 bytes max serialized. |
Unknown keys are rejected, not ignored. If you send customerRef instead of
customer_ref you get a 400 naming the field. This is deliberate: silently dropping
a field you thought we were reading is a much worse outcome than a loud failure.
Item
| Field |
Required |
Notes |
item_ref |
yes |
Your id for this image. Unique within the order. |
role |
yes |
print or postcard_front (and postcard_back in the earlier postcard shape; see Postcards) |
source |
yes |
See below |
print |
yes |
See below |
quantity |
no |
Copies to print. Defaults to 1, max 1000. |
enhance |
no |
{"profile": "default" | "none"}; none skips image enhancement |
back |
no |
What goes on the back we print. {"qr_url": "https://…"} puts your own link in a QR code on the back; see Where the QR code points. Absent means no code. {"location": false} leaves the map and place off; see Leaving the location off. {"cobrand": "NAME"} prints a name beside ours; see Your name on the back. On a postcard, also message, signature and voice; see Postcards. |
source
| Field |
Required |
Notes |
url |
yes |
https only. Up to 8192 characters, so long presigned URLs are fine. |
content_type |
no |
e.g. image/jpeg. Helps when the URL path has no file extension. |
filename |
no |
Cosmetic, and a useful extension hint. |
sha256 |
no |
Hex digest. If you send it we verify it and fail the item on a mismatch. |
Supported formats: JPEG, PNG, TIFF, WebP, HEIC/HEIF, and DNG, CR2, CR3, NEF,
ARW, RAF, ORF, RW2 raw.
We identify the format from the file's own bytes, so an image served as
application/octet-stream from a URL with no extension works fine. That is the normal
shape of a presigned URL and we handle it. Equally, an image served under the wrong
extension is handled by what it actually is. But something that is not an image at all
is refused rather than stored, even if the URL claims otherwise.
Send the original
Send the file the camera produced, unmodified. This matters more than anything else
in this document, because when it is wrong the order still succeeds and the print is
simply worse.
Do not resize to the print dimensions for us, and do not re-encode. We enhance first
and fit to the print afterwards, and enhancement at full resolution followed by a
downsample is measurably better than enhancement at 4x6: sharper and cleaner, because
the downsample averages away noise and compression artifacts. Resizing first also puts
a generation of JPEG loss in front of the enhancement, and it throws away the room a
customer needs to zoom in (see Framing below).
Resizing tends to cost the colour profile too. A camera original carries one; most
resize and export tooling drops it unless told not to, and a photo whose profile has
gone missing is read as sRGB, which, for the Display P3 an iPhone actually produces,
means every colour is slightly wrong with nothing reporting an error. Sending the
original avoids the whole question.
print
| Field |
Required |
Values |
size |
yes |
"4x6", the only size today |
zoom |
no |
1.0 (default) fits as much of the photo as the print allows; 2.0 is twice the magnification. |
center |
no |
{"x": 0.5, "y": 0.5} (default): where the middle of the print sits on the photo. |
There is no finish. The paper goes with the product and is not yours to
pick: photo prints come on double-sided luster, postcards on thick matte card.
finish was required here until November 2026, when it had one legal value
and chose nothing. If you still send it, nothing breaks: it becomes one of the
unknown keys this block keeps (see below), and it is ignored.
Framing
By default we centre-crop: we take the largest part of the photo that fits the
print's shape, from the middle. If your app lets someone pinch and drag a photo, send
us where they left it instead; otherwise that work is discarded and the print is our
guess.
Send zoom, center, or both:
{
"size": "4x6",
"zoom": 1.8,
"center": { "x": 0.42, "y": 0.35 }
}
zoom is 1.0 or more. 1.0 is the default centre crop, the most of the photo
the print's shape can hold, so sending 1.0 changes nothing. 2.0 halves how much
of the photo you see in each direction. Below 1.0 is clamped to 1.0: there is no
more photograph to show, and the frame has to be filled.
- There is no upper limit, and that is not the same as anything going. A 4x6 at
300dpi is 1800x1200, so zoom until the window is smaller than that and the print
comes out soft. We upscale rather than refuse, because refusing an order at the
printer helps nobody. On a 12MP phone photo the window starts at 4032px wide, so
anything up to about 2.2x is free; past that you are spending resolution. Work
the limit out from the photo you actually have rather than picking a number.
center is where the middle of the print lands, as fractions of the image.
{"x": 0.5, "y": 0.5} is the middle; {"x": 0.0} is hard against the left edge. If
the requested centre would put the frame off the edge of the photo we slide it back
on, so you can send a gesture's raw value without clamping it yourself.
- Either may be sent without the other.
Fractions rather than pixels throughout, so the framing still means the same thing
after anyone resizes anything, on your side or ours. And no aspect ratio to compute:
we derive the window from the print, so a second print size would not change your code.
Three things to know:
center is measured on the image as displayed, after any EXIF orientation is
applied (see Orientation below). A phone photo is usually stored sideways with a
tag saying so; computing against the stored pixels puts the frame somewhere else
entirely. This is the single most common way to get this wrong.
- We frame after enhancement, not before, so the enhancement still sees the whole
photograph.
- Framing cannot change the orientation. The window always has the print's shape in
the photo's own orientation (again, see below).
Anything we cannot use (a zoom that is not a number, values outside 0–1) falls
back to the centre crop and the order still prints. We will not fail an item over
framing.
Orientation
The print's orientation is taken from the photo, and there is no field for it. A
portrait photo prints portrait; a landscape photo prints landscape. You do not send
anything, and there is nothing to get wrong.
EXIF orientation is honoured. We auto-orient before doing anything else, so a phone
photo whose pixels are stored sideways with a tag saying so prints the right way up. It
is the displayed shape that decides, not the stored one: a file that is 4032x3024 on
disk with a rotation tag is a portrait photo to us, and prints portrait.
That is the other reason to send the camera original rather than a re-encode: rotating
a photo by rewriting its pixels, or stripping EXIF while doing something else, is how a
picture arrives claiming to be a shape it is not.
Framing does not affect it. zoom and center choose a region that already has the
print's shape in the photo's own orientation, so no amount of zooming or panning turns a
landscape print portrait.
Other unknown keys inside print are accepted and stored verbatim, the one place
in the API where that is true. This is the forward-compatibility hatch: when we add more
print geometry (bleed, rotation) you will be able to send it without waiting for a new
spec version, and anything we do not understand today is preserved rather than dropped.
Where the QR code points
The back of a photo print or a postcard can carry a small QR code, about 0.9 inch square, in
the bottom corner, linking to a page of yours for that print. We don't host
pages for prints, so the code is only there if you give us the link, per item:
back |
The QR on that print's back |
absent, {}, or {"qr_url": null} |
No code and no caption. The corner is left blank; nothing else on the back moves. |
{"qr_url": "https://…"} |
Exactly your URL, character for character, captioned "Scan for more". |
{
"item_ref": "p1",
"role": "print",
"source": { "url": "https://media.example.com/o/841/IMG_9243.jpeg?X-Amz-Signature=…" },
"print": { "size": "4x6" },
"back": { "qr_url": "https://example.com/p/k3x9q2" }
}
Rules for qr_url, all enforced with a 400:
- https only, with a host.
- At most 100 characters. The code is printed at a fixed size, so every
character makes its squares smaller; past about 100 it stops scanning reliably
off paper. Shorter is better: a host and a short id is ideal.
- URL characters only (RFC 3986):
no spaces, no non-ASCII, no
{ } " < >. Percent-encode anything else.
back is strict, like everything else outside print: an unknown key inside it
is rejected.
We never visit the URL. We encode it and print it, so it must keep working for
as long as the print exists, which is years, not the length of a session. Treat
it as public: anyone holding the print can read it, so it should identify a page,
not carry a credential or a customer's details.
back is part of the order body, so changing it under the same order_ref is a
409, like any other change (Idempotency).
Leaving the location off
The back of a photo print or postcard shows where the photo was taken (a small map, the place
name and the coordinates), read from the GPS in the file. A customer may not want
that on a print, most often for a photo taken at home. Send location: false and
that back has none of it, whatever the file contains:
back.location |
The back |
absent or true |
The map, place and coordinates, if the file has GPS. |
false |
No map, place or coordinates. The panel gets a few lines to write on instead, exactly like a photo with no location. The date and time stay. |
"back": { "qr_url": "https://example.com/p/k3x9q2", "location": false }
- It is
true or false, nothing else; "no", 0 or null are a 400.
- The coordinates are not just left undrawn: we never read them, so they are never
sent to the map and place-name services we otherwise use to draw the back.
- It changes only the printed back. The image file is yours and we do not edit
its metadata; if you show the original to anyone, strip the GPS yourself.
Your name on the back
The bottom of every back we print reads PRINTED BY FOURBYSIX. It can carry
a second name beside ours, joined by two small rings (PRINTED BY FOURBYSIX ⚭
WITH YOUR NAME), in our type and our ink, at the same size. A name we have
agreed with you can be set on your account, so every print carries it; send
cobrand on an item to use a different one for that print, such as one of your
own customers' brands:
"back": { "qr_url": "https://example.com/p/k3x9q2", "cobrand": "CHARLESTOWN PLAYHOUSE" }
Rules, all enforced with a 400:
- At most 24 characters, so it fits beside ours on one line.
- Letters, digits, spaces and
& ' . - only, starting and ending with
a letter or digit. It is printed in capitals whatever case you send.
- A name, nothing more. There is no logo, colour or caption to go with it.
null or absent uses the name on your account, if there is one; with neither,
the back carries our name alone.
Postcards
A postcard order is exactly one item: a postcard_front, quantity 1, which is
the photo on the front. We print the back. It is the same back a photo print
gets (the map of where the photo was taken, the date, your QR code and our name
with yours) with your customer's message set in the space beside the map. The
card is mailed in an envelope with the address printed on the envelope, so the
back carries no address and needs no room for a stamp.
{
"item_ref": "card",
"role": "postcard_front",
"source": { "url": "https://media.example.com/o/77/lake.jpg?X-Amz-Signature=…" },
"print": { "size": "4x6" },
"back": {
"qr_url": "https://example.com/c/8q4kx2",
"message": "Dear Ava,\n\nThe garden is finally blooming. We miss you!",
"signature": "Love, Grandma",
"voice": true
}
}
back field |
Meaning |
message |
The message, printed as sent. Up to 400 characters and 8 lines; \n starts a new line. Absent or null: no message, and the back is a photo print's. |
signature |
One line under the message, set in bold. Up to 40 characters, no line breaks. |
voice |
true when the page your QR code opens has a voice recording on it. The caption under the code then reads "Scan to hear a voice message" under a small orange waveform, instead of "Scan for more". Needs qr_url. The recording stays yours: we never receive it and never ask for it. |
The message panel is sized to the message. A short note sits beside most of the
map; a longer one takes more of it, and the type gets smaller only after that.
At the limits above everything fits; the longest messages may take the whole
panel, and that card prints without its map.
Rules, all enforced with a 400:
- Letters, digits and ordinary punctuation only: Latin letters with their
accents, curly quotes, dashes, the ellipsis, the euro sign. No emoji or
other symbols. They would print as empty boxes, so we refuse them rather than
print that.
message, signature and voice are postcard only. On a print item they
are rejected.
shipping is required, because it is the only place the address now comes
from. It is printed on the envelope and nowhere else. On a postcard it has
exactly this shape (every field a single line of up to 100 characters; line2
optional, and region (the state) required only when country is US; any
other key is a 400):
"shipping": {
"name": "Ava Reyes",
"line1": "417 Montgomery St",
"line2": "Floor 5",
"city": "San Francisco",
"region": "CA",
"postal_code": "94104",
"country": "US"
}
A postcard is one card to one address. For another card, or another copy, send
another order. You cannot mix postcards and prints in one order either.
What the back looks like
To show your customer the real back before they order, ask
POST /v1/previews/back: it is rendered by the same code,
in the same type, that prints the card. These three were made that way:



The back follows the front: a landscape photo gets a landscape back. If you
draw your own instead, these are its proportions, which hold at any size (S
is the short edge):
| Part |
Where and how big |
| Map |
The top of the card, edge to edge, down to a hairline about 56% of the way down (71% on a portrait card, where the message band sits inside it). A heart marks where the photo was taken. No location: no map, and the message takes the whole panel. |
| Message panel (landscape) |
The right of the map panel, behind a vertical hairline. It starts at 35% of the width and widens to 45%, 55% and 65% as the message needs. |
| Message panel (portrait) |
A band across the bottom of the map panel. It starts at 40% of its height and grows to 55% and 70%. |
| Message type |
4% of S (about 11.5pt), shrinking to 2.8% (about 8pt) only once the panel has stopped growing. Line height about 1.5. Signature in bold, at the same size, under a small gap. The longest messages take the whole panel and the card has no map. |
| Caption band |
Below the hairline: the place in bold (4.8% of S), then the date and time, then the coordinates, then PRINTED BY FOURBYSIX ⚭ WITH YOUR NAME. Left margin 10% of S. |
| QR code |
Bottom right, 22.5% of S square, with its caption centred under it in the secondary grey: "Scan for more", or, when voice is true, a small waveform of six rounded bars in #d4552e over "Scan to hear / a voice message". |
We set the card in Nunito Sans,
which is free to use under the SIL Open Font License, so your preview can be
set in it too. Ink
#1c232c, secondary text #55616e and #8b97a3, hairlines #d7dee4, the
heart and the voice waveform #d4552e, map roads #6d7b85 and water #cfdde6
on white. A map you cannot draw can be a pale panel with the heart in the
middle of what is left of it.
The earlier shape: your own rendered back
Until October 2026 a postcard was two items: a postcard_front and a
postcard_back, an image of the back you rendered yourself. That shape is
still accepted, unchanged (its shipping is free-form, as it was), so nothing
breaks if you are sending it today. What we do with your back has changed: we
no longer print it. We read it (the QR code, the message and the sign-off
line under it) and set what it says on our back, as above. If we cannot read it
with confidence, we print your card as you made it, so a card is never held up.
Reading text back off an image is never as exact as being sent it: straight
quotes may come back where you had curly ones, for instance. Please move to the
one-item shape when you can. Send the message in back or a postcard_back
image, not both: that is a 400.
postcard_back defaults to enhance.profile: "none".
Idempotency
order_ref is unique per partner, which makes retrying a request that timed out safe.
| You send |
We do |
Same order_ref, byte-identical intent |
200 with the original response. Nothing is queued twice. |
Same order_ref, different body |
409 order_ref_conflict. Nothing changes. |
Comparison is on a canonical form, so key order and whitespace do not matter;
reserializing your payload will not trip a conflict. It does distinguish 1 from
1.0, since those are genuinely different JSON values.
We will never silently modify an order you already submitted. If you need to change
one, submit a new order under a new order_ref; the conflict response tells you the
order_id of the one that already exists:
{
"error": {
"code": "order_ref_conflict",
"message": "order_ref 'DOC-1' was already submitted with a different body. Use a new order_ref.",
"details": { "order_id": "01m2qt7q87qrm9axn9gjp3xf2h" }
}
}
The practical consequence: retry aggressively on timeouts. A retried POST is free.
GET /v1/orders/{order_id}
Everything we know about an order. This is how you find out what happened.
{
"order_id": "01m2qt7q87qrm9axn9gjp3xf2h",
"order_ref": "DOC-1",
"order_type": "photo_print",
"spec_version": "1.0",
"state": "blocked",
"priority": 100,
"received_at": "2026-09-17T13:52:26.887181Z",
"completed_at": "2026-09-17T13:52:27.003327Z",
"updated_at": "2026-09-17T13:52:27.003363Z",
"mail_state": "unmailed",
"mailed_at": null,
"trimmed_at": null,
"items": [
{
"item_id": "01m2qt7q879m7p7bqqbxzf27y3",
"item_ref": "p1",
"seq": 0,
"role": "print",
"state": "source_expired",
"quantity": 2,
"enhance_profile": "default",
"source_filename": "IMG_9243.jpeg",
"original_ext": "",
"original_bytes": null,
"original_sha256": "",
"stored_at": null,
"spec_json": { "size": "4x6", "bleed_in": 0.125 },
"attempts": 1,
"last_error_code": "source_expired",
"last_error": "Source returned 403; the URL is no longer valid.",
"processed_at": null,
"artifacts": [],
"created_at": "2026-09-17T13:52:26.887619Z",
"updated_at": "2026-09-17T13:52:26.998590Z"
}
]
}
mail_state is unmailed or mailed, and mailed_at is the timestamp when it
flipped. This is a separate axis from state, and it is the one to watch if you
want to tell a customer their prints have shipped. complete means every image
has been processed and stored. It is true well before anything is printed, and
often days before anything is mailed. An order can sit at complete /
unmailed for some time; that is normal and not a fault.
spec_json is your print block as submitted, including any keys we do not yet
interpret. original_key is our internal storage reference, useful to quote in a
support conversation, but not a URL you can fetch. Another partner's order returns
404, not 403.
There is no polling rate limit today, but once a minute is plenty; nothing here moves
faster than the download takes.
Order states
| State |
Meaning |
Terminal |
received |
Accepted, nothing downloaded yet |
|
fetching |
Downloads in progress |
|
ready |
Every image stored; queued for printing |
|
processing |
Partly through production |
|
complete |
Done |
yes |
partial |
Some items succeeded, the rest are dead |
yes |
blocked |
Source URLs expired. Resubmit under a new order_ref. |
yes |
failed |
Dead for other reasons |
yes |
Note what complete does not mean: it is not "printed" and not "mailed". Those
live on mail_state, above, which moves independently and after it.
What we keep
We keep your orders' images only as long as it takes to print and mail them.
Thirty days after an order is mailed, every file belonging to it is deleted:
the photos you sent, the prints we made, thumbnails and postcard photographs.
The thirty days are for reprinting a package lost in the mail. Orders that end blocked or failed printed nothing,
so their files go thirty days after we received them. The order record itself
stays, with no images, for our accounts; trimmed_at says when the files went.
We host no pages for your prints. If you want customers to reach the photo again,
send a qr_url for your own page and serve the photo from your own copy.
Mail states
| State |
Meaning |
unmailed |
Not yet in the mail. The default, including while complete. |
mailed |
Handed to the carrier; mailed_at says when. |
There is no tracking number in the API. Poll for
this like everything else; the one thing we will push to you is described under
Callbacks, and mailing is not it.
Item states
pending_fetch ──▶ fetching ──▶ stored ──▶ processed
│
├──▶ fetch_failed (up to 3 attempts in total, then terminal)
└──▶ source_expired TERMINAL, never retried
source_expired means the URL answered 401, 403, 404 or 410. That is a dead
URL rather than a flaky one, so retrying would only waste time; we stop immediately.
POST /v1/previews/back
The back of a card as we will print it: a JPEG, rendered by the same code and
in the same type that prints every card, from the same back block an order
item carries. Use it to show your customer their card before they pay. It
writes nothing and creates no order.
We are never sent the photo. A back is drawn from where and when the photo was
taken, so send those, read from your copy of the original's EXIF.
POST /v1/previews/back
Authorization: Bearer sk_fourbysix_...
Content-Type: application/json
{
"role": "postcard_front",
"orientation": "landscape",
"taken_at": "2026-06-14T15:42:00",
"location": { "lat": 39.9496, "lon": -75.1503 },
"back": {
"qr_url": "https://example.com/c/8q4kx2",
"message": "Dear Ava,\n\nThe garden is finally blooming. We miss you!",
"signature": "Love, Grandma",
"voice": true
}
}
| Field |
Required |
Meaning |
orientation |
yes |
landscape or portrait: the shape of the print, which the back follows. |
role |
no |
print (the default) or postcard_front. As in an order, message, signature and voice are for postcards only. |
taken_at |
no |
When the photo was taken, as the camera wrote it, in its own local time: YYYY-MM-DDTHH:MM:SS. Absent or null: no date line, as for a photo without one. |
location |
no |
Where it was taken, in decimal degrees. Absent or null: no map and no place, as for a photo without GPS. Ignored when back.location is false. |
back |
no |
Exactly an order item's back, validated by the same rules. |
The answer is 200 with Content-Type: image/jpeg, 1200 pixels on the long
edge. Anything the same back would be refused for in an order is a 400 here
too, so a preview is also a check.
| Status |
error.code |
Do this |
503 |
preview_pending |
We are fetching the map for a place we have not drawn before, which can take up to a minute. Wait for the Retry-After header's seconds and send the same request again. After that, the same place takes a few seconds. |
422 |
does_not_fit |
The message cannot fit on a card of this shape. An order with this back would be accepted and then fail at the printer, so shorten it first. |
429 |
rate_limited |
Too many previews at once. Wait a minute. |
503 |
preview_unavailable |
Previews are down. Your orders are not affected. |
Ask for a preview when your customer reaches the step where they look at their
card, not on every keystroke: each new place costs a lookup on public map
services that our printing depends on as well.
GET /v1/me
Confirms a key works and reports your account limits. Useful as a deploy-time smoke
test.
{
"partner": {
"uid": "295c40bf-a692-4f37-89c8-bc425c8b2cdb",
"slug": "acme",
"name": "Acme Photos",
"max_items_per_order": 200,
"max_source_bytes": 104857600
},
"key": { "last4": "SKqE", "label": "production", "expires_at": null },
"callbacks": { "enabled": false, "url": "" }
}
callbacks.enabled is how you confirm we have actually switched your endpoint on:
both the URL and the signing secret are set by hand at our end, so "I sent you a
URL" and "it is live" are different states. See Callbacks. The signing
secret is never returned by any endpoint.
Callbacks
Opt-in, and off unless you asked. Almost everything in this API is polled: you
call GET /v1/orders/{order_id} whenever you like and we never call you. There is
one exception.
item.proof: photographs of a mailed postcard
If you send postcards, we photograph each finished card on a copy stand before it
goes in the envelope: the front, and the back with the message on it. Those
two photographs are the only thing in this system you cannot usefully poll for,
because by the time you thought to ask, the card is in a mailbox. So we push them.
To turn it on, send us an https:// endpoint. We will send you a signing secret
in return. Both of those come from us by hand; there is no self-serve dashboard.
What arrives
POST to your URL, Content-Type: application/json:
POST /your/hook HTTP/1.1
X-Fourbysix-Event: item.proof
X-Fourbysix-Signature: t=1758470400,v1=5f2c…
Content-Type: application/json
{
"event": "item.proof",
"event_id": "01k5rj8v4h0000000000000000",
"created_at": "2026-09-21T16:20:00+00:00",
"order_id": "01k4t8z9m3q7r2v6w1x5y8a0b2",
"order_ref": "YOUR-REF-1",
"item_id": "01k4t8z9m4b1c2d3e4f5g6h7j8",
"item_ref": "your-item-ref",
"proof": {
"front": {
"url": "https://…signed…",
"expires_at": "2026-09-22T16:20:00+00:00",
"bytes": 4821004,
"sha256": "9f86d0…",
"content_type": "image/jpeg"
},
"back": { "url": "https://…signed…", "…": "…" }
}
}
order_ref and item_ref are yours (the values you sent us), so you do not
need a mapping table. The links are signed and time-limited; download the bytes,
do not store the URL. expires_at tells you how long you have, and it is measured
in hours rather than minutes precisely so the payload can sit in your own queue.
The payload carries nothing else on purpose. No order state, no shipping, no other
items. GET /v1/orders/{order_id} is still where you learn everything else, and a
callback that grew those fields would quietly become a status feed we have not
promised to keep accurate.
Verifying the signature
Do this. The URL is the only thing an attacker needs to post you a convincing
fake, and the photographs are of a real person's address.
X-Fourbysix-Signature is t=<unix seconds>,v1=<hex>, where v1 is
HMAC-SHA256(secret, "<t>.<raw body>"). Verify against the raw bytes you
received, before any JSON parsing; re-serializing the body changes it.
import hashlib, hmac, time
def verify(secret: str, body: bytes, header: str, tolerance: int = 300) -> bool:
parts = dict(p.split("=", 1) for p in header.split(",") if "=" in p)
try:
timestamp = int(parts["t"])
except (KeyError, ValueError):
return False
if abs(time.time() - timestamp) > tolerance: # replay window
return False
expected = hmac.new(
secret.encode(), f"{timestamp}.".encode() + body, hashlib.sha256
).hexdigest()
return hmac.compare_digest(expected, parts.get("v1", ""))
The timestamp is inside the signed string, not merely beside it, so rejecting an
old one actually means something.
Delivery
|
|
| Success |
Any 2xx. Respond quickly; we do not read your body. |
| Retries |
5xx, 429 and connection failures are retried with exponential backoff: twelve attempts spread over about three and a half hours, starting 10 seconds after the first failure. |
| Given up |
Other 4xx are not retried. They mean the request was wrong, and sending it again would loop. |
410 Gone |
Stops retries immediately. Return this if you have decommissioned the endpoint. |
| Redirects |
Not followed. A 3xx is a failed delivery. Give us the final URL. |
| Ordering |
None. Do not assume it. |
| At-least-once |
You may get the same event_id twice. Dedupe on it. |
Two things that will not happen, so you can design around them:
- A failed callback never changes your order. If your endpoint is down for a
day, the cards still print, still mail, and the order still reaches
complete.
You have only missed a notification.
- We will never call you to ask for anything, in particular not for a fresh
source URL. See the top of this document.
If you do miss one, GET /v1/orders/{order_id} will show proof_front and
proof_back in that item's artifacts, so you can always tell whether a card
was photographed. What polling cannot give you is the bytes: r2_key is an
internal reference, not a URL, and the signed links exist only inside a callback.
Ask us and we will re-send it.
Re-shooting
If a photograph was bad we re-take it, and you get a second callback for the
same item_ref with a new event_id. The later one wins. This is not an error
and it is not a duplicate. Treat the most recent created_at for an item as
current.
Rotating the secret
Ask and we will issue a new one. There is no overlap window: the old secret
stops working the moment the new one is issued. Callbacks signed during the swap
fail your check, get retried, and land once you have deployed the new value,
which is survivable rather than elegant, and is the reason the retry window is
hours rather than minutes.
Errors
Every error has the same three fields, on every endpoint:
{ "error": { "code": "…", "message": "…", "details": {} } }
Branch on code. Treat message as human-readable only; we may reword it.
| Code |
Status |
Meaning |
invalid_request |
400 |
Validation failed. details locates the problem. |
unauthorized |
401 |
Missing, unknown, revoked or expired key |
partner_suspended |
403 |
Valid key, inactive account |
not_found |
404 |
No such order for this account |
order_ref_conflict |
409 |
order_ref reused with a different body |
does_not_fit |
422 |
Previews only: the message cannot fit on a card of this shape |
rate_limited |
429 |
Previews only: too many at once; wait a minute |
preview_pending |
503 |
Previews only: the map for a new place is being fetched; retry after Retry-After seconds |
preview_unavailable |
503 |
Previews only: previews are down; orders are unaffected |
For invalid_request, details mirrors the shape of your request. Order-level
problems map a field name to a list of messages:
{ "error": { "code": "invalid_request",
"message": "The request body failed validation.",
"details": { "spec_version": ["Unsupported spec_version '2.0'; this API speaks 1.x."] } } }
Item-level problems are keyed by the item's index in your items array:
{ "error": { "code": "invalid_request",
"message": "The request body failed validation.",
"details": { "items": { "0": { "source": { "url": ["Must be an https URL."] },
"print": { "size": ["Unsupported size '5x7'."] } } } } } }
Note that details.items is an object keyed by index when individual items are at
fault, and a list of strings when the problem is with the collection as a whole
("A postcard order is exactly one postcard_front item.").
Handle both.
Per-item failures are not request errors
If an image fails to download, the request already succeeded. The failure shows up on
the item as state and last_error_code:
last_error_code |
Meaning |
Retried? |
source_expired |
URL returned 401/403/404/410 |
no (terminal) |
upstream_error |
5xx or timeout from your storage |
yes, 3 attempts total |
rate_limited |
429 from your storage (we honour Retry-After) |
yes, 3 attempts total |
bad_source_response |
Another 4xx; retrying cannot help |
no |
unsupported_type |
The bytes are not a supported image |
no |
source_too_large |
Over your per-file limit (see GET /v1/me) |
no |
sha256_mismatch |
Did not match the source.sha256 you declared |
yes, 3 attempts total |
Building a correct integration
- Mint presigned URLs at send time, with a TTL of 15 minutes or more.
- POST the order. Expect
202.
- Retry on timeouts and 5xx with the same
order_ref. Idempotency makes this
free; not retrying loses orders.
- Treat
409 as a bug in your code, not a transient condition: it means you
reused an order_ref for different content.
- Store our
order_id against your own record.
- Poll
status_url until the order reaches a terminal state.
- Alert on
blocked. It almost always means your URLs are expiring before we
fetch them, and every affected order needs resubmitting.
- Do not send a
429-worthy burst of orders; there is no enforced rate limit on
orders today, but that may change.
- Optional: preview the back at the step where your customer reviews their
card, not per keystroke. Previews are rate-limited per account, and a new place
can answer
503 preview_pending for up to a minute: wait and send the same
request again.
Mistakes worth avoiding
- Minting URLs too early. The single most common cause of
blocked orders.
- Assuming
202 means the images arrived. It means the order is recorded.
- Not retrying a timed-out POST. The order may well have been created; retrying
tells you, and costs nothing.
- Reusing an
order_ref across a content change. You get 409 and no order.
- Sending a camelCase field name. Unknown keys are rejected, by design.
- Mixing postcards and prints in one order. Send two.
- Expecting a callback for order status. There is exactly one callback and it
is about postcard proof photographs (Callbacks). Everything else
is polled, including
complete, blocked and mailed.
- Treating a callback as the record. It is a notification. If you did not get
one, ask; if you got one twice, dedupe on
event_id.
Rules the JSON Schema cannot express
order.schema.json covers almost everything, and both example
files validate against it. Two rules it cannot state, which we still enforce:
item_ref must be unique within an order.
items is capped at your account's max_items_per_order, not a fixed 200.
Code
Python
import time
import requests
BASE = "https://api.fourbysix.co"
SESSION = requests.Session()
SESSION.headers["Authorization"] = f"Bearer {API_KEY}"
def submit(order_ref, image_urls):
body = {
"spec_version": "1.0",
"order_ref": order_ref,
"order_type": "photo_print",
"items": [
{
"item_ref": f"p{i}",
"role": "print",
# Presign here, not earlier: the URL has to outlive only this request.
"source": {"url": url},
"print": {"size": "4x6"},
}
for i, url in enumerate(image_urls)
],
}
response = SESSION.post(f"{BASE}/v1/orders", json=body, timeout=30)
if response.status_code == 409:
raise ValueError(f"order_ref {order_ref} already used for different content")
response.raise_for_status()
return response.json()["order_id"] # 200 and 202 are both success
def check(order_id):
order = SESSION.get(f"{BASE}/v1/orders/{order_id}", timeout=30).json()
if order["state"] == "blocked":
expired = [i["item_ref"] for i in order["items"]
if i["last_error_code"] == "source_expired"]
raise RuntimeError(f"source URLs expired for {expired}; resubmit with a new order_ref")
return order["state"]
Retrying on a timeout is just calling submit again with the same order_ref.
Previewing a postcard's back before the order, with the time and place read from
your copy of the photo's EXIF:
def preview_back(orientation, taken_at, lat, lon, back, role="postcard_front"):
body = {"role": role, "orientation": orientation, "taken_at": taken_at,
"location": {"lat": lat, "lon": lon} if lat is not None else None,
"back": back}
for _ in range(12): # a new place can take up to a minute
response = SESSION.post(f"{BASE}/v1/previews/back", json=body, timeout=30)
if response.status_code == 200:
return response.content # JPEG bytes, 1200px on the long edge
code = response.json()["error"]["code"]
if code != "preview_pending":
raise RuntimeError(f"no preview: {code}")
time.sleep(int(response.headers.get("Retry-After", "10")))
raise RuntimeError("preview still pending; try again later")
jpeg = preview_back("landscape", "2026-06-14T15:42:00", 39.9496, -75.1503,
{"qr_url": "https://example.com/c/8q4kx2",
"message": "Dear Ava,\n\nThe garden is finally blooming.",
"signature": "Love, Grandma", "voice": True})
TypeScript
const BASE = "https://api.fourbysix.co";
async function submit(orderRef: string, imageUrls: string[]): Promise<string> {
const response = await fetch(`${BASE}/v1/orders`, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.FOURBYSIX_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
spec_version: "1.0",
order_ref: orderRef,
order_type: "photo_print",
items: imageUrls.map((url, i) => ({
item_ref: `p${i}`,
role: "print",
source: { url },
print: { size: "4x6" },
})),
}),
});
const body = await response.json();
if (!response.ok) {
// 409 means this order_ref was used for different content: a bug, not a retry.
throw new Error(`${body.error.code}: ${body.error.message}`);
}
return body.order_id; // 200 (replay) and 202 (new) are both success
}
// The back of a card, as a JPEG Blob. Retries while a new place's map is fetched.
async function previewBack(request: object): Promise<Blob> {
for (let attempt = 0; attempt < 12; attempt++) {
const response = await fetch(`${BASE}/v1/previews/back`, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.FOURBYSIX_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify(request),
});
if (response.ok) return response.blob();
const { error } = await response.json();
if (error.code !== "preview_pending") throw new Error(`${error.code}: ${error.message}`);
const wait = Number(response.headers.get("Retry-After") ?? "10");
await new Promise((resolve) => setTimeout(resolve, wait * 1000));
}
throw new Error("preview still pending; try again later");
}
Getting set up
Email [email protected]. Tell us the account name you want and whether you need
limits above the defaults (200 items per order, 100 MB per image), and we will send
back a key and confirm your account slug.
Keys are issued by a person. There is no self-service signup and no dashboard.