Skip to main content
POST
/
api
/
v1
/
organizations
/
{organizationId}
/
projects
/
{projectId}
/
assets
/
{id}
/
optimize
curl -X POST "https://api.metabind.ai/api/v1/organizations/org123/projects/proj456/assets/asset789/optimize" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "options": {
      "quality": 80,
      "format": "webp",
      "width": 1200,
      "height": 800
    }
  }'
{
  "data": {
    "id": "asset789",
    "name": "hero-image.webp",
    "type": "image/webp",
    "status": "active",
    "url": "https://cdn.metabind.ai/org123/proj456/assets/asset789/hero-image.webp",
    "size": 245760,
    "metadata": {
      "width": 1200,
      "height": 800,
      "format": "webp",
      "originalSize": 2048576,
      "compressionRatio": 0.12
    },
    "tags": ["hero", "optimized"],
    "createdAt": "2024-03-20T10:00:00Z",
    "updatedAt": "2024-03-21T17:00:00Z"
  }
}
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

organizationId
string
required
The unique identifier of the organization
projectId
string
required
The unique identifier of the project
id
string
required
The unique identifier of the asset

Request Body

options
object
required
Optimization options

Response

Returns the optimized Asset object with updated metadata.
curl -X POST "https://api.metabind.ai/api/v1/organizations/org123/projects/proj456/assets/asset789/optimize" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "options": {
      "quality": 80,
      "format": "webp",
      "width": 1200,
      "height": 800
    }
  }'
{
  "data": {
    "id": "asset789",
    "name": "hero-image.webp",
    "type": "image/webp",
    "status": "active",
    "url": "https://cdn.metabind.ai/org123/proj456/assets/asset789/hero-image.webp",
    "size": 245760,
    "metadata": {
      "width": 1200,
      "height": 800,
      "format": "webp",
      "originalSize": 2048576,
      "compressionRatio": 0.12
    },
    "tags": ["hero", "optimized"],
    "createdAt": "2024-03-20T10:00:00Z",
    "updatedAt": "2024-03-21T17:00:00Z"
  }
}

Optimization Tips

For general web use, convert to WebP with quality 80:
{
  "options": {
    "format": "webp",
    "quality": 80
  }
}
For thumbnails, resize and compress aggressively:
{
  "options": {
    "format": "webp",
    "quality": 70,
    "width": 300,
    "height": 300
  }
}
For smallest file size, use AVIF (where supported):
{
  "options": {
    "format": "avif",
    "quality": 60
  }
}