Upload a file
AI agents: read /llms.txt; add .md to any page URL. This page as Markdown: /reference/uploads/v1-async-upload-store.md. Index of every page and the rules for every call: /llms.txt. Guides and concepts in one file: /llms-full.txt. OpenAPI: /openapi.json.
POST/
Uploads one file that does not belong to anything yet, and returns its id. Then attach it with the operation for its destination, passing the id as attachment[].id: a job's mockups and production files, a sales order, a purchase order or a customer.
Send multipart/form-data with the file in media. Choose collection mockup for mockup images (images only) or production_file for production files; leave it out for other files (default).
Business rules
mediais required and must be a file.- On the Free plan a file can be at most 5,240 KB. On paid plans the whole request (the file and the form around it) can be at most 100 MB.
location(text) andshow_mockup(a boolean) are checked but not saved here; set them with the update operation.
Side effects
- Stores the file. It stays until you attach or delete it; unattached uploads are not cleaned up automatically.
Path parameters
Your team slug, shown as Team ID next to your API key in Profile.
- Example
your-team
- Example
Request body
multipart/form-data, required.
The file. With
collection=mockupit must be an image a preview can be made of: PNG, JPG (JPE, JFIF), GIF, TIFF, BMP, WebP, SVG, HEIC or AVIF, and at most 120 megapixels.collectionstringWhat the file is for.
- One of:
"default","mockup","production_file" - Default
"default"
- One of:
Response
200Successful response.
A file attached to a record has extra fields for it:
job_id(withjob_serviceand the current approval fields),job_preset_id(a job preset's file, withjob_service: the preset's service ids),order_id,po_idorcustomer_id.Child fields (19)
assetUrlstringImages that are unattached uploads or job mockups only: a signed link the mockup editor uses. It expires; don't store it.
collectionstringAn upload is
default,mockuporproduction_file. A file attached to a record can be in another collection of that record.created_atstring (date-time)custom_propertiesobject | arraySaved properties such as
locationandshow_mockup. An empty list[]when there are none.dimensionsobject | nullPixel size of an image, read from its header; null for other files and for images uploaded before the size was recorded.
file_namestringidstringThe upload id. Pass it as
attachment[].idto attach the file.is_imagebooleanmime_typestringnamestringThe original file name without its extension.
positioninteger | nullThe file's place in its list.
previewobject | nullPreview links
small,mediumandlarge(250, 800 and 1200 px). Images up to 10 MB are their own preview, so they have these at once; a larger image has them oncepreview_stateisready. Other files have null while they are unattached uploads; once attached, some records (such as jobs) give them links to a converted preview.previewUrlstringSame images only: a signed preview link for the mockup editor. It expires; don't store it.
preview_statestringready: the preview links work.processing: an image over 10 MB whose stored preview a worker is still making (seconds); read the file again, or in the web app wait formedia.preview_state_changedon the team channel.too_large: an image over 120 megapixels; it never gets a preview.failed: the worker gave up, or the converter could not read the original (missing, broken or unsupported); it is not retried.none: not an image.- One of:
"ready","processing","too_large","failed","none"
- One of:
show_in_pdfboolean | nullsizeintegerBytes.
source_media_idstring | nullThe file this one was copied from, when it is a copy. Always null on job and job preset files.
urlstringA signed download link. It expires; don't store it.
view_urlstringA signed link to view the file. It expires; don't store it.
Errors
401The API key is missing or wrong (
unauthenticated).403You are not allowed to do this.
api_access_not_in_plan: your team's plan doesn't include API access (Pro and above, with an active subscription or trial), so every request answers this until the team upgrades. When your role lacks the permission the operation needs, the body is only{"message": "Insufficient Permission"}. Other refusals use the error envelope, withunauthorizedoruser_is_not_authorized.404Not found.
page_not_found: the team slug is unknown, you are not a member of the team, or an id in the path is not one of this team's.code: null, with a message that starts "No query results for": there is no record with that id.413
- When
- The request is over 100 MB. The web server refuses it before YoPrint reads it, so the body is not JSON.
- Fix
- Keep files under 100 MB. Don't retry the same file.
422Validation failed, or the image was refused by the media rules: a mockup that is not an image a preview can be made of (
mockup_type_not_allowed), or an image over a size limit (image_not_allowed), or a file that is a web page, a script or a program (validation_failedonmedia, orupload_not_allowed: "This type of file cannot be uploaded.");error.messageis one sentence naming the limit.- When
mediais missing or not a file,collectionis not allowed, or the file is over the Free plan limit (validation_failed, with the field undererror.fields).- Fix
- Send the file as
mediain a multipart form. - When
- A mockup is not one of the image formats above (
error.codemockup_type_not_allowed), or an image is over 120 megapixels (error.codeimage_not_allowed);error.messageis one sentence naming the limit. - Fix
- Send the file as a production file instead, or a smaller image.
- When
- The file is a web page, a script or a program, judged by its extension and by its detected type (for example .html, .js, .php, .py, .sh, .exe, .bat, .jar, .apk, .app, .dmg).
error.fields.mediasays "This type of file cannot be uploaded." (validation_failed). - Fix
- Put the file in a .zip, or send a different file type.
Notes
- The
urlandview_urllinks are signed and expire. Keep theid, not the links. - Attach the upload soon after uploading it. An upload can be attached once; after that, it belongs to its record.
Related
- GETGet an uploaded file
/v1/ api/ store/ {team_slug}/ async_upload/ {hash_id} - DELETEDelete an uploaded file
/v1/ api/ store/ {team_slug}/ async_upload/ {hash_id} - PUTAttach uploaded files to an order
/v2/ api/ store/ {team_slug}/ v2/ sales_order/ {hash_id}/ media/ attach
