Appearance
User Templates API
Save custom template configurations for quick reuse.
Overview
User Templates allow you to:
- Save frequently used configurations
- Create branded templates with preset styles
- Share template IDs across your team
- Quickly generate consistent images
List Templates
Endpoint
GET /api/user-templatesAuthentication
Requires session cookie (logged-in user).
Response
json
{
"templates": [
{
"id": "uuid-here",
"template_id": "blog-dark",
"template_data": {
"template": "blog",
"theme": "dark",
"logo_url": "https://mysite.com/logo.png"
},
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
]
}Get Single Template
Endpoint
GET /api/user-templates?template_id=blog-darkResponse
json
{
"template": {
"id": "uuid-here",
"template_id": "blog-dark",
"template_data": {...},
"created_at": "2024-01-15T10:30:00Z"
}
}Create Template
Endpoint
POST /api/user-templatesRequest Body
json
{
"template_id": "my-blog-template",
"template_data": {
"template": "blog",
"theme": "dark",
"logo_url": "https://mysite.com/logo.png",
"author_name": "My Company Blog"
}
}Response
json
{
"template": {
"id": "uuid-here",
"template_id": "my-blog-template",
"template_data": {...},
"created_at": "2024-01-15T10:30:00Z"
},
"message": "Template created successfully"
}Update Template
Endpoint
PUT /api/user-templates?template_id=my-blog-templateRequest Body
json
{
"template_data": {
"template": "blog",
"theme": "light",
"logo_url": "https://mysite.com/new-logo.png"
}
}Response
json
{
"template": {...},
"message": "Template updated successfully"
}Delete Template
Endpoint
DELETE /api/user-templates?template_id=my-blog-templateResponse
json
{
"message": "Template deleted successfully"
}Using Saved Templates
Once you've saved a template, reference it when generating images:
Via API
bash
curl -X POST https://ogimageapi.io/api/generate \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{
"user_template_id": "my-blog-template",
"title": "My New Blog Post",
"subtitle": "This uses my saved template settings"
}' \
--output image.pngThe saved template settings will be merged with your request, with request parameters taking precedence.
Example Workflow
1. Create a Branded Template
javascript
// Save your brand settings once
const response = await fetch('/api/user-templates', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
credentials: 'include',
body: JSON.stringify({
template_id: 'company-blog',
template_data: {
template: 'blog',
theme: 'dark',
logo_url: 'https://mycompany.com/logo.png',
author_avatar_url: 'https://mycompany.com/team.png'
}
})
});2. Generate Images with Template
javascript
// Now just pass the title and template ID
const imageResponse = await fetch('/api/generate', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': apiKey
},
body: JSON.stringify({
user_template_id: 'company-blog',
title: 'New Feature Announcement',
subtitle: 'Introducing our latest update'
})
});Template Data Schema
You can save any valid generate API parameters:
json
{
"template_id": "my-template",
"template_data": {
"template": "blog|product|profile|...",
"theme": "dark|light",
"logo_url": "string",
"author_name": "string",
"author_avatar_url": "string",
"brand": "string",
// ... any other generate API parameters
}
}Best Practices
- Use descriptive IDs —
company-blog-darkis better thantemplate1 - Create templates per use case — Separate templates for blog, products, events
- Include brand assets — Logo URLs, default author info
- Version your templates — Use IDs like
blog-v2when making changes - Document internally — Keep track of what each template is for
Limits
| Plan | Max Templates |
|---|---|
| Free | 5 |
| Pro | 50 |
| Business | Unlimited |