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
contents
property 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: true
disables others).
Email Templates
Requirements:- Set
isEmail: true
. - Include both
email_subject
andemail_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
200
"b17ebe45-ae35-4dce-11f8-8c3b3894a432"
An internal name you set to help organize and track Templates. Maximum 128 characters.
The date and time the template was created in ISO 8601 format.
The date and time the template was last updated in ISO 8601 format.