Skip to contentSkip to navigationSkip to topbar
On this page

Sending Messages


(error)

Proxy Public Beta is not available to new customers

Proxy Public Beta is currently closed for new customers. Please consider using Twilio Conversations and Programmable Voice directly if you are building your masking application.

Note that this does not have any impact on Twilio Flex customers.

(warning)

Public Beta for customers already using Proxy

Twilio's Proxy API is currently available as a Public Beta product. Some features are not yet implemented and others may be changed before the product is declared as Generally Available.

Public Beta products are not covered by a Twilio SLA(link takes you to an external page).

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
Property nameTypeRequiredDescriptionChild properties
sidSID<KI>Optional
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>Optional

The SID of the parent Session resource.

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

service_sidSID<KS>Optional

The SID of the parent Service resource.

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

account_sidSID<AC>Optional

The SID of the Account that created the MessageInteraction resource.

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

datastringOptional
PII MTL: 30 days

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


typeenum<string>Optional

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

Possible values:
messagevoiceunknown

participant_sidSID<KP>Optional

The SID of the Participant resource.

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

inbound_participant_sidSID<KP>Optional

Always empty for created Message Interactions.

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

inbound_resource_sidSIDOptional

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>Optional

Always empty for created Message Interactions.

Possible values:
acceptedansweredbusycanceledcompleteddeleteddelivereddelivery-unknownfailedin-progress

inbound_resource_typestringOptional

Always empty for created Message Interactions.


inbound_resource_urlstring<uri>Optional

Always empty for created Message Interactions.


outbound_participant_sidSID<KP>Optional

The SID of the outbound Participant resource.

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

outbound_resource_sidSIDOptional

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>Optional

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_typestringOptional

The outbound resource type. This value is always Message.


outbound_resource_urlstring<uri>Optional

The URL of the Twilio message resource.


date_createdstring<date-time>Optional

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


date_updatedstring<date-time>Optional

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


urlstring<uri>Optional

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

Path parameters

path-parameters page anchor
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
Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
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 MessageInteractionLink to code sample: Create a MessageInteraction
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function createMessageInteraction() {
11
const messageInteraction = await client.proxy.v1
12
.services("KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.sessions("KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
14
.participants("KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
15
.messageInteractions.create({
16
body: "This will be the body of the new message!",
17
});
18
19
console.log(messageInteraction.sid);
20
}
21
22
createMessageInteraction();

Output

1
{
2
"service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"data": "{\"body\":\"some message\"}",
4
"date_created": "2015-07-30T20:00:00Z",
5
"date_updated": "2015-07-30T20:00:00Z",
6
"participant_sid": "KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
7
"inbound_participant_sid": null,
8
"inbound_resource_sid": null,
9
"inbound_resource_status": null,
10
"inbound_resource_type": null,
11
"inbound_resource_url": null,
12
"outbound_participant_sid": "KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
13
"outbound_resource_sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"outbound_resource_status": "sent",
15
"outbound_resource_type": "Message",
16
"outbound_resource_url": null,
17
"sid": "KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
18
"type": "message",
19
"url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants/KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/MessageInteractions/KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
20
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
21
"session_sid": "KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
22
}

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.