curl -X POST "https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/assets/asset789/optimize" \
-H "Authorization: Bearer YOUR_JWT" \
-H "Content-Type: application/json" \
-d '{
"options": {
"quality": 80,
"format": "webp",
"width": 1200,
"height": 800
}
}'
const response = await fetch(
'https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/assets/asset789/optimize',
{
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_JWT',
'Content-Type': 'application/json'
},
body: JSON.stringify({
options: {
quality: 80,
format: 'webp',
width: 1200,
height: 800
}
})
}
);
const data = await response.json();
{
"data": {
"id": "asset790",
"name": "hero-image-w1200-h800-q80.webp",
"type": "image/webp",
"status": "active",
"url": "https://cdn.metabind.ai/org123/proj456/assets/asset790/hero-image-w1200-h800-q80.webp",
"size": 245760,
"metadata": {
"width": 1200,
"height": 800,
"format": "webp",
"originalAssetId": "asset789",
"optimizationParams": {
"quality": 80,
"format": "webp",
"width": 1200,
"height": 800
}
},
"tags": ["hero", "optimized"],
"createdAt": "2024-03-21T17:00:00Z",
"updatedAt": "2024-03-21T17:00:00Z"
}
}
{
"error": {
"code": "VALIDATION_FAILED",
"message": "Asset optimization is only supported for images, not video/mp4"
}
}
Assets
Optimize Asset
Create an optimized version of an asset with format conversion and resizing
POST
/
app
/
v1
/
organizations
/
{organizationId}
/
projects
/
{projectId}
/
assets
/
{id}
/
optimize
curl -X POST "https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/assets/asset789/optimize" \
-H "Authorization: Bearer YOUR_JWT" \
-H "Content-Type: application/json" \
-d '{
"options": {
"quality": 80,
"format": "webp",
"width": 1200,
"height": 800
}
}'
const response = await fetch(
'https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/assets/asset789/optimize',
{
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_JWT',
'Content-Type': 'application/json'
},
body: JSON.stringify({
options: {
quality: 80,
format: 'webp',
width: 1200,
height: 800
}
})
}
);
const data = await response.json();
{
"data": {
"id": "asset790",
"name": "hero-image-w1200-h800-q80.webp",
"type": "image/webp",
"status": "active",
"url": "https://cdn.metabind.ai/org123/proj456/assets/asset790/hero-image-w1200-h800-q80.webp",
"size": 245760,
"metadata": {
"width": 1200,
"height": 800,
"format": "webp",
"originalAssetId": "asset789",
"optimizationParams": {
"quality": 80,
"format": "webp",
"width": 1200,
"height": 800
}
},
"tags": ["hero", "optimized"],
"createdAt": "2024-03-21T17:00:00Z",
"updatedAt": "2024-03-21T17:00:00Z"
}
}
{
"error": {
"code": "VALIDATION_FAILED",
"message": "Asset optimization is only supported for images, not video/mp4"
}
}
Create an optimized version of an image asset with specified transformations. This permanently creates a new optimized version of the asset.
For on-demand transformations without creating new assets, use CDN URL parameters instead.
Path Parameters
Request Body
Response
Returns a new Asset object for the optimized image. The original asset is not changed.curl -X POST "https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/assets/asset789/optimize" \
-H "Authorization: Bearer YOUR_JWT" \
-H "Content-Type: application/json" \
-d '{
"options": {
"quality": 80,
"format": "webp",
"width": 1200,
"height": 800
}
}'
const response = await fetch(
'https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/assets/asset789/optimize',
{
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_JWT',
'Content-Type': 'application/json'
},
body: JSON.stringify({
options: {
quality: 80,
format: 'webp',
width: 1200,
height: 800
}
})
}
);
const data = await response.json();
{
"data": {
"id": "asset790",
"name": "hero-image-w1200-h800-q80.webp",
"type": "image/webp",
"status": "active",
"url": "https://cdn.metabind.ai/org123/proj456/assets/asset790/hero-image-w1200-h800-q80.webp",
"size": 245760,
"metadata": {
"width": 1200,
"height": 800,
"format": "webp",
"originalAssetId": "asset789",
"optimizationParams": {
"quality": 80,
"format": "webp",
"width": 1200,
"height": 800
}
},
"tags": ["hero", "optimized"],
"createdAt": "2024-03-21T17:00:00Z",
"updatedAt": "2024-03-21T17:00:00Z"
}
}
{
"error": {
"code": "VALIDATION_FAILED",
"message": "Asset optimization is only supported for images, not video/mp4"
}
}
Optimization Tips
Web Images
Web Images
For general web use, convert to WebP with quality 80:
{
"options": {
"format": "webp",
"quality": 80
}
}
Thumbnails
Thumbnails
For thumbnails, resize and compress aggressively:
{
"options": {
"format": "webp",
"quality": 70,
"width": 300,
"height": 300
}
}
Maximum Compression
Maximum Compression
For smallest file size, use AVIF (where supported):
{
"options": {
"format": "avif",
"quality": 60
}
}