Skip to content

ZPL rendering API: ZPL to PNG and PDF over HTTP

One endpoint renders ZPL to PNG or PDF. It is compatible with Labelary's v1 API: same paths, headers and errors.

Render a label

GET  https://api.openzpl.com/v1/printers/{dpmm}/labels/{width}x{height}/{index}/{zpl}
POST https://api.openzpl.com/v1/printers/{dpmm}/labels/{width}x{height}/{index}
POST https://api.openzpl.com/v1/printers/{dpmm}/labels/{width}x{height}/
dpmmPrint density: 6dpmm, 8dpmm, 12dpmm, 24dpmm.
width, heightLabel size in inches, for example 4x6 or 2.25x1.25. Up to 15 inches each.
indexWhich label to render, starting at 0. Leave it out with PDF output to get every label, one per page.
zplFor GET, the URL-encoded ZPL. Encode # as %23. Use POST for anything long.

With POST, send the ZPL as the raw request body, or as a multipart form field named file.

API keys

Without a key you get 3 labels a day per IP address, enough to try it. With a key from your dashboard, send it in the X-API-Key header and the limits of your workspace's plan apply.

curl https://api.openzpl.com/v1/printers/8dpmm/labels/4x6/0/ \
  -H "X-API-Key: oz_live_…" --data-binary @label.zpl > label.png

Examples

Each one sends label.zpl, saves label.pdf and shows the API's error message if something is wrong. For a PNG, ask for image/png and add the label's index (/0/) to the URL.

curl https://api.openzpl.com/v1/printers/8dpmm/labels/4x6/ \
  -H "Accept: application/pdf" \
  --data-binary @label.zpl --fail-with-body -o label.pdf
import requests  # pip install requests

with open("label.zpl", "rb") as f:
    res = requests.post(
        "https://api.openzpl.com/v1/printers/8dpmm/labels/4x6/",
        data=f.read(),
        headers={"Accept": "application/pdf"},
        timeout=30,
    )
if not res.ok:
    raise SystemExit(res.text)
with open("label.pdf", "wb") as f:
    f.write(res.content)
// Node.js 18+; save as label.mjs
import { readFile, writeFile } from "node:fs/promises";

const res = await fetch("https://api.openzpl.com/v1/printers/8dpmm/labels/4x6/", {
  method: "POST",
  headers: { Accept: "application/pdf" },
  body: await readFile("label.zpl"),
});
if (!res.ok) throw new Error(await res.text());
await writeFile("label.pdf", Buffer.from(await res.arrayBuffer()));
<?php
$ch = curl_init("https://api.openzpl.com/v1/printers/8dpmm/labels/4x6/");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => file_get_contents("label.zpl"),
    CURLOPT_HTTPHEADER => ["Accept: application/pdf"],
    CURLOPT_RETURNTRANSFER => true,
]);
$pdf = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_RESPONSE_CODE) !== 200) {
    exit($pdf);
}
file_put_contents("label.pdf", $pdf);
using var http = new HttpClient();
var req = new HttpRequestMessage(HttpMethod.Post,
    "https://api.openzpl.com/v1/printers/8dpmm/labels/4x6/")
{
    Content = new StringContent(File.ReadAllText("label.zpl")),
};
req.Headers.Add("Accept", "application/pdf");

var res = await http.SendAsync(req);
if (!res.IsSuccessStatusCode)
    throw new Exception(await res.Content.ReadAsStringAsync());
File.WriteAllBytes("label.pdf", await res.Content.ReadAsByteArrayAsync());
// Java 11+
import java.net.URI;
import java.net.http.*;
import java.nio.file.Path;

public class Label {
    public static void main(String[] args) throws Exception {
        var req = HttpRequest.newBuilder(
                URI.create("https://api.openzpl.com/v1/printers/8dpmm/labels/4x6/"))
            .header("Accept", "application/pdf")
            .POST(HttpRequest.BodyPublishers.ofFile(Path.of("label.zpl")))
            .build();
        var res = HttpClient.newHttpClient()
            .send(req, HttpResponse.BodyHandlers.ofByteArray());
        if (res.statusCode() != 200)
            throw new RuntimeException(new String(res.body()));
        java.nio.file.Files.write(Path.of("label.pdf"), res.body());
    }
}
package main

import (
	"io"
	"log"
	"net/http"
	"os"
)

func main() {
	zpl, err := os.Open("label.zpl")
	if err != nil {
		log.Fatal(err)
	}
	req, _ := http.NewRequest("POST", "https://api.openzpl.com/v1/printers/8dpmm/labels/4x6/", zpl)
	req.Header.Set("Accept", "application/pdf")
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)
	if res.StatusCode != 200 {
		log.Fatal(string(body))
	}
	os.WriteFile("label.pdf", body, 0o644)
}
require "net/http"

uri = URI("https://api.openzpl.com/v1/printers/8dpmm/labels/4x6/")
res = Net::HTTP.post(uri, File.binread("label.zpl"), "Accept" => "application/pdf")
abort res.body unless res.is_a?(Net::HTTPSuccess)
File.binwrite("label.pdf", res.body)
Invoke-WebRequest -Method Post `
  -Uri "https://api.openzpl.com/v1/printers/8dpmm/labels/4x6/" `
  -Headers @{ Accept = "application/pdf" } `
  -InFile "label.zpl" -OutFile "label.pdf"

Request headers

HeaderValuesDefault
Acceptimage/png, application/pdfPNG
X-QualityGrayscale (8-bit, smooth edges) or Bitonal (1-bit, smaller files)Grayscale
X-Rotation0, 90, 180, 270, clockwise0
X-Languagezpl, epl, tspl, auto: the body's printer language. Without it, a body with no ^ or ~ is read as EPL or TSPL when it looks like one.zpl
X-API-KeyYour workspace key, optional—

Limits

  • Without a key: 3 requests per second and 3 labels per UTC day, per IP address. With a free key from the dashboard: 20 labels per UTC day.
  • Labels, not requests, count against the allowance (per UTC day on Free, per UTC calendar month on paid plans): every label rendered, ^PQ copies and PDF pages included. A 10-label PDF is 1 request and 10 labels.
  • Watermark: without a key, labels carry "openzpl.com · preview" across the label (X-OpenZPL-Watermark: preview). With a Free key they carry a small "openzpl.com · free plan" badge in the corner (X-OpenZPL-Watermark: free-plan). Paid keys render without either.
  • Every request: up to 50 labels, a 1 MB body, 15 inches per side, and 10 seconds of render time.
  • Paid plans (Pro $29/month: 10 requests/s and 100,000 labels/month, Business $99/month: 20 requests/s and 1,000,000 labels/month): subscriptions, monthly or yearly, from the dashboard's Billing page (card, through Stripe), and you can cancel at any time. The workspace's API keys move to the plan's limits as soon as the payment is approved.
  • Over a limit the API answers 429 with Retry-After (seconds) and a body that names the limit, e.g. ERROR: Daily limit reached: 20 labels per UTC day on this plan (^PQ copies and PDF pages count).

Responses and errors

Successful responses carry X-Total-Count, the number of labels the ZPL produces, ^PQ copies included. Errors are plain text that starts with ERROR:.

Without a key, labels carry openzpl.com · preview across the label. With a Free key they carry a small openzpl.com · free plan badge in the corner. The response says which in the X-OpenZPL-Watermark header, and paid keys render clean.

StatusMeaning
400A parameter is invalid, the label is too large, or the index is out of range.
401The API key is unknown or was revoked.
406The Accept header asks for an output format that isn't available yet.
413The body is over 1 MB, or the ZPL produces more than 50 labels.
429Too many requests or labels for your plan. Wait the number of seconds in Retry-After.
503The label took longer than 10 seconds to render, or the service is at capacity. Retry, or lower the density or the size.

What the engine draws, ignores or doesn't support yet is on the compatibility page; how fast it renders, measured on the production server, on the benchmarks page.

Templates: fill a saved design with your data

Design a label with {{variables}} placeholders, save it, and copy its ID from your dashboard: d123 for a design, l45 for a saved label. Then your system sends only the data, with an API key.

curl https://api.openzpl.com/v1/templates/d123 \
  -H "X-API-Key: oz_live_…" -H "Accept: application/pdf" \
  -d '{"rows": [{"sku": "A-100"}, {"sku": "A-101"}]}' > labels.pdf

Use {"data": {...}} for one label or {"rows": [...]} for up to 50. Accept gives a PDF or PNG, or text/plain the filled ZPL to send to a printer. Values are escaped, so your data can never start a ZPL command.

Print on a local printer

With the print agent running next to the printer, POST /v1/print-jobs queues ZPL for it and POST /v1/templates/{id}/print fills a saved design. Both take a printer name and return a job ID; GET /v1/print-jobs/{id} tells you whether it printed.

Questions

How much does the API cost?

Without a key you can try it with 3 labels a day. A free key allows 20 labels a day, and paid plans start at $29 a month for 100,000 labels with no watermark.

Is it compatible with Labelary?

Yes: the same paths, headers and errors. Change the hostname and send your key, as the migration guide shows.

Do you keep my labels?

Not with an API key: the label is rendered and returned. The privacy page has the details and the deadlines.

Can an AI assistant use it?

Yes, through the MCP server: Claude, Cursor and other assistants can render labels with it.

OpenAPI and Markdown

The same contract is published as OpenAPI 3.1 and as Markdown, for code generators and coding assistants.

Step-by-step guides: Python, Node.js, PHP, C#. Moving from Labelary: migration guide.

Feedback