Skip to content

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-templates

Authentication

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-dark

Response

json
{
  "template": {
    "id": "uuid-here",
    "template_id": "blog-dark",
    "template_data": {...},
    "created_at": "2024-01-15T10:30:00Z"
  }
}

Create Template

Endpoint

POST /api/user-templates

Request 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-template

Request 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-template

Response

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.png

The 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

  1. Use descriptive IDscompany-blog-dark is better than template1
  2. Create templates per use case — Separate templates for blog, products, events
  3. Include brand assets — Logo URLs, default author info
  4. Version your templates — Use IDs like blog-v2 when making changes
  5. Document internally — Keep track of what each template is for

Limits

PlanMax Templates
Free5
Pro50
BusinessUnlimited

Generate stunning Open Graph images programmatically.