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

service_sidSID<KS>

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

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

account_sidSID<AC>

The SID of the Account(link takes you to an external page) 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(link takes you to an external page) 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(link takes you to an external page) or Message(link takes you to an external page).

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

inbound_resource_urlstring<uri>

The URL of the Twilio inbound resource


outbound_participant_sidSID<KP>

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

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

outbound_resource_sidSID

The SID of the outbound resource; either the Call(link takes you to an external page) or Message(link takes you to an external page).

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

outbound_resource_urlstring<uri>

The URL of the Twilio outbound resource.


date_createdstring<date-time>

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


date_updatedstring<date-time>

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


urlstring<uri>

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
ServiceSidSID<KS>required

The SID of the parent Service(link takes you to an external page) 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(link takes you to an external page) 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

fetch-an-interaction 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('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.

ServiceSidSID<KS>required

The SID of the parent Service(link takes you to an external page) 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(link takes you to an external page) to read the resources from.

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

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

Minimum: 1Maximum: 1000

Pageinteger

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

Minimum: 0

PageTokenstring

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.

ServiceSidSID<KS>required

The SID of the parent Service(link takes you to an external page) 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(link takes you to an external page) 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
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: