Queues resource
On this reference page, you'll learn the properties, methods, and parameters for the Queues resource. See Related how-to documentation to learn the steps to use the info on this page.
A Queue resource describes a call queue that contains individual calls, which are described by the queue's Members subsresource. 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 enqueuing calls, see Queueing Calls.
Warning
Queues persist. To optimize fetch operations, inactive Queues should be deleted.
POST https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Queues.json
application/x-www-form-urlencodedA descriptive string that you created to describe this resource. It can be up to 64 characters long.
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/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID at twilio.com/console5// Provision API Keys at twilio.com/console/runtime/api-keys6// and set the environment variables. See http://twil.io/secure7// For local testing, you can use your Account SID and Auth token8const accountSid = process.env.TWILIO_ACCOUNT_SID;9const apiKey = process.env.TWILIO_API_KEY;10const apiSecret = process.env.TWILIO_API_SECRET;11const client = twilio(apiKey, apiSecret, { accountSid: accountSid });1213async function createQueue() {14const queue = await client.queues.create({ friendlyName: "FriendlyName" });1516console.log(queue.dateUpdated);17}1819createQueue();
Response
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}
GET https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Queues/{Sid}.json
The SID of the Account that created the Queue resource to fetch.
^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34The Twilio-provided string that uniquely identifies the Queue resource to fetch
^QU[0-9a-fA-F]{32}$Min length: 34Max length: 341// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID at twilio.com/console5// Provision API Keys at twilio.com/console/runtime/api-keys6// and set the environment variables. See http://twil.io/secure7// For local testing, you can use your Account SID and Auth token8const accountSid = process.env.TWILIO_ACCOUNT_SID;9const apiKey = process.env.TWILIO_API_KEY;10const apiSecret = process.env.TWILIO_API_SECRET;11const client = twilio(apiKey, apiSecret, { accountSid: accountSid });1213async function fetchQueue() {14const queue = await client15.queues("QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")16.fetch();1718console.log(queue.dateUpdated);19}2021fetchQueue();
Response
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}
GET https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Queues.json
How many resources to return in each list page. The default is 50, and the maximum is 1000.
1Maximum: 1000The page token. This is provided by the API.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID at twilio.com/console5// Provision API Keys at twilio.com/console/runtime/api-keys6// and set the environment variables. See http://twil.io/secure7// For local testing, you can use your Account SID and Auth token8const accountSid = process.env.TWILIO_ACCOUNT_SID;9const apiKey = process.env.TWILIO_API_KEY;10const apiSecret = process.env.TWILIO_API_SECRET;11const client = twilio(apiKey, apiSecret, { accountSid: accountSid });1213async function listQueue() {14const queues = await client.queues.list({ limit: 20 });1516queues.forEach((q) => console.log(q.end));17}1819listQueue();
Response
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}20],21"start": 0,22"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Queues.json?PageSize=1&Page=0"23}
POST https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Queues/{Sid}.json
The SID of the Account that created the Queue resource to update.
^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34The Twilio-provided string that uniquely identifies the Queue resource to update
^QU[0-9a-fA-F]{32}$Min length: 34Max length: 34application/x-www-form-urlencodedA descriptive string that you created to describe this resource. It can be up to 64 characters long.
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/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID at twilio.com/console5// Provision API Keys at twilio.com/console/runtime/api-keys6// and set the environment variables. See http://twil.io/secure7// For local testing, you can use your Account SID and Auth token8const accountSid = process.env.TWILIO_ACCOUNT_SID;9const apiKey = process.env.TWILIO_API_KEY;10const apiSecret = process.env.TWILIO_API_SECRET;11const client = twilio(apiKey, apiSecret, { accountSid: accountSid });1213async function updateQueue() {14const queue = await client15.queues("QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")16.update({ friendlyName: "FriendlyName" });1718console.log(queue.dateUpdated);19}2021updateQueue();
Response
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}
DELETE https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Queues/{Sid}.json
The SID of the Account that created the Queue resource to delete.
^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34The Twilio-provided string that uniquely identifies the Queue resource to delete
^QU[0-9a-fA-F]{32}$Min length: 34Max length: 341// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID at twilio.com/console5// Provision API Keys at twilio.com/console/runtime/api-keys6// and set the environment variables. See http://twil.io/secure7// For local testing, you can use your Account SID and Auth token8const accountSid = process.env.TWILIO_ACCOUNT_SID;9const apiKey = process.env.TWILIO_API_KEY;10const apiSecret = process.env.TWILIO_API_SECRET;11const client = twilio(apiKey, apiSecret, { accountSid: accountSid });1213async function deleteQueue() {14await client.queues("QUaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").remove();15}1617deleteQueue();