Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Interaction


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

Property nameTypePIIDescription
sidSID<KI>
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>

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 Interaction 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 of message interactions (e.g. {"body": "hello"}) or the call duration (when available) of a call (e.g. {"duration": "5"}).


typeenum<string>

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

Possible values:
messagevoiceunknown

inbound_participant_sidSID<KP>

The SID of the inbound Participant resource.

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

inbound_resource_sidSID

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>

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_typestring

The inbound resource type. Can be Call or Message.


inbound_resource_urlstring<uri>

The URL of the Twilio inbound resource


outbound_participant_sidSID<KP>

The SID of the outbound Participant).

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

outbound_resource_sidSID

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>

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_typestring

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


outbound_resource_urlstring<uri>

The URL of the Twilio outbound 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 Interaction resource.


Create an Interaction resource

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

GET https://proxy.twilio.com/v1/Services/{ServiceSid}/Sessions/{SessionSid}/Interactions/{Sid}

Path parameters

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 Interaction

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

_20
// Download the helper library from https://www.twilio.com/docs/node/install
_20
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_20
_20
// Find your Account SID and Auth Token at twilio.com/console
_20
// and set the environment variables. See http://twil.io/secure
_20
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_20
const authToken = process.env.TWILIO_AUTH_TOKEN;
_20
const client = twilio(accountSid, authToken);
_20
_20
async function fetchInteraction() {
_20
const interaction = await client.proxy.v1
_20
.services("KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_20
.sessions("KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_20
.interactions("KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_20
.fetch();
_20
_20
console.log(interaction.sid);
_20
}
_20
_20
fetchInteraction();

Output

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


Read multiple Interaction resources

GET https://proxy.twilio.com/v1/Services/{ServiceSid}/Sessions/{SessionSid}/Interactions

Retrieve a list of Interactions for a given Session.

Path parameters

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

Query parameters

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.

List multiple Interactions

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

_19
// Download the helper library from https://www.twilio.com/docs/node/install
_19
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_19
_19
// Find your Account SID and Auth Token at twilio.com/console
_19
// and set the environment variables. See http://twil.io/secure
_19
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19
const authToken = process.env.TWILIO_AUTH_TOKEN;
_19
const client = twilio(accountSid, authToken);
_19
_19
async function listInteraction() {
_19
const interactions = await client.proxy.v1
_19
.services("KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19
.sessions("KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19
.interactions.list({ limit: 20 });
_19
_19
interactions.forEach((i) => console.log(i.sid));
_19
}
_19
_19
listInteraction();

Output

_12
{
_12
"interactions": [],
_12
"meta": {
_12
"previous_page_url": null,
_12
"next_page_url": null,
_12
"url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Interactions?PageSize=50&Page=0",
_12
"page": 0,
_12
"first_page_url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Sessions/KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Interactions?PageSize=50&Page=0",
_12
"page_size": 50,
_12
"key": "interactions"
_12
}
_12
}


Delete an Interaction resource

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.

Path parameters

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

Delete an Interaction

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

_18
// Download the helper library from https://www.twilio.com/docs/node/install
_18
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18
_18
// Find your Account SID and Auth Token at twilio.com/console
_18
// and set the environment variables. See http://twil.io/secure
_18
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18
const authToken = process.env.TWILIO_AUTH_TOKEN;
_18
const client = twilio(accountSid, authToken);
_18
_18
async function deleteInteraction() {
_18
await client.proxy.v1
_18
.services("KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18
.sessions("KCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18
.interactions("KIaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18
.remove();
_18
}
_18
_18
deleteInteraction();


Rate this page: