Skip to contentSkip to navigationSkip to topbar
On this page

Queue Resource


The Queue resource describes a call queue that contains individual calls, which are described by the queue's Member resources. Your account can have more than one call queue. Each queue can be retrieved by its sid directly using fetch. Alternately, you can read the list of Queues and filter by friendly_name or any other property you prefer.

Call queues are created when you add a call to a queue that doesn't exist and when you create one explicitly.

For information about enqueing calls, see Queueing Calls.

(warning)

Warning

Queues persist. To optimize fetch operations, inactive Queues should be deleted.


Queue Properties

queue-properties page anchor
Property nameTypeRequiredDescriptionChild properties
date_updatedstring<date-time-rfc-2822>Optional
Not PII

current_sizeintegerOptional

The number of calls currently in the queue.

Default: 0

friendly_namestringOptional

A string that you assigned to describe this resource.


uristringOptional

The URI of this resource, relative to https://api.twilio.com.


account_sidSID<AC>Optional

The SID of the Account that created this Queue resource.

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

average_wait_timeintegerOptional

The average wait time in seconds of the members in this queue. This is calculated at the time of the request.

Default: 0

sidSID<QU>Optional

The unique string that that we created to identify this Queue resource.

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

date_createdstring<date-time-rfc-2822>Optional

The date and time in GMT that this resource was created specified in RFC 2822(link takes you to an external page) format.


max_sizeintegerOptional

The maximum number of calls that can be in the queue. The default is 1000 and the maximum is 5000.

Default: 0

POST https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Queues.json

Path parameters

path-parameters page anchor
Property nameTypeRequiredPIIDescription
AccountSidSID<AC>required

The SID of the Account that will create the resource.

Pattern: ^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34
Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
FriendlyNamestringrequired

A descriptive string that you created to describe this resource. It can be up to 64 characters long.


MaxSizeintegerOptional

The maximum number of calls allowed to be in the queue. The default is 1000. The maximum is 5000.

Create a Queue resourceLink to code sample: Create a Queue resource
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 createQueue() {
11
const queue = await client.queues.create({ friendlyName: "FriendlyName" });
12
13
console.log(queue.dateUpdated);
14
}
15
16
createQueue();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"average_wait_time": 0,
4
"current_size": 0,
5
"date_created": "Tue, 04 Aug 2015 18:39:09 +0000",
6
"date_updated": "Tue, 04 Aug 2015 18:39:09 +0000",
7
"friendly_name": "FriendlyName",
8
"max_size": 100,
9
"sid": "QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
10
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json",
11
"subresource_uris": {
12
"members": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members.json"
13
}
14
}

GET https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Queues/{Sid}.json

Property nameTypeRequiredPIIDescription
AccountSidSID<AC>required

The SID of the Account that created the Queue resource to fetch.

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

SidSID<QU>required

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

Pattern: ^QU[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 fetchQueue() {
11
const queue = await client
12
.queues("QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.fetch();
14
15
console.log(queue.dateUpdated);
16
}
17
18
fetchQueue();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"average_wait_time": 0,
4
"current_size": 0,
5
"date_created": "Tue, 04 Aug 2015 18:39:09 +0000",
6
"date_updated": "Tue, 04 Aug 2015 18:39:09 +0000",
7
"friendly_name": "0.361280134646222",
8
"max_size": 100,
9
"sid": "QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
10
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json",
11
"subresource_uris": {
12
"members": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members.json"
13
}
14
}

Read multiple Queue resources

read-multiple-queue-resources page anchor
GET https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Queues.json

Property nameTypeRequiredPIIDescription
AccountSidSID<AC>required

The SID of the Account that created the Queue resources to read.

Pattern: ^AC[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 listQueue() {
11
const queues = await client.queues.list({ limit: 20 });
12
13
queues.forEach((q) => console.log(q.dateUpdated));
14
}
15
16
listQueue();

Output

1
{
2
"end": 0,
3
"first_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues.json?PageSize=1&Page=0",
4
"next_page_uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues.json?PageSize=1&Page=1&PageToken=PAQUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
5
"page": 0,
6
"page_size": 1,
7
"previous_page_uri": null,
8
"queues": [
9
{
10
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
11
"average_wait_time": 0,
12
"current_size": 0,
13
"date_created": "Tue, 04 Aug 2015 18:39:09 +0000",
14
"date_updated": "Tue, 04 Aug 2015 18:39:09 +0000",
15
"friendly_name": "0.361280134646222",
16
"max_size": 100,
17
"sid": "QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
18
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json",
19
"subresource_uris": {
20
"members": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members.json"
21
}
22
}
23
],
24
"start": 0,
25
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues.json?PageSize=1&Page=0"
26
}

POST https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Queues/{Sid}.json

Property nameTypeRequiredPIIDescription
AccountSidSID<AC>required

The SID of the Account that created the Queue resource to update.

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

SidSID<QU>required

The Twilio-provided string that uniquely identifies the Queue resource to update

Pattern: ^QU[0-9a-fA-F]{32}$Min length: 34Max length: 34
Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
FriendlyNamestringOptional

A descriptive string that you created to describe this resource. It can be up to 64 characters long.


MaxSizeintegerOptional

The maximum number of calls allowed to be in the queue. The default is 1000. The maximum is 5000.

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 updateQueue() {
11
const queue = await client
12
.queues("QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.update({ friendlyName: "FriendlyName" });
14
15
console.log(queue.dateUpdated);
16
}
17
18
updateQueue();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"average_wait_time": 0,
4
"current_size": 0,
5
"date_created": "Tue, 04 Aug 2015 18:39:09 +0000",
6
"date_updated": "Tue, 04 Aug 2015 18:39:09 +0000",
7
"friendly_name": "FriendlyName",
8
"max_size": 100,
9
"sid": "QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
10
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json",
11
"subresource_uris": {
12
"members": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues/QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members.json"
13
}
14
}

DELETE https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Queues/{Sid}.json

Property nameTypeRequiredPIIDescription
AccountSidSID<AC>required

The SID of the Account that created the Queue resource to delete.

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

SidSID<QU>required

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

Pattern: ^QU[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 deleteQueue() {
11
await client.queues("QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").remove();
12
}
13
14
deleteQueue();

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.