Images
You add an image in one of two ways: send its public HTTPS URL as source_url on a create or update request, or upload a local file first and send the file_id it returns. With an external URL, Flint downloads the image during that request, checks it, and stores its own copy. The response returns a Flint-hosted url with the image's width and height, and buyers load the image from Flint from then on. Flint contacts your host only while your request runs, so the source can move, expire, or go offline afterward without breaking a checkout.
These fields take images:
| Resource | Field | Holds |
|---|---|---|
| Products | images | Up to 8, in display order |
| Product variants | images | Up to 8, replacing the product's images for that variant |
| Bundles | images | Up to 8 |
| Subscription plans | images | Up to 8 |
| Payment links | image | 1, shown on the link's checkout page |
| Merchant | logo, icon | 1 each, used on checkout, receipts, and emails in every mode |
| Order line items | image | 1, an image Flint already hosts |
How Flint handles an external image#
This is the flow when you send an external source_url. For images on your own machine, see Upload a local file.
- Your backend sends 1. create or update with source_url to Flint
- Flint sends 2. GET source_url to Your image host
- Your image host returns image bytes to Flint
- Flint sends 3. check, strip metadata, store to Flint
- Flint returns the resource with its Flint url, width, and height to Your backend
- Buyer sends 4. load url on checkout or your storefront to Flint
- It happens inside your request. With an external
source_url, there is no separate upload step, webhook, or processing status to poll. When the response arrives, the image is stored and ready, or the request failed and the resource didn't change. - The format stays the same. A JPEG stays a JPEG, and the same goes for PNG and WebP. Flint removes embedded metadata, such as camera details and GPS location, before storing the image.
- An unchanged source isn't downloaded again. On an update, if a
source_urlexactly matches the one that produced an image still attached to the same field of the same resource, Flint keeps that image without contacting your host. See Replace an image behind the same URL. - Identical images share a URL. If the bytes downloaded from an external
source_urlmatch an image you already added in the same mode or sandbox, Flint returns that image'surlrather than storing a second copy, even when thesource_urldiffers. This doesn't apply to local file uploads, which each get their ownfile_idandurl, even when the bytes are identical.
Add images to a product#
You need an API key that can write products. This request creates a product with two images; the first one is the primary image:
curl -X POST https://api.withflintpay.com/v1/products \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: product-travel-mug-001" \
-d '{
"variant_mode": "simple",
"name": "Travel mug",
"product_type": "physical",
"default_variant": {
"unit_price_money": {"amount": 2800, "currency": "USD"}
},
"images": [
{
"source_url": "https://developers.withflintpay.com/examples/travel-mug-front.jpg",
"alt": "Front view of a matte black travel mug",
"source_reference": "media_8421"
},
{
"source_url": "https://developers.withflintpay.com/examples/travel-mug-open.png",
"alt": "Travel mug with the lid open",
"source_reference": "media_8422"
}
]
}'
Flint responds with 201 Created. Abridged:
{
"data": {
"product_id": "prod_01M4VJ7NAZDEN74V4V31X44TG4",
"name": "Travel mug",
"version": 1,
"images": [
{
"url": "https://images.withflintpay.com/canonical/mer_01KJZT86DXN184KEX4XNJHNXP7/live/img_3H5YCG76HTQN4NAZ6AA30966DY/original.jpg",
"alt": "Front view of a matte black travel mug",
"source_reference": "media_8421",
"width": 1600,
"height": 1200
},
{
"url": "https://images.withflintpay.com/canonical/mer_01KJZT86DXN184KEX4XNJHNXP7/live/img_0YGES5CBYTXMBECWS93MFP3C11/original.png",
"alt": "Travel mug with the lid open",
"source_reference": "media_8422",
"width": 1600,
"height": 1200
}
]
}
}
Each item in an images array, and each image, logo, or icon, takes these fields. Send exactly one of source_url and file_id; sending both, or neither, fails with 400 INVALID_REQUEST.
source_urlstringWhere Flint downloads the image: an HTTPS URL of up to 8,192 characters that meets the source requirements. Signed URLs with query strings work, as long as the signature is valid while your request runs. Flint never returns source_url or includes it in an error message. You can also send a url Flint returned earlier, to reuse that image without downloading anything.
file_idstringThe ID of a ready file you uploaded, beginning with file_. Flint attaches the file without downloading anything.
altstringAlternative text for screen readers, up to 512 characters. Flint's checkout uses it, and treats an image without alt as decorative. Describe what a buyer would otherwise miss, such as the color or the item's contents.
source_referencestringYour own reference for the image, such as the asset ID in your media library: 1 to 255 characters. Flint returns it on the image and doesn't interpret it. Spaces and letter case are kept exactly as you send them, so Front and front are different references. It's the stable value to compare when you sync images, since a signed source_url changes every time you sign it.
Within one gallery, each source_url, each file_id, and each source_reference must be unique.
Images on products, variants, bundles, subscription plans, payment links, and the merchant come back with url, width, height, and, when set, alt and source_reference. An image that is a Flint file also includes its file_id, however you attached it. Images on order line items, invoices, public payment links, and other buyer-facing responses return only url, alt, width, and height, so your source_reference and file IDs stay out of them.
Upload a local file#
Use a file upload when the image isn't on a public HTTPS host. You upload the bytes to Flint, then attach the file to the resource by its file_id. The Files reference lists every field and status.
- Create the file with
POST /v1/files. Send thepurpose(product,product_variant,bundle,payment_link,subscription_plan,merchant_logo, ormerchant_icon), the exactcontent_type(image/jpeg,image/png, orimage/webp), andsize_bytesfrom 1 to 5,242,880. - The
201response returns afile_idthat begins withfile_, statusawaiting_upload, and anuploadobject.PUTthe bytes toupload.urlwith every header inupload.headers, exactly as returned. The upload URL expires atupload.expires_at, 15 minutes after creation. - Call
POST /v1/files/{file_id}/completewith no body. The200response returns the file with statusreadyand its Flinturl,width, andheight. If you call it before the bytes arrive, you get409 ACTION_NOT_ALLOWEDwith reasonstatus_not_reachedand the file staysawaiting_upload, so you can finish the upload and complete it again. - Pass the ready file's
file_idin the image field instead of asource_url. Flint attaches it without downloading anything.
curl -X POST https://api.withflintpay.com/v1/files \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"purpose": "product",
"content_type": "image/png",
"size_bytes": 48213
}'
Attach the file when you create or update the resource:
curl -X PATCH https://api.withflintpay.com/v1/products/prod_01M4VJ7NAZDEN74V4V31X44TG4 \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"expected_version": 2,
"images": [
{
"file_id": "file_01J00000000000000000000000",
"alt": "Travel mug on a desk",
"source_reference": "upload_5531"
}
]
}'
An unattached ready file can be attached until its expires_at, 24 hours after it becomes ready. Attaching it removes that deadline. If you remove the image from everything it was attached to, you have 7 days to attach it again.
Call GET /v1/files/{file_id} to check a file at any time. It returns the file's status (awaiting_upload, processing, ready, failed, or expired), a failure_code when it failed, and expires_at while a deadline applies. It never returns the upload URL, so to retry an upload that expired or failed, create a new file.
If a file isn't ready, attaching it fails with 409 ACTION_NOT_ALLOWED with reason terminal_status; read the file to see whether to complete it or upload a new one. An unknown file, or one from another merchant or environment, returns 404 RESOURCE_NOT_FOUND with param such as images[0].file_id.
These checks apply to a new write. Retrying a committed write with the same request and Idempotency-Key returns its original result, even if the file or image can no longer be attached.
To recover a lost response, send an Idempotency-Key on POST /v1/files and repeat the request with the same key. Without a key, create another file; the unused upload expires after 15 minutes. Both write routes accept the key, and a replay returns the original result and keeps the original deadlines.
- Each upload is its own file. Uploading the same bytes twice returns two different
file_idandurlvalues. - Formats and size. Only JPEG, PNG, and WebP images up to 5 MB are accepted, the same as for external URLs.
- Scope depends on
purpose. You need the write scope for the resource, such ascommerce.products.writeforproduct, to create and complete a file, and its read or write scope to read one. Files formerchant_logoandmerchant_iconneedmerchants.profile.writeand a live-mode credential or a Dashboard session in any selected environment. Creating or completing them with a test credential returns403 FORBIDDENwith reasonlive_mode_required. Partner installs cannot be granted the profile scope; a live install credential gets403 INSUFFICIENT_SCOPEwith ascope_requirement. Other file purposes remain writable in their own environment. - Environment. Logos and icons apply to the whole merchant, including from a sandbox. Other files belong to the mode or sandbox that created them.
- Purpose and destination. A
merchant_logofile attaches only as thelogo, and amerchant_iconfile only as theicon. The other purposes attach to any product, variant, bundle, plan, or payment link image.
Show images to buyers#
Use url exactly as returned, and store it if you render images from your own database. Flint image URLs are permanent: the bytes behind a URL never change, so they're served with a one-year immutable cache header. A different image always gets a different URL.
<img
src="https://images.withflintpay.com/canonical/mer_01KJZT86DXN184KEX4XNJHNXP7/live/img_3H5YCG76HTQN4NAZ6AA30966DY/original.jpg"
width="1600"
height="1200"
alt="Front view of a matte black travel mug"
style="max-width: 100%; height: auto"
>
Setting width and height from the response lets the browser reserve space before the image loads, so your layout doesn't jump. The URL serves the stored image at its full size and doesn't accept resizing parameters. Size it with CSS, and don't upload images much larger than your storefront displays them. Don't build or edit Flint image URLs; their paths can change.
Change a gallery#
images on a product, variant, bundle, or subscription plan always holds the complete gallery. Each update replaces the whole array, so there's no call to add or remove one image. Send the full array you want, in display order, along with the resource's current version as expected_version:
| To | Send |
|---|---|
| Leave the gallery as it is | Leave images out. expected_version isn't needed. |
| Replace it | Every image you want, in order. The first is the primary image. |
Reorder it, or change alt | Every image in the new order. Send the same source_url you sent before, or the Flint url or file_id of the image, so nothing is downloaded. |
| Remove one image | Every other image. |
| Clear it | "images": [] |
curl -X PATCH https://api.withflintpay.com/v1/products/prod_01M4VJ7NAZDEN74V4V31X44TG4 \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"expected_version": 1,
"images": [
{
"source_url": "https://images.withflintpay.com/canonical/mer_01KJZT86DXN184KEX4XNJHNXP7/live/img_0YGES5CBYTXMBECWS93MFP3C11/original.png",
"alt": "Travel mug with the lid open",
"source_reference": "media_8422"
},
{
"source_url": "https://images.withflintpay.com/canonical/mer_01KJZT86DXN184KEX4XNJHNXP7/live/img_3H5YCG76HTQN4NAZ6AA30966DY/original.jpg",
"alt": "Front view of a matte black travel mug",
"source_reference": "media_8421"
}
]
}'
This swaps the two images without downloading either. The response has the same URLs in the new order. Abridged:
{
"data": {
"product_id": "prod_01M4VJ7NAZDEN74V4V31X44TG4",
"version": 2,
"images": [
{
"url": "https://images.withflintpay.com/canonical/mer_01KJZT86DXN184KEX4XNJHNXP7/live/img_0YGES5CBYTXMBECWS93MFP3C11/original.png",
"alt": "Travel mug with the lid open",
"source_reference": "media_8422",
"width": 1600,
"height": 1200
},
{
"url": "https://images.withflintpay.com/canonical/mer_01KJZT86DXN184KEX4XNJHNXP7/live/img_3H5YCG76HTQN4NAZ6AA30966DY/original.jpg",
"alt": "Front view of a matte black travel mug",
"source_reference": "media_8421",
"width": 1600,
"height": 1200
}
]
}
}
expected_versionis required wheneverimagesis in an update. Without it, the request fails with400 INVALID_REQUEST. If the resource changed since you read it, or an image write lost a race with another write, the request fails with409 VERSION_CONFLICT.details[0].current_versionis the version Flint saw, which can equal the one you sent after a lost race. Read the resource again, rebuild the request, and send it with a newIdempotency-Key.- Variant updates also change the product's
version. Read the product again after updating one of its variants and before updating the product's own gallery. - An unchanged gallery changes no images. If the gallery you send matches the current one, Flint keeps the same images and doesn't record an image change. The update still follows the resource's usual rules, such as advancing
versionwhere it has one. - Variant galleries are set on the variant with
PATCH /v1/products/{product_id}/variants/{variant_id}, which has its ownversion.
You can change a gallery while the item is on sale, in an open order or checkout, or part of a payment link, subscription plan, or subscription. Orders, invoices, subscription plans, and subscriptions keep the image they already have, and new checkouts show the new one.
Replace an image behind the same URL#
Flint treats a source_url as naming fixed content. When an update repeats the exact source_url of an image that is still attached to that field, Flint keeps the image and doesn't download the URL again, even if the bytes behind it have changed. The match is on the exact string, including the query string, and only against the same field of the same resource: a product's images and a variant's images are separate fields.
To replace the bytes behind a stable URL, send a different URL, such as one with a version query parameter (travel-mug-front.jpg?v=2), or upload a file. A signed URL changes each time you sign it, so Flint downloads it again.
Payment link images and store branding#
A payment link's image and the merchant's logo and icon hold one image each. Unlike a gallery, they don't need expected_version. Send it anyway, with the version you read, to detect a concurrent edit to the link or the merchant profile:
- Leave the field out to keep the current image.
- Send an image object to replace it.
- Send
nullto remove it.
Update logo and icon with PATCH /v1/merchant. They belong to your whole account, so the same logo and icon appear in live mode and every sandbox, and require a live-mode credential or a Dashboard session in any selected environment. A test credential cannot set or clear them and gets 403 FORBIDDEN with reason live_mode_required. A logo URL only works as a logo, and an icon URL only as an icon. An icon must be square and at least 128 by 128 pixels; anything else fails with 400 INVALID_REQUEST and detail code INVALID_VALUE.
Variant images#
A variant either shows its product's images or replaces them with its own:
what you set
images
The variant's own gallery. Empty means the variant uses the product's images. Read and write this field when you sync your catalog.
what buyers see
effective_images
The gallery to display: the variant's own images if it has any, otherwise the product's. images_inherited is true when they come from the product. Render this field in your storefront.
A variant gallery replaces the product's images completely; the two are never combined. To return a variant to the product's images, update the variant with "images": [] and its expected_version.
Images on orders, invoices, and subscriptions#
When an order includes a catalog item, its line item image is the item's primary image at that moment: the first of the variant's effective_images, or of the bundle's images. Subscription line items work the same way, and invoices show their order's line items. The line item keeps that image, so later catalog changes don't alter orders, invoices, or subscriptions that already exist. These images return only url, alt, width, and height.
A line item you describe yourself, without a variant_id or bundle_id, can show an image Flint already hosts. Pass its url in image:
{
"type": "custom",
"name": "Engraving",
"quantity": 1,
"unit_price_money": {"amount": 500, "currency": "USD"},
"fulfillment": {"requirement": "none"},
"tax": {"taxable": false},
"image": {
"url": "https://images.withflintpay.com/canonical/mer_01KJZT86DXN184KEX4XNJHNXP7/live/img_3H5YCG76HTQN4NAZ6AA30966DY/original.jpg",
"alt": "Engraved travel mug"
}
}
Creating an order never downloads an image. Any other URL fails with 400 INVALID_REQUEST and detail code NOT_ALLOWED. To show an image that Flint doesn't host yet, add it to a product, bundle, plan, or payment link first, then use the url from that response.
Reuse an image without downloading it again#
Anywhere an image field takes source_url, you can send a url Flint returned instead. Flint looks the image up and attaches it without contacting any outside host, so the request is faster, and repeated requests can't fail because of your image host. Use this to copy an image from one resource to another. Send the url exactly as returned.
The url must come from the same mode or sandbox: a sandbox image can't be used in live mode, and one merchant can't use another's images. To attach an image you uploaded, send its file_id instead.
An image stays reusable while it's attached anywhere, including to an order. Once you remove it from everything, you have 7 days to attach it again, and its URL keeps loading for buyers during that time. After that, the request fails with 409 ACTION_NOT_ALLOWED with reason terminal_status; send the original source_url again. An unknown URL, or one from another mode, sandbox, or merchant, fails with 404 RESOURCE_NOT_FOUND, with param naming the image field.
Keep images in sync with your catalog#
If your products live in another system, such as a PIM or an ecommerce platform, a sync can resend the stable URLs of images that didn't change: Flint doesn't download an image again while its exact source_url is still attached to the field. A signed URL is different each time, so it is downloaded again. Your sync decides when to skip a request and which URL to send:
- Save your media ID as the
source_referenceof each image you add. - On each sync, build the gallery from your media records in display order, with each record's ID as
source_reference. - If the gallery's order,
source_referencevalues, andalttext all match what Flint has, and no image changed, skip the request. - Otherwise, send the full gallery with the
versionyou last read asexpected_version. For an image that didn't change, send the samesource_urlas last time. If your URLs are signed, each signature is a different URL that Flint downloads again, so send the saved Flinturlof unchanged images instead. Send your own URL for new images. For an image whose bytes changed, send a new URL (see Replace an image behind the same URL). On409 VERSION_CONFLICT, read the resource again and repeat from step 2.
// mediaRecords: your images for one product, in display order, each with
// { id, url, altText, changedSinceLastSync }.
// product: the product as Flint last returned it.
// Returns the PATCH body, or null when nothing changed.
function galleryUpdate(mediaRecords, product) {
const inFlint = new Map(
product.images.map((image) => [image.source_reference, image]),
);
const unchanged =
mediaRecords.length === product.images.length &&
mediaRecords.every((media, i) => {
const current = product.images[i];
return (
!media.changedSinceLastSync &&
media.id === current.source_reference &&
(media.altText ?? "") === (current.alt ?? "")
);
});
if (unchanged) return null;
const images = mediaRecords.map((media) => {
const existing = inFlint.get(media.id);
const reuse = existing && !media.changedSinceLastSync;
return {
// Flint's own url is never downloaded again, even when yours is signed.
source_url: reuse ? existing.url : media.url,
alt: media.altText ?? undefined,
source_reference: media.id,
};
});
return { expected_version: product.version, images };
}
One request can download at most 32 images from outside hosts, with no more than 100 megapixels in total. Flint downloads them a few at a time, and the request fails with 504 REQUEST_TIMEOUT if they take more than 30 seconds altogether. To bring in a large catalog, send each product's images in its own request.
Source requirements#
Flint checks each external source_url and the image it returns. The URL, redirect, and response rows apply only to external URLs. Local file uploads accept the same formats and the same 5 MB limit.
| Requirement | Limit |
|---|---|
| URL | https:// on port 443. No user name or password, no #fragment, and a hostname rather than an IP address. |
| Redirects | Up to 3, each to a URL that meets the same rules. |
| Response | A 2xx with the image bytes, uncompressed (no Content-Encoding), within 10 seconds including redirects. |
| Format | JPEG, PNG, or WebP. Animated PNG and WebP images and GIFs aren't supported. |
| File size | 5 MB |
| Dimensions | 1 to 12,000 pixels on each side, and at most 40 megapixels |
| Per request | 32 images from outside hosts, 100 megapixels in total |
Flint requests images with the user agent Flint-Image-Ingestion/2.0. If your image host blocks automated traffic, allow that user agent.
Handle errors#
Image errors use the standard error envelope. error.param points to the exact field, such as images[1].source_url or variants[3].images[0].source_url. When several images fail in one request, error.details lists each one. If an invalid image and a source timeout occur together, the response is 400 INVALID_REQUEST with one INVALID_VALUE detail per failed image. The error and every detail have retry none, including the timeout detail. Correct the invalid images, then send the request with a new key.
To decide whether to retry, read error.remediation:
409 ACTION_NOT_ALLOWEDwithdetails[0].reasonimage_ingestion_restart_required: this attempt is over, and resending the sameIdempotency-Keyreplays the same error. Fix the cause if the error names one, then send the request with a new key, or without one.retryissame_requestwith no such action: retry the same request with the same key afterRetry-Afteror a short wait.IDEMPOTENCY_KEY_IN_PROGRESSmeans an earlier request with that key is still downloading the image.retryisnone: fix the request before sending it again.
A failed download always ends its attempt, even when the cause is temporary, such as your host being down. Retry those with a new key once the host recovers.
Fix the request#
These fail before Flint downloads anything. Each is 400 INVALID_REQUEST, and error.param and details[].param name the image field. The detail code is INVALID_VALUE unless noted. Send the corrected request with a new Idempotency-Key.
Fix the image#
Flint downloaded the source, but couldn't use it. Each is 400 INVALID_REQUEST with detail code INVALID_VALUE, and param names the image field. Fix the source, then retry with a new Idempotency-Key.
Retry#
Conflicts#
A missing image, or one outside the merchant or environment of the attachment request, returns 404 RESOURCE_NOT_FOUND with details[0].resource_type set to image and no resource_id. When the image or the resource receiving it exists but its state refuses attachment, the response is 409 ACTION_NOT_ALLOWED with reason unsupported_state and its actual current_status. Read that state before choosing another action.
Errors lists every code with its remediation.
Sandboxes and live mode#
Images belong to the mode or sandbox they were added in, except the merchant logo and icon, which apply everywhere. Files follow the same rule. When you copy catalog data from one environment to another, images aren't copied. Add them again in the target environment, using the original source_url values or new files.
Endpoints#
Next steps#
- Files: upload a local image, read its status, and attach it by
file_id. - Catalog setup: products, variants, and bundles to sell.
- Payment links: sell from a link with its own image.
- Idempotency: store keys and retry writes safely.
- Error handling: read
error.param,details, andremediation.
