API
Documentation

Requesting a batched render via API

This guide explains how to request a batched render via the API.

This is useful when you want to create multiple renders at once without creating a 1 request for each render request. Results would be batched automatically based on the total number of renders given in the request.

Authorisation

To request a render, you must be authenticated with an API token. You can view a guide on how to create one by visiting the Creating API Tokens page.

Authorisation is done by including the 'Authorization' header with the token in the request. The header should be in the format 'Bearer <token>'.

POSTCreate Batch Render Request

https://imagefactory.io/api/request-batch-render

Note: You will need to set the request Accept header to be 'application/json'

Request Body

The request body should be a JSON object

{
    "requests": [
        {
            "key": "<YOUR REQUEST REFERENCE>",
            "input_{x}": "<Input {x} Content>"
        },
        {
            "key": "<YOUR REQUEST REFERENCE>",
            "input_{x}": "<Input {x} Content>"
        },
        ...
    ],
    "theme_id": <Theme ID>,
}

Note: input_{x} would be replaced with input_1, input_2, input_3 ... input_30. If the theme expects an image input, add the full URL including https:// to the properties value. You would use the key to add your own unique reference so that you know where that render result belongs to. The request array is required along with the child key attributes.

As soon as you make the request, you will get this response:

{
    "success": true,
    "uuid": "944f4320-161a-454e-9539-e896d4d6cbe8",
    "webhook_url": "https://yourwebhook.com/webhook/imagefactory"
}

Where `uuid` is the unique id of the request, and the `webhook_url` is the url where the results will be sent to. Use this `uuid` to track what webhook response is for which original request.

Once the batches of images has been generated, the webhook url will be sent the following in json format:

{
    "uuid":"944f4320-161a-454e-9539-e896d4d6cbe8",
    "output":[
        {
            "key":"YOUR REQUEST REFERENCE",
            "public_url":"https:\/\/d3g0u9hd8wvah6.cloudfront.net\/renders\/3af73a62-413d-4601-aac5-28436e171bf0.jpg"
        },
        {
            "key":"YOUR REQUEST REFERENCE",
            "public_url":"https:\/\/d3g0u9hd8wvah6.cloudfront.net\/renders\/d0347feb-57a7-42a1-b8d7-e708a0dc7094.jpg"
        }
    ]
}

Where uuid identifies the original request, and public_url is where the asset is stored. You can take that and download the image as required. The output array would contain a batch of your results. Note that they may not be in the same order and you can have multiple webhook requests sent to you depending on the size of your request and theme chosen.