v1

latestOpenAPI 3.1.02026-07-26497885.9 KB

Create template

Create reusable message templates for push, email, and SMS channels. Templates can be accessed through both the dashboard and API using a template_id.

post/templates

Headers

Authorizationstring required

Your App API key with prefix Key . See Keys & IDs.

Content-Typestring required

Request body

app_idstring required

Your OneSignal App ID in UUID v4 format. See Keys & IDs.

namestring required

An internal name you set to help organize and track Templates. Maximum 128 characters.

isEmailboolean

Required to be set true for email templates.

email_subjectstring

Required for email templates. The subject of the email. Supports Message Personalization.

email_bodystring

The body of the email in HTML format. Required for email templates. Supports Message Personalization.

isSMSboolean

Required to be set true for SMS templates.

dynamic_contentobject

Add personalization to your templates programmatically. No need to upload a CSV. See Dynamic Content for details.

Example request

{
  "dynamic_content": {
    "campaign_id": {
      "A": {
        "title": "Custom Title A",
        "message": "Custom Message A",
        "url": "https://www.onesignal.com"
      },
      "B": {
        "title": "Custom Title B",
        "message": "Custom Message B",
        "url": "https://www.onesignal.com/login"
      }
    }
  }
}

Response

The created template record. content reflects the configuration as stored — fields not relevant to the chosen channel are returned as null.

idstring uuid required

Template ID in UUID v4 format.

namestring

Internal label set when the template was created or last updated. Maximum 128 characters.

channel'push' | 'email' | 'SMS'

The primary channel the template is configured for. Note: SMS is uppercased while the others are lowercased.

created_atstring date-time

ISO-8601 timestamp when the template was created.

updated_atstring date-time

ISO-8601 timestamp when the template was last updated.