Endpoints

Upload asset

Upload a file to a chat and get a permanent CDN URL

POST/api/client-app/assets/upload

Uploads a file to a chat’s Assets and returns a permanent CDN URL. Use this for images, documents, audio, video, or any other file you want your app or workflow to reference by URL.

Request

POST /api/client-app/assets/upload

Headers

HeaderRequiredDescription
AuthorizationYesBearer macaly_...
Content-TypeYesmultipart/form-data

Form Data Parameters

FieldTypeRequiredDefaultDescription
chatIdstringYes-The chat to upload the asset to
filefileYes-The file to upload. Max size 20 MB
folderPathstringNo-Slash-separated folder path, e.g. images/products
createFoldersstringNofalse"true", "1", or "yes" creates missing folders in folderPath
folderIdstringNo-Existing folder ID. Do not send both folderId and folderPath
titlestringNoOriginal filenameDisplay title for the asset
metadatastring (JSON)No-JSON object stored alongside the asset

Provide either folderId or folderPath, not both. Sending both returns a 400 error.

Example Request

curl -X POST https://www.macaly.com/api/client-app/assets/upload \
  -H "Authorization: Bearer macaly_abc123..." \
  -F "chatId=abc123def456" \
  -F "file=@./logo.png;type=image/png"

Uploading into a folder

Use folderPath for a human-readable folder structure, and set createFolders=true to create any missing folders along the path:

cURL
curl -X POST https://www.macaly.com/api/client-app/assets/upload \
  -H "Authorization: Bearer macaly_abc123..." \
  -F "chatId=abc123def456" \
  -F "folderPath=images/products" \
  -F "createFolders=true" \
  -F "title=Product hero image" \
  -F "file=@./hero.png;type=image/png"

Response

{
  "success": true,
  "asset": {
    "assetId": "asset_123",
    "url": "https://cdn.macaly.app/user/chat/key/logo.png",
    "storageKey": "user/chat/key/logo.png",
    "contentType": "image/png",
    "fileSize": 12345,
    "type": "image",
    "folderId": "folder_123"
  }
}
FieldTypeDescription
asset.assetIdstringUnique identifier for the asset
asset.urlstringPermanent CDN URL for the uploaded file
asset.storageKeystringInternal storage path
asset.contentTypestringMIME type of the uploaded file
asset.fileSizenumberFile size in bytes
asset.typestringInferred asset type, e.g. image, document
asset.folderIdstring | nullFolder the asset was placed in, if any

Status Codes

StatusDescription
200Success - Asset uploaded
400Missing chatId or file, invalid metadata JSON, or both folderId and folderPath provided
401Invalid or missing API key
403API key does not have access to this chat
404Folder not found
413File exceeds the 20 MB upload limit
500Server error

Folder rules

  • Folder paths are split on /, trimmed, and empty segments are ignored.
  • Maximum depth is 8 folders.
  • Each folder name can be up to 255 characters.
  • Folder matching is case-insensitive within the same parent.
  • If folderPath doesn’t exist and createFolders isn’t true, the upload fails with a 404.

Good to know

  • This endpoint uses the same macaly_... API key as the rest of the API, even though the URL starts with /api/client-app/. No separate token is needed.
  • The chat referenced by chatId must belong to the same team as your API key.
  • Uploaded assets get a permanent CDN URL you can reference in Create chat or Publish message as an attachment, or use anywhere outside Macaly.