Skip to main content

Upload asset

Endpoint

/i/content/asset-upload

Enterprise Only
This API is available exclusively in Countly Enterprise.

Overview

Uploads an asset file with compression, thumbnail generation, and GridFS storage.

Authentication

  • Authentication methods:
    • API Key (parameter): api_key=YOUR_API_KEY
    • Auth Token (parameter): auth_token=YOUR_AUTH_TOKEN
    • Auth Token (header): countly-token: YOUR_AUTH_TOKEN

Permissions

  • Required permission: Create on the content feature

Request Parameters

ParameterTypeRequiredDescription
api_keyStringYes (or auth_token)API key for authentication
auth_tokenStringYes (or api_key)Auth token for authentication
app_idStringYesApplication identifier
assetsFileYesMultipart file upload (max 5 MB)
nameStringNoCustom filename; defaults to uploaded filename
thumbnailStringNoData URL thumbnail (for example data:image/png;base64,...)
tagsStringNoJSON stringified array of tags
widthNumberNoStored as metadata.dimensions.width (only if height is also provided)
heightNumberNoStored as metadata.dimensions.height (only if width is also provided)

Response

Success Response

{
"status": "Success",
"assetId": "507f1f77bcf86cd799439011"
}

Response Fields

FieldTypeDescription
statusStringOperation status
assetIdStringGridFS object ID of uploaded asset

Error Responses

HTTP StatusResponse
400"Missing app_id"
400"File Size exceeds 5MB"
400"Missing file thumbnail"
400"Asset not found"
400"The file named {name} could not be added because it already exists."
400Processing/validation error message from upload flow

Behavior/Processing

  1. Validates request authentication and permissions.
  2. Parses optional metadata (tags, width, height).
  3. Enforces 5 MB max file size.
  4. Compresses image data and generates thumbnail (or uses provided thumbnail).
  5. Saves file and metadata to GridFS.
  6. Returns uploaded assetId.

Database Collections

CollectionUsed forData touched by this endpoint
countly_fs.content_assets{app_id}.filesEndpoint data source** - GridFS file metadata
countly_fs.content_assets{app_id}.chunksEndpoint data source** - GridFS binary chunks

Examples

Example 1: Upload JPEG

curl -X POST "https://your-server.com/i/content/asset-upload" \
-F "api_key=YOUR_API_KEY" \
-F "app_id=5be987d7b93798516eb5289a" \
-F "assets=@banner.jpg" \
-F "name=campaign_banner_v1" \
-F 'tags=["campaign","banner"]'

Example 2: Upload PNG With Dimensions

curl -X POST "https://your-server.com/i/content/asset-upload" \
-F "api_key=YOUR_API_KEY" \
-F "app_id=5be987d7b93798516eb5289a" \
-F "assets=@logo.png" \
-F "name=company_logo" \
-F 'tags=["branding","logo"]' \
-F "width=1024" \
-F "height=512"

Limitations

  • Max file size: 5 MB.
  • Compression handling is implemented for JPEG and PNG inputs.
  • Filenames must be unique within the app-specific GridFS bucket.
  • Auto thumbnail max size is 400 × 400.

Ⓔ Enterprise

This feature is part of Countly Enterprise.

Get Access:

Already a Customer? Use support portal if you have any questions


Last Updated

2026-02-16