---
title: "Create template"
method: POST
path: "/templates"
---

# Create template

`POST /templates`

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

## Headers

- `Authorization` string, required
- `Content-Type` string, required

## Request body

- object
  - `app_id` string, required — Your OneSignal App ID in UUID v4 format. See [Keys & IDs](/docs/en/keys-and-ids).
  - `name` string, 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](/docs/en/multi-language-messaging#supported-languages). Required for push and SMS templates. Supports [Message Personalization](/docs/message-personalization).
    - `en` string, required — The required message language type. See [Supported Languages](/docs/en/multi-language-messaging#supported-languages).
  - `isEmail` boolean — Required to be set `true` for email templates.
  - `email_subject` string — Required for email templates. The subject of the email. Supports [Message Personalization](/docs/message-personalization).
  - `email_body` string — The body of the email in HTML format. Required for email templates. Supports [Message Personalization](/docs/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](/docs/dynamic-content) for details.

## Response `200`

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

- TemplateResource — 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` 'push' | 'email' | 'SMS' — The primary channel the template is configured for. Note: `SMS` is uppercased while the others are lowercased.
  - `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` TemplateResourceContent — 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.
    - `isAndroid` boolean, nullable
    - `isIos` boolean, nullable
    - `isMacOSX` boolean, nullable
    - `isAdm` boolean, nullable
    - `isAlexa` boolean, nullable
    - `isWP` boolean, nullable
    - `isWP_WNS` boolean, nullable
    - `isChrome` boolean, nullable
    - `isChromeWeb` boolean, nullable
    - `isSafari` boolean, nullable
    - `isFirefox` boolean, nullable
    - `isEdge` boolean, nullable
    - `isHuawei` boolean, nullable
    - `headings` object, nullable — Map of language code to localized string. Keys are 2-letter ISO codes (e.g., `en`, `es`); values are the message text.
    - `subtitle` object, nullable — Map of language code to localized string. Keys are 2-letter ISO codes (e.g., `en`, `es`); values are the message text.
    - `contents` object, nullable — Map of language code to localized string. Keys are 2-letter ISO codes (e.g., `en`, `es`); values are the message text.
    - `global_image` string, nullable — URL of the image to render with the push notification.
    - `url` string, uri, nullable — Click-action URL for push notifications.
    - `isEmail` boolean, nullable
    - `email_body` string, nullable — HTML body of the email.
    - `email_subject` string, nullable
    - `email_preheader` string, nullable
    - `email_from_address` string, email, nullable
    - `email_from_name` string, nullable
    - `email_reply_to_address` string, email, nullable
    - `email_bcc` string[], nullable — BCC recipients for the email template. Maximum 5 addresses. Only supported when the email service provider is OneSignal Email.
    - `disable_email_click_tracking` boolean, nullable
    - `isSMS` boolean, nullable
    - `sms_from` string, nullable — Sender phone number in E.164 format.
    - `sms_media_urls` string[], nullable — Optional array of media URLs to attach to the SMS (MMS).
    - `huawei_badge_add_num` integer, nullable — Increment value for the Huawei badge counter.
    - `huawei_badge_class` string, nullable — Activity class associated with the Huawei badge counter.
    - `huawei_badge_set_num` integer, nullable — Absolute value to set the Huawei badge counter to.

## Other responses

- `400` — 400
- `422` — 422
- `429` — Rate limit exceeded. Wait the number of seconds in the `Retry-After` header before retrying.
- `503` — Service temporarily unavailable. Retry after a short backoff. The body may be empty or non-JSON in some failure modes.

---

[API](https://skmtc.net/onesignal/apis/api-onesignal-com.md) · [All operations](https://skmtc.net/onesignal/apis/api-onesignal-com/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/onesignal/api-onesignal-com/versions/0fc223f7e338/schema)
