For the complete documentation index, see llms.txt. This page is also available as Markdown.

Message Templates

Learn how to use Message Templates when calling the Mobile Text Alerts API

Saved message templates allow you to create a message once and then send it at any time. You can create and send message templates in the platform, mobile app, and the API.

Use a template to send a message with the API

Templates can be sent by making a POST request to the /send endpoint. All requests to this endpoint must contain both recipient and content information. When using a message template, the templateId is used as the content.

Required request fields:

  • Choose recipient(s): (Must be one of the following.)

    • subscriberIds: number[] - List of subscriber IDs of recipients. Messages can be sent to specific subscribers, with each subscriber assigned a unique subscriberId.

    • subscribers: (number | string)[] - List of recipient phone numbers or email addresses. A new subscriber will be created for new recipients that are not already subscribers on your account.

    • allSubscribers: boolean - Indicates whether to send a message to all subscribers. When allSubscribers is set to true, no other recipient fields should be specified. The default value is false.

    • groups: number[] - List of group IDs of recipients. Messages can be sent to specific groups, with each group assigned a unique groupId.

    • threadId: number - Messages can be sent in reply to a thread, with each thread assigned a unique threadId.

  • Content:

    • templateId: number - The ID of a saved template on your account.

  • Other fields:

    • linkId: number - Include this field when the template requires a shortlink. Links can be created with the /links/shortlinks endpoint.

Send a message template with the API

1

Indicate the recipient(s)

You can send a message to a phone number as a test. Set the subscribers field to the recipient's phone number.

"subscribers": ["+13175551111"]
2

Indicate the template to send

Use the templateId field to indicate which template will be used.

"templateId": 101
3

Form API request

Create the API request to the /send endpoint. Remember to include the Authorization header.

curl --location 'https://api.mobile-text-alerts.com/v3/send' \
  --header 'Authorization: Bearer <APIKey>' \
  --header 'Content-Type: application/json' \
  --data '{"subscribers": ["+13175551111"],
        "templateId": 101 }'
4

Receive response

The API will return a message about the status of your request.

{
  "data": {
    "messageId": "uuid",
    "totalSent": 1,
    "totalFailedInternationalRecipients": 0
  }
}

POST /send

When sending or scheduling a message, the /send endpoint composes the message body using the provided templateId for a controlled template. If required, it also uses the provided linkId. Links can be created with the /links/shortlinks endpoint:

Create Link /links/shortlinks

Include personalization in a template

Mobile Text Alerts supports Liquid templates for message personalization. A template can include custom variables such as {{firstName}}, which are replaced using per-recipient properties. This requires a properties object that maps each phone number to its corresponding data.

See Properties field for custom variables in messages to learn more.

Templates API endpoints

View all templates

You can call GET /templates to see all the available templates on your account:

List Templates GET /templates

View a specific template

To see the details of a specific template, you need the template's {id}. Then call GET /templates/{id}:

Get Template GET /templates/{id}

Update a specific template

To make changes to a specific template, you need the template's {id}. Then call PATCH /templates/{id} with a body containing the new template data. The message field is required.

Example request:

Update Template PATCH /templates/{id}

Delete a template

To remove a specific template, you need the template's {id}. Then call POST /templates/{id}.

Delete Template POST /templates/{id}

Create a new template

When creating a new template, the message field is required to hold the content of the message.

Example request:

Create Templates POST /templates

Template-Only Sending

If your account is configured for template-only message sending, please use the Controlled Template endpoints to view available templates:

Template Examples

Last updated

Was this helpful?