Skip to contentSkip to navigationSkip to topbar
On this page

Interaction


(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).

Interactions are read-only communications logs of a given Session. Each Interaction represents a single communication.

Interactions are composed of an inbound (to Twilio) and an outbound (from Twilio) leg. Interactions can have both inbound and outbound legs or be "one-sided" (like when creating a Message Interaction resource).

If a user sends an SMS to a proxy number, and Twilio Proxy handles the proxying to the other Participant, you'll have an Interaction with both an inbound SMS and an outbound SMS.


Interaction Properties

interaction-properties page anchor
Property nameTypeRequiredDescriptionChild properties
sidSID<KI>Optional
Not PII

The unique string that we created to identify the Interaction 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 Interaction 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 of message interactions (e.g. {"body": "hello"}) or the call duration (when available) of a call (e.g. {"duration": "5"}).


typeenum<string>Optional

The Type of the Interaction. Can be: message, voice or unknown.

Possible values:
messagevoiceunknown

inbound_participant_sidSID<KP>Optional

The SID of the inbound Participant resource.

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

inbound_resource_sidSIDOptional

The SID of the inbound resource; either the Call or Message.

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

inbound_resource_statusenum<string>Optional

The inbound resource status of the Interaction. Will always be delivered for messages and in-progress for calls.

Possible values:
acceptedansweredbusycanceledcompleteddeleteddelivereddelivery-unknownfailedin-progress

inbound_resource_typestringOptional

The inbound resource type. Can be Call or Message.


inbound_resource_urlstring<uri>Optional

The URL of the Twilio inbound resource


outbound_participant_sidSID<KP>Optional

The SID of the outbound Participant).

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

outbound_resource_sidSIDOptional

The SID of the outbound resource; either the Call or Message.

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

outbound_resource_statusenum<string>Optional

The outbound resource status of the Interaction. Can be: accepted, canceled, deleted, delivered, delivery-unknown, failed, partially-delivered, queued, read, received, receiving, scheduled, sending, sent, undelivered, or unknown for messages. Can be initiated or completed or unknown for calls.

Possible values:
acceptedansweredbusycanceledcompleteddeleteddelivereddelivery-unknownfailedin-progress

outbound_resource_typestringOptional

The outbound resource type. Can be: Call or Message.


outbound_resource_urlstring<uri>Optional

The URL of the Twilio outbound resource.


date_createdstring<date-time>Optional

The ISO 8601(link takes you to an external page) date and time in GMT when the Interaction 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 Interaction resource.


Create an Interaction resource

create-an-interaction-resource page anchor

You cannot POST to the Interactions resource. Instead, you can generate Interactions via the appropriate Participant's MessageInteraction resource. For details, see Sending Messages. Otherwise, Interactions are created automatically when Participants text or call each other.


Fetch an Interaction resource

fetch-an-interaction-resource page anchor
GET https://proxy.twilio.com/v1/Services/{ServiceSid}/Sessions/{SessionSid}/Interactions/{Sid}

Path parameters

path-parameters page anchor
Property nameTypeRequiredPIIDescription
ServiceSidSID<KS>required

The SID of the parent Service of the resource to fetch.

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

SessionSidSID<KC>required

The SID of the parent Session of the resource to fetch.

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

SidSID<KI>required

The Twilio-provided string that uniquely identifies the Interaction resource to fetch.

Pattern: ^KI[0-9a-fA-F]{32}$Min length: 34Max length: 34
Fetch an InteractionLink to code sample: Fetch an Interaction
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 fetchInteraction() {
11
const interaction = await client.proxy.v1
12
.services("KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.sessions("KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
14
.interactions("KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
15
.fetch();
16
17
console.log(interaction.sid);
18
}
19
20
fetchInteraction();

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
"inbound_participant_sid": "KPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
7
"inbound_resource_sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
8
"inbound_resource_status": "sent",
9
"inbound_resource_type": "Message",
10
"inbound_resource_url": null,
11
"outbound_participant_sid": "KPbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
12
"outbound_resource_sid": "SMbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
13
"outbound_resource_status": "sent",
14
"outbound_resource_type": "Message",
15
"outbound_resource_url": null,
16
"sid": "KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
17
"type": "message",
18
"url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Interactions/KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
19
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
20
"session_sid": "KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
21
}

Read multiple Interaction resources

read-multiple-interaction-resources page anchor
GET https://proxy.twilio.com/v1/Services/{ServiceSid}/Sessions/{SessionSid}/Interactions

Retrieve a list of Interactions for a given Session.

Property nameTypeRequiredPIIDescription
ServiceSidSID<KS>required

The SID of the parent Service to read the resources from.

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

SessionSidSID<KC>required

The SID of the parent Session to read the resources from.

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

How many resources to return in each list page. The default is 50, and the maximum is 1000.

Minimum: 1Maximum: 1000

PageintegerOptional

The page index. This value is simply for client state.

Minimum: 0

PageTokenstringOptional

The page token. This is provided by the API.

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 listInteraction() {
11
const interactions = await client.proxy.v1
12
.services("KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.sessions("KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
14
.interactions.list({ limit: 20 });
15
16
interactions.forEach((i) => console.log(i.sid));
17
}
18
19
listInteraction();

Output

1
{
2
"interactions": [],
3
"meta": {
4
"previous_page_url": null,
5
"next_page_url": null,
6
"url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Interactions?PageSize=50&Page=0",
7
"page": 0,
8
"first_page_url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Interactions?PageSize=50&Page=0",
9
"page_size": 50,
10
"key": "interactions"
11
}
12
}

Delete an Interaction resource

delete-an-interaction-resource page anchor
DELETE https://proxy.twilio.com/v1/Services/{ServiceSid}/Sessions/{SessionSid}/Interactions/{Sid}

Deleting an Interaction removes it permanently.

(error)

Danger

Any Message or Call records created during this interaction will NOT be deleted automatically. If you want to delete all related Message/Call resources, you must issue direct DELETE requests for the inbound and outbound resources directly. Once you have deleted an interaction, those resource SIDs will not be discoverable via Proxy.

Property nameTypeRequiredPIIDescription
ServiceSidSID<KS>required

The SID of the parent Service of the resource to delete.

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

SessionSidSID<KC>required

The SID of the parent Session of the resource to delete.

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

SidSID<KI>required

The Twilio-provided string that uniquely identifies the Interaction resource to delete.

Pattern: ^KI[0-9a-fA-F]{32}$Min length: 34Max length: 34
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 deleteInteraction() {
11
await client.proxy.v1
12
.services("KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.sessions("KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
14
.interactions("KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
15
.remove();
16
}
17
18
deleteInteraction();

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.