Update previously created templates for push, email and sms visible and usable in the dashboard and API.

Overview

This endpoint lets you update an existing template using the same payload format as creating templates. This will immediately change the template in OneSignal and anything using that template to generate messages will have the new content going forward.


How to use this API

You will need to your OneSignal App ID and the Template ID.

App ID

This field specifies the app containing the template you are updating. It is added as a query parameter to the request after the template ID in your request path. /templates/{template_id}?app_id={app_id}

Template ID

To update a template, it must be identifiable via the template_id path parameters. This is the UUID found in the URL, when viewing the template you intend to make updates to.

Push templates

Requirements:

All Push Channel Properties are valid to include in your push templates.

By default, all push platforms are enabled (set to true). You can disable specific push platforms by only setting the ones you want enabled to true. For example, setting isAndroid: true will make iOS and Web platforms disabled in the template. See Platforms to delivery To for details.

Email templates

Requirements:

  • Set isEmail: true.
  • Must include the email_subject and email_body properties.

All Email Channel Properties are valid to include in your email templates.

SMS templates

Requirements:

  • Set isSMS: true.

All SMS Channel Properties are valid to include in your SMS templates.



Examples

Updating a push template

curl --location --request PATCH 'https://api.onesignal.com/templates?app_id=<APP ID>' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{
    "name":"updated push name",
    "contents": {
        "en": "Updated English Message"
    }       
}'

Updating an email template

curl --location --request PATCH 'https://api.onesignal.com/templates?app_id=<APP ID>' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{
    "name":"Updated email name",
    "isEmail": true,
    "email_subject":"Updated English Subject",
    "email_body":"Updated English Message"
}'

Updating an SMS template

curl --location --request PATCH 'https://api.onesignal.com/templates?app_id=<APP ID>' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{
    "name":"email example",
    "isSMS": true,
    "sms_from":"+1234567890",
    "contents": { 
    	"en": "Updated English Message" 
     },
    "sms_media_urls": ["https://cat.com/cat.jpg"],
}'

Body parameters

contents

Type object

See Content Properties for details.

Description

Specifies the content shown to the end user for push templates.

  • The object consists of key-value pairs where each key is a language code string (e.g., "en" for English, "es" for Spanish), and the value is the localized message intended for speakers of that language.
  • English localization must be included in the mapping to ensure broad accessibility.
  • This field supports Message Personalization.

isEmail

Type boolean

Description

Specifies the channel for the template as email.

  • Set this value to true if the intended usage for the template is to send to email users.
  • If this value is set to true, all email channel properties may be used in the body of this request.

email_body

Type string

Description

Specifies the body of the email being sent.

  • Required if isEmail is set to true

isSMS

Type boolean

Description

Specifies the channel for the template as SMS.

  • Set this value to true if the intended usage for the template is to send to SMS users.
  • If this value is set to true, all SMS channel properties may be used in the body of this request.

dynamic_content

Type json

Description

JSON object that can be used as a source of message personalization data for fields that support tag variable substitution. Each top-level key must have a JSON object as its value, the structure of those JSON objects are determined by the caller.

  • Use this json object to personalize content within the template that will be unique to each user. See message personalization for examples.
  • There is a limit of 200,000 bytes of valid JSON per template.
Language