Java icon

Java

JavaJava

Generate an image from a template with a single POST request, using the java.net.http.HttpClient built into Java 11 and later. Imejis returns the finished image directly, so there are no webhooks and nothing to poll.

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, for example headline.text.

Java (HttpClient)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.io.FileOutputStream;
 
public class Main {
    public static void main(String[] args) throws Exception {
        String designId = System.getenv("IMEJIS_DESIGN_ID");
        String apiKey = System.getenv("IMEJIS_API_KEY");
        String json = "{\"headline.text\":\"Hello from Java\"}";
 
        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://render.imejis.io/v1/" + designId))
            .header("dma-api-key", apiKey)
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(json))
            .build();
 
        HttpResponse<byte[]> response =
            client.send(request, HttpResponse.BodyHandlers.ofByteArray());
        try (FileOutputStream out = new FileOutputStream("output.jpg")) {
            out.write(response.body());
        }
        System.out.println("status " + response.statusCode() + " bytes " + response.body().length);
    }
}

Override any field. Each dynamic component exposes keys like headline.text, title.color, or image.image. Send only the ones you want to change. You can find a design's overridable fields in its Share / API panel.

The response is the raw image (image/jpeg by default). Save it to disk, stream it, or return it straight from your own endpoint.