Skip to content

Custom Templates

Build your own templates using a declarative JSON layer system. Custom templates are stored per-user and can be referenced in /render requests using the custom:<name> prefix.

Authentication: Required Plan: Scale only (402 on lower plans)

POST https://og-engine.com/templates
{
"name": "my-card",
"layers": [
{ "type": "gradient", "gradient": "void" },
{
"type": "rect",
"color": "{{accent}}",
"x": 0,
"y": 0,
"width": 6,
"height": "full"
},
{
"type": "text",
"content": "{{title}}",
"fontSize": 48,
"fontWeight": 800,
"x": 80,
"y": 120,
"width": 1040,
"maxLines": 3,
"color": "#ffffff"
},
{
"type": "text",
"content": "{{description}}",
"fontSize": 22,
"x": 80,
"y": 340,
"width": 1040,
"maxLines": 4,
"color": "#94a3b8"
}
]
}

If a template with the same name already exists for your account, it’s updated in place.

{
"id": "a1b2c3d4-...",
"name": "my-card",
"layerCount": 4,
"message": "Template created."
}
FieldTypeDescription
colorstringHex color or {{accent}}
FieldTypeDescription
gradientstringvoid, deep-sea, ember, forest, plum, slate
FieldTypeDescription
colorstringFill color
x, ynumber/stringPosition ("center", "right", or pixel number)
width, heightnumber/stringSize (number, "full", or "50%")
radiusnumberBorder radius (optional)
FieldTypeDefaultDescription
contentstringText or variable: {{title}}, {{description}}, {{author}}, {{tag}}
fontSizenumberFont size in pixels
fontWeightnumber/string400Font weight
colorstring#ffffffText color
alignstringleftleft, center, right
lineHeightnumber1.2Line height multiplier
maxLinesnumberallMax visible lines (overflow adds ellipsis)
ellipsisbooleantrueAdd ... on overflow
FieldTypeDefaultDescription
fitstringcovercover, contain, fill
FieldTypeDescription
x, ynumberStart point
x2, y2numberEnd point
colorstringStroke color
lineWidthnumberLine width (default: 1)
FieldTypeDescription
opacitynumber0–1, applied during rendering
x, ynumber/stringPosition
width, heightnumber/stringDimensions

Use {{variable}} syntax in text.content and any color field:

  • {{title}} — render request title
  • {{description}} — render request description
  • {{author}} — render request author
  • {{tag}} — render request tag
  • {{accent}} — style accent color

Reference your template with the custom: prefix:

{
"format": "og",
"template": "custom:my-card",
"title": "Hello from my custom template!"
}
GET https://og-engine.com/templates

Returns all custom templates for the authenticated user.

DELETE https://og-engine.com/templates/:id
StatusCodeCause
400invalid_requestInvalid layer definition
401unauthorizedMissing API key
402plan_requiredCustom templates require Scale plan
404not_foundTemplate not found (when using custom:<name> in /render)