# save_site_message_template

Source: https://modulify.ai/docs/api/messages/save-site-message-template

Creates a text template of the site's own, or changes the text of one, and sends it for review.

- Title: Save a text template
- Scope: `config:write`
- Access: Makes changes
- Endpoint: `POST /v1/save_site_message_template`

Leave `key` out to create a template, with a name no other template on the site has, up to 40 characters, and a site can have 20 of its own. Pass `key` to change a template that is `initial`, `rejected` or `disabled`, and a built-in one keeps its name. Write the text with each placeholder in double braces, such as `Hi {{name}}, your order {{order}} is ready at {{site}}. Reply STOP to opt out.`, and give a realistic example for each in `examples`. A text that starts or ends with a placeholder, has two placeholders side by side, or has too few words around them is refused, and a placeholder named `link` or `url` needs a full `https://` link as its example. The text can be 1,024 characters with 10 placeholders. `category` is `UTILITY`, the default, for an update about something the person did or asked for, or `MARKETING` for a promotion, which must have the word STOP in it, such as `Reply STOP to opt out.` The review refuses an update with an offer or a discount in it, so the tool tells the client to keep updates factual, name the site with `{{site}}`, write each language as its own template and use the built-in verification code for sign-in codes. Changing a template without `category` keeps its category, and a built-in template always keeps its own. Before anything goes for review, the text is checked against the review rules, and a text that would likely be rejected, or that texting cannot be used for, such as pretending to be a bank or asking for card details, is refused with the reasons and nothing is saved, so fix every reason before calling again. `submitted` false means it was saved but sending it for review failed, with the reason, and `retrying` true means that was for a reason outside the template, so it is sent for review again on its own and needs nothing more. See [Your own templates](https://modulify.ai/docs/built-in/messages#your-own-templates).

## Request

Call it with a `POST` to `https://api.modulify.ai/v1/save_site_message_template`, sending the inputs below as a JSON object. The token needs the `config:write` scope.

It makes changes, so send an [Idempotency-Key](https://modulify.ai/docs/api/idempotency) header whenever you might retry it. A retry with the same key gets the first answer back instead of running again.

```bash
curl -X POST https://api.modulify.ai/v1/save_site_message_template \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"projectId":"PROJECT_ID","text":"TEXT","examples":{}}'
```

Over MCP, the same method is the [save_site_message_template tool](https://modulify.ai/docs/mcp/messages/save-site-message-template).

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `projectId` | string | Yes | The site id. |
| `key` | string | No | The key of the template to change, from `list_site_message_templates`. Leave it out to create a new one. |
| `name` | string | No | What to call a new template, such as Pickup ready. Ignored for a built-in template. |
| `text` | string | Yes | The text with its `{{placeholders}}`. |
| `examples` | object | Yes | An example value for each placeholder, keyed by its name. |
| `category` | string | No | `UTILITY` for an update or `MARKETING` for a promotion. Left out, a new template is `UTILITY` and a changed one keeps its category. |

## Response

Every call answers with the [JSON envelope](https://modulify.ai/docs/api/requests-and-responses#the-response) of `success`, `message`, `data`, `code` and `version`. `data` holds the result described above, and on a method that returns a total, `count` carries it. The [response headers](https://modulify.ai/docs/api/requests-and-responses#headers-on-every-method-call) carry the call's `X-Request-Id` and what is left of your per-minute budget in `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`. [Errors](https://modulify.ai/docs/api/errors) explains every status code a call can answer with.