Skip to content

Files

Files let you upload local JPEG, PNG, and WebP images to Flint before attaching them to a product, variant, bundle, payment link, subscription plan, merchant logo, or merchant icon.

Call POST /v1/files with purpose, the exact content_type, and size_bytes from 1 to 5,242,880. For example:

JSON
{
  "purpose": "product",
  "content_type": "image/png",
  "size_bytes": 12345
}

The 201 response returns a file_id beginning with file_, status awaiting_upload, and an upload object. Send the image bytes to upload.url using upload.method and every value in upload.headers verbatim. The signed URL expires after 15 minutes. Keep it out of logs.

After the PUT succeeds, call POST /v1/files/{file_id}/complete with no body or {}. The 200 response returns the same file at status ready, with its canonical url, width, and height. Calling complete again returns the ready file. Completing before the bytes arrive returns 409 ACTION_NOT_ALLOWED with reason status_not_reached and leaves the file available for upload.

Attach a file#

Attach a ready file by passing its file_id in an image field instead of a source_url: images: [{ "file_id": "file_…" }] on a product, variant, bundle, or subscription plan, or { "file_id": "file_…" } in a payment link's image or a merchant's logo or icon. Each image input takes exactly one of file_id and source_url. Flint attaches the file without downloading anything.

A file for a catalog purpose (product, product_variant, bundle, payment_link, or subscription_plan) can be attached to any catalog or payment link image field. A merchant_logo file attaches only as the merchant logo, and a merchant_icon file only as the merchant icon. Any other combination returns 404 RESOURCE_NOT_FOUND. A file that doesn't exist, or belongs to another merchant or environment, returns the same error, with param naming the field, such as images[0].file_id.

A file that isn't ready returns 409 ACTION_NOT_ALLOWED with reason terminal_status and param naming the field. Read the file to see why: complete a file that is awaiting_upload or processing, and create a new file when it is failed or expired.

You can still copy a ready file's canonical url into source_url on another resource. The file_id identifies the file for attachment and is the value to store.

Read a file#

Call GET /v1/files/{file_id} to read a file's current status. The response never includes upload, so reads don't expose an upload credential. To retry an upload that can no longer succeed, create a new file. There is no endpoint to list files.

The status is one of five values:

StatusMeaning
awaiting_uploadFlint created the file and is waiting for the bytes. expires_at equals upload.expires_at.
processingFlint is checking and storing the image. Read the file again in a moment. Completing it meanwhile returns 409 IDEMPOTENCY_KEY_IN_PROGRESS.
readyThe image is stored. url, width, and height are present, and you can attach the file.
failedFlint couldn't use the image. failure_code says why. Create a new file.
expiredThe upload deadline passed before completion, or the ready file wasn't attached in time. Create a new file.

expires_at is when the file expires if it stays in its current status:

  • While awaiting_upload, it is the upload deadline, 15 minutes after creation.
  • While ready and not attached, it is the last instant you can attach the file: 24 hours after processing, or 7 days after the file was last removed from every resource it was attached to.
  • It is omitted while the file is attached, and in every other status.

Flint evaluates deadlines when you read, so a file whose deadline has passed reads as expired immediately. content_type and size_bytes are the values you declared until the file is ready, then the stored image's values. width, height, and url appear only when the file is ready.

When a file is failed, failure_code is one of:

  • image_unsupported: the file isn't a supported JPEG, PNG, or WebP image, it is animated or damaged, or a merchant_icon image isn't square or is smaller than 128 by 128 pixels.
  • image_too_large: the file is larger than 5 MB, or its dimensions or stored size exceed the image limits.
  • processing_failed: Flint couldn't process the image for another reason.

Handle a failure_code value you don't recognize like processing_failed, since Flint can add codes. When completion rejects an unusable image, it returns 400 INVALID_REQUEST with detail code INVALID_VALUE for an unsupported format or a source that is too large, and the file then reads as failed.

Failed and expired files stay readable for at least 30 days, then return 404 RESOURCE_NOT_FOUND. The response carries Cache-Control: no-store.

Scopes and environments#

Use the write scope for the purpose to create and complete a file: commerce.products.write for product and product_variant, commerce.bundles.write for bundle, checkouts.payment_links.write for payment_link, commerce.subscription_plans.write for subscription_plan, and merchants.profile.write for merchant_logo and merchant_icon.

To read a file, the credential needs the read scope for the file's purpose, such as commerce.products.read for a product file, or the matching write scope. A credential without it gets 403 INSUFFICIENT_SCOPE with scope_requirement.

Logos and icons are merchant-wide, including when uploaded from a sandbox. Other files belong to the environment that created them; reading or completing one from another environment returns 404 RESOURCE_NOT_FOUND.

Partner installs can upload and read commerce images. They cannot upload or read merchant logos or icons because merchant profile scopes aren't grantable to partner installs; those purposes return 403 INSUFFICIENT_SCOPE with scope_requirement.

Recover from a lost response#

Both write routes accept an optional Idempotency-Key, scoped to merchant, credential, environment, and route, with file_id also part of the completion identity. Replays return the original result and do not extend upload or attachment deadlines.

  • If a create response is lost, repeat POST /v1/files with the same Idempotency-Key to get the original upload target. Without a key, you never learned the file_id, so create another file. The unused upload expires after 15 minutes.
  • If a complete response is lost, repeat the request, with the same key if you sent one, or read the file to see its status. Completing a ready file returns it again.
  • If the upload URL expires, create a new file.

The File object#

An image uploaded to Flint. Create the file, PUT its bytes to upload.url with upload.headers, then complete it. Attach a ready file with images[].file_id on a catalog resource or file_id in a branding image field. A ready unattached file expires after 24 hours; attachment removes that deadline. Each upload has its own file_id, including uploads of identical bytes.

Returned by GET /v1/files/{file_id} and carried by the endpoints below.

Attributes

content_typeenumRequired

The stored image media type when ready; the declared upload media type otherwise.

  • image/jpeg
  • image/png
  • image/webp
created_atstringRequired

When the upload was created.

expires_atstring

When this file expires if it stays in its current status. While awaiting_upload, equals upload.expires_at. While ready and unattached, 24 hours after processing or 7 days after its last detachment. Omitted while attached and in every other status.

failure_codeenum

A safe failure category, present only when failed. Unknown processing causes use processing_failed.

  • image_unsupported
  • image_too_large
  • processing_failed
file_idstringRequired

The file's stable Flint ID.

heightinteger

The stored image height in pixels, present only when ready.

purposeenumRequired

What the image is used for. Set when the file is created.

  • product
  • product_variant
  • bundle
  • payment_link
  • subscription_plan
  • merchant_logo
  • merchant_icon
size_bytesintegerRequired

The stored image size when ready; the declared upload size otherwise.

statusenumRequired

Where the file is in its lifecycle. Only a `ready` file can be attached.

  • awaiting_upload
  • processing
  • ready
  • failed
  • expired
supported_actionsarray of enumRequired

Lifecycle actions Flint accepts now. complete is offered while awaiting_upload or processing and remains accepted for completed files, returning the completed file. It can remain available after an attachment deadline expires until Flint removes the stored file. An in-progress completion can still return a transient refusal.

  • complete
uploadobject

Present only in the create response while awaiting_upload. GET never returns upload credentials. PUT bytes before upload.expires_at, then complete the file.

urlstring

The canonical image URL, present when ready. Attach the file with images[].file_id, or copy this URL into source_url on another resource.

widthinteger

The stored image width in pixels, present only when ready.

JSON
{
  "content_type": "image/png",
  "created_at": "2026-11-02T15:04:05Z",
  "failure_code": "image_unsupported",
  "file_id": "file_01J00000000000000000000000",
  "purpose": "product",
  "size_bytes": 12345,
  "status": "failed",
  "supported_actions": []
}

Create a file#

POST/v1/filesIdempotent

Requires scope checkouts.payment_links.write or commerce.bundles.write or commerce.products.write or commerce.subscription_plans.write or merchants.profile.write

Rate limit: sensitive_write

Upload a local image to Flint. Create a file, PUT the bytes to upload.url with upload.method and every upload.headers value, then POST /v1/files/{file_id}/complete. The URL works for 15 minutes. Purpose requires its own write scope: product and product_variant use commerce.products.write; bundle uses commerce.bundles.write; payment_link uses checkouts.payment_links.write; subscription_plan uses commerce.subscription_plans.write; merchant_logo and merchant_icon use merchants.profile.write. Logo and icon files are merchant-wide. Creating or completing them requires a live-mode credential or a Dashboard session in any selected environment; test credentials fail with `FORBIDDEN` and reason `live_mode_required`. All other purposes belong to the authenticated environment. Partner installs can upload commerce images but cannot upload merchant_logo or merchant_icon: live install credentials receive INSUFFICIENT_SCOPE with scope_requirement because merchants.profile.write is not grantable to installs. Idempotency is scoped to merchant, credential, environment, and route. A replay returns the original upload target without extending its expiry. After a lost response, retry with the same idempotency key or create another file. Each upload URL expires 15 minutes after creation.

Request body

content_typeenumRequired

Media type of the image you will upload.

  • image/jpeg
  • image/png
  • image/webp
purposeenumRequired

What the image will be used for. Creating or completing merchant_logo and merchant_icon files changes shared branding and requires a live-mode credential or a Dashboard session in any selected environment. Test credentials receive 403 FORBIDDEN with reason live_mode_required. Partner installs support the five commerce purposes; merchant_logo and merchant_icon require merchants.profile.write, which partner installs cannot grant, so live install credentials receive INSUFFICIENT_SCOPE with scope_requirement.

  • product
  • product_variant
  • bundle
  • payment_link
  • subscription_plan
  • merchant_logo
  • merchant_icon
size_bytesintegerRequired

Size of the image you will upload, in bytes, from 1 to 5,242,880 (5 MiB).

Response · 201

The file awaiting upload.

dataobjectRequired

Resource, collection, or operation result returned by this request.

metaobject

Additional information about this response.

request_idstringRequired

Identifier of this API request, used to correlate logs and support requests.

curl -X POST https://api.withflintpay.com/v1/files \
  -H "Flint-Version: 2026-09-07" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: a-unique-key" \
  -d '{
    "content_type": "image/png",
    "purpose": "product",
    "size_bytes": 12345
  }'

Get a file#

GET/v1/files/{file_id}

Requires scope checkouts.payment_links.read or checkouts.payment_links.write or commerce.bundles.read or commerce.bundles.write or commerce.products.read or commerce.products.write or commerce.subscription_plans.read or commerce.subscription_plans.write or merchants.profile.read or merchants.profile.write

Rate limit: read

Returns a file's current status without upload credentials. Purpose requires its own read scope: product and product_variant use commerce.products.read; bundle uses commerce.bundles.read; payment_link uses checkouts.payment_links.read; subscription_plan uses commerce.subscription_plans.read; merchant_logo and merchant_icon use merchants.profile.read. The matching write scope also grants read access. Dashboard sessions require the purpose's manage capability. Logo and icon files are merchant-wide; other files belong to the authenticated environment. Partner installs can read commerce files but cannot read merchant_logo or merchant_icon. Expired deadlines are reflected immediately. Only ready files include url, width, and height. The response uses Cache-Control: no-store.

Path parameters

file_idstringRequired

Flint file ID.

Response · 200

The file's current status.

Same response as Create a file.

curl https://api.withflintpay.com/v1/files/file_01KEZF7C00BZ179303GY9R0P03 \
  -H "Flint-Version: 2026-09-07" \
  -H "Authorization: Bearer YOUR_API_KEY"

The file's current status.

JSON
{
  "data": {
    "content_type": "image/png",
    "created_at": "2026-11-02T15:04:05Z",
    "failure_code": "image_unsupported",
    "file_id": "file_01J00000000000000000000000",
    "purpose": "product",
    "size_bytes": 12345,
    "status": "failed",
    "supported_actions": []
  },
  "meta": {
    "api_version": "2026-09-07"
  },
  "request_id": "req_01KWM6WAHG3N9Q8T2V5XRZ7C4D"
}

Complete a file#

POST/v1/files/{file_id}/completeIdempotent

Requires scope checkouts.payment_links.write or commerce.bundles.write or commerce.products.write or commerce.subscription_plans.write or merchants.profile.write

Rate limit: sensitive_write

Completing a merchant_logo or merchant_icon file requires a live-mode credential or a Dashboard session in any selected environment. Test credentials fail with `FORBIDDEN` and reason `live_mode_required`. After PUT succeeds, complete the file to process its image. Returns the ready file; completing a ready file again returns it. Send no request body or {}. Completing before the bytes arrive returns ACTION_NOT_ALLOWED with reason status_not_reached and current_status awaiting_upload. Attach the returned file_id as images[].file_id before expires_at, 24 hours after processing. Completion requires the purpose's write scope, with the same merchant-wide branding and environment boundaries as createFile. Partner installs can upload commerce images but cannot upload merchant_logo or merchant_icon: live install credentials receive INSUFFICIENT_SCOPE with scope_requirement because merchants.profile.write is not grantable to installs. Idempotency is scoped to merchant, credential, environment, route, and file_id. A replay returns the original result; it does not extend upload or attachment deadlines. After a lost completion response, repeat this route with the same key and file_id.

Path parameters

file_idstringRequired

Flint file ID.

Response · 200

The ready file.

Same response as Create a file.

curl -X POST https://api.withflintpay.com/v1/files/file_01KEZF7C00BZ179303GY9R0P03/complete \
  -H "Flint-Version: 2026-09-07" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: a-unique-key" \
  -d '{}'

Was this helpful?