Skip to contentSkip to navigationSkip to topbar
Rate this page:
On 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

Property nameTypePIIDescription
sidSID<KI>
Not PII

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

Pattern: ^KI[0-9a-fA-F]{32}$Min length: 34Max length: 34

session_sidSID<KC>

The SID of the parent Session resource.

Pattern: ^KC[0-9a-fA-F]{32}$Min length: 34Max length: 34

service_sidSID<KS>

The SID of the parent Service resource.

Pattern: ^KS[0-9a-fA-F]{32}$Min length: 34Max length: 34

account_sidSID<AC>

The SID of the Account that created the MessageInteraction resource.

Pattern: ^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34

datastring
PII MTL: 30 days

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


typeenum<string>

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

Possible values:
messagevoiceunknown

participant_sidSID<KP>

The SID of the Participant resource.

Pattern: ^KP[0-9a-fA-F]{32}$Min length: 34Max length: 34

inbound_participant_sidSID<KP>

Always empty for created Message Interactions.

Pattern: ^KP[0-9a-fA-F]{32}$Min length: 34Max length: 34

inbound_resource_sidSID

Always empty for created Message Interactions.

Pattern: ^[a-zA-Z]{2}[0-9a-fA-F]{32}$Min length: 34Max length: 34

inbound_resource_statusenum<string>

Always empty for created Message Interactions.

Possible values:
acceptedansweredbusycanceledcompleteddeleteddelivereddelivery-unknownfailedin-progress

inbound_resource_typestring

Always empty for created Message Interactions.


inbound_resource_urlstring<uri>

Always empty for created Message Interactions.


outbound_participant_sidSID<KP>

The SID of the outbound Participant resource.

Pattern: ^KP[0-9a-fA-F]{32}$Min length: 34Max length: 34

outbound_resource_sidSID

The SID of the outbound Message resource.

Pattern: ^[a-zA-Z]{2}[0-9a-fA-F]{32}$Min length: 34Max length: 34

outbound_resource_statusenum<string>

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

Possible values:
acceptedansweredbusycanceledcompleteddeleteddelivereddelivery-unknownfailedin-progress

outbound_resource_typestring

The outbound resource type. This value is always Message.


outbound_resource_urlstring<uri>

The URL of the Twilio message resource.


date_updatedstring<date-time>

The ISO 8601 date and time in GMT when the resource was last updated.


urlstring<uri>

The absolute URL of the MessageInteraction resource.


Create a MessageInteraction resource

POST https://proxy.twilio.com/v1/Services/{ServiceSid}/Sessions/{SessionSid}/Participants/{ParticipantSid}/MessageInteractions

Path parameters

Property nameTypeRequiredPIIDescription
ServiceSidSID<KS>required

The SID of the parent Service resource.

Pattern: ^KS[0-9a-fA-F]{32}$Min length: 34Max length: 34

SessionSidSID<KC>required

The SID of the parent Session resource.

Pattern: ^KC[0-9a-fA-F]{32}$Min length: 34Max length: 34

ParticipantSidSID<KP>required

The SID of the Participant resource.

Pattern: ^KP[0-9a-fA-F]{32}$Min length: 34Max length: 34

Request body parameters

Property nameTypeRequiredPIIDescription
Bodystringrequired if MediaUrl is not passed

The message to send to the participant


MediaUrlarray[string<uri>]required if Body is not passed

Reserved. Not currently supported.

Create a MessageInteraction

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_22
// Download the helper library from https://www.twilio.com/docs/node/install
_22
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_22
_22
// Find your Account SID and Auth Token at twilio.com/console
_22
// and set the environment variables. See http://twil.io/secure
_22
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_22
const authToken = process.env.TWILIO_AUTH_TOKEN;
_22
const client = twilio(accountSid, authToken);
_22
_22
async function createMessageInteraction() {
_22
const messageInteraction = await client.proxy.v1
_22
.services("KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_22
.sessions("KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_22
.participants("KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_22
.messageInteractions.create({
_22
body: "This will be the body of the new message!",
_22
});
_22
_22
console.log(messageInteraction.sid);
_22
}
_22
_22
createMessageInteraction();

Output

_22
{
_22
"service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_22
"data": "{\"body\":\"some message\"}",
_22
"date_created": "2015-07-30T20:00:00Z",
_22
"date_updated": "2015-07-30T20:00:00Z",
_22
"participant_sid": "KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_22
"inbound_participant_sid": null,
_22
"inbound_resource_sid": null,
_22
"inbound_resource_status": null,
_22
"inbound_resource_type": null,
_22
"inbound_resource_url": null,
_22
"outbound_participant_sid": "KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_22
"outbound_resource_sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_22
"outbound_resource_status": "sent",
_22
"outbound_resource_type": "Message",
_22
"outbound_resource_url": null,
_22
"sid": "KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_22
"type": "message",
_22
"url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/MessageInteractions/KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_22
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_22
"session_sid": "KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
_22
}


Rate this page: