Images
Use POST /v1/images to render one of your designs with your own values and get the finished file back. You send the design id plus any layers you want to change, and OKZest returns the image itself as binary data. It is not a JSON response and it is not a URL.
This page covers the request, layer overrides, output formats, errors and samples. If this is your first call, start with the API quickstart. To check your key first, see Getting started.
Authentication
Send your API key in the x-api-key header. There is no other authentication scheme on this endpoint. A missing, empty or wrong key returns 401. You can create a key in your account.
A key belongs to one company. If the key is linked to a user, it can only render designs in projects that user can read. A design the key cannot see behaves exactly like a design that does not exist.
Send the body as JSON with Content-Type: application/json. Property names use snake_case.
Endpoint
POST https://api.okzest.com/v1/images
The change you send applies to this one render only.
Request
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
design_id | string | Yes | none | The design to render. Get it from List designs. |
layers | array of layer overrides | No | none | Changes to individual layers, matched to the design by layer_id. Leave it out if you only change the background or the format. |
background | object | No | none | Background colour, background image and size. See below. |
format | string | No | jpg, or png if the design canvas is transparent | One of jpg, jpeg (an alias of jpg), png, webp, pdf or pdf_letter. Not case-sensitive. Anything else returns a 400. |
quality | integer | No | The quality saved with the design | 1 to 100. Applies to jpg and webp only. |
orientation | string | No | portrait | portrait or landscape. Applies to PDF output only. |
Only design_id is required. A body of {"design_id": "..."} renders the design exactly as saved.
Background
| Field | Type | Description |
|---|---|---|
color | string | Background colour as hex, for example #003366. |
image_url | string | A public http or https URL. It must be a full URL, not localhost and not a private address. |
width, height | string | Size of the background image. They default to the size of the design. These two values are strings, not numbers. |
Layer overrides
Each item in layers must include a layer_id, which has to match a layer id in the design. Get the valid ids from Get design fields.
If a layer_id does not exist in the design, OKZest skips it without an error and returns the image unchanged. If your change does not appear, check the id first.
OKZest decides how to apply an override from the design's own layer: a text layer takes the text keys, and an image layer takes the image keys. Keys that do not suit the layer type are ignored without an error.
Keys for every layer
| Key | Type | Description |
|---|---|---|
layer_id | string | Required. The layer to change. |
x, y | integer | Position of the layer. |
width, height | integer | Size of the layer. |
angle | integer | Rotation in degrees. |
opacity | number | 0.0 to 1.0. |
visible | boolean | Show or hide the layer. |
Text layers
| Key | Type | Description |
|---|---|---|
text | string | The new text. Merge-tag rules still apply. |
color | string | Text colour as hex. |
font_size | integer | Font size. |
font_family | string | For example Roboto. |
font_weight | string | bold, normal, or 100 to 900. |
font_style | string | italic or normal. |
underline, linethrough | boolean | Text decoration. |
text_align | string | left, center, right or justify. |
vertical_align | string | top, middle or bottom. |
text_casing | string | none, lowercase, uppercase or capitalize. |
text_auto_fit | string | overflow, truncate or fit. |
direction | string | ltr or rtl. |
merge_tag | string | For example [NAME]. |
default_text | string | Used when no merge-tag value is supplied. |
Text layers also accept background, stroke, border and shadow keys: background, background_mode, background_padding, corner_radius, stroke_enabled, stroke_color, stroke_width, border_enabled, border_color, border_width, shadow_color, shadow_blur, shadow_offset_x and shadow_offset_y. Call Get design fields to see exactly which keys your design's layers accept.
Image layers
| Key | Type | Description |
|---|---|---|
image_url | string | A public http or https URL. For a logo layer, give a domain such as example.com. |
default_image | string | URL used when no image is supplied. |
is_logo, is_screenshot | boolean | Fetch a company logo or a website screenshot from the URL or domain. |
extract_domain | boolean | Turn an email address into the company domain before fetching a logo or screenshot. |
preserve_width | string | "true" keeps the width, "false" keeps the height. |
border_radius_enabled, border_radius | boolean, integer | Rounded corners, 0 to 100. |
Circle images also accept pan_x, pan_y and the circle_border_* and circle_shadow_* keys.
Do not send border_color on an image layer. OKZest reads it as a text key, so the border is drawn but your image_url is ignored and the design's default image is shown.
Formats
Set format to choose the file type. The response Content-Type matches it.
format | Response | Notes |
|---|---|---|
jpg or jpeg | image/jpeg | The default. |
png | image/png | The default for designs with a transparent canvas, because JPG would turn transparency black. |
webp | image/webp | Honours quality. |
pdf | application/pdf | A single A4 page, with the image scaled to fit and centred. |
pdf_letter | application/pdf | The same on US Letter. |
Set orientation to landscape to rotate a PDF page. GIF is not supported, and PDF is export only.
Sample request and response
Render a design with one text layer changed, as a PNG.
export OKZEST_API_KEY="your-api-key-here"
export OKZEST_DESIGN_ID="your-design-id"
curl -s -X POST https://api.okzest.com/v1/images \
-H "x-api-key: $OKZEST_API_KEY" -H "Content-Type: application/json" \
-d "{\"design_id\":\"$OKZEST_DESIGN_ID\",\"format\":\"png\",\"layers\":[{\"layer_id\":\"first_name\",\"text\":\"Kevin\",\"color\":\"#ff0000\",\"font_size\":60}]}" \
-o image.png
A successful call returns 200 with Content-Type: image/png and the file bytes as the body. The -o image.png option saves them to a file.
JavaScript sample
Node 18 or later.
import { writeFile } from "node:fs/promises";
const res = await fetch("https://api.okzest.com/v1/images", {
method: "POST",
headers: { "x-api-key": process.env.OKZEST_API_KEY, "Content-Type": "application/json" },
body: JSON.stringify({
design_id: process.env.OKZEST_DESIGN_ID,
format: "png",
layers: [{ layer_id: "first_name", text: "Kevin", color: "#ff0000" }],
}),
});
if (!res.ok) console.log(res.status, await res.text()); // plain sentence, or problem+json
else await writeFile("out.png", Buffer.from(await res.arrayBuffer()));
Python sample
Python 3.9 or later, standard library only. Set a User-Agent: the default one used by urllib is blocked with a 403 and the body error code: 1010.
import json, os, urllib.request, urllib.error
BASE = "https://api.okzest.com/v1"
KEY = os.environ["OKZEST_API_KEY"]
DESIGN_ID = os.environ["OKZEST_DESIGN_ID"]
def call(method, path, body=None):
data = json.dumps(body).encode() if body is not None else None
req = urllib.request.Request(f"{BASE}{path}", data=data, method=method,
headers={"x-api-key": KEY, "Content-Type": "application/json",
"User-Agent": "okzest-sample/1.0"})
try:
with urllib.request.urlopen(req) as res:
return res.status, res.headers.get("Content-Type"), res.read()
except urllib.error.HTTPError as err:
return err.code, err.headers.get("Content-Type"), err.read()
status, ctype, body = call("POST", "/images", {
"design_id": DESIGN_ID,
"format": "webp",
"quality": 80,
"layers": [{"layer_id": "first_name", "text": "Kevin"}],
})
if status == 200:
with open("out.webp", "wb") as f:
f.write(body)
print("POST /images", status, ctype, len(body), "bytes")
C# sample
.NET 10 or later, run with dotnet run okzest.cs.
#:property PublishAot=false
#:property JsonSerializerIsReflectionEnabledByDefault=true
using System.Net.Http.Json;
var designId = Environment.GetEnvironmentVariable("OKZEST_DESIGN_ID")!;
using var http = new HttpClient { BaseAddress = new Uri("https://api.okzest.com/v1/") };
http.DefaultRequestHeaders.Add("x-api-key", Environment.GetEnvironmentVariable("OKZEST_API_KEY"));
var create = await http.PostAsJsonAsync("images", new
{
design_id = designId,
format = "jpg",
quality = 90,
layers = new[] { new { layer_id = "first_name", text = "Kevin" } }
});
var bytes = await create.Content.ReadAsByteArrayAsync();
if (create.IsSuccessStatusCode) await File.WriteAllBytesAsync("out.jpg", bytes);
Console.WriteLine($"POST images {(int)create.StatusCode} {create.Content.Headers.ContentType} {bytes.Length} bytes");
Errors
Errors come in three shapes: a JSON body, a plain-text body, or an empty body. A bad image URL currently returns 500 with an empty body.
| Status | Content-Type | Body | When |
|---|---|---|---|
| 401 | application/problem+json | {"type":"https://tools.ietf.org/html/rfc9110#section-15.5.2","title":"Unauthorized","status":401,"traceId":"00-...-...-03"} | Missing, empty or invalid x-api-key. |
| 400 | text/plain | Design not found. | Unknown design id, or one the key's user cannot read. |
| 400 | text/plain | Unsupported format 'gif'. Valid formats are: jpg, png, webp, pdf, pdf_letter. | Bad format. The value you sent is echoed. |
| 400 | application/problem+json | {"type":"https://tools.ietf.org/html/rfc9110#section-15.5.1","title":"One or more validation errors occurred.","status":400,"errors":{"$":["JSON deserialization for type 'Api.Model.DesignRequest' was missing required properties including: 'design_id'."],"request":["The request field is required."]},"traceId":"..."} | design_id is missing. |
| 400 | application/problem+json | The same shape, with the problem described under errors. | Malformed JSON, or a value of the wrong type such as a string for font_size. The wording of these messages can change. |
| 400 | text/plain | Request failed: <message> | The renderer rejected the request. |
| 500 | none | Empty | Usually a bad image URL in a layer or in background.image_url. |
If you get a 500 with an empty body, check that every image URL is a full public http or https address.
Limits
For the limits and usage that apply to your plan, see pricing. Do not rely on figures copied from elsewhere.
Related pages
- API quickstart: your first image in a few minutes.
- Merge tags and URL parameters: how
textand merge-tag values work. - Troubleshooting: when a request fails or the image looks wrong.
- Designs: list designs, get one, and get its editable fields.