Send a Message
Learn how create a request to the Mobile Text Alerts API that will send a message.
Messages are sent from your account’s default number. You can add dedicated numbers (10DLC, toll-free, or short code) if you need higher throughput or two-way messaging.
Ready to send your own content?
You may be restricted to sending templated message content if you’re still on a trial account and/or have an unverified phone number. Click here to learn how to get a verified number and start sending your own content.
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. WhenallSubscribersis 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. To retrieve the templates configured on your account, use the List Templates endpoint.
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.
Create message content
Write the content of the message to be sent.
Trial accounts and unverified phone numbers are restricted to only sending templated message content. Click here to learn how to get a verified number and start sending your own content.
Form API request
Create the API request to the /send endpoint. Remember to include Authorization header.
In a test_send.js file :
Requirements: Node.js 18+ (native fetch) and an MTA_API_KEY environment variable.
Use this as a standalone script to send a test, in a test_send.py file:
Requirements: pip install requests python-dotenv and an MTA_API_KEY environment variable.
Receive Response
The API will return a message about the status of your request.
See Error Response Codes to learn about possible reasons your request may fail.
Learn more
Learn how you can customize your message sends.
Last updated
Was this helpful?