CDN Endpoints

API endpoints for uploading, managing, and transforming assets.

POST/cdn/upload

Generate a presigned URL for uploading a file.

REQUEST BODY

FieldTypeRequiredDescription
filenamestringrequiredOriginal filename
mimeTypestringrequiredMIME type (e.g., image/jpeg)
sizenumberrequiredFile size in bytes (max 100MB)
folderstringoptionalFolder path for organization
metadataobjectoptionalCustom metadata

RESPONSE

FieldTypeDescription
uploadUrlstringPresigned S3 URL for upload
assetIdstringAsset ID for confirmation
cdnUrlstringCDN URL for the file
expiresAtISO 8601URL expiration time
Example Request
curl -X POST "https://api.stack0.dev/cdn/upload" \
-H "Authorization: Bearer sk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"filename": "profile.jpg",
"mimeType": "image/jpeg",
"size": 102400,
"folder": "avatars"
}'
POST/cdn/upload/{assetId}/confirm

Confirm that a file upload has completed successfully.

Example Request
curl -X POST "https://api.stack0.dev/cdn/upload/asset_xxx/confirm" \
-H "Authorization: Bearer sk_live_your_api_key"
GET/cdn/assets/{id}

Get a single asset by ID.

GET/cdn/assets

List assets with optional filters and pagination.

QUERY PARAMETERS

ParameterTypeDescription
limitnumberMax results (default 50, max 100)
offsetnumberOffset for pagination
folderstringFilter by folder
typestringFilter by type (image, video, audio, document, other)
searchstringSearch by filename
sortBystringSort by: createdAt, filename, size
sortOrderstringSort order: asc, desc
PATCH/cdn/assets/{id}

Update asset metadata.

DELETE/cdn/assets/{id}

Delete a single asset.

POST/cdn/assets/delete

Delete multiple assets by their IDs.

POST/cdn/assets/move

Move one or more assets to a different folder.

POST/cdn/transform

Get a URL for a transformed image with resize, crop, and effects options.

TRANSFORM OPTIONS

OptionTypeDescription
widthnumberTarget width (max 4096)
heightnumberTarget height (max 4096)
fitstringcover | contain | fill | inside | outside
formatstringauto | jpeg | webp | avif | png
qualitynumber1-100
blurnumber0.3-1000
grayscalebooleanConvert to grayscale
Example Request
curl -X POST "https://api.stack0.dev/cdn/transform" \
-H "Authorization: Bearer sk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"assetId": "asset_xxx",
"options": {
"width": 400,
"height": 300,
"fit": "cover",
"format": "webp",
"quality": 80
}
}'