Skip to main content

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​

FieldTypeRequiredDefaultDescription
design_idstringYesnoneThe design to render. Get it from List designs.
layersarray of layer overridesNononeChanges to individual layers, matched to the design by layer_id. Leave it out if you only change the background or the format.
backgroundobjectNononeBackground colour, background image and size. See below.
formatstringNojpg, or png if the design canvas is transparentOne of jpg, jpeg (an alias of jpg), png, webp, pdf or pdf_letter. Not case-sensitive. Anything else returns a 400.
qualityintegerNoThe quality saved with the design1 to 100. Applies to jpg and webp only.
orientationstringNoportraitportrait or landscape. Applies to PDF output only.

Only design_id is required. A body of {"design_id": "..."} renders the design exactly as saved.

Background​

FieldTypeDescription
colorstringBackground colour as hex, for example #003366.
image_urlstringA public http or https URL. It must be a full URL, not localhost and not a private address.
width, heightstringSize 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​

KeyTypeDescription
layer_idstringRequired. The layer to change.
x, yintegerPosition of the layer.
width, heightintegerSize of the layer.
angleintegerRotation in degrees.
opacitynumber0.0 to 1.0.
visiblebooleanShow or hide the layer.

Text layers​

KeyTypeDescription
textstringThe new text. Merge-tag rules still apply.
colorstringText colour as hex.
font_sizeintegerFont size.
font_familystringFor example Roboto.
font_weightstringbold, normal, or 100 to 900.
font_stylestringitalic or normal.
underline, linethroughbooleanText decoration.
text_alignstringleft, center, right or justify.
vertical_alignstringtop, middle or bottom.
text_casingstringnone, lowercase, uppercase or capitalize.
text_auto_fitstringoverflow, truncate or fit.
directionstringltr or rtl.
merge_tagstringFor example [NAME].
default_textstringUsed 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​

KeyTypeDescription
image_urlstringA public http or https URL. For a logo layer, give a domain such as example.com.
default_imagestringURL used when no image is supplied.
is_logo, is_screenshotbooleanFetch a company logo or a website screenshot from the URL or domain.
extract_domainbooleanTurn an email address into the company domain before fetching a logo or screenshot.
preserve_widthstring"true" keeps the width, "false" keeps the height.
border_radius_enabled, border_radiusboolean, integerRounded corners, 0 to 100.

Circle images also accept pan_x, pan_y and the circle_border_* and circle_shadow_* keys.

caution

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.

formatResponseNotes
jpg or jpegimage/jpegThe default.
pngimage/pngThe default for designs with a transparent canvas, because JPG would turn transparency black.
webpimage/webpHonours quality.
pdfapplication/pdfA single A4 page, with the image scaled to fit and centred.
pdf_letterapplication/pdfThe 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.

StatusContent-TypeBodyWhen
401application/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.
400text/plainDesign not found.Unknown design id, or one the key's user cannot read.
400text/plainUnsupported format 'gif'. Valid formats are: jpg, png, webp, pdf, pdf_letter.Bad format. The value you sent is echoed.
400application/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.
400application/problem+jsonThe 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.
400text/plainRequest failed: <message>The renderer rejected the request.
500noneEmptyUsually 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.