> For the complete documentation index, see [llms.txt](https://codemash.gitbook.io/codemash/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://codemash.gitbook.io/codemash/cloud/sms/templates/editor.md).

# Create or edit a template

Create an SMS template — name, type and a text per language — and change it later.

**Where:** SMS → Templates → **Create Template** (new) or press a template name (edit) · `/projects/<project>/sms/templates/new` · `…/sms/templates/<id>/edit`

## Before you start

* The project languages are set under [Project → Settings → Languages](/codemash/cloud/project/settings/languages.md). The template needs a text for every one of them before a campaign or trigger can use it.
* You need `sms:create` on SMS templates (`sms:update` to edit).

## Steps

1. Press **Create Template**. The form **Add New SMS Template** opens with one translation block for the project's default language.

   <figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-6dd0bd193ae48f8c1850ae34f9cc0f1a4bee1afa%2Ftemplates-create-1.png?alt=media" alt="Add New SMS Template: empty Template name and Description, Translations with the language tags EN (default) and LT, and the English block"><figcaption><p>The empty form.</p></figcaption></figure>
2. Fill in the form:

   | Field                             | Required          | What it does                                                                                                                                                                           | Example                                                                  |
   | --------------------------------- | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
   | Template name                     | yes               | The name in the list and in the template pickers.                                                                                                                                      | `Delivery update`                                                        |
   | Description                       | no                | A note for your team, up to 500 characters. Today the text is not kept: after **Create** or **Update** the field is empty again.                                                       | `Sent when an order leaves the warehouse`                                |
   | Translations                      | yes               | The language tags (`EN (default)`, `LT`, …). Each selected tag adds a block; see [Translate a template](/codemash/cloud/sms/templates/translate.md).                                   | `EN (default)`                                                           |
   | Message body                      | yes, per language | The text, up to 1,600 characters, with tokens such as `@Model.FirstName`. The counter under the box shows `x / 160 characters`, and `— will be sent as N SMS parts` for a longer text. | `Hi @Model.FirstName, your Acme order @Model.OrderNumber is on its way.` |
   | Marketing SMS / Transactional SMS | yes               | The type. **Transactional SMS** (default) for codes, alerts and confirmations; **Marketing SMS** for promotions.                                                                       | `Transactional SMS`                                                      |

   There is no sender field: the phone shows the number or sender ID of the [integration](/codemash/cloud/sms/integrations.md) that sends the SMS.

   <figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-f42521a3aa1fd5b2dd822d81503ad1c7e5cf2a70%2Ftemplates-create-2.png?alt=media" alt="The filled form: Template name Delivery update, the Description, the English Message body with @Model.FirstName and @Model.OrderNumber, the type Transactional SMS selected, and the Cancel and Create buttons"><figcaption><p>The filled form.</p></figcaption></figure>
3. Press **Create**. **Cancel** goes back to the list without saving.

## Result

Cloud returns to the [templates list](/codemash/cloud/sms/templates.md) with the new template, **Is Active** = **Yes**. A template that misses a project language carries the amber **Missing …** badge until you [translate](/codemash/cloud/sms/templates/translate.md) it.

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-b5873c3f0111709e591ab54e26e817f51ad276fd%2Ftemplates-list-1.png?alt=media" alt="SMS Templates list with Delivery update at the top, Transactional, Is Active Yes, and the amber badge Missing lt"><figcaption><p>The new template; the Lithuanian text is still missing.</p></figcaption></figure>

Open it again to edit it. The page is now **Edit SMS Template**, shows the id (`tmpl_…`, press it to copy), a **Test** button and the **Actions** menu, and its save button says **Update**.

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-1703c29b904d2f21ee7d3717b4defc4c660f0271%2Ftemplates-edit-1.png?alt=media" alt="Edit SMS Template of Delivery update: the id tmpl_ with a copy button, Template name, Description, Translations with EN (default) and LT, and the Test and Actions buttons"><figcaption><p>The editor of a saved template.</p></figcaption></figure>

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-a48c573a51ec309d6ee45aa84c726b40452f3244%2Ftemplates-edit-2.png?alt=media" alt="The Actions menu of a saved template: Create Campaign, Archive, Unarchive (greyed out), Clone, See documentation, Delete"><figcaption><p>The Actions menu of a saved template.</p></figcaption></figure>

## Change or remove it later

* **Edit** — change the fields and press **Update**. Every future send that uses the template, triggers included, gets the new text. An archived template cannot be updated — unarchive it first. While the form has unsaved changes, **Test** and every action except **Delete** are off.
* **Create Campaign** — opens [Create a campaign](/codemash/cloud/sms/campaigns/new.md) with this template picked.
* **Clone** — creates a copy with the same name, translations and type.
* **Archive** / **Unarchive** — see [Archive or unarchive a template](/codemash/cloud/sms/templates/publish.md).
* **Delete** — see [Delete a template](/codemash/cloud/sms/templates/delete.md).

## Do it from code

`communicationChannel` is `Transactional`, `Marketing` or `System`; each translation is `{ language, content: { body } }`. An update sends the whole template again, with its id as `viewId`.

```ts
const { id } = await norbix.hub.notifications.createSmsTemplate({
  templateName: 'Password changed',
  communicationChannel: 'Transactional',
  translations: [
    { language: 'en', content: { body: 'Your Acme password was changed. Not you? Call +37052000000.' } },
    { language: 'lt', content: { body: 'Jūsų Acme slaptažodis pakeistas. Ne jūs? Skambinkite +37052000000.' } },
  ],
});
console.log(id); // tmpl_…

const { item } = await norbix.hub.notifications.getSmsTemplate({ id });
await norbix.hub.notifications.updateSmsTemplate({
  viewId: id,
  templateName: item.templateName,
  communicationChannel: item.communicationChannel,
  translations: item.translations.map((t) =>
    t.language === 'en' ? { ...t, content: { body: 'Your Acme password was changed. Not you? Call +37052000000 now.' } } : t),
});
```

```sh
norbix hub notifications sms template create --templateName 'Shipping delay' --communicationChannel Transactional --translations '[{"language":"en","content":{"body":"Your Acme order is delayed by one day."}},{"language":"lt","content":{"body":"Jūsų Acme užsakymas vėluoja viena diena."}}]'
```

The client setup is on the [SMS page](/codemash/cloud/sms.md#use-it-from-code). API: [Create Sms Template](/codemash/api-reference/notifications/sms/create-sms-template.md) · [Update Sms Template](/codemash/api-reference/notifications/sms/update-sms-template.md) · [Clone Sms Template](/codemash/api-reference/notifications/sms/clone-sms-template.md)
