Skip to contentSkip to navigationSkip to topbar
Rate this Page:

Sending Messages


We can send text messages through the Proxy API by creating a Message Interaction on a Participant. The referenced Participant will receive the message from their allocated proxy number on the appropriate channel.

Note: Only POST (create) is available on Message Interactions. To query past messages you've created with this resource, query the Interaction resource.


MessageInteraction Properties

messageinteraction-properties page anchor
Resource properties
sidtype: SID<KI>Not PII

The unique string that we created to identify the MessageInteraction resource.


service_sidtype: SID<KS>Not PII

The SID of the parent Service(link takes you to an external page) resource.


account_sidtype: SID<AC>Not PII

The SID of the Account(link takes you to an external page) that created the MessageInteraction resource.


datatype: stringPII MTL: 30 days

A JSON string that includes the message body sent to the participant. (e.g. {"body": "hello"})


typetype: enum<STRING>Not PII

The Type of Message Interaction. This value is always message.

Possible values:
messagevoiceunknown

participant_sidtype: SID<KP>Not PII

inbound_participant_sidtype: SID<KP>Not PII

Always empty for created Message Interactions.


inbound_resource_sidtype: SIDNot PII

Always empty for created Message Interactions.


inbound_resource_statustype: enum<STRING>Not PII

Always empty for created Message Interactions.


inbound_resource_typetype: stringNot PII

Always empty for created Message Interactions.


inbound_resource_urltype: string<URI>Not PII

Always empty for created Message Interactions.


outbound_participant_sidtype: SID<KP>Not PII

The SID of the outbound Participant(link takes you to an external page) resource.


outbound_resource_sidtype: SIDNot PII

The SID of the outbound Message(link takes you to an external page) resource.


outbound_resource_statustype: enum<STRING>Not PII

The outbound message resource status. Can be: accepted, deleted, delivered, delivery-unknown, failed, queued, received, receiving, scheduled, sending, sent, undelivered, or unknown.


outbound_resource_typetype: stringNot PII

The outbound resource type. This value is always Message.


outbound_resource_urltype: string<URI>Not PII

The URL of the Twilio message resource.


date_createdtype: string<DATE TIME>Not PII

The ISO 8601(link takes you to an external page) date and time in GMT when the resource was created.


date_updatedtype: string<DATE TIME>Not PII

The ISO 8601(link takes you to an external page) date and time in GMT when the resource was last updated.


urltype: string<URI>Not PII

The absolute URL of the MessageInteraction resource.


Create a MessageInteraction resource

create-a-messageinteraction-resource page anchor
POST https://proxy.twilio.com/v1/Services/{ServiceSid}/Sessions/{SessionSid}/Participants/{ParticipantSid}/MessageInteractions

Parameters

create-parameters page anchor
URI parameters
ServiceSidtype: SID<KS>Not PII
Path Parameter

The SID of the parent Service(link takes you to an external page) resource.


SessionSidtype: SID<KC>Not PII
Path Parameter

The SID of the parent Session(link takes you to an external page) resource.


ParticipantSidtype: SID<KP>Not PII
Path Parameter

Request body parameters
Bodytype: stringNot PII
Required if MediaUrl is not passed

The message to send to the participant


MediaUrltype: string[]Not PII
Required if Body is not passed

Reserved. Not currently supported.

Create a MessageInteraction

create-a-messageinteraction page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_13
// Download the helper library from https://www.twilio.com/docs/node/install
_13
// Find your Account SID and Auth Token at twilio.com/console
_13
// and set the environment variables. See http://twil.io/secure
_13
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_13
const authToken = process.env.TWILIO_AUTH_TOKEN;
_13
const client = require('twilio')(accountSid, authToken);
_13
_13
client.proxy.v1.services('KSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_13
.sessions('KCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_13
.participants('KPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_13
.messageInteractions
_13
.create({body: 'body'})
_13
.then(message_interaction => console.log(message_interaction.sid));

Output

_24
{
_24
"service_sid": "KSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_24
"data": {
_24
"body": "some message"
_24
},
_24
"date_created": "2015-07-30T20:00:00Z",
_24
"date_updated": "2015-07-30T20:00:00Z",
_24
"participant_sid": "KPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_24
"inbound_participant_sid": null,
_24
"inbound_resource_sid": null,
_24
"inbound_resource_status": null,
_24
"inbound_resource_type": null,
_24
"inbound_resource_url": null,
_24
"outbound_participant_sid": "KPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_24
"outbound_resource_sid": "SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_24
"outbound_resource_status": "sent",
_24
"outbound_resource_type": "Message",
_24
"outbound_resource_url": null,
_24
"sid": "KIXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_24
"type": "message",
_24
"url": "https://proxy.twilio.com/v1/Services/KSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Sessions/KCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Participants/KPXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/MessageInteractions/KIXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_24
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_24
"session_sid": "KCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_24
}


Rate this Page: