Create Images from Templates (Bulk)
Send a POST request to this endpoint to create multiple images at once using multiple templates.
ℹ️
You will need to authenticate to use this API. See authentication.
ℹ️
This endpoint consumes 1 credit per image generated in the batch. For example, requesting 10 image variations will consume 10 credits.
Request
POST https://api.ojo.so/v1/image/bulkRequest Body
| Parameter | Type | Description | 
|---|---|---|
| templates | array | Array of template objects to generate images from | 
| defaultOptions | object | (Optional) Default options to apply to all templates unless overridden | 
Template Object
| Parameter | Type | Description | 
|---|---|---|
| templateId | string | The ID of the template to use | 
| modifications | array | Array of objects containing variables to modify in the template for each image | 
| viewportHeight | number | (Optional) Height of the viewport in pixels (overrides defaultOptions) | 
| viewportWidth | number | (Optional) Width of the viewport in pixels (overrides defaultOptions) | 
| transparentBackground | boolean | (Optional) When true, generates images with transparent backgrounds (overrides defaultOptions) | 
DefaultOptions Object
| Parameter | Type | Description | 
|---|---|---|
| viewportHeight | number | (Optional) Default height of the viewport in pixels (default: 800) | 
| viewportWidth | number | (Optional) Default width of the viewport in pixels (default: 1280) | 
| transparentBackground | boolean | (Optional) Default transparent background setting (default: false) | 
curl --request POST \
  --url https://api.ojo.so/v1/image/bulk \
  --header 'Authorization: Bearer <API Key>' \
  --header 'Content-Type: application/json' \
  --data '{
    "defaultOptions": {
      "viewportWidth": 1200,
      "viewportHeight": 630,
      "transparentBackground": false
    },
    "templates": [
      {
        "templateId": "product-card-template",
        "modifications": [
          {
            "title": "Premium Headphones",
            "price": "$199.99",
            "color": "#FF5733"
          },
          {
            "title": "Wireless Earbuds",
            "price": "$89.99",
            "color": "#33FF57"
          }
        ]
      },
      {
        "templateId": "social-post-template",
        "viewportHeight": 1080,
        "viewportWidth": 1080,
        "modifications": [
          {
            "heading": "Summer Sale",
            "tagline": "Up to 50% off",
            "bgColor": "#3357FF"
          }
        ]
      }
    ]
  }'Response
Everything went as planned and your images are generated.
{
  "images": [
    {
      "id": "image-id-1",
      "templateId": "product-card-template",
      "imageUrl": "https://example.com/path/to/image1.png",
      "createdAt": "2023-08-29T12:34:56Z"
    },
    {
      "id": "image-id-2",
      "templateId": "product-card-template",
      "imageUrl": "https://example.com/path/to/image2.png",
      "createdAt": "2023-08-29T12:34:57Z"
    },
    {
      "id": "image-id-3",
      "templateId": "social-post-template",
      "imageUrl": "https://example.com/path/to/image3.png",
      "createdAt": "2023-08-29T12:34:58Z"
    }
  ],
  "totalRequested": 3,
  "successCount": 3,
  "failureCount": 0
}If some images failed to generate, you will receive both successful results and errors:
{
  "images": [
    {
      "id": "image-id-1",
      "templateId": "product-card-template",
      "imageUrl": "https://example.com/path/to/image1.png",
      "createdAt": "2023-08-29T12:34:56Z"
    },
    {
      "id": "image-id-3",
      "templateId": "social-post-template",
      "imageUrl": "https://example.com/path/to/image3.png",
      "createdAt": "2023-08-29T12:34:58Z"
    }
  ],
  "errors": [
    {
      "templateId": "product-card-template",
      "modify": {
        "title": "Wireless Earbuds",
        "price": "$89.99",
        "color": "#33FF57"
      },
      "error": "Failed to generate image",
      "logs": ["Error detail information"]
    }
  ],
  "totalRequested": 3,
  "successCount": 2,
  "failureCount": 1
}Limitations
- Maximum Batch Size: You can generate up to 50 images in a single batch request across all templates combined.
 - Credit Consumption: Each image generated in the batch consumes 1 credit.
 - Rate Limiting: Bulk requests are subject to the same rate limits as individual requests. See rate limits for details.