1. Help Center Home
  2. API
  3. Using the API
  4. Uploading Files via the API

Uploading Files via the API

The File Upload API lets an integration add, organise and remove the files held in your CIMcloud site’s file storage — the image assets your site serves and the files it collects from its own forms. This article covers the endpoints, their limits, and how to confirm that an upload finished.

Contents

Before you start

This article is written for developers and integrators. You will need:

Uploading and deleting through this API changes the files your live site serves. Test against a sandbox site before pointing an integration at production.

Base URL

All file endpoints sit under your site’s API base URL:

https://api.cimcloud.com/{sitename}/files

Replace {sitename} with your site name. The examples below use the short form /files for readability.

Authentication

Every file endpoint requires an authenticated request. Both authorization types are supported: JWT Bearer (send Authorization: Bearer <token>) and Basic. Obtaining and refreshing tokens is covered in Authentication and Refresh Tokens; this article assumes you already hold a valid token.

To obtain one:

curl -X POST "https://api.cimcloud.com/<sitename>/authenticate" \
  -H "Content-Type: application/json" \
  -d '{
    "AuthKey": "your-app-auth-key",
    "AuthUserName": "your-app-username",
    "AuthPassword": "your-app-password"
  }'

An unauthenticated request to any file endpoint returns 401 Unauthorized.

Uploads are recorded against the authenticated user. Your integration cannot set that attribution itself — a UserIdentifier sent by the client is ignored.

Where files are stored

Every file and folder lives under a reserved root folder, and a path that does not begin with one is rejected. These are the roots you work with:

Root folder Used for
images General image assets for the site — product, category and web page images.
uploads Files uploaded on the site itself, typically through Form Builder or the Product Configurator.
attachments Files attached to CRM tickets. The CRM bundle uploads these to the same storage through its own API.

All three appear under Images & Files in the Worker Portal. Uploading to attachments with this API stores the file normally, but it will not attach it to a ticket, because the CRM bundle creates that link itself.

Files in these folders are served from the web, and anyone holding a file’s URL can retrieve it without signing in to your site. Do not use these endpoints for documents that should be visible only to a particular customer or user.

The root folders themselves cannot be deleted. You can create and delete your own folders beneath them.

File and folder naming

Names and paths are cleaned on upload:

  • Names are lowercased and URL-decoded.
  • A + character is replaced with _. A folder name cannot contain + at all.
  • A leading . is removed from each segment of the name.
  • Backslashes are converted to forward slashes.

Build your integration so it reads the returned fileName and filePath rather than assuming the name it sent was kept verbatim.

Limits and allowed file types

Limit Value
Files per upload request 10
Maximum request size 500 MB, covering the whole request including a multi-file upload
Files inside a single archive 10,000
Uncompressed size of a single archive 500 MB

Contact CIMcloud Support if your integration needs a higher limit.

Files are accepted by MIME type:

Group Accepted types
Images image/jpeg, image/png, image/gif, image/bmp, image/webp, image/avif
Documents application/pdf, text/plain, text/csv, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document
Archives application/zip, application/x-zip-compressed
Other Any text/* type

On /files/upload, the content type your client declares for each part is what is checked. On /files/upload-stream the type is worked out from the file name’s extension instead, and the request’s Content-Type is used only when the extension is unrecognised — so send a correct extension in X-Upload-FileName.

Endpoints

Upload files

POST /files/upload uploads one or more files as multipart form data. Files are accepted, queued, and written to storage in the background. Use this endpoint for ordinary uploads of one or a few files.

Content type: multipart/form-data

Field Type Required Description
Files file[] Yes The files to upload. Ten at most.
FilePath string Yes Destination path. Must start with one of the root folders above.
UnzipFile bool No Extract the file after upload, if it is an archive.
RecursiveUnzip bool No Also extract archives nested inside the archive.
ExternalId string No The file’s identifier in the system it came from. Stored alongside the file, so a later sync can tell that it is already here.
curl -X POST "https://api.cimcloud.com/<sitename>/files/upload" \
  -H "Authorization: Bearer <token>" \
  -F "Files=@/path/to/widget-blue.jpg" \
  -F "FilePath=images/products" \
  -F "UnzipFile=false" \
  -F "RecursiveUnzip=false"

A successful request returns 200 OK:

{
  "success": true,
  "jobId": "A1B2C3D4E5F6...",
  "message": "",
  "errorMessage": null,
  "uploadedFiles": [
    {
      "id": "abc123...",
      "jobId": "A1B2C3D4E5F6...",
      "fileAction": "upload_file",
      "referenceId": "...",
      "fileName": "widget-blue.jpg",
      "filePath": "images/products",
      "status": "queued",
      "contentType": "image/jpeg",
      "uploadDate": "2026-07-23T14:00:00Z",
      "errorMessage": ""
    }
  ]
}

A 200 means the files were accepted, not that they are stored. Keep the jobId and poll the job status endpoint to confirm the upload finished.

Upload a single large file

POST /files/upload-stream uploads one file as a raw binary body rather than multipart form data, which suits large files. It is queued exactly as /files/upload is, and returns the same response.

Body: the raw file bytes, sent as application/octet-stream or the file’s own content type.

Header Required Description
X-Upload-FileName Yes The file name, including its extension.
X-Upload-FilePath Yes Destination path. Same rules as FilePath.
X-Upload-UnzipFiles No Extract after upload.
X-Upload-UnzipRecursively No Also extract nested archives.
X-Upload-ExternalId No The file’s identifier in the system it came from, as ExternalId above.
curl -X POST "https://api.cimcloud.com/<sitename>/files/upload-stream" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/octet-stream" \
  -H "X-Upload-FileName: catalog.zip" \
  -H "X-Upload-FilePath: images/catalog" \
  -H "X-Upload-UnzipFiles: true" \
  -H "X-Upload-UnzipRecursively: false" \
  --data-binary "@/path/to/catalog.zip"

Uploading an archive

Set UnzipFile, or X-Upload-UnzipFiles on the stream endpoint, to extract an archive when it arrives. This is the efficient way to load a batch of product images in one call.

  • The folder structure inside the archive is recreated under your destination path.
  • Each extracted file is queued under the same jobId as the upload, so one status poll covers the whole archive.
  • The archive itself is not kept. Only its contents are stored.
  • Archives nested inside the archive are extracted only when RecursiveUnzip is also set.
  • An archive that fails validation is reported against the job with the message Invalid or potentially unsafe zip file.

Create a folder

POST /files/folder creates an empty folder. The folder is recorded immediately, so it appears in your file list straight away; it holds nothing until you upload files into it.

Content type: multipart/form-data

Field Required Description
FilePath Yes The parent path the folder is created under.
FolderName Yes Name of the new folder. Cannot contain +.
curl -X POST "https://api.cimcloud.com/<sitename>/files/folder" \
  -H "Authorization: Bearer <token>" \
  -F "FilePath=images/test" \
  -F "FolderName=spring catalog"

Delete files

DELETE /files deletes one or more individual files. The files are removed during the request, not queued.

Content type: application/json

{ "files": ["images/products/widget-blue.jpg", "images/logo.png"] }

Pass the full stored path of each file. A successful request returns:

{ "success": true, "message": "File(s) Successfully Deleted." }

Delete a folder

DELETE /files/folder deletes a folder and everything in it. Send FilePath as multipart form data.

The folder record is removed immediately, so it disappears from your file list at once, and its contents are then deleted in the background. Nothing in this API reverses the deletion, and the files are not recoverable through it. Confirm the path before you call it.

The root folders cannot be deleted.

Check the status of an upload

GET /files/queue/{jobId} returns the processing status of every file in an upload or delete job. Pass the jobId the upload returned.

{
  "jobId": "A1B2C3D4E5F6...",
  "success": true,
  "errorMessage": "",
  "fileCount": 1,
  "successFileCount": 1,
  "errorFileCount": 0,
  "pendingFileCount": 0,
  "files": [
    {
      "fileId": "abc123...",
      "jobId": "A1B2C3D4E5F6...",
      "status": "success",
      "fileName": "widget-blue.jpg",
      "filePath": "images/products",
      "contentType": "image/jpeg",
      "errorMessage": ""
    }
  ]
}

Each file carries one of these statuses:

Status Meaning
queued Accepted, not yet picked up.
pending Being processed.
success Written to storage. The file is live.
failed Not stored. Read errorMessage on that file.
deleted Removed. Delete jobs only.

The count fields cover files only; folder entries are not included in them.

Treat the job as finished when pendingFileCount reaches zero. A file that comes back failed will not be retried for you — read its errorMessage, correct the problem, and upload it again. Poll at a sensible interval rather than in a tight loop; a few seconds between calls is enough for an ordinary upload.

Immediate and queued operations

Some operations complete inside the request and some are queued, so your integration should not treat them alike.

Operation Behaviour
Upload files Queued. Poll the job status endpoint.
Upload a single large file Queued. Poll the job status endpoint.
Create a folder Completes in the request.
Delete files Completes in the request.
Delete a folder The folder record is removed in the request; its contents are deleted in the background.

Response shapes by status code

The file endpoints return two different objects, and which one you get depends on the status code. Parse accordingly.

Status Body
200 The standard response object, with success: true.
400 The same object, with success: false and the reason in errorMessage, or in message for a few validation failures.
401 No body. The token is missing, expired or invalid.
500 An error object: { "error": "...", "errorCode": "INTERNAL_ERROR" }. The job status endpoint uses errorCode: "STATUS_ERROR".

For status codes across the wider API, see HTTP Status Codes.

Worked example

Uploading one product image and confirming it stored, end to end.

1. Get a token.

curl -X POST "https://api.cimcloud.com/<sitename>/authenticate" \
  -H "Content-Type: application/json" \
  -d '{"AuthKey":"...","AuthUserName":"...","AuthPassword":"..."}'

2. Upload the file, and keep the jobId from the response.

curl -X POST "https://api.cimcloud.com/<sitename>/files/upload" \
  -H "Authorization: Bearer <token>" \
  -F "Files=@/path/to/widget-blue.jpg" \
  -F "FilePath=images/products"

3. Poll the job until nothing is pending.

curl -X GET "https://api.cimcloud.com/<sitename>/files/queue/A1B2C3D4E5F6..." \
  -H "Authorization: Bearer <token>"

4. Confirm. When pendingFileCount is 0 and the file’s status is success, it is stored and live on the site.

Troubleshooting

Message Cause and fix
No files provided The request carried no Files field, or it was empty.
Too many files. Maximum allowed: 10 Split the upload into batches of ten or fewer, or send an archive and let it extract.
A file path is required. FilePath was missing.
Files must be uploaded under the following root folders: attachments, images, uploads. The destination path does not start with a root folder. Use images or uploads for your own files.
File '<name>' is empty The file arrived with no name.
File '<name>' exceeds maximum size of <N>MB The file is over the size limit.
File type '<contentType>' is not allowed for file '<name>' The MIME type is not in the accepted list. Check what your client is sending as the content type — the declared type is what is checked, not the extension.
Invalid or potentially unsafe zip file. The archive failed validation, or exceeds 10,000 files or 500 MB uncompressed. Reported against the job rather than the request.
X-Upload-FileName header is required Stream upload only. Add the header.
Invalid folder name/path provided. The folder name or parent path was missing, or the name contains +.
Folder already exists. A folder of that name is already present at that path.
Folder not found. The path given to the folder delete does not exist.
Folder is protected and cannot be deleted. The path is one of the reserved root folders.
File '<name>' is in a protected folder and cannot be deleted. As above, for an individual file.
Invalid file IDs supplied. The files array was empty.
No records found for given Job ID. The jobId is wrong, or the job has aged out.

References

Was this article helpful

Related Articles