Message Templates
Learn how to use Message Templates when calling the Mobile Text Alerts API
Pre-set message templates allow you to create a message once and then have it on hand to send 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 in a message by sending 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
will be 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 uniquesubscriberId
.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
- Flag to indicate send message to all subscribers iftrue
. WhenallSubscribers
is set totrue
, no other recipient fields should be specified. Default value isfalse
.groups: number[]
- List of group IDs of recipients. Messages can be sent to specific groups, with each group assigned a uniquegroupId
.threadId: number
- Messages can be sent in reply to a thread, with each thread assigned a uniquethreadId
.
Content:
templateId: number
- Messages can be saved as pre-set message templates for reuse with saved controlled templates on your account assigned atemplateId
.
Other fields:
linkId: number
- if a message contains alinkId
then this field is required. Links can be created with the/shortlinks
endpoint.
Send a message template with the API
Form API request
Create the API request to the /send
endpoint. Remember to include Authorization header.
curl --location 'https://api.mobile-text-alerts.com/v3/send' \
--header 'Authorization: Bearer 89fa747a-e01b-5940-99c2-4e96fa996258' \
--data '{"subscribers": [1112223333],
"templateId": 101
}'
Using Shortlinks with Controlled Templates
When sending or scheduling a message, the /send
endpoint will compose the message body using the provided templateId
for a controlled template and, if required by the template, a provided linkId
. Links can be created with the /shortlinks
endpoint.
Templates API endpoints
View all templates
You can call GET /templates
to see all the available templates on your account:
View a specific template
To see the details on a specific template, you will need the {id}
of the template. Then call GET /templates/{id}
:
Update a specific template
To make changes to a specific template, you will need the {id}
of the template. Then call PATCH /templates/{id}
with the body containing the new template data, message
is required.
isMMS
will default to false and a SMS template will be created unless an attachment
is provided. If name
is not provided, up to the first 32 characters of the message will be used as the name.
Example request:
curl --location --request PATCH 'https://api.mobile-text-alerts.com/v3/templates/123' \
--data '{
"name": "Updated Template Name",
"message": "This is an updated template message",
"isMMS": true
}'
Delete a Template
To remove a specific template, you will need the {id}
of the template, then call DELETE /templates/{id}
Create a new template
When creating a new template, the message
field is required to hold the content of the message.
isMMS
will default to false and a SMS template will be created unless an attachment
is provided. If name
is not provided, up to the first 32 characters of the message will be used as the name.
Example request:
curl --location 'https://api.mobile-text-alerts.com/v3/templates' \
--data '{
"name": "New Template",
"message": "This is a template message",
"isMMS": true
}'
Template-Only Sending
If your account is configured for template-only message sending, please use the Controlled Template endpoints below to view available templates:
Template Examples
Last updated
Was this helpful?