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:
{
"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 FILE_NOT_UPLOADED and leaves the file available for upload.
Attach a ready file by passing its url as images[].source_url on a catalog or branding resource. Canonical Flint URLs attach without refetching. The ready file's expires_at is the last instant it can be attached, 24 hours after processing. Attachment removes that deadline. There is no file read route; keep the returned file details.
Use the write scope for the purpose: 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. Logos and icons are merchant-wide, including when uploaded from a sandbox. Other files belong to the environment that created them; completing one from another environment returns 404 RESOURCE_NOT_FOUND.
Partner installs can upload commerce images. They cannot upload merchant logos or icons because merchants.profile.write is not grantable to partner installs; those purposes return 403 INSUFFICIENT_SCOPE with scope_requirement.
Both 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 an upload URL expires, create a new file. If a create response cannot be recovered, contact support with X-Request-Id before starting another upload.
