latestSwagger 2.02026-08-101561322.2 MB

3e4029d19684

Outbound Messages

Send message

<a class="try-sandbox-link" href="https://sandbox.textmagic.com/#/Messages%3A%20Send%0A/sendMessage" target="_blank">Try in sandbox</a><br>This is the main entrypoint to send messages. See the examples above for the reference.

post/api/v2/messages

Request body

textstring required

Message text. Required if the template_id is not set.

templateIdinteger

Template used instead of message text. Required if the text is not set.

sendingTimeinteger

DEPRECATED, consider using sendingDateTime and sendingTimezone parameters instead: Optional (required with rrule set). Message sending time in unix timestamp format. Default is now.

sendingDateTimestring

Sending time in Y-m-d H:i:s format (e.g. 2022-05-27 13:05:10). This time is relative to sendingTimezone. Note: for correct operation, the value of seconds must not be less than 10.

sendingTimezonestring

ID or ISO-name of timezone used for sending when sendingDateTime parameter is set. E.g. if you specify sendingDateTime = "2016-05-27 13:02:33" and sendingTimezone = "America/Buenos_Aires", your message will be sent at May 27, 2016 13:02:33 Buenos Aires time, or 16:02:33 UTC. Default is account timezone.

contactsstring

Comma separated array of contact resources id message will be sent to.

listsstring

Comma separated array of list resources id message will be sent to.

phonesstring required

Comma separated array of E.164 phone numbers message will be sent to.

cutExtraboolean

Should sending method cut extra characters which not fit supplied partsCount or return 400 Bad request response instead.

partsCountinteger

Maximum message parts count (Textmagic allows sending 1 to 6 message parts).

referenceIdinteger

Custom message reference id which can be used in your application infrastructure.

fromstring

One of allowed Sender ID (phone number or alphanumeric sender ID). If specified Sender ID is not allowed for some destinations, a fallback default Sender ID will be used to ensure delivery. See Get timezones.

rrulestring

iCal RRULE parameter to create recurrent scheduled messages. When used, sendingTime is mandatory as start point of sending. See https://www.textmagic.com/free-tools/rrule-generator for format details.

createChatboolean

Should sending method try to create new Chat (if not exist) with specified recipients?

ttsboolean

Send a Text-to-Speech message.

localboolean

Treat phone numbers passed in the 'phones' field as local.

localCountrystring

The 2-letter ISO country code for local phone numbers, used when 'local' is set to true. Default is the account country.

destinationstring

Messsage destination type allowed [mms, tts].

resourcesstring

File name from mms attachment response (named as resource)

Example request

{
  "text": "Hello, how are you?",
  "templateId": 1,
  "sendingTime": 1565606455,
  "sendingDateTime": "2020-05-27 13:02:33",
  "sendingTimezone": "America/Buenos_Aires",
  "contacts": "1,2,3,4",
  "lists": "1,2,3,4",
  "phones": "447860021130,447860021131",
  "cutExtra": true,
  "partsCount": 6,
  "referenceId": 1,
  "from": "Test sender id",
  "rrule": "FREQ=YEARLY;BYMONTH=1;BYMONTHDAY=1;COUNT=1",
  "localCountry": "US",
  "destination": "mms",
  "resources": "tmauKcSmwflB77kLQ15904023426649.jpg"
}

Response

Returned when successful.

idinteger required

Message ID.

hrefstring required

URI of the message session.

type'message' | 'session' | 'schedule' | 'bulk' required

Message response type:

  • message – when the message is sent to a single recipient.
  • session – when the message is sent is to multiple recipients.
  • schedule - when the message is scheduled for sending.
  • bulk - when the message is sent to multiple recipients and the number of recipients requires asynchronous processing See Sending more than 1,000 messages in one session.
sessionIdinteger nullable required

Message session ID.

bulkIdinteger nullable required
messageIdinteger nullable required

Message ID.

scheduleIdinteger nullable required

Message Schedule ID.

chatIdinteger nullable required

Message Chat ID.

Example response

{
  "id": 10489,
  "href": "/api/v2/sessions/10489",
  "type": "session",
  "sessionId": 10489
}