---
title: "HTML to image (PNG, JPEG or WebP)"
method: POST
path: "/capture"
tags: ["Images"]
---

# HTML to image (PNG, JPEG or WebP)

`POST /capture`

## Request

- Base URL: `https://api.cofferdock.com`
- URL: `https://api.cofferdock.com/capture`
- Auth: API key in header `x-api-key`

Renders HTML (with inline CSS; fonts and images from the internet are allowed, JavaScript is not executed) into an image. Ideal for social cards, certificates, tickets, OG images or any design you can describe in HTML. Send either html, or template + data to use a ready-made design.

Costs 1 credit per call.

## Request body

- object
  - `html` string: The HTML to render (max 5 MB). Put the CSS inline or in a <style> tag. Required unless you use template.
  - `template` 'social' | 'og' | 'invoice' | 'receipt' | 'certificate' | 'youtube': Use one of our ready-made designs instead of sending html. Fields, example texts and sizes: https://cofferdock.com/templates.json
  - `data` object: Texts for the template, e.g. { "name": "Jane Doe", "course": "n8n basics" } for "certificate". Plain text only: everything is escaped. Fields you leave out keep the example text.
  - `lang` 'en' | 'es': Language of the example texts of the template.
  - `width` integer: Image width in pixels (100-3840). Default 1200.
  - `height` integer: Image height in pixels (100-2160). Default 630, the standard social-card (Open Graph) proportion.
  - `format` 'png' | 'jpeg' | 'webp': Image format: "png" (lossless, default), "jpeg" or "webp".
  - `quality` integer: For jpeg and webp.
  - `full_page` boolean: Capture the whole content height instead of the viewport.
  - `wait_ms` integer: Extra wait before the snapshot.
  - `output` 'json' | 'binary' | 'url' | 'image': How to return the image: "json" (base64 in the JSON response), "binary" (the image itself, ready for n8n/Make/Zapier) or "url" (a temporary download link, valid 15 minutes). Default: json when the request is JSON, binary when the input was sent raw.

## Response `200`

The resulting image (shape depends on `output`).

- union
  - object
    - `success` boolean
    - `image` string, byte
    - `mime_type` 'image/png' | 'image/jpeg' | 'image/webp'
    - `meta` object
      - `size_bytes` integer
      - `width` integer
      - `height` integer
      - `format` string
      - `used` integer: Credits used this month, after this call.
      - `remaining` integer, nullable: Credits left this month (null = unlimited).
      - `unlimited` boolean
  - object: Returned when output=url: a temporary download link (valid 15 minutes).
    - `success` boolean
    - `url` string, uri: Temporary download link. Expires in 15 minutes.
    - `expires_at` string, date-time
    - `mime_type` string
    - `size_bytes` integer
    - `meta` object
      - `used` integer: Credits used this month, after this call.
      - `remaining` integer, nullable: Credits left this month (null = unlimited).
      - `unlimited` boolean

## Other responses

- `400`: Invalid input (nothing is charged).
- `401`: Missing or invalid API key.
- `403`: Email not verified.
- `422`: An image, font or stylesheet linked from the HTML did not finish loading within 20 seconds. The body says which sites (`hosts`). The credit is not charged.
- `429`: Monthly credit limit reached, or too many requests per minute for this key (see Retry-After).
- `503`: Server busy (queue full). Retry after the seconds in the Retry-After header.

---

[API](https://skmtc.dev/cofferdock/apis/cofferdock-api.md) · [All operations](https://skmtc.dev/cofferdock/apis/cofferdock-api/llms.txt) · [OpenAPI document](https://skmtc.dev/cofferdock/apis/cofferdock-api/revisions/b57aa000d33a?raw)
