Send a Message
Learn how create a request to the Mobile Text Alerts API that will send a message.
Send a message with the Mobile Text Alerts API
Messages are sent via the API with POST
requests to the /send
endpoint. The request data must contain both recipient and content information.
Required Fields: (Must be one of the following from each)
Recipient(s):
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:
message: string
- The content of the message being sent.image: string
- The URL of an attachment for a message. By default, messages with attachments (image
) will be sent as an MMS. This URL needs to be publicly accessible; this ensures Mobile Text Alerts can access it when sending.templateId: number
- Messages can be saved as pre-set message templates for reuse with saved controlled templates on your account assigned atemplateId
.
If using a templateId
of a template that requires a link, then a linkId
is also required.
How to build a sample request to the API
Let's create a simple request to the /send
endpoint.
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],"message": "Use promo code TESTMESSAGE for 5% off when you sign up. STOP to end"}'
Used when a reference can be null
POST /v3/send HTTP/1.1
Host: api.mobile-text-alerts.com
Authorization: Bearer apiKey
Content-Type: application/json
Accept: */*
Content-Length: 1032
{
"groups": [
1
],
"subscribers": [
1
],
"subscriberIds": [
1
],
"allSubscribers": true,
"excludedGroupIds": [
1
],
"threadId": 1,
"message": "text",
"image": "text",
"rehost": true,
"externalId": "text",
"scheduledDate": "text",
"header": "text",
"footer": "text",
"properties": {
"ANY_ADDITIONAL_PROPERTY": {
"ANY_ADDITIONAL_PROPERTY": "text"
}
},
"isMMS": true,
"repeat": {
"monday": true,
"tuesday": true,
"wednesday": true,
"thursday": true,
"friday": true,
"saturday": true,
"sunday": true,
"type": "week",
"frequency": -1,
"ANY_ADDITIONAL_PROPERTY": "anything"
},
"linkClickDays": 1,
"templateId": 1,
"linkId": 1,
"longcodeId": 1,
"eventId": "text",
"skipHeaderFooter": true,
"addPlaceholder": true,
"source": "control-panel",
"userSignature": "text",
"tags": {
"ANY_ADDITIONAL_PROPERTY": "text"
},
"poolId": "text",
"userId": 1,
"senderName": "text",
"customRepeatFrequencyType": 1,
"customRepeatFrequency": 1,
"customRepeatDays": {
"monday": true,
"tuesday": true,
"wednesday": true,
"thursday": true,
"friday": true,
"saturday": true,
"sunday": true
},
"customEndMessageType": 1,
"customEndMessageDate": "text",
"customEndMessageOccurrences": 1
}
{
"statusCode": "MTANoLinkedAccountError",
"success": true,
"error": "text",
"message": "text",
"data": {
"messageId": "text",
"totalSent": 1,
"totalFailedInternationalRecipients": 1,
"outboundIds": [
1
]
}
}
Click here to learn more about how to customize your message sends.
Last updated
Was this helpful?