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.
Documentation Index
Fetch the complete documentation index at: https://documentation.onesignal.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Use this endpoint to create a new message template in your OneSignal app. Once created, the template becomes available for use when sending messages via both the Dashboard and the REST API by referencing thetemplate_id.
Templates streamline and standardize message content across push, email, and SMS channels.
How to use this API
Before using this endpoint, ensure that the target channel (push, email, or SMS) is properly configured in your OneSignal app. See Channel Setup for guidance.Push Templates
Requirements:- Set the
contentsproperty with the English (en) language key. - All Push Channel Properties are valid for use in push templates.
- By default, all push platforms are enabled. You can target specific platforms by explicitly setting them (e.g.,
isAndroid: truedisables others).
Email Templates
Requirements:- Set
isEmail: true. - Include both
email_subjectandemail_body. - All Email Channel Properties are valid for use in email templates.
SMS Templates
Requirements:- Set
isSMS: true. - Provide SMS-specific parameters like
contents. - All SMS Channel Properties are valid for use in SMS templates.
Body
Your OneSignal App ID in UUID v4 format. See Keys & IDs.
An internal name you set to help organize and track Templates. Maximum 128 characters.
The main message body with language-specific values. Required for push and SMS templates. Supports Message Personalization.
Required to be set true for email templates.
Required for email templates. The subject of the email. Supports Message Personalization.
The body of the email in HTML format. Required for email templates. Supports Message Personalization.
Required to be set true for SMS templates.
Add personalization to your templates programmatically. No need to upload a CSV. See Dynamic Content for details.
"{\"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.
A template record. The content block is a TemplateResourceContent whose populated fields depend on the template's channel(s).
Template ID in UUID v4 format.
Internal label set when the template was created or last updated. Maximum 128 characters.
The primary channel the template is configured for. Note: SMS is uppercased while the others are lowercased.
push, email, SMS ISO-8601 timestamp when the template was created.
ISO-8601 timestamp when the template was last updated.
The content block of a template. Every field is nullable: a field is populated only when the corresponding channel feature is enabled for the template. For example, push fields (isAndroid, isIos, headings, ...) are populated for push templates; email fields (isEmail, email_body, ...) for email templates; and SMS fields (isSMS, sms_from, ...) for SMS templates. Cross-channel templates may have multiple feature blocks populated.