Skip to main content
PATCH
/
templates
/
{template_id}
?app_id=
{app_id}
Update template
curl --request PATCH \
  --url 'https://api.onesignal.com/templates/{template_id}?app_id={app_id}' \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "YOUR_TEMPLATE_NAME",
  "isEmail": true,
  "email_body": "<string>",
  "isSMS": true,
  "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\"}}}"
}
'
{
  "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "name": "<string>",
  "channel": "push",
  "created_at": "2023-11-07T05:31:56Z",
  "updated_at": "2023-11-07T05:31:56Z",
  "content": {
    "isAndroid": true,
    "isIos": true,
    "isMacOSX": true,
    "isAdm": true,
    "isAlexa": true,
    "isWP": true,
    "isWP_WNS": true,
    "isChrome": true,
    "isChromeWeb": true,
    "isSafari": true,
    "isFirefox": true,
    "isEdge": true,
    "isHuawei": true,
    "headings": {},
    "subtitle": {},
    "contents": {},
    "global_image": "<string>",
    "url": "<string>",
    "isEmail": true,
    "email_body": "<string>",
    "email_subject": "<string>",
    "email_preheader": "<string>",
    "email_from_address": "jsmith@example.com",
    "email_from_name": "<string>",
    "email_reply_to_address": "jsmith@example.com",
    "email_bcc": "jsmith@example.com",
    "disable_email_click_tracking": true,
    "isSMS": true,
    "sms_from": "<string>",
    "sms_media_urls": [
      "<string>"
    ],
    "huawei_badge_add_num": 123,
    "huawei_badge_class": "<string>",
    "huawei_badge_set_num": 123
  }
}

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

This endpoint allows you to update an existing push, email, or SMS template in your OneSignal app. Once updated, the changes are applied immediately and reflected across both the Dashboard and API when using the associated template_id. Templates are updated using the same structure as when creating templates.
See Templates for more information.

How to use this API

To update a template, you must supply:
  • Your OneSignal App ID found in Keys & IDs.
  • The Template ID

Template ID

Each template has a unique OneSignal-generated template_id (UUID v4). You can find it:
  • Using the View Templates API
  • In the OneSignal Dashboard under Messages > Templates > Options > Copy Template ID
Copy Template ID in OneSignal Dashboard

Channel-Specific Requirements

Push Templates

  • The contents property must use the en (English) key along with other languages you want to support.
  • All Push Notification Properties are valid.
  • All platforms are enabled by default. To limit, explicitly enable desired ones (e.g., isAndroid: true disables iOS and Web).

Email Templates

SMS Templates


Headers

Authorization
string
default:Key YOUR_APP_API_KEY
required

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

Path Parameters

template_id
string
default:YOUR_TEMPLATE_ID
required

The template ID in UUID v4 format. See Templates.

Query Parameters

app_id
string
default:YOUR_APP_ID
required

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

Body

application/json
name
string
default:YOUR_TEMPLATE_NAME
required

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

contents
object

The main message body with language-specific values. Supports Message Personalization.

isEmail
boolean

Required to be set true for email templates.

email_body
string

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

isSMS
boolean

Required to be set true for SMS templates.

dynamic_content
object

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

Example:

"{\"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 updated template record. Same shape as POST /templates.

A template record. The content block is a TemplateResourceContent whose populated fields depend on the template's channel(s).

id
string<uuid>
required

Template ID in UUID v4 format.

name
string

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

channel
enum<string>

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

Available options:
push,
email,
SMS
created_at
string<date-time>

ISO-8601 timestamp when the template was created.

updated_at
string<date-time>

ISO-8601 timestamp when the template was last updated.

content
object

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.