A file is an asset in the store: a video, an image, a PDF, a download, or a link to a file elsewhere. Files are uploaded once and attached wherever they are used, as a product’s download or poster, an entry’s video, a page’s image.
Upload a file
An upload takes three calls: reserve the file, send its bytes, then complete it.
POST /uploadsreserves the file and answers where to send its bytes:upload.url,upload.method(PUT),upload.headersandupload.expires_at.- Send the bytes to
upload.urlwith that method and those headers, beforeexpires_at. The body must be exactlybyteslong. This request goes to the upload URL as it is, without your token. POST /assets/{asset}/completemarks it done once its bytes are in place: the file becomesready, with its size as uploaded.
curl -X POST 'https://api.sherpo.io/merchant/v1/stores/STORE_ID/uploads' \
-H "Authorization: Bearer $SHERPO_TOKEN" \
-H 'Content-Type: application/json' \
-d '{
"enforcement": "signed",
"name": "watercolor-workbook",
"title": "Workbook",
"mime": "application/pdf",
"bytes": 2481152
}'const answer = await sherpo('POST', '/v1/stores/STORE_ID/uploads', {
body: {
"enforcement": "signed",
"name": "watercolor-workbook",
"title": "Workbook",
"mime": "application/pdf",
"bytes": 2481152
},
});Answers 201, abridged:
{
"asset": {
"id": "d3c2b1a0-9f8e-4d7c-8b6a-5f4e3d2c1b0a",
"name": "watercolor-workbook",
"title": "Workbook",
"mime": "application/pdf",
"bytes": 2481152,
"enforcement": "signed",
"status": "pending"
},
"upload": {
"method": "PUT",
"expires_at": "2026-11-03T11:00:00.000Z"
}
}What a reservation takes:
enforcementdecides who may reach the bytes:signed, the default, for a file served only through links that expire, the one for anything you sell;publicfor a file anyone with its link may load, such as images on your pages, which takes images (not SVG), video, audio and PDFs alone.POST /assets/{asset}/movewith the otherenforcementchanges it later.nameis a short name in lowercase letters, digits and hyphens;titleis what people see.mimeis its type andbytesits size, up to 5 GiB.extis its extension, the type’s usual one when left out.- A file that would take the store past its plan’s storage allowance is refused as
409conflict.
A small file in one call
A file up to 2 MiB can go in the request itself: POST /uploads/inline takes what a reservation takes, with the bytes as data in place of bytes, base64 with padding, and answers the file, already ready. Use it when your code can’t send a request to the upload URL; for anything larger, or to send bytes as they are read, reserve and send them as above. A larger data is refused as 422 invalid.
curl -X POST 'https://api.sherpo.io/merchant/v1/stores/STORE_ID/uploads/inline' \
-H "Authorization: Bearer $SHERPO_TOKEN" \
-H 'Content-Type: application/json' \
-d '{
"name": "price-list",
"title": "Price list",
"mime": "text/csv",
"data": "cGxhbixwcmljZQpCYXNpYywxMAo="
}'const answer = await sherpo('POST', '/v1/stores/STORE_ID/uploads/inline', {
body: {
"name": "price-list",
"title": "Price list",
"mime": "text/csv",
"data": "cGxhbixwcmljZQpCYXNpYywxMAo="
},
});Answers 201, abridged:
{
"id": "d3c2b1a0-9f8e-4d7c-8b6a-5f4e3d2c1b0a",
"name": "price-list",
"title": "Price list",
"mime": "text/csv",
"bytes": 20,
"enforcement": "signed",
"status": "ready"
}POST /assets/{asset}/cancel drops an upload you won’t complete. To link a file hosted elsewhere, such as an external video, use POST /assets instead. The upload guide has the whole flow in code.
Attach it
A file shows nowhere until it is attached. POST /{kind}/{id}/attachments attaches it to a product, an entry, a page, a quiz, a certificate, a holding or the store (the stores kind with the store’s own id), in a role:
deliverable: what a buyer gets, withdeliveryset todownload,inline(viewed in place) orstream(a video or audio played in place).poster: a product’s or an entry’s image. It takes an image only: any other file, a video included, is refusedconflictonmimewith the reason, and so is a replace or a type change that would make a poster’s file something else.PUT /products/{product}/postersets a product’s thumbnail, held to a JPEG or PNG image within the limits its reference lists and refusedinvalidonassetotherwise.embed: media shown beside a target’s text. An entry’s own video or PDF, as a lesson’s video or slides, keeps its kind: a replace or a type change to a file of another kind is refusedconflictonmimewith the reason.GET /assets/{asset}names the kind a file keeps inkept_kind(videoorpdf, null when none holds one), so a client can ask for that kind before it uploads.stylesheetandlogo: a page’s CSS and a certificate’s image. Attaching, swapping in, replacing or setting a file of another type is refusedconflictonmimewith the reason.teaser,promptand the others the reference lists, each where its target takes it.
preview_only: true makes an attachment part of the preview anyone may see. PATCH /attachments/{attachment}, POST /{kind}/{id}/attachments/reorder and POST /attachments/{attachment}/detach change, reorder and detach them, keeping the file. Images and videos inside a text are blocks in its rich text instead.
A file nothing uses can be deleted with DELETE /assets/{asset}; GET /asset_uses lists where a file is used, within its filter[asset_id]. POST /assets/{asset}/replace swaps a file’s bytes for another upload’s, keeping every place it is used. A file a page or a text shows as an image takes new bytes, or a type that stops it playing, of at most 15 MB, as does a poster or a picture a product attaches as its own.
Fetch a file’s bytes
POST /assets/{asset}/url answers where a file’s bytes are, with expires_at:
curl -X POST 'https://api.sherpo.io/merchant/v1/stores/STORE_ID/assets/d3c2b1a0-9f8e-4d7c-8b6a-5f4e3d2c1b0a/url' \
-H "Authorization: Bearer $SHERPO_TOKEN" \
-H 'Content-Type: application/json' \
-d '{
"disposition": "attachment",
"expires_in": 300
}'const answer = await sherpo('POST', '/v1/stores/STORE_ID/assets/d3c2b1a0-9f8e-4d7c-8b6a-5f4e3d2c1b0a/url', {
body: {
"disposition": "attachment",
"expires_in": 300
},
});Answers 200, abridged:
{
"url": "https://api.sherpo.io/merchant/v1/stores/STORE_ID/files/CAPABILITY",
"expires_at": "2026-11-03T10:05:00.000Z"
}- A link comes back as it is, and a public file viewed in place as its public URL.
- A private file, or any file asked for as a download (
disposition: "attachment"), comes back as a URL on this API,/v1/stores/{store}/files/.... Fetch it with aGETand the same token in theAuthorizationheader: the URL is bound to that token, so another token, or none, can’t fetch it. A token in its query string (access_token) is refused asinvalid.
const { url } = await sherpo('POST', '/v1/stores/STORE_ID/assets/ASSET_ID/url', {
body: { disposition: 'attachment' },
});
// A linked file's URL is elsewhere, so only this API's own URLs get the token.
const headers = url.startsWith(`${BASE}/`) ? { Authorization: `Bearer ${TOKEN}` } : {};
const file = await fetch(url, { headers });
if (!file.ok) throw new Error(`The file answered ${file.status}.`);
const bytes = new Uint8Array(await file.arrayBuffer());The URL serves until expires_at (set it with expires_in, in seconds), or until the file changes; then ask for a new one. A file shown in place answers a Range header naming one bytes range with 206 and those bytes, and If-Range with an earlier ETag answers the whole file once it changed; a range outside the file, or several ranges, answers 416 range_not_satisfiable. A download is answered whole and works once, so its URL takes no HEAD. A 403 means the URL is another token’s or no longer valid; a 401, that the token itself is no longer honored.
Videos
A video plays as soon as its upload completes. It can also have subtitles, a transcript, a summary and chapters, generated from its audio; the API calls them its outputs.
POST /assets/{asset}/outputs/generategenerates one, or generates it again; subtitles come first, and the others are made from them. Each lands as a draft. Subtitles of audio longer than 10 hours (limits.subtitles_max_seconds) are refused withconflictonstatus,too_long, as is any other output that would wait on them, subtitles that would hold more than an edit saves land as their leading cues, and a transcript that would hold more than an edit saves or a run holds lands as its leading paragraphs, which takes about 800,000 characters, or 500,000 in scripts such as Chinese, Hindi or Thai.GET /assets/{asset}/outputslists them and where each one’s generation stands;GET /assets/{asset}/outputreads one with its content, andPATCH /assets/{asset}/outputedits it. An output an edit couldn’t save at all, such as subtitles with no cue left, reads ascontent: nullwithunreadable: true: edit it again, or generate it again. Subtitles hold at most 36,000 cues of 500 characters andlimits.subtitles_max_bytesbytes of their cues’ JSON; longer ones read as what an edit saves, each text cut at 500 characters and the leading cues that fit, withtruncated: true, and saving those drops the rest.POST /assets/{asset}/outputs/publishshows one to customers, or takes it back to a draft.
Generating subtitles uses the store’s transcription minutes, which its plan allows each period.
Storage and allowances
GET /quota answers the storage the store’s files use against its plan’s allowance (used_bytes, allowance_bytes, available_bytes), by type, by who may reach them and by where they are used, as the merchant app’s storage page shows it. GET /plan_usage answers every allowance of the plan with what the store uses of it: storage, transcription minutes, customers, pages, menu items and redirects, and the features it includes, with the add-on blocks of storage and AI video minutes the store holds on top (add_ons).