Java
Generate images from a template with java.net.http from the JDK: no dependencies, and nothing to add to a build file. Imejis returns the finished image directly in the response, so there is nothing to poll and no webhook to receive.
Set two environment variables first: IMEJIS_API_KEY (from your dashboard) and IMEJIS_DESIGN_ID (any design's id). Then send the fields you want to change as component.property pairs: headline.text, title.color, image.image. Only the fields you send change; everything else keeps its designed value, and a design's overridable fields are listed in its Share / API panel.
Every block below is a copy-paste runnable program, and every one of them is executed in Docker against a real render service before it ships.
Generate a single imageGenerate a single image
One POST, one image. The response body is the rendered image itself, with nothing to poll and no webhook to receive.
import java.io.FileOutputStream;
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
static final String API_KEY = System.getenv("IMEJIS_API_KEY");
static final String DESIGN_ID = System.getenv("IMEJIS_DESIGN_ID");
static final String BASE = envOr("IMEJIS_RENDER_URL", "https://render.imejis.io");
static final HttpClient CLIENT = HttpClient.newHttpClient();
static String envOr(String key, String fallback) {
String value = System.getenv(key);
return (value == null || value.isEmpty()) ? fallback : value;
}
/** The size to render on a multi-size design; absent/"master" is the base. */
static String variation() {
return envOr("IMEJIS_VARIATION_ID", "story");
}
/** POST a JSON body to `path` with the render key; returns the raw response. */
static HttpResponse<byte[]> render(String path, String query, String json)
throws Exception {
String url = BASE + path + (query.isEmpty() ? "" : "?" + query);
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("dma-api-key", API_KEY)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
return CLIENT.send(request, HttpResponse.BodyHandlers.ofByteArray());
}
static String encode(String value) {
return URLEncoder.encode(value, StandardCharsets.UTF_8);
}
/** Build a query string from alternating key/value pairs. */
static String query(String... pairs) {
StringBuilder out = new StringBuilder();
for (int i = 0; i < pairs.length; i += 2) {
if (i > 0) out.append('&');
out.append(encode(pairs[i])).append('=').append(encode(pairs[i + 1]));
}
return out.toString();
}
/**
* Pull one string field out of a JSON response. Any JSON library (Jackson,
* Gson) does this better — this keeps the samples dependency-free so they
* compile with nothing but the JDK.
*/
static String field(String json, String name) {
Matcher m = Pattern.compile("\"" + name + "\"\\s*:\\s*\"([^\"]*)\"").matcher(json);
return m.find() ? m.group(1) : "";
}
public static void main(String[] args) throws Exception {
// Render one image. The response body IS the image — no polling, no webhook.
HttpResponse<byte[]> res = render("/v1/" + DESIGN_ID, "",
"{\"headline.text\":\"Hello from Java\",\"subtitle.text\":\"Rendered in one request\"}");
try (FileOutputStream out = new FileOutputStream("output.jpg")) {
out.write(res.body());
}
System.out.println("single: " + res.statusCode() + " " + res.body().length + " bytes");
}
}Every output format png jpeg webp and pdfEvery output format: PNG, JPEG, WebP and PDF
Pick the output with ?format=. PNG and WebP keep transparency, JPEG is the smallest lossy option, and PDF is a single print-ready page. ?quality= applies to JPEG only.
import java.io.FileOutputStream;
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
static final String API_KEY = System.getenv("IMEJIS_API_KEY");
static final String DESIGN_ID = System.getenv("IMEJIS_DESIGN_ID");
static final String BASE = envOr("IMEJIS_RENDER_URL", "https://render.imejis.io");
static final HttpClient CLIENT = HttpClient.newHttpClient();
static String envOr(String key, String fallback) {
String value = System.getenv(key);
return (value == null || value.isEmpty()) ? fallback : value;
}
/** The size to render on a multi-size design; absent/"master" is the base. */
static String variation() {
return envOr("IMEJIS_VARIATION_ID", "story");
}
/** POST a JSON body to `path` with the render key; returns the raw response. */
static HttpResponse<byte[]> render(String path, String query, String json)
throws Exception {
String url = BASE + path + (query.isEmpty() ? "" : "?" + query);
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("dma-api-key", API_KEY)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
return CLIENT.send(request, HttpResponse.BodyHandlers.ofByteArray());
}
static String encode(String value) {
return URLEncoder.encode(value, StandardCharsets.UTF_8);
}
/** Build a query string from alternating key/value pairs. */
static String query(String... pairs) {
StringBuilder out = new StringBuilder();
for (int i = 0; i < pairs.length; i += 2) {
if (i > 0) out.append('&');
out.append(encode(pairs[i])).append('=').append(encode(pairs[i + 1]));
}
return out.toString();
}
/**
* Pull one string field out of a JSON response. Any JSON library (Jackson,
* Gson) does this better — this keeps the samples dependency-free so they
* compile with nothing but the JDK.
*/
static String field(String json, String name) {
Matcher m = Pattern.compile("\"" + name + "\"\\s*:\\s*\"([^\"]*)\"").matcher(json);
return m.find() ? m.group(1) : "";
}
public static void main(String[] args) throws Exception {
// Every output format, with JPEG quality. PNG and WebP keep
// transparency; PDF is a single print-ready page. quality only affects
// JPEG.
for (String format : new String[] {"png", "jpeg", "webp", "pdf"}) {
String q = format.equals("jpeg")
? query("format", format, "quality", "85")
: query("format", format);
HttpResponse<byte[]> r = render("/v1/" + DESIGN_ID, q,
"{\"headline.text\":\"Format: " + format + "\"}");
try (FileOutputStream out = new FileOutputStream("output." + format)) {
out.write(r.body());
}
System.out.println("formats: " + format + " "
+ r.headers().firstValue("content-type").orElse("") + " " + r.body().length);
}
}
}Render multiple sizes from one templateRender multiple sizes from one template
A multi-size design carries several canvases: an OG image, a square post, a vertical story. ?variation=<id> picks which one you get back; omit it for the base size.
import java.io.FileOutputStream;
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
static final String API_KEY = System.getenv("IMEJIS_API_KEY");
static final String DESIGN_ID = System.getenv("IMEJIS_DESIGN_ID");
static final String BASE = envOr("IMEJIS_RENDER_URL", "https://render.imejis.io");
static final HttpClient CLIENT = HttpClient.newHttpClient();
static String envOr(String key, String fallback) {
String value = System.getenv(key);
return (value == null || value.isEmpty()) ? fallback : value;
}
/** The size to render on a multi-size design; absent/"master" is the base. */
static String variation() {
return envOr("IMEJIS_VARIATION_ID", "story");
}
/** POST a JSON body to `path` with the render key; returns the raw response. */
static HttpResponse<byte[]> render(String path, String query, String json)
throws Exception {
String url = BASE + path + (query.isEmpty() ? "" : "?" + query);
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("dma-api-key", API_KEY)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
return CLIENT.send(request, HttpResponse.BodyHandlers.ofByteArray());
}
static String encode(String value) {
return URLEncoder.encode(value, StandardCharsets.UTF_8);
}
/** Build a query string from alternating key/value pairs. */
static String query(String... pairs) {
StringBuilder out = new StringBuilder();
for (int i = 0; i < pairs.length; i += 2) {
if (i > 0) out.append('&');
out.append(encode(pairs[i])).append('=').append(encode(pairs[i + 1]));
}
return out.toString();
}
/**
* Pull one string field out of a JSON response. Any JSON library (Jackson,
* Gson) does this better — this keeps the samples dependency-free so they
* compile with nothing but the JDK.
*/
static String field(String json, String name) {
Matcher m = Pattern.compile("\"" + name + "\"\\s*:\\s*\"([^\"]*)\"").matcher(json);
return m.find() ? m.group(1) : "";
}
public static void main(String[] args) throws Exception {
// One template, many sizes. ?variation=<id> picks the size; omit it for
// the base. The ids are listed in the design's Share / API panel.
HttpResponse<byte[]> sized = render("/v1/" + DESIGN_ID,
query("format", "png", "variation", variation()),
"{\"headline.text\":\"Story size\"}");
System.out.println("variation: " + sized.statusCode() + " " + sized.body().length + " bytes");
}
}An image url for img tags email and thumbnailsAn image URL for <img> tags, email and thumbnails
The same render as a plain GET URL, with the field values in the query string. Drop it into an <img src>, an HTML email, or a Slack message and it renders fresh every time it is fetched.
import java.io.FileOutputStream;
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
static final String API_KEY = System.getenv("IMEJIS_API_KEY");
static final String DESIGN_ID = System.getenv("IMEJIS_DESIGN_ID");
static final String BASE = envOr("IMEJIS_RENDER_URL", "https://render.imejis.io");
static final HttpClient CLIENT = HttpClient.newHttpClient();
static String envOr(String key, String fallback) {
String value = System.getenv(key);
return (value == null || value.isEmpty()) ? fallback : value;
}
/** The size to render on a multi-size design; absent/"master" is the base. */
static String variation() {
return envOr("IMEJIS_VARIATION_ID", "story");
}
/** POST a JSON body to `path` with the render key; returns the raw response. */
static HttpResponse<byte[]> render(String path, String query, String json)
throws Exception {
String url = BASE + path + (query.isEmpty() ? "" : "?" + query);
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("dma-api-key", API_KEY)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
return CLIENT.send(request, HttpResponse.BodyHandlers.ofByteArray());
}
static String encode(String value) {
return URLEncoder.encode(value, StandardCharsets.UTF_8);
}
/** Build a query string from alternating key/value pairs. */
static String query(String... pairs) {
StringBuilder out = new StringBuilder();
for (int i = 0; i < pairs.length; i += 2) {
if (i > 0) out.append('&');
out.append(encode(pairs[i])).append('=').append(encode(pairs[i + 1]));
}
return out.toString();
}
/**
* Pull one string field out of a JSON response. Any JSON library (Jackson,
* Gson) does this better — this keeps the samples dependency-free so they
* compile with nothing but the JDK.
*/
static String field(String json, String name) {
Matcher m = Pattern.compile("\"" + name + "\"\\s*:\\s*\"([^\"]*)\"").matcher(json);
return m.find() ? m.group(1) : "";
}
public static void main(String[] args) throws Exception {
// The same render as a plain GET URL — drop it into an <img> tag, an
// HTML email, or a Slack message. Field overrides ride the query string.
String getUrl = BASE + "/v1/" + DESIGN_ID + "?" + query(
"dma-api-key", API_KEY,
"format", "png",
"headline.text", "Hello from a URL",
"subtitle.text", "No request body needed");
System.out.println("get: " + getUrl);
HttpResponse<byte[]> viaUrl = CLIENT.send(
HttpRequest.newBuilder().uri(URI.create(getUrl)).GET().build(),
HttpResponse.BodyHandlers.ofByteArray());
System.out.println("get: " + viaUrl.statusCode() + " " + viaUrl.body().length + " bytes");
}
}Hosted delivery get a public image url backHosted delivery: get a public image URL back
?delivery=hosted stores the render and returns a public URL instead of raw bytes, which is what an email, a webhook payload, or a dashboard needs: a link rather than a file.
import java.io.FileOutputStream;
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
static final String API_KEY = System.getenv("IMEJIS_API_KEY");
static final String DESIGN_ID = System.getenv("IMEJIS_DESIGN_ID");
static final String BASE = envOr("IMEJIS_RENDER_URL", "https://render.imejis.io");
static final HttpClient CLIENT = HttpClient.newHttpClient();
static String envOr(String key, String fallback) {
String value = System.getenv(key);
return (value == null || value.isEmpty()) ? fallback : value;
}
/** The size to render on a multi-size design; absent/"master" is the base. */
static String variation() {
return envOr("IMEJIS_VARIATION_ID", "story");
}
/** POST a JSON body to `path` with the render key; returns the raw response. */
static HttpResponse<byte[]> render(String path, String query, String json)
throws Exception {
String url = BASE + path + (query.isEmpty() ? "" : "?" + query);
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("dma-api-key", API_KEY)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
return CLIENT.send(request, HttpResponse.BodyHandlers.ofByteArray());
}
static String encode(String value) {
return URLEncoder.encode(value, StandardCharsets.UTF_8);
}
/** Build a query string from alternating key/value pairs. */
static String query(String... pairs) {
StringBuilder out = new StringBuilder();
for (int i = 0; i < pairs.length; i += 2) {
if (i > 0) out.append('&');
out.append(encode(pairs[i])).append('=').append(encode(pairs[i + 1]));
}
return out.toString();
}
/**
* Pull one string field out of a JSON response. Any JSON library (Jackson,
* Gson) does this better — this keeps the samples dependency-free so they
* compile with nothing but the JDK.
*/
static String field(String json, String name) {
Matcher m = Pattern.compile("\"" + name + "\"\\s*:\\s*\"([^\"]*)\"").matcher(json);
return m.find() ? m.group(1) : "";
}
public static void main(String[] args) throws Exception {
// delivery=hosted stores the render and returns a PUBLIC URL instead of
// bytes — for an email, a webhook payload, or a dashboard that needs a
// link.
HttpResponse<byte[]> hostedRes = render("/v1/" + DESIGN_ID,
query("delivery", "hosted", "format", "png"),
"{\"headline.text\":\"Hosted delivery\"}");
String hosted = new String(hostedRes.body(), StandardCharsets.UTF_8);
System.out.println("hosted: " + field(hosted, "url"));
}
}Signed delivery a private expiring image urlSigned delivery: a private, expiring image URL
?delivery=signed stores the render privately and returns a time-limited signed URL. ?expiresIn= is minutes.
import java.io.FileOutputStream;
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
static final String API_KEY = System.getenv("IMEJIS_API_KEY");
static final String DESIGN_ID = System.getenv("IMEJIS_DESIGN_ID");
static final String BASE = envOr("IMEJIS_RENDER_URL", "https://render.imejis.io");
static final HttpClient CLIENT = HttpClient.newHttpClient();
static String envOr(String key, String fallback) {
String value = System.getenv(key);
return (value == null || value.isEmpty()) ? fallback : value;
}
/** The size to render on a multi-size design; absent/"master" is the base. */
static String variation() {
return envOr("IMEJIS_VARIATION_ID", "story");
}
/** POST a JSON body to `path` with the render key; returns the raw response. */
static HttpResponse<byte[]> render(String path, String query, String json)
throws Exception {
String url = BASE + path + (query.isEmpty() ? "" : "?" + query);
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("dma-api-key", API_KEY)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
return CLIENT.send(request, HttpResponse.BodyHandlers.ofByteArray());
}
static String encode(String value) {
return URLEncoder.encode(value, StandardCharsets.UTF_8);
}
/** Build a query string from alternating key/value pairs. */
static String query(String... pairs) {
StringBuilder out = new StringBuilder();
for (int i = 0; i < pairs.length; i += 2) {
if (i > 0) out.append('&');
out.append(encode(pairs[i])).append('=').append(encode(pairs[i + 1]));
}
return out.toString();
}
/**
* Pull one string field out of a JSON response. Any JSON library (Jackson,
* Gson) does this better — this keeps the samples dependency-free so they
* compile with nothing but the JDK.
*/
static String field(String json, String name) {
Matcher m = Pattern.compile("\"" + name + "\"\\s*:\\s*\"([^\"]*)\"").matcher(json);
return m.find() ? m.group(1) : "";
}
public static void main(String[] args) throws Exception {
// delivery=signed stores it privately and returns a time-limited signed
// URL. expiresIn is minutes (default 60, max 7 days).
HttpResponse<byte[]> signedRes = render("/v1/" + DESIGN_ID,
query("delivery", "signed", "format", "png", "expiresIn", "30"),
"{\"headline.text\":\"Signed delivery\"}");
String signed = new String(signedRes.body(), StandardCharsets.UTF_8);
System.out.println("signed: " + field(signed, "expiresAt") + " "
+ field(signed, "url").substring(0, 80) + "...");
}
}Bulk image generation in one callBulk image generation in one call
POST /bulk to render many images in a single request: several sizes, several data variants, a mix of designs, or the ordered slides of a carousel. results preserves input order, so results[i] is items[i].
import java.io.FileOutputStream;
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
static final String API_KEY = System.getenv("IMEJIS_API_KEY");
static final String DESIGN_ID = System.getenv("IMEJIS_DESIGN_ID");
static final String BASE = envOr("IMEJIS_RENDER_URL", "https://render.imejis.io");
static final HttpClient CLIENT = HttpClient.newHttpClient();
static String envOr(String key, String fallback) {
String value = System.getenv(key);
return (value == null || value.isEmpty()) ? fallback : value;
}
/** The size to render on a multi-size design; absent/"master" is the base. */
static String variation() {
return envOr("IMEJIS_VARIATION_ID", "story");
}
/** POST a JSON body to `path` with the render key; returns the raw response. */
static HttpResponse<byte[]> render(String path, String query, String json)
throws Exception {
String url = BASE + path + (query.isEmpty() ? "" : "?" + query);
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("dma-api-key", API_KEY)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
return CLIENT.send(request, HttpResponse.BodyHandlers.ofByteArray());
}
static String encode(String value) {
return URLEncoder.encode(value, StandardCharsets.UTF_8);
}
/** Build a query string from alternating key/value pairs. */
static String query(String... pairs) {
StringBuilder out = new StringBuilder();
for (int i = 0; i < pairs.length; i += 2) {
if (i > 0) out.append('&');
out.append(encode(pairs[i])).append('=').append(encode(pairs[i + 1]));
}
return out.toString();
}
/**
* Pull one string field out of a JSON response. Any JSON library (Jackson,
* Gson) does this better — this keeps the samples dependency-free so they
* compile with nothing but the JDK.
*/
static String field(String json, String name) {
Matcher m = Pattern.compile("\"" + name + "\"\\s*:\\s*\"([^\"]*)\"").matcher(json);
return m.find() ? m.group(1) : "";
}
public static void main(String[] args) throws Exception {
// Many images in ONE call. results keeps input order, so results[i] is
// items[i] — for a carousel the array IS the slide order. Each item is
// one metered render, and a failed item does not abort the rest.
String bulkBody = """
{
"delivery": "hosted",
"format": "png",
"items": [
{ "designId": "%s", "overrides": { "headline.text": "Slide 1" } },
{ "designId": "%s", "variation": "%s", "format": "jpeg", "quality": 80,
"overrides": { "headline.text": "Slide 2" } },
{ "designId": "%s", "format": "pdf",
"overrides": { "headline.text": "Slide 3" } }
]
}
""".formatted(DESIGN_ID, DESIGN_ID, variation(), DESIGN_ID);
HttpResponse<byte[]> bulkRes = render("/bulk", "", bulkBody);
String bulk = new String(bulkRes.body(), StandardCharsets.UTF_8);
Matcher summary = Pattern.compile("\"summary\"\\s*:\\s*(\\{[^}]*\\})").matcher(bulk);
System.out.println("bulk: " + (summary.find() ? summary.group(1) : bulk));
Matcher urls = Pattern.compile("\"url\"\\s*:\\s*\"([^\"]*)\"").matcher(bulk);
while (urls.find()) {
System.out.println(" " + urls.group(1));
}
}
}Bulk from a list of rowsBulk from a list of rows
Send data instead of items and every row becomes one render, with no item list to build. That is the shape to reach for when the input is a spreadsheet, a database query, or a CSV.
import java.io.FileOutputStream;
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
static final String API_KEY = System.getenv("IMEJIS_API_KEY");
static final String DESIGN_ID = System.getenv("IMEJIS_DESIGN_ID");
static final String BASE = envOr("IMEJIS_RENDER_URL", "https://render.imejis.io");
static final HttpClient CLIENT = HttpClient.newHttpClient();
static String envOr(String key, String fallback) {
String value = System.getenv(key);
return (value == null || value.isEmpty()) ? fallback : value;
}
/** The size to render on a multi-size design; absent/"master" is the base. */
static String variation() {
return envOr("IMEJIS_VARIATION_ID", "story");
}
/** POST a JSON body to `path` with the render key; returns the raw response. */
static HttpResponse<byte[]> render(String path, String query, String json)
throws Exception {
String url = BASE + path + (query.isEmpty() ? "" : "?" + query);
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("dma-api-key", API_KEY)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
return CLIENT.send(request, HttpResponse.BodyHandlers.ofByteArray());
}
static String encode(String value) {
return URLEncoder.encode(value, StandardCharsets.UTF_8);
}
/** Build a query string from alternating key/value pairs. */
static String query(String... pairs) {
StringBuilder out = new StringBuilder();
for (int i = 0; i < pairs.length; i += 2) {
if (i > 0) out.append('&');
out.append(encode(pairs[i])).append('=').append(encode(pairs[i + 1]));
}
return out.toString();
}
/**
* Pull one string field out of a JSON response. Any JSON library (Jackson,
* Gson) does this better — this keeps the samples dependency-free so they
* compile with nothing but the JDK.
*/
static String field(String json, String name) {
Matcher m = Pattern.compile("\"" + name + "\"\\s*:\\s*\"([^\"]*)\"").matcher(json);
return m.find() ? m.group(1) : "";
}
public static void main(String[] args) throws Exception {
// The same design over a LIST OF ROWS — one render per row, no items[]
// to build. Use "variations": ["master","story"] instead to render
// every SIZE.
String rowsBody = """
{
"designId": "%s",
"delivery": "signed",
"expiresIn": 15,
"format": "png",
"data": [
{ "headline.text": "Ada Lovelace", "subtitle.text": "Mathematician" },
{ "headline.text": "Alan Turing", "subtitle.text": "Computer scientist" },
{ "headline.text": "Grace Hopper", "subtitle.text": "Rear admiral" }
]
}
""".formatted(DESIGN_ID);
HttpResponse<byte[]> rowsRes = render("/bulk", "", rowsBody);
String rows = new String(rowsRes.body(), StandardCharsets.UTF_8);
Matcher rowsSummary = Pattern.compile("\"summary\"\\s*:\\s*(\\{[^}]*\\})").matcher(rows);
System.out.println("bulk-data: " + (rowsSummary.find() ? rowsSummary.group(1) : rows));
}
}The response is the raw image (`image/jpeg` by default). Choose the format with `?format=png|jpeg|webp|pdf` (default jpeg) and set JPEG quality with `?quality=1-100`. Store the result and get a URL back with `?delivery=hosted` (or `?delivery=signed&expiresIn=60`), and render a specific size of a multi-size design with `?variation=<id>`.
| Parameter | Values | Default | What it does |
|---|---|---|---|
?format= | png · jpeg · webp · pdf | jpeg | Output image format. |
?quality= | 1–100 | none | Compression quality for lossy output; ignored for other formats. (JPEG only) |
?delivery= | stream · hosted · signed | stream | stream = raw image bytes (default); hosted = store + return a public URL; signed = store + return a time-limited URL. |
?expiresIn= | minutes | 60 | Signed-URL lifetime in minutes (default 60, max 10080 = 7 days). (delivery=signed only) |
?variation= | <size id> | master | Which multi-dimension SIZE to render. Omit or use "master" for the base size; an unknown id falls back to the master. (multi-size designs only) |
- PNG (
?format=png): Lossless, supports transparency. Largest file. - JPEG (
?format=jpeg): Smaller, lossy, no transparency. Quality adjustable. - WebP (
?format=webp): Smallest, supports transparency. Modern browsers. - PDF (
?format=pdf): Vector page, for print and documents.
See the delivery modes and generate images with the API guides.
In Spring the same call becomes an endpoint; the Spring Boot page has all five, including why the class is a @Controller. HttpClient has no default timeout, so set one per request. Each call is one render, and the first 100 a month are free; pricing has the tiers.