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

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

The unique string that we created to identify the Interaction 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 Interaction resource.


datatype: stringPII 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"}).


typetype: enum<STRING>Not PII

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

Possible values:
messagevoiceunknown

inbound_participant_sidtype: SID<KP>Not PII

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


inbound_resource_sidtype: SIDNot PII

inbound_resource_statustype: enum<STRING>Not PII

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


inbound_resource_typetype: stringNot PII

inbound_resource_urltype: string<URI>Not PII

The URL of the Twilio inbound resource


outbound_participant_sidtype: SID<KP>Not PII

outbound_resource_sidtype: SIDNot PII

outbound_resource_statustype: enum<STRING>Not PII

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.


outbound_resource_typetype: stringNot PII

outbound_resource_urltype: string<URI>Not PII

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

Parameters

fetch-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) of the resource to fetch.


SessionSidtype: SID<KC>Not PII
Path Parameter

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


Sidtype: SID<KI>Not PII
Path Parameter

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

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

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

Output

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


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.

URI parameters
ServiceSidtype: SID<KS>Not PII
Path Parameter

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


SessionSidtype: SID<KC>Not PII
Path Parameter

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


PageSizetype: integerNot PII
Query Parameter

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


Pagetype: integerNot PII
Query Parameter

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


PageTokentype: stringNot PII
Query Parameter

The page token. This is provided by the API.

List multiple Interactions

list-multiple-interactions page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

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

Output

_12
{
_12
"interactions": [],
_12
"meta": {
_12
"previous_page_url": "https://proxy.twilio.com/v1/Services/KSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Sessions/KCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Interactions?PageSize=50&Page=0",
_12
"next_page_url": "https://proxy.twilio.com/v1/Services/KSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Sessions/KCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Interactions?PageSize=50&Page=1",
_12
"url": "https://proxy.twilio.com/v1/Services/KSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Sessions/KCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Interactions?PageSize=50&Page=0",
_12
"page": 0,
_12
"first_page_url": "https://proxy.twilio.com/v1/Services/KSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Sessions/KCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Interactions?PageSize=50&Page=0",
_12
"page_size": 50,
_12
"key": "interactions"
_12
}
_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.

URI parameters
ServiceSidtype: SID<KS>Not PII
Path Parameter

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


SessionSidtype: SID<KC>Not PII
Path Parameter

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


Sidtype: SID<KI>Not PII
Path Parameter

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

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

_11
// Download the helper library from https://www.twilio.com/docs/node/install
_11
// Find your Account SID and Auth Token at twilio.com/console
_11
// and set the environment variables. See http://twil.io/secure
_11
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11
const authToken = process.env.TWILIO_AUTH_TOKEN;
_11
const client = require('twilio')(accountSid, authToken);
_11
_11
client.proxy.v1.services('KSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.sessions('KCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.interactions('KIXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11
.remove();


Rate this page: