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}}'