Skip to content

POST /validate

Validates whether title and description text will fit within the specified format’s layout constraints. Returns line count, max lines, and overflow status for each text block. Does not generate an image.

POST https://og-engine.com/validate

Authentication: Optional — accepts Authorization: Bearer header but does not require it Cost: Free, unlimited, never metered against your plan quota

FieldTypeRequiredDefaultDescription
formatstringYesog, twitter, square, linkedin, story
titlestringYesThe title text to measure
descriptionstringNoThe description text to measure
fontstringNo"Outfit"Font family to use for measurement
titleSizenumberNo48Title font size in pixels (28–72)
descSizenumberNo22Description font size in pixels (14–32)
maxTitleLinesnumberNo3Maximum lines before title overflows
maxDescLinesnumberNo4Maximum lines before description overflows
autoFitbooleanNofalseAuto-find optimal font sizes that prevent overflow
Terminal window
curl -X POST https://og-engine.com/validate \
-H "Content-Type: application/json" \
-d '{
"format": "og",
"title": "The Complete Guide to Building High-Performance APIs with Bun",
"description": "A walkthrough covering routing, middleware, database access, caching, authentication, and deployment.",
"font": "Outfit",
"titleSize": 48,
"descSize": 22
}'
{
"fits": true,
"title": {
"lines": 3,
"maxLines": 3,
"overflow": false
},
"description": {
"lines": 3,
"maxLines": 4,
"overflow": false
},
"computeTimeMs": 0.18
}
FieldTypeDescription
fitsbooleantrue if both title and description are within limits
title.linesnumberNumber of lines the title wraps to
title.maxLinesnumberMaximum lines allowed (from request or default)
title.overflowbooleantrue if lines > maxLines
description.linesnumberNumber of lines the description wraps to
description.maxLinesnumberMaximum lines allowed
description.overflowbooleantrue if lines > maxLines
computeTimeMsnumberTime taken to measure the text in milliseconds
Terminal window
curl -X POST https://og-engine.com/validate \
-H "Content-Type: application/json" \
-d '{
"format": "og",
"title": "An Extremely Long Title That Will Definitely Overflow The Available Space In The Layout Engine",
"description": "A very long description that contains way too much information to fit in a standard OG image format."
}'
{
"fits": false,
"title": {
"lines": 4,
"maxLines": 3,
"overflow": true
},
"description": {
"lines": 5,
"maxLines": 4,
"overflow": true
},
"computeTimeMs": 0.22
}

When fits is false, consider:

  • Using autoFit: true to let the engine find optimal font sizes automatically
  • Shortening the text
  • Reducing titleSize / descSize
  • Passing custom maxTitleLines / maxDescLines if your template allows more room

Set autoFit: true to let OG Engine find the largest font size that fits within the line limits. Uses binary search for optimal results.

Terminal window
curl -X POST https://og-engine.com/validate \
-H "Content-Type: application/json" \
-d '{
"format": "og",
"title": "A Very Long Title That Would Normally Overflow But AutoFit Finds The Right Size",
"autoFit": true
}'
{
"fits": true,
"autoFit": {
"titleSize": 38,
"descSize": 32
},
"title": {
"lines": 3,
"maxLines": 3,
"overflow": false
},
"computeTimeMs": 0.45
}

Pass these fitted sizes to /render with style.autoFit: true to use the same algorithm at render time.

Terminal window
curl -X POST https://og-engine.com/validate \
-H "Content-Type: application/json" \
-d '{
"format": "og",
"title": "My Article Title",
"description": "My article description.",
"font": "Playfair Display",
"titleSize": 52,
"maxTitleLines": 2,
"maxDescLines": 3
}'

Always match the font and size values you plan to use in /render — different fonts have different metrics and will produce different line counts.

StatusCodeCause
400missing_fieldformat or title not provided
400invalid_formatformat is not a recognized value
400invalid_fontfont is not a supported font family