Documentation
Update Template

Update Template

Update an existing image template.

ℹ️

You will need to authenticate to use this API. See authentication.

Request

PUT https://api.ojo.so/v1/template/:templateId

Path Parameters

ParameterTypeDescription
templateIdstringThe unique identifier of the template to update

Headers

HeaderValueDescription
Content-Typeapplication/jsonSpecify that the request body is JSON

Request Body

FieldTypeDescription
htmlstring(Optional) The updated HTML content of the template (must be encoded)
variablesobject(Optional) Updated variables used in the template

You can encode your HTML content using the HTML Encoder (opens in a new tab).

Dynamic Template

You can update your template with Handlebars expressions and generate images by providing the necessary data. When making a request to generate an image, include a modify object in your request body with the data to populate your Handlebars placeholders. Learn how to create image with variables.

Example:

{
  "templateId": "template-uuid-123",
  "modify": {
    "title": "Welcome to Our Site",
    "user": {
      "name": "Alice Smith"
    },
    "showDetails": true,
    "items": ["Item 1", "Item 2", "Item 3"]
  }
}
curl --request PUT \
  --url https://api.ojo.so/v1/template/<Replace with template ID> \
  --header 'Authorization: Bearer <API Key>' \
  --header 'Content-Type: application/json' \
  --data '{
    "html": "...encoded HTML content...",
    "variables": {
      "title": "Updated Template Title",
      "content": "This is the updated content."
    }
  }'

Response

Template successfully updated.

{
  "id": "template-uuid-1",
  "message": "Template updated successfully"
}