Skip to content

docs / signed-urls

Signed image URLs

A signed URL is the image. Every field is in the address, and a signature at the end proves you made it, so nobody can change a word or spend your credits by editing it. Put it anywhere that takes an image link: an og:image tag, an email, a CMS field, a no-code tool.

https://postimager.com/i/{account}/{key version}/{template}.{png|jpg|pdf}?{fields}&size={size}&brand=default&s={signature}

What it costs

The first time anyone opens a new image (a new combination of template, size, format and values), it is made and uses one credit. Every later request for the same URL is free: Cloudflare's edge serves most of them without reaching PostImager, and the rest get the stored file. After the file's 7 days of storage it is made again, also free. A render that fails is not charged, and the next attempt is the one that counts.

Build one

Easiest: open a template in the editor, fill it in, and use the Image URL tab, or call POST /v1/url-sign with the same body as a render. To build URLs yourself (in n8n's Crypto node or your own code), take your URL key from API keys and sign the path plus the sorted query:

  1. Collect the fields you want (template fields, plus size and brand if used). Leave out empty ones.
  2. Sort them by name, then by value. Percent-encode each name and value (encodeURIComponent; a space becomes %20).
  3. Join as name=value with &, and put it after the path and a ?: /i/ACCOUNT/1/blog-cover.png?category=Guides&headline=...
  4. HMAC-SHA256 that string with your URL key, encode it base64url, keep the first 32 characters, and add it as &s=.
// Node 18 or newer, no dependencies.
import { createHmac } from 'node:crypto';

const ACCOUNT = 'your-account-id';      // from API keys → URL key
const VERSION = 1;                      // the number after your account id in the URL
const KEY = process.env.POSTIMAGER_URL_KEY;

export function imageUrl(template, ext, fields) {
  const path = `/i/${ACCOUNT}/${VERSION}/${template}.${ext}`;
  const pairs = Object.entries(fields).filter(([, v]) => v !== undefined && v !== '')
    .map(([k, v]) => [k, String(v)]).sort(([a, x], [b, y]) => (a < b ? -1 : a > b ? 1 : x < y ? -1 : 1));
  const query = pairs.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`).join('&');
  const s = createHmac('sha256', KEY).update(`${path}?${query}`).digest('base64url').slice(0, 32);
  return `https://postimager.com${path}?${query}&s=${s}`;
}

console.log(imageUrl('blog-cover', 'png', { size: 'link', brand: 'default', headline: 'How we plan a week of posts', category: 'Guides' }));

Open Graph example

Give every blog post its own share image without making one by hand: put the post's title in the URL, and the image exists the first time a network asks for it.

<!-- In your page's <head>: social networks fetch the image when someone shares the link. -->
<meta property="og:image" content="https://postimager.com/i/ACCOUNT/1/blog-cover.png?brand=default&amp;category=Guides&amp;headline=How%20we%20plan%20a%20week%20of%20posts&amp;size=link&amp;s=SIGNATURE">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:card" content="summary_large_image">

Errors and safety

403 signature_invalid: the URL was edited or signed wrongly; nothing was read or charged. 403 url_key_revoked: you replaced your URL key, which turns off every URL signed with the old one (use it if a key leaks). 422: a field is wrong; the message names it. 402 insufficient_credits: the account is out of credits, and only a new image needs one. Responses carry Cache-Control: public, max-age=604800.