All Questions

How do you generate images from an API?

Send an HTTP POST request to an image generation API with your template ID and data payload. The API renders the image server-side and returns a URL or binary file in the response.

Generating images from an API follows a simple request-response pattern. Here's the typical workflow:

1. Create or import a template

First, you need a template, a design with dynamic fields that can be swapped. You can either:

2. Get your template ID and field names

After creating the template, you'll have:

  • A template ID (e.g., tpl_abc123)
  • A list of customizable fields (e.g., headline, subtitle, product_image)

3. Make an API call

bash
curl -X POST \ "https://api.layerre.com/v1/template/3fa85f64-5717-4562-b3fc-2c963f66afa6/variant" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "overrides": [ { "layer_id": "11111111-2222-4333-8444-555555555555", "properties": { "text": "Flash Sale Today" } }, { "layer_id": "22222222-3333-4444-9555-666666666666", "properties": { "text": "Up to 50% off everything" } }, { "layer_id": "33333333-4444-5555-a666-777777777777", "properties": { "img_url": "https://example.com/shoe.png" } } ], "export_type": "png" }'

4. Receive the result

The API returns the rendered image, either as a direct URL you can download, a binary stream, or a base64-encoded string depending on the API.

Common patterns for using image APIs:

  • On-demand rendering: Generate an image when a user takes an action (signup, purchase, share)
  • Batch processing: Loop through a spreadsheet and generate one image per row
  • Webhook-triggered: Generate when an event fires in your CRM, e-commerce, or marketing tool
  • Scheduled: Run a cron job or scheduled automation to generate daily/weekly content

Languages and frameworks: Most image generation APIs work with any language (JavaScript, Python, Ruby, PHP, Go) via standard HTTP requests. Some offer SDKs for popular languages.

Ready to generate images from your Canva designs?

Import your Canva templates and start generating via API in minutes. Free tier included; no credit card required.

Explore the API Docs

Related Questions