Files
Attach artwork, engraving files and print data to an order or one of its items. Request an upload slot (POST /v1/uploads), send the file bytes to the returned address with HTTP PUT, then reference its upload_id in order-level files or items[].files. The same flow adds files through a pre-start change command. Content is validated when Meykt accepts the reference, not when bytes arrive in the slot.
#Two-step upload
The file never passes through the Meykt application server. POST /v1/uploads only hands out a short-lived, signed storage address; the bytes go straight to storage.
This has three practical consequences:
- Separate byte transfer. File bytes do not consume the order JSON body limit. The file size limit and network timeouts still apply; do not base64-encode files into an order request.
- Retrying is cheap. If the
PUTfails, repeat only thePUT. If the order call fails, repeat only the order call with the sameupload_idvalues. - Validation happens later. The upload slot accepts whatever you send. Type checking, SVG sanitizing and acceptance happen when creation or a change command references the upload.
POST /v1/uploads requires the scope files:write. Creating the order requires orders:write; changing an existing order requires orders:change. Requesting a slot needs its own files:write permission. Reading an accepted file through its order needs orders:read. None of these permissions implies another.
#Step 1 request an upload slot
Send the file name you want the file to be stored under. The name is sanitized (directory parts removed, unusual characters replaced with _, truncated to 120 characters) and the sanitized value is echoed back as filename.
curl -X POST https://api.meykt.com/v1/uploads \
-H "Authorization: Bearer $MEYKT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"filename": "artwork-logo.svg"}'Response 201:
{
"data": {
"upload_id": "3f0a9c1e-2b77-4c1a-9f1c-0d2a4e6b8c10",
"filename": "artwork-logo.svg",
"upload_url": "https://…signed…",
"method": "PUT",
"expires_in_seconds": 7200,
"max_bytes": 52428800
}
}One upload_id belongs to exactly one file. Request a separate slot for every file you want to attach.
#Step 2 send the file
Send the raw file content as the request body of a single PUT to upload_url. No authorization header is needed — the address is already signed.
response=$(curl -s -X POST https://api.meykt.com/v1/uploads \
-H "Authorization: Bearer $MEYKT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"filename": "artwork-logo.svg"}')
upload_url=$(echo "$response" | jq -r '.data.upload_url')
upload_id=$(echo "$response" | jq -r '.data.upload_id')
curl -X PUT "$upload_url" --data-binary @artwork-logo.svgA 2xx confirms successful transfer. A timeout or failed repeat does not prove that an earlier attempt stored nothing: keep the original upload_id and check the order outcome before replacing it. An unavailable or unaccepted upload is rejected when the order references it; a new upload ID is different creation content.
#Step 3 reference the upload in an order
Add the upload_id to order-level files or the files array of its item. role is optional free text of 1–80 characters when present; use a stable name describing its purpose. It does not grant access or mark a physical action complete.
curl -X POST https://api.meykt.com/v1/orders \
-H "Authorization: Bearer $MEYKT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"external_order_id": "ORDER-2026-1044",
"customer": { "name": "Anna Beispiel" },
"items": [{
"sku": "CAP-NAVY",
"name": "Cap navy",
"quantity": 2,
"personalization": { "embroidery_text": "All the best" },
"files": [{ "upload_id": "3f0a9c1e-2b77-4c1a-9f1c-0d2a4e6b8c10", "role": "artwork" }]
}]
}'Files are accepted before anything is written. A single unusable file rejects the whole order with 422 and nothing is created — this is the same all-or-nothing rule that applies to field validation.
Accepted files are immutable. Meykt keeps a separate copy of each accepted file. Sending bytes to the original upload address again cannot change that copy. The accepted file keeps its returned opaque id and download_path; ordinary identical retries and references already attached to that same order remain usable. To supply changed bytes, request a fresh upload slot and submit a pre-start order change with orders:change and the current expected_revision.
Order and item responses report accepted files. Where an API file reference is available, they include its opaque ID and authorized download route:
{
"files": [{
"id": "3f0a9c1e-2b77-4c1a-9f1c-0d2a4e6b8c10",
"name": "artwork-logo.svg",
"role": "artwork",
"download_path": "/v1/orders/8c4d2f9a-5b71-4e6c-9a03-1f7d8e2b6c45/files/3f0a9c1e-2b77-4c1a-9f1c-0d2a4e6b8c10"
}]
}Follow that route with the same connection/environment and orders:read to request a temporary download URL; see Order-wide attachments and downloads. A file name alone is not a downloadable handle.
#Allowed file types
The actual content is checked, not the file extension and not the Content-Type you sent. Detection reads the first bytes of the stored file. Renaming a .mp4 to .svg does not help — it is rejected with file_type_not_allowed, and the error message names the type that was detected.
| Format | Detected type |
|---|---|
| PNG | image/png |
| JPEG | image/jpeg |
| WebP | image/webp |
| GIF | image/gif |
| SVG | image/svg+xml |
| TIFF | image/tiff |
| BMP | image/bmp |
| HEIC / HEIF / AVIF | image/heic, image/heif, image/avif |
application/pdf | |
| DXF | application/dxf |
| EPS / PS | application/postscript |
| ZIP (including ZIP-based Office formats) | application/zip |
| Plain text / CSV | text/plain, text/csv |
Notes:
- Adobe Illustrator files are accepted through the format they are actually written in: older PostScript-based
.aifiles are detected asapplication/postscript, current PDF-based.aifiles asapplication/pdf. - A file must start with a recognizable header. A truncated or empty upload is reported as
file_not_found, not as a type error. - SVG is sanitized automatically. Scripts, inline event handlers, external references and active URL schemes are stripped, and the file is stored with
Content-Disposition: attachment. The stored SVG can therefore differ from the bytes you uploaded.
#Limits
- 50 MiB per file (
max_bytes: 52428800). - Up to 10 files at order level and 10 per item, at most 100 references in the order. Exceeding these limits fails validation.
- One file per
upload_id. upload_idmust be a UUID — the exact value returned byPOST /v1/uploads.- Upload slots per organization: 500 per hour and 5,000 per day, counted across all live keys of the organization. Beyond that,
POST /v1/uploadsanswers429upload_limit_reachedwith aRetry-Afterheader. Request one slot per file and only when you are about to upload it. - Unused uploads: up to 10 GB per organization may wait for an order at the same time. When more is waiting, new slots are refused with
429upload_limit_reacheduntil orders have referenced the waiting uploads or the 14-day cleanup has removed them. Files that an order accepted, or thatPOST /v1/returns/evidenceprepared as return evidence, no longer count against this limit. Accepted order files count toward your storage allowance instead (next item). - Accepted files count toward your storage. Once an order has accepted a file, it counts against the storage allowance of your organization (Settings → Usage & credits), like any other file in your account. This applies to orders placed with live keys; files accepted for orders placed with a test key do not count with you (test runs are free) — but they are not removed automatically either, so keep sandbox files small. If a live order is handed to a fulfillment partner, the partner's copy counts there. Orders placed with a test key are never handed to a fulfillment partner. Unused uploads in the waiting area do not count. Currently, accepting an order does not depend on your storage allowance: the file is accepted and counted, and the order is not rejected because the allowance is full. While it is full, other ways of storing files in your account still fail — new uploads in the Meykt app, and
POST /v1/returns/evidence, which then answers503command_outcome_unknown(the message names a full allowance as a possible cause) until space is free again. Accepted files are not removed automatically and cannot be deleted through the API, so plan the volume you send with that in mind. - Test keys have their own, smaller allowance: 50 slots per hour, 500 per day and 1 GB of unused test uploads. Test and live uploads are counted separately, so a test suite or a loop with a sandbox key can never use up the slots of your live integration — it can only exhaust its own allowance, answered with the same
429upload_limit_reached(the message says "with test keys"). A test upload waits in its own area and is only usable by test keys' orders and return evidence, and a test key's order can only reference test uploads (a live upload is not found for it, and the other way round); it expires after 14 days like any unused upload.
#Lifetime
- The
upload_urlpermits transfer for 2 hours (expires_in_seconds: 7200). Its expiry does not erase bytes already uploaded. If no transfer succeeded before it expired, request a new slot; an unused stored upload remains subject to the 14-day cleanup period. - An upload that is never referenced by an order expires after 14 days. Nothing to clean up on your side, and there is no endpoint to delete an upload.
- An accepted order file is not part of the 14-day cleanup and is not removed automatically; there is no endpoint to delete it. Its signed upload/download URLs still expire independently.
#Reusing uploads on retry
Duplicate detection for orders is computed over the upload_id values, not over storage locations. That makes retries safe:
- Resending the identical order body, including the same
upload_idvalues, returns200with the existing order — never a duplicate. - Using new
upload_idvalues with the sameexternal_order_idcounts as different content and returns409order_already_exists_with_different_content. - If creation was rejected before acceptance, preserve references to valid uploads when correcting the complete request. A missing, expired or unsupported file still needs to be uploaded or corrected. Exact retries of an accepted order retain their original references even though the upload is no longer in the waiting area.
#Errors
Both file errors are reported with HTTP 422 and the top-level code validation_failed; the specific code sits in errors[] together with the exact position in field, using bracket notation.
{
"error": {
"code": "validation_failed",
"message": "The order was rejected because of file problems. Nothing was created.",
"doc_url": "https://www.meykt.com/en/developers/errors/validation_failed",
"errors": [
{
"code": "file_type_not_allowed",
"message": "The file for upload_id 3f0a9c1e-2b77-4c1a-9f1c-0d2a4e6b8c10 has an unsupported type (detected: video/mp4).",
"field": "items[0].files[0].upload_id"
}
]
}
}file_not_found — the upload_id is unknown, the PUT in step 2 never succeeded, the upload already expired after 14 days, the upload was requested with a key of the other environment (a test key only finds uploads requested with a test key, and a live key only live uploads — the message names this), or (return evidence only) the upload was already used up by an earlier POST /v1/returns/evidence — the message then says so and field is upload_id. Fix: run POST /v1/uploads, PUT the content to upload_url, verify the PUT returned 2xx, then reference the upload_id — with a key of the same environment that requested the slot. Details: /developers/errors/file_not_found.
file_type_not_allowed — the detected content is not in the allowed list. The message names the detected type. Fix: export the file in one of the formats listed under Allowed file types. Renaming the extension changes nothing, because the content is what is checked. Details: /developers/errors/file_type_not_allowed.
Both errors mean that no part of the order was created. Correct the file, then resend the complete order.
Full list of codes: /developers/errors. Order semantics, limits and warnings: /developers/orders.
#Order-wide attachments and downloads
The same file-reference shape is accepted in order-level files and in items[].files. There are at most 10 references per level/item and 100 across an order. A file role is optional; use stable role names that identify its purpose. File bytes never belong in personalization or JSON metadata.
Read the order to obtain a file id and its download_path, when available. GET /v1/orders/{id}/files/{fileId} (orders:read) returns {data:{file:{id,name,download_url,expires_in:300}}}. The URL expires; request a new one instead of persisting it as a durable file reference. Only accepted files of this key's channel and environment are downloadable. No endpoint accepts arbitrary storage paths or external URLs. In a change command, omitting files preserves that section; sending a file list replaces it, and files: [] removes current attachments at that level. Include every file reference you want to retain. Reuse an already attached file’s returned ID as upload_id for that same order; use a fresh slot for new bytes. An accepted upload is not a general file-library handle for creating unrelated orders.
#Complete field reference
- Files: field reference — all request, response and parameter fields, including required values and conditional alternatives.
Machine-readable version of this page: https://www.meykt.com/developers/files.md