Your username is your User ID and your password is your API Key. Both of these are available from the dashboard. The code samples demonstrate how to authenticate your request.
Treat your API Key like a password. If exposed, it could be used to create images using your account.
Creating an image
To generate an image, make an HTTP request to the API.
post https://hcti.io/v1/image
Parameters
The create image endpoint accepts the following parameters. Accepted as either json or formdata.
Name
Type
Description
html†
String
This is the HTML you want to render. You can send an HTML snippet (<div>Your content</div>) or an entire webpage.
css
String
The CSS for your image. When using with url it will be injected into the page.
url†
String
The fully qualified URL to a public webpage. Such as https://htmlcsstoimage.com. When passed this will override the html param and will generate a screenshot of the url.
Required params
† Either url OR html is required, but not both. css is optional.
Additional parameters
Optional parameters for greater control over your image.
Name
Type
Description
google_fonts
String
Google fonts to be loaded. Example: Roboto. Multiple fonts can be loaded like this: Roboto|Open Sans
selector
String
A CSS selector for an element on the webpage. We’ll crop the image to this specific element. For example: section#complete-toolkit.container-lg
ms_delay
Integer
The number of milliseconds the API should delay before generating the image. This is useful when waiting for JavaScript. We recommend starting with 500. Large values slow down the initial render time. Learn more.
max_wait_ms
Integer
Sets a maximum time limit (500-10000ms) for waiting before taking the screenshot. Unlike ms_delay, this is a cap rather than a fixed delay. Useful when pages load extra irrelevant content.
device_scale
Double
Controls the image resolution by adjusting the pixel ratio. Minimum: 0.1, Maximum: 3. Higher values increase image quality and file size. For example, 2 will double the resolution. Learn more.
render_when_ready
Boolean
Set to true to control when the image is generated. Call ScreenshotReady() from JavaScript to generate the image. Learn more.
full_screen
Boolean
When set to true, the API will generate an image of the entire height of the page. Learn more.
block_consent_banners
Boolean
When set to true, automatically blocks cookie consent banners and popups on websites. Most useful for URL screenshots. Learn more.
viewport_width
Integer
Set the width of Chrome’s viewport. This will disable automatic cropping. Both height and width parameters must be set if using either. Learn more.
viewport_height
Integer
Set the height of Chrome’s viewport. This will disable automatic cropping. Both height and width parameters must be set if using either. Learn more.
color_scheme
String
Set Chrome to render in light or dark mode. Affects websites using prefers-color-scheme. Learn more.
timezone
String
Render your image with Chrome set to a specified timezone. Use IANA timezone identifiers like America/New_York. Learn more.
disable_twemoji
Boolean
Twemoji is used by default to render emoji consistently. Set to true to use native emoji fonts instead.
{"error":"Bad Request","statusCode":400,"message":"HTML is Required"}
STATUS: 429 TOO MANY REQUESTS
{"error":"Plan limit exceeded","statusCode":429,"message":"You've used 3055 of your 3000 renders. Upgrade via the Dashboard: https://htmlcsstoimage.com/dashboard"}
Getting an image
After creating an image, you can use the returned URL to either download your image, or use it directly in your website.
get https://hcti.io/v1/image/:image_id
This URL is permanent for as long as your account is active. It’s automatically cached and optimized by Cloudflare’s global content delivery network. You can use it directly on your webpages and not worry about hurting your page speed score.
Lossless optimization: each image is optimized with no change in image quality.
Global cache: the image is cached near your users to reduce latency.
File formats
The API supports jpg, png, webp, and pdf. If no file extension is passed, you’ll get back a png by default. If you need a different file format, adjust the extension on the url.
The API returns png by default. If no extension is on the URL, a png will be generated.
Query parameters
Query parameters can be added to the URL to adjust your image.
Name
Type
Description
height
Integer
The height of the image. Maximum 5000.
width
Integer
The width of the image. Maximum 5000.
dpi
Integer
Sets the DPI metadata tag on the image. Minimum 30, maximum 600.
dl
Integer
Set dl=1 and the image will be served as a downloadable attachment.
Cropping parameters
Advanced cropping options for precise control over the rendered image region.
Name
Type
Description
aspect_ratio
String
Crop to a specific aspect ratio. Format: width_height (e.g., 16_9, 1_1).
x_origin
String
Origin point for x-axis cropping. Accepts pixels (100px) or percentage (50%).
y_origin
String
Origin point for y-axis cropping. Accepts pixels (100px) or percentage (50%).
x_1
String
Starting x coordinate for crop region. Use with x_2 or crop_width.
x_2
String
Ending x coordinate for crop region. Must be used with x_1.
y_1
String
Starting y coordinate for crop region. Use with y_2 or crop_height.
y_2
String
Ending y coordinate for crop region. Must be used with y_1.
crop_width
String
Width of the crop region. Use with x_1 or alone with aspect_ratio.
crop_height
String
Height of the crop region. Use with y_1 or alone with aspect_ratio.
Cropping examples
Here’s a base image (600x400 pixels) and how different cropping parameters affect it:
Original image:
Crop to 1:1 square from center (aspect_ratio=1_1&crop_height=100%):
?aspect_ratio=1_1&crop_height=100%
Crop left third (x_1=0&crop_width=33%):
?x_1=0&crop_width=33%
Crop center section (x_1=33%&x_2=66%):
?x_1=33%&x_2=66%
Crop right third (x_1=67%&crop_width=33%):
?x_1=67%&crop_width=33%
Crop to 16:9 aspect ratio (aspect_ratio=16_9&crop_width=100%):
?aspect_ratio=16_9&crop_width=100%
Deleting an image
delete https://hcti.io/v1/image/:image_id
To delete an image using the API, you can send a DELETE request to your image URL. This will remove your image from our servers and clear the caching for the image in our CDN.
All data and copies of the image are deleted. This cannot be undone.
Example response
STATUS: 202 ACCEPTED
Batch image creation
Create up to 25 images in a single API request. This is more efficient than making multiple individual requests.
post https://hcti.io/v1/image/batch
Parameters
Name
Type
Description
default_options
Object
Default parameters applied to all images in the batch. Accepts all standard image creation parameters.
variations
Array
Array of image objects. Each can override default_options. Maximum 25 items.
To check your account usage, you can make a request to the usage endpoint. It will return the total images created for your account rolled up into different time periods.
We recommend using this endpoint for tracking your usage in tools such as Datadog.