Skip to the documentation
API

Upload a template image

Store an image and get its public address for a template.

POST/templates/images

Runs the real call on your workspace.

POST /templates/images

Store an image and get its public address for a template.

Example

Needs templates:write. Send the bytes as the body with their type as Content-Type: PNG, JPEG, WebP, GIF or SVG, up to 100 MB. It is fitted into 1200 by 1800 pixels and stored in a form every mail client shows. Add ?crop=x,y,width,height, four fractions of the image, to keep only part of it. Answers 201.

curl
curl -X POST "$API/templates/images" -H "$AUTH" -H "Content-Type: image/png" \  --data-binary @hero.png
Response
{  "object": "template_image",  "id": "5f0c9a8e-2b7d-4c1e-9a3f-8d6b2e4c7a10",  "url": "https://cdn.nextmail.sh/templates/images/8a9c35f0/5f0c9a8e-2b7d-4c1e-9a3f-8d6b2e4c7a10.png",  "size": 48213,  "width": 1200,  "height": 630}

An image of another type, one over 100 MB or one that cannot be read is a 422 invalid_image, and a crop that does not fit inside the image a 422 invalid_parameter. A busy image service answers 503 image_busy and a failed save 502 image_not_stored.

Reference