Menu
Docs/OG Image API

OG Image API

Generate beautiful 1200×630 Open Graph images from templates. Pass your data, get a perfect social preview image.

The OG Image API requires a Starter plan or above. Free plan requests return 403 plan_required. View plans →

POST/v1/og-image

Request body

{
  "template": "blog-post",
  "data": {
    "title": "How to Scale Your Startup",
    "author": "Jane Doe",
    "date": "March 25, 2026",
    "reading_time": "5 min",
    "tag": "Engineering"
  },
  "width": 1200,
  "height": 630,
  "format": "png"
}
ParameterTypeDefaultDescription
template*stringTemplate ID. See /v1/templates for available templates.
data*objectTemplate variables as key-value pairs.
widthnumber1200Output width in pixels. Min 100, max 3840.
heightnumber630Output height in pixels. Min 100, max 2160.
formatenumpngOutput format: png, jpeg, or webp.
cachebooleantrueCache the result in Redis.
cache_ttlnumber3600Cache TTL in seconds.

Available templates

Template IDVariables
blog-posttitle, author, date, avatar_url, reading_time, tag, bg_color
social-cardtitle, description, logo_url, site_name, bg_color
product-cardname, tagline, price, image_url, badge, bg_color
github-readmerepo, description, stars, forks, language, owner_avatar
quote-cardquote, author, role, avatar_url, bg_color

Example

Generate a blog post OG image:

curl -X POST "https://api.snapsharp.dev/v1/og-image" \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "template": "blog-post",
    "data": {
      "title": "Why Your Headless Chrome Keeps Crashing",
      "author": "Alex Chen",
      "date": "March 25, 2026",
      "reading_time": "8 min",
      "tag": "DevOps"
    }
  }' -o og.png

Response

Returns binary image data directly in the response body.

HeaderValue
Content-Typeimage/png, image/jpeg, or image/webp (based on format param)
X-Response-TimeRender time in milliseconds
X-CacheHIT or MISS

Use format: "jpeg" or format: "webp" for smaller file sizes (30–50% smaller than PNG). Most social platforms accept JPEG for OG images. WebP offers the best compression but isn't supported by all unfurlers.

Custom templates

In addition to the 5 built-in templates, you can design your own with HTML/CSS using the Custom Templates feature (Growth+ plan). Use your template's slug as the template parameter.

SDK examples

Using the official SDKs:

// Node.js
import { SnapSharp } from '@snapsharp/sdk';
const snap = new SnapSharp('sk_live_...');
const image = await snap.ogImage('blog-post', {
  title: 'My Article',
  author: 'Jane Doe',
});
# Python
from snapsharp import SnapSharp
snap = SnapSharp("sk_live_...")
image = snap.og_image("blog-post", {"title": "My Article", "author": "Jane Doe"})

See all SDKs at SDKs & Libraries.