Create Images from Template (Bulk)
Send a POST request to this endpoint to create multiple images at once using a predefined template.
ℹ️
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/bulk
Request Body
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 (default: 800) |
viewportWidth | number | (Optional) Width of the viewport in pixels (default: 1280) |
transparentBackground | boolean | (Optional) When set to true, generates the image with a transparent background. Defaults to false if not specified. |
curl --request POST \
--url https://api.ojo.so/v1/image/bulk \
--header 'Authorization: Bearer <API Key>' \
--header 'Content-Type: application/json' \
--data '{
"templateId": "your-template-id",
"modifications": [
{
"title": "First Image Title",
"color": "#FF5733"
},
{
"title": "Second Image Title",
"color": "#33FF57"
},
{
"title": "Third Image Title",
"color": "#3357FF"
}
],
"viewportHeight": 1000,
"viewportWidth": 1500,
"transparentBackground": false
}'
Response
Everything went as planned and your images are generated.
{
"images": [
{
"id": "image-id-1",
"imageUrl": "https://example.com/path/to/image1.png",
"createdAt": "2023-08-29T12:34:56Z"
},
{
"id": "image-id-2",
"imageUrl": "https://example.com/path/to/image2.png",
"createdAt": "2023-08-29T12:34:57Z"
},
{
"id": "image-id-3",
"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",
"imageUrl": "https://example.com/path/to/image1.png",
"createdAt": "2023-08-29T12:34:56Z"
},
{
"id": "image-id-3",
"imageUrl": "https://example.com/path/to/image3.png",
"createdAt": "2023-08-29T12:34:58Z"
}
],
"errors": [
{
"modify": {
"title": "Second Image Title",
"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.
- 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.