File Management API
These endpoints manage files and media in your EverShop store. All file management endpoints require admin authentication.
File Operations
Browse Files
Lists one level of a directory, one page at a time. The path after /files/ specifies which directory to browse. Sub-directories and files are returned in separate keys: folders is a flat list of directory names, files carries a name, a servable URL, the size in bytes and a media type derived from the extension (size and mimeType can be missing for third-party storage providers).
Query parameters:
limit: entries per page, 1 to 500. Default 100.cursor: thenextCursorof the previous page.nextCursoris present while more entries remain and absent at the end. There is no total count.prefix: keep only the entries whose name starts with this text (case-sensitive). It filters folder names too.
baseUrl is the store's base URL, used to turn the relative URLs of the local provider (/assets/…) into full ones. A cursor from another storage provider answers 400.
- cURL
- JavaScript
curl
-H "Accept: application/json"
-H "Authorization: Bearer <admin JWT token>"
https://<your domain>/api/files/{path}
fetch('https://<your domain>/api/files/{path}', {
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer <admin JWT token>'
}
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
{
"data": {
"folders": [
"thumbnails"
],
"files": [
{
"name": "product-image.jpg",
"url": "/assets/catalog/products/product-image.jpg",
"size": 88120,
"mimeType": "image/jpeg"
}
],
"nextCursor": "…",
"baseUrl": "https://your-store.com"
}
}
Upload File
Uploads one or more files to the specified directory. Send them as multipart form data under the field name images — up to 20 per request. The path segment must match ^[a-zA-Z0-9_/-]+$.
File names are lowercased, and every character other than a-z and 0-9 in the base name becomes a hyphen. A file with the same name in the folder is replaced without warning (local and cloud providers). A type outside the allowed upload types answers 400 with The file you are trying to upload is not allowed; a file over the size limit answers 400 with a message that starts with The file is too large.
- cURL
- JavaScript
curl
-H "Accept: application/json"
-H "Authorization: Bearer <admin JWT token>"
--data-raw '<JSON DATA>'
https://<your domain>/api/files/{path}
fetch('https://<your domain>/api/files/{path}', {
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer <admin JWT token>'
},
body: <JSON DATA>
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
{
"data": {
"files": [
{
"name": "uploaded-file.pdf",
"mimetype": "application/pdf",
"size": 102400,
"url": "/assets/documents/uploaded-file.pdf"
}
]
}
}
Delete File
Deletes a file at the specified path. A path that does not exist is treated as already deleted and answers 200. Folders cannot be deleted: in 2.4.0, a folder path throws Requested path is not a file, which is not caught and answers 500.
The delete does not update anything that uses the file (product images, content, widgets, branding settings), and resized copies already made by the storefront image processor are not removed.
- cURL
- JavaScript
curl
-H "Accept: application/json"
-H "Authorization: Bearer <admin JWT token>"
https://<your domain>/api/files/{path}
fetch('https://<your domain>/api/files/{path}', {
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer <admin JWT token>'
}
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
{
"data": {
"path": "catalog/my-image.png"
}
}
Rename File
Renames a file inside its folder. The new name can contain letters, digits, dots, hyphens and underscores; it cannot contain a path separator or change the extension (The file extension cannot be changed — it must stay ".jpg"). If name has no extension, the current one is kept. A name already in the folder answers 400 A file with that name already exists. Every validation failure answers 400 with the reason.
The response returns the new path and the renamed file as the browse endpoint lists it. Like a delete, a rename does not update anything that uses the old URL.
| Field Name | Field Type | Required |
|---|---|---|
| name | string | Yes |
- cURL
- JavaScript
curl
-H "Accept: application/json"
-H "Authorization: Bearer <admin JWT token>"
--data-raw '<JSON DATA>'
https://<your domain>/api/files/{path}
fetch('https://<your domain>/api/files/{path}', {
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer <admin JWT token>'
},
body: <JSON DATA>
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
{
"data": {
"path": "banners/spring-sale.jpg",
"file": {
"name": "spring-sale.jpg",
"url": "/assets/banners/spring-sale.jpg",
"size": 993848,
"mimeType": "image/jpeg"
}
}
}
Image Operations
Upload Image
Identical to POST /api/files/{path} except that every uploaded file must have an image/* mimetype. A type outside the allowed upload types is refused first, with 400 The file you are trying to upload is not allowed. An allowed type that is not an image (for example PDF, when the store allows it) is then rejected with 400 Only images are allowed.
No processing happens on upload: files are written as received. There is no resizing and no thumbnail generation. (Resizing is done on read by the storefront image processor, from the original.)
- cURL
- JavaScript
curl
-H "Accept: application/json"
-H "Authorization: Bearer <admin JWT token>"
--data-raw '<JSON DATA>'
https://<your domain>/api/images/{path}
fetch('https://<your domain>/api/images/{path}', {
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer <admin JWT token>'
},
body: <JSON DATA>
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
{
"data": {
"files": [
{
"name": "product-photo.jpg",
"mimetype": "image/jpeg",
"size": 88120,
"url": "/assets/catalog/products/product-photo.jpg"
}
]
}
}
Folder Operations
Create Folder
Creates a new directory in the media storage.
| Field Name | Field Type | Required |
|---|---|---|
| path | string | Yes |
- cURL
- JavaScript
curl
-H "Accept: application/json"
-H "Authorization: Bearer <admin JWT token>"
--data-raw '<JSON DATA>'
https://<your domain>/api/folders
fetch('https://<your domain>/api/folders', {
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer <admin JWT token>'
},
body: <JSON DATA>
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
{
"data": {
"path": "catalog/new-folder",
"name": "new-folder"
}
}
See also
- File Storage — local disk, S3, Azure or Google Cloud storage
- Media Library — the same files in the admin panel