PlatformXeDocs
Get API Key

Upload Files

API reference for uploading files by direct upload, batch upload, or a signed URL and registration.

PlatformXe supports three upload methods depending on your architecture: direct server-side upload (one file or a batch), and a signed URL for a client-side upload that you then register.

Direct upload

Upload one file from your server to PlatformXe, base64-encoded in a JSON body.

POST /api/v1/storage/media/upload

Scope: storage:upload

Content-Type: application/json

Send an x-idempotency-key header to make a retry safe: a repeat with the same key answers the first upload's result instead of storing the file again.

Request body

FieldTypeRequiredDescription
modulestringYesYour grouping, e.g. properties
entityIdstringYesThe record the file belongs to
filenamestringYesThe file's name
mimeTypestringYesMIME type, e.g. image/jpeg. Images (JPEG, PNG, WebP, GIF, HEIC), videos (MP4, MOV, WebM) and documents (PDF, DOC, DOCX, XLS, XLSX)
contentstringYesThe file's bytes, base64-encoded
categorystringNoYour category for the file
metadataobjectNoYour own key-value data

The file is stored under your caller service, module and entityId, and takes the next display order for that record. A video is handed to streaming (streamingAssetId). The base64 text counts toward the request body limit of about 4.5 MB (about 3.3 MB of file); use a signed upload for anything larger.

HEIC/HEIF is accepted and converted. iPhone photos arrive as HEIC, which no browser except Safari renders. PlatformXe transcodes them to JPEG before storage, so the stored file, its url, format and fileSize describe the JPEG (the name keeps its stem with a .jpg extension, and the JPEG is typically ~1.5× the HEIC). A HEIC the decoder cannot read is refused with 415 UNSUPPORTED_MEDIA_TYPE rather than stored unreadable — convert it before uploading (on an iPhone: Settings → Camera → Formats → Most Compatible).

Response (201)

The stored file, with the same fields as each item of a batch upload's uploaded:

{
  "success": true,
  "data": {
    "id": "k7w2p9x4m1q8z3n6t5r0v2ya",
    "url": "https://…/receipt.pdf",
    "publicUrl": "https://…/receipt.pdf",
    "providerKey": "your-app/invoices/inv-2026-001/receipt.pdf",
    "storagePath": "your-app/invoices/inv-2026-001/receipt.pdf",
    "supabasePath": null,
    "storageProvider": "<storage tier>",
    "mimeType": "application/pdf",
    "displayOrder": 1,
    "width": null,
    "height": null,
    "fileSize": 245760,
    "fileHash": "…",
    "thumbnailUrl": null,
    "moderationStatus": "SKIPPED",
    "duration": null,
    "format": "pdf",
    "streamingAssetId": null
  }
}

Use id to read, reorder or delete the file, and storagePath rather than supabasePath, its older name, which is null for files in current storage.

CodeStatusDescription
BAD_REQUEST400The body is not JSON, or module, entityId, filename, mimeType or content is missing
UNSUPPORTED_MEDIA_TYPE415An accepted type that could not be made storable (a HEIC/HEIF the decoder cannot read)
UPLOAD_FAILED500The file was not stored. This includes a type that is not accepted and a file over its size limit: the message says which; do not retry those unchanged

curl

curl -X POST https://api.platformxe.com/api/v1/storage/media/upload \
  -H "Content-Type: application/json" \
  -H "x-api-key: pxk_live_your_api_key_here" \
  -H "x-idempotency-key: upload-inv-2026-001-receipt" \
  -d '{
    "module": "invoices",
    "entityId": "inv-2026-001",
    "filename": "receipt.pdf",
    "mimeType": "application/pdf",
    "content": "JVBERi0xLjcK..."
  }'

SDK

import { PlatformXeClient } from '@caldera/platformxe-sdk';

const px = new PlatformXeClient({ apiKey: 'pxk_live_your_api_key_here' });

const file = await px.storage.upload({
  module: 'invoices',
  entityId: 'inv-2026-001',
  filename: 'receipt.pdf',
  mimeType: 'application/pdf',
  content: pdfBuffer.toString('base64'),
});

console.log(file.id, file.url);

Batch upload

Upload up to 20 files for one record in a single request. The files are stored one after another; a file that fails does not stop the others.

POST /api/v1/storage/media/upload/batch

Scope: storage:upload

Content-Type: application/json

Request body

FieldTypeRequiredDescription
modulestringYesYour grouping, e.g. properties
entityIdstringYesThe record the files belong to
filesarrayYes1 to 20 files, each below
files[].filenamestringYesThe file's name
files[].mimeTypestringYesMIME type, e.g. image/jpeg
files[].contentstringYesThe file's bytes, base64-encoded
files[].categorystringNoYour category for the file

Each file is stored as a single upload stores it: a HEIC/HEIF is converted to JPEG, and a video is handed to streaming.

curl -X POST https://api.platformxe.com/api/v1/storage/media/upload/batch \
  -H "Content-Type: application/json" \
  -H "x-api-key: pxk_live_your_api_key_here" \
  -d '{
    "module": "properties",
    "entityId": "prop-1",
    "files": [
      { "filename": "front.jpg", "mimeType": "image/jpeg", "content": "/9j/4AAQSkZJRg..." },
      { "filename": "kitchen.jpg", "mimeType": "image/jpeg", "content": "/9j/4AAQSkZJRg...", "category": "interior" }
    ]
  }'

Response (201)

{
  "success": true,
  "data": {
    "totalUploaded": 1,
    "uploaded": [
      {
        "id": "f3g7j1k5m9p2r6t0v4x8z1bd",
        "url": "https://…/front.jpg",
        "publicUrl": "https://…/front.jpg",
        "providerKey": "your-app/properties/prop-1/front.jpg",
        "storagePath": "your-app/properties/prop-1/front.jpg",
        "supabasePath": null,
        "storageProvider": "<storage tier>",
        "mimeType": "image/jpeg",
        "displayOrder": 1,
        "width": 1600,
        "height": 1200,
        "fileSize": 248000,
        "fileHash": "…",
        "thumbnailUrl": null,
        "moderationStatus": "PENDING",
        "duration": null,
        "format": "jpg",
        "streamingAssetId": null
      }
    ],
    "errors": ["Failed to upload kitchen.jpg: …"]
  }
}

uploaded holds each stored file (the same fields as a single upload's answer); errors holds one message per file that was not stored. The answer is 201 whenever the request was valid, also when some or all files failed: check errors (and totalUploaded against the number you sent) and resend only the failed files. Use storagePath rather than supabasePath, its older name, which is null for files in current storage.

CodeStatusDescription
BAD_REQUEST400Invalid JSON; module, entityId or a non-empty files array missing; or more than 20 files
UPLOAD_FAILED500The batch could not be run

Signed upload

Get a presigned URL so a browser can upload a large file straight to storage, without passing the bytes through your server. Then register the file (Register a presigned upload, below) so PlatformXe records it.

POST /api/v1/storage/media/sign-upload

Scope: storage:upload

Request body

FieldTypeRequiredDescription
filenamestringYesOriginal filename. PlatformXe makes it unique in the stored path
mimeTypestringYesMIME type of the file (e.g. image/jpeg)
modulestringNoYour grouping, e.g. properties. Default media
entityIdstringNoThe record the file belongs to. Default general

Any other field is ignored. The file is stored at {your caller service}/{module}/{entityId}/{unique filename}.

Response

{
  "success": true,
  "data": {
    "signedUrl": "https://…/your-app/properties/prop-1/1732113000000-k3x9qa-avatar.jpg?…",
    "path": "your-app/properties/prop-1/1732113000000-k3x9qa-avatar.jpg",
    "publicUrl": "https://…/your-app/properties/prop-1/1732113000000-k3x9qa-avatar.jpg",
    "bucket": "<container>",
    "provider": "<storage tier>",
    "requiredHeaders": { "<header>": "<value>" }
  }
}
FieldDescription
signedUrlThe URL to PUT the file's bytes to
pathThe stored path. Send it as storagePath when you register the file
publicUrlWhere the file is served from once it is uploaded. Send it as url when you register the file
bucketThe storage container
providerAn opaque label for the storage tier that signed the URL. Do not branch on its value
requiredHeadersPresent on some storage tiers only. Send every entry, as given, on the PUT, or the upload is refused
tokenPresent on some storage tiers only. An upload token for that tier; the signedUrl already carries what the PUT needs

Upload within 15 minutes of signing. Some storage tiers allow longer, but do not rely on it: if the PUT is refused as expired, request a new signed URL.

Error responses

CodeStatusDescription
BAD_REQUEST400The body is not JSON, or filename or mimeType is missing
SIGN_FAILED500The URL could not be signed. Retry

curl

# Step 1: get the signed URL
curl -X POST https://api.platformxe.com/api/v1/storage/media/sign-upload \
  -H "Content-Type: application/json" \
  -H "x-api-key: pxk_live_your_api_key_here" \
  -d '{
    "filename": "avatar.jpg",
    "mimeType": "image/jpeg",
    "module": "avatars",
    "entityId": "user-1"
  }'

# Step 2: PUT the bytes to data.signedUrl, with every data.requiredHeaders entry
curl -X PUT "<data.signedUrl>" \
  -H "Content-Type: image/jpeg" \
  -H "<header>: <value>" \
  --data-binary @avatar.jpg

# Step 3: register the file (see below), with url = data.publicUrl and storagePath = data.path

Register a presigned upload

Record a file your app already put in storage through a presigned (signed-upload) URL. PlatformXe checks it, records it beside the files uploaded through PlatformXe, and from then on serves, lists and deletes it like any other.

POST /api/v1/storage/media/register

Scope: storage:upload

Request body

FieldTypeRequiredDescription
urlstringYesThe stored file's URL
originalFilenamestringYesThe file's name
fileSizenumberYesSize in bytes: a positive whole number, at most 2,199,023,254,528 (2^31 - 1 KiB; a string of digits is read as its number). Anything else answers 400 BAD_REQUEST. It is what your organisation's storage usage records
mimeTypestringYesMIME type, e.g. image/jpeg, video/mp4
storagePathstringNoThe path inside the container. Without it, the path is read from the url (supabasePath, its older name, is still accepted)
modulestringNoYour grouping, e.g. properties. Default media
entityIdstringNoThe record the file belongs to. Default general
width, heightnumberNoImage dimensions
duration, formatnumber, stringNoVideo details, kept as metadata
sourceProbedbooleanNoA video that already passed POST /api/v1/media/probe (strict) is not probed again

Response (201)

{
  "success": true,
  "data": {
    "id": "f3g7j1k5m9p2r6t0v4x8z1bd",
    "callerService": "your-app",
    "module": "properties",
    "entityId": "prop-1",
    "originalFilename": "front.jpg",
    "mimeType": "image/jpeg",
    "fileSize": 248000,
    "storageProvider": "<storage tier>",
    "providerKey": "your-app/properties/prop-1/front.jpg",
    "publicUrl": "https://…/front.jpg",
    "width": 1600,
    "height": 1200,
    "displayOrder": 3,
    "moderationStatus": "PENDING",
    "mediaType": "IMAGE",
    "streamingAssetId": null,
    "createdAt": "2026-11-10T14:30:00.000Z"
  }
}

The file takes the next display order of its module and entityId. A video is probed (unless sourceProbed) and handed to streaming; streamingAssetId is its asset, or null when the hand-off did not succeed (the file is still recorded and served as is). Every registered file emits FILE_UPLOADED to your organisation's event subscriptions, as an upload through PlatformXe does.

A registered HEIC/HEIF is normalised the same way as a direct upload: PlatformXe fetches it back, converts it to JPEG, stores the JPEG beside it and deletes the original. The response and the file record describe the JPEG. A blob that cannot be converted returns 415 UNSUPPORTED_MEDIA_TYPE and nothing is recorded.

Error responses

CodeDescription
BAD_REQUESTHTTP 400. The body is not JSON or a required field is missing (on a register, also a fileSize that is not whole bytes, or a url outside the storage container with no storagePath)
FORBIDDENAPI key does not have the storage:upload scope
RATE_LIMITEDRate limit exceeded for this API key
UPLOAD_FAILEDHTTP 500 on a direct or batch upload. A type that is not accepted or a file over its size limit is answered here too (the message says which). Content moderation never refuses an upload: its verdict is the file's moderationStatus
Probe codesHTTP 400 on a register of a video that fails the strict probe (POST /api/v1/media/probe): the probe's own code and message. Not sent when sourceProbed is true
SIGN_FAILEDHTTP 500 on a signed upload. The URL could not be signed; retry
REGISTER_FAILEDHTTP 500 on a register. The file was not recorded; the message is fixed (the cause is logged on PlatformXe's side). Retry
UNSUPPORTED_MEDIA_TYPEHTTP 415. The file is an accepted type that could not be made storable (a HEIC/HEIF the decoder cannot read). Convert it before uploading; retrying will not help