CDN Endpoints
API endpoints for uploading, managing, and transforming assets.
POST
/cdn/uploadGenerate a presigned URL for uploading a file.
REQUEST BODY
| Field | Type | Required | Description |
|---|---|---|---|
| filename | string | required | Original filename |
| mimeType | string | required | MIME type (e.g., image/jpeg) |
| size | number | required | File size in bytes (max 100MB) |
| folder | string | optional | Folder path for organization |
| metadata | object | optional | Custom metadata |
RESPONSE
| Field | Type | Description |
|---|---|---|
| uploadUrl | string | Presigned S3 URL for upload |
| assetId | string | Asset ID for confirmation |
| cdnUrl | string | CDN URL for the file |
| expiresAt | ISO 8601 | URL 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}/confirmConfirm 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/assetsList assets with optional filters and pagination.
QUERY PARAMETERS
| Parameter | Type | Description |
|---|---|---|
| limit | number | Max results (default 50, max 100) |
| offset | number | Offset for pagination |
| folder | string | Filter by folder |
| type | string | Filter by type (image, video, audio, document, other) |
| search | string | Search by filename |
| sortBy | string | Sort by: createdAt, filename, size |
| sortOrder | string | Sort order: asc, desc |
PATCH
/cdn/assets/{id}Update asset metadata.
DELETE
/cdn/assets/{id}Delete a single asset.
POST
/cdn/assets/deleteDelete multiple assets by their IDs.
POST
/cdn/assets/moveMove one or more assets to a different folder.
POST
/cdn/transformGet a URL for a transformed image with resize, crop, and effects options.
TRANSFORM OPTIONS
| Option | Type | Description |
|---|---|---|
| width | number | Target width (max 4096) |
| height | number | Target height (max 4096) |
| fit | string | cover | contain | fill | inside | outside |
| format | string | auto | jpeg | webp | avif | png |
| quality | number | 1-100 |
| blur | number | 0.3-1000 |
| grayscale | boolean | Convert 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}}'
Video Merge Endpoints
Endpoints for merging multiple videos and images into a single video.
POST
/cdn/video/mergeCreate a merge job to combine multiple videos and images into a single video.
REQUEST BODY
| Field | Type | Required | Description |
|---|---|---|---|
| projectSlug | string | required | Project identifier |
| inputs | array | required | Array of assets to merge (1-100 items) |
| inputs[].assetId | uuid | required | Asset ID of video or image |
| inputs[].duration | number | optional | Duration in seconds (required for images, max 3600) |
| inputs[].startTime | number | optional | Trim start time in seconds (videos only) |
| inputs[].endTime | number | optional | Trim end time in seconds (videos only) |
| audioTrack | object | optional | Audio track overlay configuration |
| audioTrack.assetId | uuid | required | Asset ID of the audio file |
| audioTrack.loop | boolean | optional | Loop audio if shorter than video (default: false) |
| audioTrack.fadeIn | number | optional | Fade in duration (0-10 seconds) |
| audioTrack.fadeOut | number | optional | Fade out duration (0-10 seconds) |
| output | object | optional | Output configuration |
| output.format | string | optional | Output format: mp4, webm (default: mp4) |
| output.quality | string | optional | Quality: 360p, 480p, 720p, 1080p, 1440p, 2160p (default: 720p) |
| output.filename | string | optional | Custom filename (max 255 chars) |
| webhookUrl | string | optional | URL for completion notification |
Example Request
curl -X POST "https://api.stack0.dev/cdn/video/merge" \-H "Authorization: Bearer sk_live_your_api_key" \-H "Content-Type: application/json" \-d '{"projectSlug": "my-project","inputs": [{ "assetId": "uuid-1" },{ "assetId": "uuid-2", "duration": 5 },{ "assetId": "uuid-3", "startTime": 10, "endTime": 60 }],"audioTrack": {"assetId": "audio-uuid","loop": true,"fadeIn": 2,"fadeOut": 3},"output": {"format": "mp4","quality": "1080p"}}'
GET
/cdn/video/merge/{jobId}Get details of a merge job including status and output asset.
RESPONSE
| Field | Type | Description |
|---|---|---|
| id | uuid | Merge job ID |
| status | string | pending, queued, processing, completed, failed, cancelled |
| progress | number | Progress percentage (0-100) |
| outputAsset | object | Output asset details (when completed) |
| outputAsset.cdnUrl | string | CDN URL of the merged video |
| outputAsset.duration | number | Total duration in seconds |
| outputAsset.size | number | File size in bytes |
GET
/cdn/video/mergeList merge jobs with optional status filter.
QUERY PARAMETERS
| Parameter | Type | Description |
|---|---|---|
| projectSlug | string | Project identifier (required) |
| status | string | Filter by status |
| limit | number | Max results (default 20, max 100) |
| offset | number | Offset for pagination |
POST
/cdn/video/merge/{jobId}/cancelCancel a pending or processing merge job.
Example Request
curl -X POST "https://api.stack0.dev/cdn/video/merge/job-uuid/cancel" \-H "Authorization: Bearer sk_live_your_api_key"