Generate images from HTML/CSS, URLs, or templates in a single request with signed URLs.
Recommendation
We recommend using the standard API endpoint for most use cases. Only use this endpoint if you specifically need to generate image URLs from client-side code or need to avoid the two-step create-then-fetch process.
Key benefits
This endpoint allows you to generate image URLs that directly render images when accessed:
No POST request needed: Generate image URLs client-side without making API calls
Client-side friendly: Use signed URLs to keep your API Key secure
Simplified workflow: Skip the image creation step and go straight to image rendering
Template ready: Create reusable signed image URLs from template values
Unlike the standard endpoint that requires a POST request followed by using the returned URL, this endpoint lets you construct a signed URL that will generate and return the image when accessed.
Each API key has an associated API ID (public) and API Key (secret). The token is generated by creating an HMAC SHA256 hash of the query string (without the ?) using your API Key as the secret. For HTML/CSS and URL renders, the signed URL includes your API ID. For templated image URLs, the signed URL uses the template_id instead.
Security note
Never expose your API Key in client-side code. The API ID and generated token are safe to use client-side.
Creating an image
To generate an image with a signed URL, construct a URL with your API ID and token:
get https://hcti.io/v1/image/create-and-render/:api_id/:token/:format
URL Components
Component
Description
api_id
Your public API ID from the dashboard
token
HMAC SHA256 hash of the query string using your API Key (see below for how to generate)
format
Optional file format: png (default), jpg, webp, or pdf
Parameters
The parameters are the same as the standard API endpoint, but they must be passed as query parameters in the URL.
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. 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.
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.
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.
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.
Customize PDF output with page size, margins, scale, and background printing. Use this when you plan to request the generated URL with a .pdf extension.
Set the width of Chrome’s viewport. This will disable automatic cropping. Both height and width parameters must be set if using either.
Creating a templated image URL
To generate an image from a template with a signed URL, construct a URL with your template_id and token. You do not need to include your API ID in the path.
get https://hcti.io/v1/image/:template_id/:token/:format?
HMAC SHA256 hash of the query string using your API Key
format
Optional file format: png (default), jpg, webp, or pdf.
Parameters
Template values are passed as query string parameters. Each query parameter name maps to a variable in your template.
Name
Type
Description
template values
String, Number, Boolean, or JSON
Values for the variables in your template. For editor templates, see the Variables guide.
template_version
Integer
Optional. Render a specific version of the template. Include this in the query string before generating the token.
Nested objects and arrays should be serialized as JSON and URL encoded. The token must be generated from the exact encoded query string you put after ?.
The author value decodes to {"name":"Jeff"}. The title value decodes to "Launch".
Use an official client
The TypeScript and .NET clients include signed URL helpers (generateTemplatedImageUrl and CreateTemplatedImageUrl) so you do not need to hand-build the query string or HMAC token.
Understanding HMAC authentication
HMAC (Hash-based Message Authentication Code) is a mechanism for calculating a message authentication code involving a hash function in combination with a secret key. In this API:
The message is your query string (without the leading ?), e.g., html=%3Cdiv%3EHello%3C%2Fdiv%3E
The secret key is your API Key
The hash function used is SHA-256
The resulting token is used in the URL path to authenticate the request
This allows you to create signed URLs without exposing your API Key. If any part of the query string is changed without updating the token, the URL will be invalid. Query parameter order, encoding style, and whitespace all matter because the token is based on the exact query string.
constcrypto=require('crypto');functiongenerateToken(queryString,apiKey){returncrypto.createHmac('sha256',apiKey).update(queryString).digest('hex');}constapiId='your_api_id_here';constapiKey='your_api_key_here';constformat='png';// Example 1: Using HTML and CSSconstparams=newURLSearchParams({html:'<div>Hello World</div>',css:'div{color:red}'});constqueryString=params.toString();consttoken=generateToken(queryString,apiKey);// Generate the URLconstimageUrl=`https://hcti.io/v1/image/create-and-render/${apiId}/${token}/${format}?${queryString}`;// Example 2: Using a URL parameterconsturlParams=newURLSearchParams({url:'https://example.com'});consturlQueryString=urlParams.toString();consturlToken=generateToken(urlQueryString,apiKey);// Generate the URL for website screenshotconstscreenshotUrl=`https://hcti.io/v1/image/create-and-render/${apiId}/${urlToken}/${format}?${urlQueryString}`;// Example 3: Using a templateconsttemplateId='t-b0354248-e7f6-4cca-81c6-2b4a70a16388';consttemplateValues={title:'Launch',author:{name:'Avery'}};consttemplateParams=newURLSearchParams();Object.keys(templateValues).sort().forEach((key)=>{templateParams.append(key,JSON.stringify(templateValues[key]));});consttemplateQueryString=templateParams.toString();consttemplateToken=generateToken(templateQueryString,apiKey);consttemplatedImageUrl=`https://hcti.io/v1/image/${templateId}/${templateToken}/${format}?${templateQueryString}`;// Now these URLs can be used directly in an <img> tag or as a link// <img src="imageUrl" alt="Generated image" />
PHP example
<?php$apiId='your_api_id_here';$apiKey='your_api_key_here';$format='png';// Example 1: Using HTML and CSS// Create query string$html='<div>Hello from PHP</div>';$css='div{color:blue;font-family:Arial}';$queryString=http_build_query(['html'=>$html,'css'=>$css,],'','&',PHP_QUERY_RFC3986);// Generate token$token=hash_hmac('sha256',$queryString,$apiKey);// Generate the URL$imageUrl="https://hcti.io/v1/image/create-and-render/$apiId/$token/$format?$queryString";echo"Generated image URL: $imageUrl\n";// Example 2: Using a URL parameter$websiteUrl='https://example.com';$urlQueryString=http_build_query(['url'=>$websiteUrl,],'','&',PHP_QUERY_RFC3986);$urlToken=hash_hmac('sha256',$urlQueryString,$apiKey);// Generate the URL for website screenshot$screenshotUrl="https://hcti.io/v1/image/create-and-render/$apiId/$urlToken/$format?$urlQueryString";echo"Screenshot URL: $screenshotUrl\n";// Example 3: Using a template$templateId='t-b0354248-e7f6-4cca-81c6-2b4a70a16388';$templateValues=['title'=>'Launch','author'=>['name'=>'Avery'],];ksort($templateValues);$templateParams=[];foreach($templateValuesas$key=>$value){$templateParams[$key]=json_encode($value);}$templateQueryString=http_build_query($templateParams,'','&',PHP_QUERY_RFC3986);$templateToken=hash_hmac('sha256',$templateQueryString,$apiKey);$templatedImageUrl="https://hcti.io/v1/image/$templateId/$templateToken/$format?$templateQueryString";echo"Templated image URL: $templatedImageUrl\n";// Use the URLs directly in your HTML// echo '<img src="' . htmlspecialchars($imageUrl) . '" alt="Generated image">';
Example response
When you access a valid signed URL, the API will return the generated image directly with the appropriate content type header (image/png, image/jpeg, or image/webp depending on the format).
If there’s an error, you’ll receive a JSON response:
STATUS: 400 BAD REQUEST
{"error":"Bad Request","statusCode":400,"message":"HTML is Required"}