Generate images using signed URLs

Generating images using signed URLs is a bit more technical.

Here's an example using Node.js (JavaScript):

const crypto = require('crypto')

const templateId = 719

const BASE_URL = `${templateId}/signed`

const apiToken = '<YOUR_API_TOKEN>'

const fields = {
    'previewify:title': 'Hello from Node.js!',
    'previewify:image': '',

// Encode fields
const base64Fields = Buffer.from(JSON.stringify(fields)).toString('base64')

// Create a signature using HMAC
const signature = crypto
    .createHmac('sha256', apiToken)

const imageUrl = `${BASE_URL}?fields=${base64Fields}&signature=${signature}`


Or the same example in PHP:


$templateId = 719;

$baseUrl = "{$templateId}/signed";

$apiToken = '<YOUR_API_TOKEN>';

$fields = [
    'previewify:title' => 'Hello from PHP!',
    'previewify:image' => ''

$base64Fields = base64_encode(json_encode($fields));

$signature = hash_hmac('sha256', $base64Fields, $apiToken);

echo "{$baseUrl}?fields={$base64Fields}&signature={$signature}";

What is happening?

  • We're encoding the fields using first: JSO and then BASE64
  • Creating a signature using HMAC which consumes the API encoded fields and API token
  • Build a URL with the fields and signature query strings