Skip to contentSkip to navigationSkip to topbar
On this page

Sessions Resource



Session Properties

session-properties page anchor
Property nameTypeRequiredDescriptionChild properties
idstring

Optional

Not PII

The Session ID.


account_sidSID<AC>

Optional

The SID of the Account that created the Session resource.

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

assistant_idstring

Optional

The Assistant ID.

Pattern: ^aia_asst_*$

verifiedboolean

Optional

True if the session is verified.


identitystring

Optional

The unique identity of user for the session.


date_updatedstring<date-time>

Optional

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


GET https://assistants.twilio.com/v1/Sessions/{id}

Path parameters

path-parameters page anchor
Property nameTypeRequiredPIIDescription
idstringrequired
Get a SessionLink to code sample: Get a Session
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 fetchSession() {
11
const session = await client.assistants.v1
12
.sessions("your-session-id")
13
.fetch();
14
15
console.log(session.id);
16
}
17
18
fetchSession();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"assistant_id": "aia_asst",
4
"date_created": "2009-07-06T20:30:00Z",
5
"date_updated": "2009-07-06T20:30:00Z",
6
"id": "your-session-id",
7
"identity": "identity",
8
"verified": false
9
}

GET https://assistants.twilio.com/v1/Sessions

Property nameTypeRequiredPIIDescription
Pageinteger

Optional

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

Minimum: 0

PageSizeinteger

Optional

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

Minimum: 1Maximum: 1000

PageTokenstring

Optional

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 listSessions() {
11
const sessions = await client.assistants.v1.sessions.list({ limit: 20 });
12
13
sessions.forEach((s) => console.log(s.id));
14
}
15
16
listSessions();

Output

1
{
2
"meta": {
3
"first_page_url": "https://www.example.com",
4
"key": "key",
5
"next_page_url": "https://www.example.com",
6
"page": 42,
7
"page_size": 42,
8
"previous_page_url": "https://www.example.com",
9
"url": "https://www.example.com"
10
},
11
"sessions": [
12
{
13
"id": "id",
14
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
15
"assistant_id": "aia_asst",
16
"verified": false,
17
"identity": "identity",
18
"date_created": "2009-07-06T20:30:00Z",
19
"date_updated": "2009-07-06T20:30:00Z"
20
}
21
]
22
}

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.