REST API: Workflow - Twilio
Register for SIGNAL by 8/31 for $250 off. Register now.

REST API: Workflow

Workflows control how tasks will be prioritized and routed into Queues, and how Tasks should escalate in priority or move across queues over time. Workflows are described in a simple JSON format and can be modified through the REST API or through the account portal.

You specify which Workflow should control a Task when you add the Task to the Workspace, and the Workflow will manage the Task's queue and priority until it is either assigned to a Worker, removed from the queue, or modified.

When a Task is assigned to a Worker, your application will receive a callback to the Workflow's AssignmentCallbackUrl, and your application can then do whatever is required to deliver the Task to the worker (for example, instructing Twilio to dial the phone number of the Worker selected to receive the call). You can read more about Task assignment here.

Here's a Workflow configuration example demonstrating some commonly used Workflow features:

{  
   "task_routing":{  
      "filters":[  
         {  
            "filter_friendly_name":"Gold Tickets",
            "expression":"customer_value == 'Gold' AND type == 'ticket'",
            "targets":[  
               {  
                  "queue":"WQ0123456789abcdef0123456789abcdef",
                  "priority":"2"
               }
            ]
         },
         {  
            "filter_friendly_name":"Silver and Bronze Tickets",
            "expression":"customer_value IN ['Silver', 'Bronze'] AND type == 'ticket'",
            "targets":[  
               {  
                  "queue":"WQabcdef0123456789abcdef0123456789",
                  "priority":"1",
                  "timeout":"300"
               },
               {  
                  "queue":"WQabcdef01234567890123456789abcdef"
               }
            ]
         },
         {  
            "filter_friendly_name":"Leads",
            "expression":"type == 'lead'",
            "targets":[  
               {  
                  "queue":"WQabcdef01234567890123456789abcdef",
                  "priority":"3"
               }
            ]
         }
      ],
      "default_filter":{  
         "queue":"WQabcdef01234567890123456789abcdef"
      }
   }
}

Read more about defining Workflows here.

Multiple Workflows

A Workspace can contain multiple Workflows. This allows you to have different sets of routing rules for different types of applications or situations.

For example: A call center has one group of Workers that handles both phone and chat tasks. These two Task types have different service-level targets and agent requirements. They will also originate from separate external applications. To separate application concerns, the call center creates a single Workspace with two separate Workflows, one for phone calls and the other for chat requests.

Creating and Distributing Tasks

Whenever you add a Task to a Workspace you indicate which Workflow should route the Task. The Workflow will prioritize the task and place it into a queue, where it will be distributed to the first available Worker that has the necessary capabilities. See the Task Resource for more information.

Handling Task Assignments with the AssignmentCallbackUrl

Every Workflow has an AssignmentCallbackURL property (as well as a FallbackAssignmentCallbackUrl in case requests to the first URL fail). When a worker is assigned a task, TaskRouter will make an HTTP request to this URL. Your application must handle this request to then do whatever is required to connect the Task to the Worker in your application. For example, this might mean pushing a case to an instance of an agent's web application, or dialing an agent's phone number using Twilio. See this section for more information on handling Task Assignment callbacks.

Important: If we cannot hit your AssignmentCallbackUrl or FallbackAssignmentCallbackUrl, your Reservation will be automatically canceled. A good first run experience is to utilize PostBin to debug that the AssignmentCallback is firing correctly and to examine the contents of the post. AssignmentCallbackUrl is not required if you are planning on using just the JS SDK, and in that case simply set the value to blank.

Actions


List All Workflows

Resource URI

GET /v1/Workspaces/{WorkspaceSid}/Workflows

Return a list of all Workflows in the Workspace identified by {WorkspaceSid}.

Example

Example for listing all workflows in a workspace.

Loading Code Samples...
Language
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const twilio = require('twilio');

const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const workspaceSid = 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';

const client = new twilio.TaskRouterClient(accountSid, authToken, workspaceSid);

client.workspace.workflows.list((err, data) => {
  data.workflows.forEach(workflows => {
    console.log(workflows.friendly_name);
  });
});
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.taskrouter.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                 .workflows
                 .each(workflows => console.log(workflows.sid));
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.TaskRouter;
class Example 
{
  static void Main(string[] args) 
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    var client = new TaskRouterClient(AccountSid, AuthToken);

    WorkflowResult workflowResult = client.ListWorkflows(WorkspaceSid);
    foreach(Workflow workflow in workflowResult.Workflows) {
        Console.WriteLine(workflow.FriendlyName);
    }
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$authToken = "your_auth_token";
$workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

$client = new TaskRouter_Services_Twilio($accountSid, $authToken, $workspaceSid);

foreach($client->workspace->workflows as $workflow)
{
	echo $workflow->friendly_name;
}
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'rubygems' # This line not needed for ruby > 1.8
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
workspace_sid = 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

client = Twilio::REST::TaskRouterClient.new account_sid,
                                            auth_token,
                                            workspace_sid

client.workspace.workflows.list.each do |workflow|
  puts workflow.friendly_name
end
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Taskrouter.V1.Workspace;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var workflows = WorkflowResource.Read(
            pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        );

        foreach(var record in workflows)
        {
           Console.WriteLine(record.Sid);
        }
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Auth Token at twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$workflows = $twilio->taskrouter->v1->workspaces("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                    ->workflows
                                    ->read();

foreach ($workflows as $record) {
    print($record->sid);
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioTaskRouterClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
workspace_sid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

client = TwilioTaskRouterClient(account_sid, auth_token)

for workflow in client.workflows(workspace_sid).list():
    print(workflow.friendly_name)
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

workflows = @client.taskrouter
                   .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                   .workflows
                   .list

workflows.each do |record|
  puts record.sid
end
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.TwilioTaskRouterClient;
import com.twilio.sdk.resource.instance.taskrouter.Workflow;
import com.twilio.sdk.resource.instance.taskrouter.Workspace;
import com.twilio.sdk.resource.list.taskrouter.WorkflowList;

public class Example { 

  // Find your Account Sid and Token at twilio.com/user/account
  private static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  private static final String AUTH_TOKEN = "your_auth_token";
  private static final String WORKSPACE_SID = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) throws TwilioRestException {
    TwilioTaskRouterClient client = new TwilioTaskRouterClient(ACCOUNT_SID, AUTH_TOKEN);

    WorkflowList workflows = client.getWorkflows(WORKSPACE_SID);
    for(Workflow workflow : workflows) {
        System.out.println(workflow.getFriendlyName());
    }

    // alternatively
    Workspace workspace = client.getWorkspace(WORKSPACE_SID);
    workflows = workspace.getWorkflows();
    for(Workflow workflow : workflows) {
        System.out.println(workflow.getFriendlyName());
    }
  }
}
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

workflows = client.taskrouter \
                  .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                  .workflows \
                  .list()

for record in workflows:
    print(record.sid)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.taskrouter.v1.workspace.Workflow;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        ResourceSet<Workflow> workflows = 
            Workflow.reader("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
            .read();

        for(Workflow record : workflows) {
            System.out.println(record.getSid());
        }
    }
}
curl -X GET 'https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows' \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
  "meta": {
    "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows?PageSize=50&Page=0",
    "key": "workflows",
    "last_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows?PageSize=50&Page=0",
    "next_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows?PageSize=50&Page=1",
    "page": 0,
    "page_size": 50,
    "previous_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows?PageSize=50&Page=0",
    "url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows?PageSize=50&Page=0"
  },
  "workflows": [
    {
      "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
      "assignment_callback_url": "http://example.com",
      "configuration": "task-routing:\n  - filter: \n      - 1 == 1\n    target:\n      - queue: WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n        set-priority: 0\n",
      "date_created": "2014-05-14T10:50:02Z",
      "date_updated": "2014-05-15T16:47:51Z",
      "document_content_type": "application/json",
      "fallback_assignment_callback_url": null,
      "friendly_name": "Default Fifo Workflow",
      "sid": "WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
      "task_reservation_timeout": 120,
      "url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
      "links": {
        "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Statistics",
        "real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/RealTimeStatistics",
        "cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/CumulativeStatistics"
      },
      "workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    }
  ],
  "workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
List All Workflows

List Filters

The following GET query string parameters allow you to limit the list returned. Note, parameters are case-sensitive:

Field Description
FriendlyName Human readable description of this Workflow (for example “Customer Support” or “2014 Election Campaign”)

Note: By default, this will return the first 50 Workflows. Supply a PageSize parameter to fetch more than 50 Workflows. See paging for more information.


Create a Workflow

Resource URI

POST /v1/Workspaces/{WorkspaceSid}/Workflows

Creates a new Workflow.

Example

Example for creating a new workflow in a workspace.

Loading Code Samples...
Language
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const twilio = require('twilio');

const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const workspaceSid = 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';

const client = new twilio.TaskRouterClient(accountSid, authToken, workspaceSid);

const salesQueue = 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const marketingQueue = 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const supportQueue = 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const everyoneQueue = 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';

let configuration = {
  task_routing: {
    filters: [
      {
        targets: [
          {
            queue: salesQueue,
          },
        ],
        expression: 'type == "sales"',
      },
      {
        targets: [
          {
            queue: marketingQueue,
          },
        ],
        expression: 'type == "marketing"',
      },
      {
        targets: [
          {
            queue: supportQueue,
          },
        ],
        expression: 'type == "support"',
      },
    ],
    default_filter: {
      queue: everyoneQueue,
    },
  },
};

// or utilizing objects
const wb = require('twilio/lib/resources/task_router/WorkflowBuilder');

// sales
const salesTarget = new wb.WorkflowRuleTarget({
  queue: salesQueue,
});
const salesRule = new wb.WorkflowRule({
  expression: "type == 'sales'",
  targets: [salesTarget],
});

// marketing
const marketingTarget = new wb.WorkflowRuleTarget({
  queue: marketingQueue,
});
const marketingRule = new wb.WorkflowRule({
  expression: "type == 'marketing'",
  targets: [marketingTarget],
});

// support
const supportTarget = new wb.WorkflowRuleTarget({
  queue: supportQueue,
});
const supportRule = new wb.WorkflowRule({
  expression: "type == 'support'",
  targets: [supportTarget],
});

// default
const defaultTarget = new wb.WorkflowRuleTarget({
  queue: everyoneQueue,
});

// put all together
const taskRouting = new wb.TaskRoutingConfiguration({
  filters: [salesRule, marketingRule, supportRule],
  default_filter: defaultTarget,
});
const config = new wb.WorkflowConfiguration({
  taskRouting: taskRouting,
});

// convert to json
configuration = config.toJSON();

client.workspace.workflows.create({
  friendlyName: 'Sales, Marketing, Support Workflow',
  assignmentCallbackUrl: 'http://example.com',
  fallbackAssignmentCallbackUrl: 'http://example2.com',
  taskReservationTimeout: '30',
  configuration: configuration,
});
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.taskrouter.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
      .workflows
      .create({
         assignmentCallbackUrl: 'http://example.com',
         fallbackAssignmentCallbackUrl: 'http://example2.com',
         taskReservationTimeout: 30,
         friendlyName: 'Sales, Marketing, Support Workflow',
         configuration: JSON.stringify({
           task_routing: {
               filters: [
                 {
                     expression: `type=='sales'`,
                     targets: [
                       {
                           queue: 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
                       }
                     ]
                 },
                 {
                     expression: `type=='marketing'`,
                     targets: [
                       {
                           queue: 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
                       }
                     ]
                 },
                 {
                     expression: `type=='support'`,
                     targets: [
                       {
                           queue: 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
                       }
                     ]
                 }
               ],
               default_filter: {
                   queue: 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
               }
           }
       })
       })
      .then(workflow => console.log(workflow.sid))
      .done();
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using System.Collections.Generic;
using Twilio.TaskRouter;

class Example
{
  static void Main(string[] args)
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    string salesQueue = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string marketingQueue = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string supportQueue = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string everyoneQueue = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    var client = new TaskRouterClient(AccountSid, AuthToken);

    // sales
    var salesRule = new Filter()
    {
        FriendlyName = "Sales",
        Expression = "type == 'sales'",
        Targets = new List<Target>() {
            new Target {
                Queue = salesQueue
            }
        }
    };

    // marketing
    var marketingRule = new Filter()
    {
        FriendlyName = "Marketing",
        Expression = "type == 'marketing'",
        Targets = new List<Target>() {
            new Target {
                Queue = marketingQueue
            }
        }
    };

    // support
    var supportRule = new Filter
    {
        FriendlyName = "Support",
        Expression = "type == 'support'",
        Targets = new List<Target>() {
            new Target {
                Queue = supportQueue
            }
        }
    };

    var workflowConfiguration = new WorkflowConfiguration();

    workflowConfiguration.Filters.Add(salesRule);
    workflowConfiguration.Filters.Add(marketingRule);
    workflowConfiguration.Filters.Add(supportRule);
    workflowConfiguration.DefaultFilter = new Target() { Queue = everyoneQueue };

    // convert to json
    var workflowJSON = workflowConfiguration.ToString();

    // call rest api
    Workflow workflow = client.AddWorkflow(WorkspaceSid, "Sales, Marketing, Support Workflow", workflowJSON, "http://example.com", "http://example2.com", 30);
    Console.WriteLine(workflow.FriendlyName);
  }
}
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'rubygems' # This line not needed for ruby > 1.8
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
workspace_sid = 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

client = Twilio::REST::TaskRouterClient.new(account_sid,
                                            auth_token,
                                            workspace_sid)

# Queues
sales_sid = 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
marketing_sid = 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
support_sid = 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
everyone_sid = 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

sales_queue_target = Twilio::TaskRouter::WorkflowRuleTarget.new sales_sid
sales_queue_targets = [sales_queue_target]
sales_rule = Twilio::TaskRouter::WorkflowRule.new 'type == "sales"',
                                                  sales_queue_targets

marketing_target = Twilio::TaskRouter::WorkflowRuleTarget.new marketing_sid
marketing_targets = [marketing_target]
marketing_rule = Twilio::TaskRouter::WorkflowRule.new 'type == "marketing"',
                                                      marketing_targets

support_target = Twilio::TaskRouter::WorkflowRuleTarget.new support_sid
support_targets = [support_target]
support_rule = Twilio::TaskRouter::WorkflowRule.new 'type == "support"',
                                                    support_targets

rules = [sales_rule, marketing_rule, support_rule]
default_target = Twilio::TaskRouter::WorkflowRuleTarget.new everyone_sid

config = Twilio::TaskRouter::WorkflowConfiguration.new rules, default_target
json = config.to_json

workflow = client.workspace.workflows.create(
  friendly_name: 'Sales, Marketing, Support Workflow',
  assignment_callback_url: 'http://example.com',
  fallback_assignment_callback_url: 'http://example.2com',
  task_reservation_timeout: '30',
  configuration: json
)

puts workflow.friendly_name
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Taskrouter.V1.Workspace;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var configuration = JsonConvert.SerializeObject(new Dictionary<string, Object>()
        {
            {"task_routing", new Dictionary<string, Object>()
                {
                    {"filters", new object [] {
                        new Dictionary<string, Object>()
                        {
                            {"expression", "type=='sales'"},
                            {"targets", new object [] {
                                new Dictionary<string, Object>()
                                {
                                    {"queue", "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}
                                }
                            }}
                        },
                        new Dictionary<string, Object>()
                        {
                            {"expression", "type=='marketing'"},
                            {"targets", new object [] {
                                new Dictionary<string, Object>()
                                {
                                    {"queue", "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}
                                }
                            }}
                        },
                        new Dictionary<string, Object>()
                        {
                            {"expression", "type=='support'"},
                            {"targets", new object [] {
                                new Dictionary<string, Object>()
                                {
                                    {"queue", "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}
                                }
                            }}
                        }
                    }},
                    {"default_filter", new Dictionary<string, Object>()
                        {
                            {"queue", "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}
                        }}
                }}
        }, Formatting.Indented);

        var workflow = WorkflowResource.Create(
            assignmentCallbackUrl: new Uri("http://example.com"),
            fallbackAssignmentCallbackUrl: new Uri("http://example2.com"),
            taskReservationTimeout: 30,
            friendlyName: "Sales, Marketing, Support Workflow",
            configuration: configuration,
            pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        );

        Console.WriteLine(workflow.Sid);
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Auth Token at twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$workflow = $twilio->taskrouter->v1->workspaces("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                   ->workflows
                                   ->create("Sales, Marketing, Support Workflow", // friendlyName
                                            array(
                                                "task_routing" => array(
                                                    "filters" => array(
                                                        array(
                                                            "expression" => "type=='sales'",
                                                            "targets" => array(
                                                                array(
                                                                    "queue" => "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                                                                )
                                                            )
                                                        ),
                                                        array(
                                                            "expression" => "type=='marketing'",
                                                            "targets" => array(
                                                                array(
                                                                    "queue" => "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                                                                )
                                                            )
                                                        ),
                                                        array(
                                                            "expression" => "type=='support'",
                                                            "targets" => array(
                                                                array(
                                                                    "queue" => "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                                                                )
                                                            )
                                                        )
                                                    ),
                                                    "default_filter" => array(
                                                        "queue" => "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                                                    )
                                                )
                                            ), // configuration
                                            array(
                                                "assignmentCallbackUrl" => "http://example.com",
                                                "fallbackAssignmentCallbackUrl" => "http://example2.com",
                                                "taskReservationTimeout" => 30
                                            )
                                   );

print($workflow->sid);
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioTaskRouterClient
from twilio.task_router.workflow_ruletarget import WorkflowRuleTarget
from twilio.task_router.workflow_rule import WorkflowRule
from twilio.task_router.workflow_config import WorkflowConfig

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
workspace_sid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

client = TwilioTaskRouterClient(account_sid, auth_token)

rules = []

sales_queue_sid = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
marketing_queue_sid = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
support_queue_sid = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
everyone_queue_sid = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

salesRuleTargets = []
salesRuleTarget = WorkflowRuleTarget(sales_queue_sid, None, None, None)
salesRuleTargets.append(salesRuleTarget)
salesRule = WorkflowRule("type=='sales'", salesRuleTargets, None)

marketingRuleTargets = []
marketingRuleTarget = WorkflowRuleTarget(marketing_queue_sid, None, None, None)
marketingRuleTargets.append(marketingRuleTarget)
marketingRule = WorkflowRule("type=='marketing'", marketingRuleTargets, None)

supportRuleTargets = []
supportRuleTarget = WorkflowRuleTarget(support_queue_sid, None, None, None)
supportRuleTargets.append(supportRuleTarget)
supportRule = WorkflowRule("type=='support'", supportRuleTargets, None)

rules.append(salesRule)
rules.append(marketingRule)
rules.append(supportRule)

defaultTarget = WorkflowRuleTarget(everyone_queue_sid, None, None, None)
config = WorkflowConfig(rules, defaultTarget)
json = config.to_json()

workflow = client.workflows(workspace_sid).create(
    friendly_name='Sales, Marketing, Support Workflow',
    assignment_callback_url='http://example.com',
    fallback_assignment_callback_url='http://example2.com',
    task_reservation_timeout='30',
    configuration=json
)

print(workflow.friendly_name)
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

workflow = @client.taskrouter
  .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .workflows
  .create(
     assignment_callback_url: 'http://example.com',
     fallback_assignment_callback_url: 'http://example2.com',
     task_reservation_timeout: 30,
     friendly_name: 'Sales, Marketing, Support Workflow',
     configuration: {
       'task_routing' => {
           'filters' => [
               {
                   'expression' => "type=='sales'",
                   'targets' => [
                       {
                           'queue' => 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
                       },
                   ]
               },
               {
                   'expression' => "type=='marketing'",
                   'targets' => [
                       {
                           'queue' => 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
                       },
                   ]
               },
               {
                   'expression' => "type=='support'",
                   'targets' => [
                       {
                           'queue' => 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
                       },
                   ]
               },
           ],
           'default_filter' => {
               'queue' => 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
           }
       }
   }.to_json
   )

puts workflow.sid
// Install the Java helper library from twilio.com/docs/java/install
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import java.lang.Exception;
import com.twilio.sdk.TwilioTaskRouterClient;
import com.twilio.sdk.resource.instance.taskrouter.Workspace;
import com.twilio.sdk.resource.instance.taskrouter.Workflow;
import com.twilio.sdk.taskrouter.WorkflowRule;
import com.twilio.sdk.taskrouter.WorkflowRuleTarget;
import com.twilio.sdk.taskrouter.WorkflowConfiguration;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  private static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  private static final String AUTH_TOKEN = "your_auth_token";
  private static final String WORKSPACE_SID = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) throws Exception {
    TwilioTaskRouterClient client = new TwilioTaskRouterClient(ACCOUNT_SID, AUTH_TOKEN);

    Workspace workspace = client.getWorkspace(WORKSPACE_SID);

    //Construct a workflow
    List<WorkflowRule> rules = new ArrayList<WorkflowRule>();

    String salesQueueSid = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    String marketingQueueSid = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    String supportQueueSid = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    String defaultQueue = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    // sales
    List<WorkflowRuleTarget> salesTargets = new ArrayList<WorkflowRuleTarget>();
    WorkflowRuleTarget salesTarget = new WorkflowRuleTarget(salesQueueSid);
    salesTargets.add(salesTarget);
    WorkflowRule salesRule = new WorkflowRule("type == \"sales\"", salesTargets);

    // marketing
    List<WorkflowRuleTarget> marketingTargets = new ArrayList<WorkflowRuleTarget>();
    WorkflowRuleTarget marketingTarget = new WorkflowRuleTarget(marketingQueueSid);
    marketingTargets.add(marketingTarget);
    WorkflowRule marketingRule = new WorkflowRule("type == \"marketing\"", marketingTargets);

    // support
    List<WorkflowRuleTarget> supportTargets = new ArrayList<WorkflowRuleTarget>();
    WorkflowRuleTarget supportTarget = new WorkflowRuleTarget(supportQueueSid);
    supportTargets.add(supportTarget);
    WorkflowRule supportRule = new WorkflowRule("type == \"support\"", supportTargets);

    // default filter
    WorkflowRuleTarget defaultTarget = new WorkflowRuleTarget(defaultQueue);

    // put rules together in order in which the workflow should process them
    rules.add(salesRule);
    rules.add(marketingRule);
    rules.add(supportRule);

    // build workflow & convert to json
    WorkflowConfiguration config = new WorkflowConfiguration(rules, defaultTarget);
    String workflowJSON = config.toJSON();

    Map<String, String> workflowParams = new HashMap<String, String>();
    workflowParams.put("Configuration", workflowJSON);
    workflowParams.put("FriendlyName", "Sales, Marketing, Support Workflow");
    workflowParams.put("AssignmentCallbackUrl", "http://example.com");
    workflowParams.put("FallbackAssignmentCallbackUrl", "http://example2.com");
    workflowParams.put("TaskReservationTimeout", "30");
    Workflow workflow = workspace.createWorkflow(workflowParams);
  }
}
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client
import json


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

workflow = client.taskrouter \
    .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
    .workflows \
    .create(
         assignment_callback_url='http://example.com',
         fallback_assignment_callback_url='http://example2.com',
         task_reservation_timeout=30,
         friendly_name='Sales, Marketing, Support Workflow',
         configuration=json.dumps({
             'task_routing': {
                 'filters': [
                     {
                         'expression': "type=='sales'",
                         'targets': [
                             {
                                 'queue': 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
                             }
                         ]
                     },
                     {
                         'expression': "type=='marketing'",
                         'targets': [
                             {
                                 'queue': 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
                             }
                         ]
                     },
                     {
                         'expression': "type=='support'",
                         'targets': [
                             {
                                 'queue': 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
                             }
                         ]
                     }
                 ],
                 'default_filter': {
                     'queue': 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
                 }
             }
         })
     )

print(workflow.sid)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.taskrouter.v1.workspace.Workflow;

import java.net.URI;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Workflow workflow = Workflow.creator(
                "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                "Sales, Marketing, Support Workflow",
                "{\"task_routing\": {\"filters\": [{\"expression\": \"type=='sales'\", \"targets\": [{\"queue\": \"WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"}]}, {\"expression\": \"type=='marketing'\", \"targets\": [{\"queue\": \"WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"}]}, {\"expression\": \"type=='support'\", \"targets\": [{\"queue\": \"WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"}]}], \"default_filter\": {\"queue\": \"WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"}}}")
            .setAssignmentCallbackUrl(
                URI.create("http://example.com"))
            .setFallbackAssignmentCallbackUrl(
                URI.create("http://example2.com"))
            .setTaskReservationTimeout(30)
            .create();

        System.out.println(workflow.getSid());
    }
}
CONFIGURATION=$(cat << EOF
{
    "task_routing": {
        "default_filter": {
            "queue": "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        },
        "filters": [
            {
                "expression": "type=='sales'",
                "targets": [
                    {
                        "queue": "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                    }
                ]
            },
            {
                "expression": "type=='marketing'",
                "targets": [
                    {
                        "queue": "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                    }
                ]
            },
            {
                "expression": "type=='support'",
                "targets": [
                    {
                        "queue": "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                    }
                ]
            }
        ]
    }
}
EOF
)

curl -X POST https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows \
--data-urlencode "AssignmentCallbackUrl=http://example.com" \
--data-urlencode "FallbackAssignmentCallbackUrl=http://example2.com" \
--data-urlencode "TaskReservationTimeout=30" \
--data-urlencode "FriendlyName=Sales, Marketing, Support Workflow" \
--data-urlencode "Configuration=$CONFIGURATION" \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
  "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "assignment_callback_url": "http://example.com",
  "configuration": {
    "task_routing": {
      "filters": [
        {
          "expression": "type=='sales'",
          "targets": [
            {
              "queue": "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            }
          ]
        },
        {
          "expression": "type=='marketing'",
          "targets": [
            {
              "queue": "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            }
          ]
        },
        {
          "expression": "type=='support'",
          "targets": [
            {
              "queue": "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            }
          ]
        }
      ],
      "default_filter": {
        "queue": "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
      }
    }
  },
  "date_created": "2014-05-14T10:50:02Z",
  "date_updated": "2014-05-14T23:26:06Z",
  "document_content_type": "application/json",
  "fallback_assignment_callback_url": "http://example2.com",
  "friendly_name": "Sales, Marketing, Support Workflow",
  "sid": "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "task_reservation_timeout": 30,
  "url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "links": {
    "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Statistics",
    "real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/RealTimeStatistics",
    "cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/CumulativeStatistics"
  }
}
Create New Workflow
Required Parameters
Parameter Description
FriendlyName A string representing a human readable name for this Workflow. Examples include 'Inbound Call Workflow' or '2014 Outbound Campaign'. (📇 PII )
Configuration JSON document configuring the rules for this Workflow. See Configuring Workflows for more information. (🏢 not PII )
Optional Parameters
Parameter Description
AssignmentCallbackUrl A valid URL for the application that will process task assignment events. See Handling Task Assignment Callback for more details. (🏢 not PII )
FallbackAssignmentCallbackUrl If the request to the AssignmentCallbackUrl fails, the assignment callback will be made to this URL. (🏢 not PII )
TaskReservationTimeout An integer value controlling how long in seconds TaskRouter will wait for a confirmation response from your application after assigning a Task to a worker. See Task Assignment Callback for more information. Defaults to 120 seconds. Maximum value is 86400 (24 hours) (🏢 not PII )

Note: The maximum amount of Workflows allowed for any given Workspace is 1,000. Please contact us if your use case will require more.


Retrieve a Workflow

Resource URI

GET /v1/Workspaces/{WorkspaceSid}/Workflows/{WorkflowSid}

Return a single Workflow resource identified by {WorkflowSid}.

Example

Example for retrieving a single Workflow in a Workspace.

Loading Code Samples...
Language
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const twilio = require('twilio');

const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const workspaceSid = 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const workflowSid = 'WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';

const client = new twilio.TaskRouterClient(accountSid, authToken, workspaceSid);

client.workspace.workflows(workflowSid).get((err, workflow) => {
  console.log(workflow.friendly_name);
});
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.taskrouter.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                 .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                 .fetch()
                 .then(workflow => console.log(workflow.friendlyName))
                 .done();
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.TaskRouter;
class Example 
{
  static void Main(string[] args) 
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string WorkflowSid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    var client = new TaskRouterClient(AccountSid, AuthToken);

    Workflow workflow = client.GetWorkflow(WorkspaceSid, WorkflowSid);
    Console.WriteLine(workflow.FriendlyName);
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$authToken = "your_auth_token";
$workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$workflowSid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

$client = new TaskRouter_Services_Twilio($accountSid, $authToken, $workspaceSid);

$workflow = $client->workspace->workflows->get($workflowSid);
echo $workflow->friendly_name;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'rubygems' # This line not needed for ruby > 1.8
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
workspace_sid = 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
workflow_sid = 'WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

client = Twilio::REST::TaskRouterClient.new(account_sid,
                                            auth_token,
                                            workspace_sid)

workflow = client.workspace.workflows.get(workflow_sid)
puts workflow.friendly_name
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Taskrouter.V1.Workspace;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var workflow = WorkflowResource.Fetch(
            pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathSid: "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        );

        Console.WriteLine(workflow.FriendlyName);
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Auth Token at twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$workflow = $twilio->taskrouter->v1->workspaces("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                   ->workflows("WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                   ->fetch();

print($workflow->friendlyName);
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioTaskRouterClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
workspace_sid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
workflow_sid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

client = TwilioTaskRouterClient(account_sid, auth_token)

workflow = client.workflows(workspace_sid).get(workflow_sid)
print(workflow.friendly_name)
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

workflow = @client.taskrouter
                  .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                  .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                  .fetch

puts workflow.friendly_name
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.TwilioTaskRouterClient;
import com.twilio.sdk.resource.instance.taskrouter.Workflow;
import com.twilio.sdk.resource.instance.taskrouter.Workspace;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  private static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  private static final String AUTH_TOKEN = "your_auth_token";
  private static final String WORKSPACE_SID = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  private static final String WORKFLOW_SID = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) throws TwilioRestException {
    TwilioTaskRouterClient client = new TwilioTaskRouterClient(ACCOUNT_SID, AUTH_TOKEN);

    Workflow workflow = client.getWorkflow(WORKSPACE_SID, WORKFLOW_SID);
    System.out.println(workflow.getFriendlyName());

    //alternatively
    Workspace workspace = client.getWorkspace(WORKSPACE_SID);
    workflow = workspace.getWorkflow(WORKFLOW_SID);
    System.out.println(workflow.getFriendlyName());
  }
}
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

workflow = client.taskrouter \
                 .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                 .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                 .fetch()

print(workflow.friendly_name)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.taskrouter.v1.workspace.Workflow;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Workflow workflow = Workflow.fetcher(
                "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
            .fetch();

        System.out.println(workflow.getFriendlyName());
    }
}
curl -X GET 'https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
  "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "assignment_callback_url": "http://example.com",
  "configuration": "task-routing:\n  - filter: \n      - 1 == 1\n    target:\n      - queue: WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n        set-priority: 0\n",
  "date_created": "2014-05-14T10:50:02Z",
  "date_updated": "2014-05-14T23:26:06Z",
  "document_content_type": "application/json",
  "fallback_assignment_callback_url": null,
  "friendly_name": "Default Fifo Workflow",
  "sid": "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "task_reservation_timeout": 120,
  "url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "links": {
    "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Statistics",
    "real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/RealTimeStatistics",
    "cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/CumulativeStatistics"
  }
}
Retrieve Single Workflow

Resource Properties

A Workflow instance resource is represented by the following properties.

Field Description
Sid The unique ID of the Workflow
AccountSid The ID of the account that owns this Workflow
WorkspaceSid The ID of the Workspace that contains this Workflow
FriendlyName Human readable description of this Workflow (for example “Customer Support” or “2014 Election Campaign”)
AssignmentCallbackUrl The URL that will be called whenever a task managed by this Workflow is assigned to a Worker. See Assignment Callback URL for more information.
FallbackAssignmentCallbackUrl If the request to the AssignmentCallbackUrl fails, the assignment callback will be made to this URL.
Configuration JSON document configuring the rules for this Workflow. See Configuring Workflows for more information.
TaskReservationTimeout Determines how long TaskRouter will wait for a confirmation response from your application after assigning a Task to a worker. Defaults to 120 seconds. Maximum value is 86400 (24 hours)
DateCreated The date this workflow was created.
DateUpdated The date this workflow was last updated.

Update a Workflow

Resource URI

POST /v1/Workspaces/{WorkspaceSid}/Workflows/{WorkflowSid}

Modifies a Workflow. Whenever you modify a workflow, the following will take place:

  • Your Workflow configuration will be validated to ensure it is syntactically correct and that all queues referenced in the document exist. If any problems are found, the update will fail, and the active Workflow will remain in place.
  • Assuming there are no problems with the configuration provided, TaskRouter will use the previous Workflow to route any Tasks that were pending prior to the change. New Tasks will begin using the updated Workflow immediately.
Example

Example for updating a workflow.

Loading Code Samples...
Language
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const twilio = require('twilio');

const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const workspaceSid = 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const workflowSid = 'WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';

const client = new twilio.TaskRouterClient(accountSid, authToken, workspaceSid);

client.workspace.workflows(workflowSid).update({
  taskReservationTimeout: '20',
}, (err, workflow) => {
  console.log(workflow.task_reservation_timeout);
});
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.taskrouter.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                 .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                 .update({taskReservationTimeout: 20})
                 .then(workflow => console.log(workflow.friendlyName))
                 .done();
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.TaskRouter;
class Example 
{
  static void Main(string[] args) 
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string WorkflowSid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    var client = new TaskRouterClient(AccountSid, AuthToken);

    client.UpdateWorkflow(WorkspaceSid, WorkflowSid, null, null, null, null, 20);
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$authToken = "your_auth_token";
$workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$workflowSid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

$client = new TaskRouter_Services_Twilio($accountSid, $authToken, $workspaceSid);

$workflow = $client->workspace->workflows->get($workflowSid);
$workflow->update(
	array(
		'TaskReservationTimeout' => '20'
	)
);
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'rubygems' # This line not needed for ruby > 1.8
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
workspace_sid = 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
workflow_sid = 'WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

client = Twilio::REST::TaskRouterClient.new account_sid,
                                            auth_token,
                                            workspace_sid

workflow = client.workspace.workflows.get(workflow_sid)
workflow = workflow.update(task_reservation_timeout: '20')
puts workflow.task_reservation_timeout
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Taskrouter.V1.Workspace;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var workflow = WorkflowResource.Update(
            taskReservationTimeout: 20,
            pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathSid: "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        );

        Console.WriteLine(workflow.FriendlyName);
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Auth Token at twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$workflow = $twilio->taskrouter->v1->workspaces("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                   ->workflows("WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                   ->update(array(
                                                "taskReservationTimeout" => 20
                                            )
                                   );

print($workflow->friendlyName);
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioTaskRouterClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
workspace_sid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
workflow_sid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

client = TwilioTaskRouterClient(account_sid, auth_token)

workflow = client.workflows(workspace_sid).update(
    workflow_sid, task_reservation_timout='20'
)
print(workflow.task_reservation_timeout)

# alternatively
workflow = client.workflows(workspace_sid).get(workflow_sid)
workflow = workflow.update(task_reservation_timeout='20')
print(workflow.task_reservation_timeout)
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

workflow = @client.taskrouter
                  .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                  .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                  .update(task_reservation_timeout: 20)

puts workflow.friendly_name
// Install the Java helper library from twilio.com/docs/java/install
import java.util.HashMap;
import java.util.Map;

import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.TwilioTaskRouterClient;
import com.twilio.sdk.resource.instance.taskrouter.Workflow;
import com.twilio.sdk.resource.instance.taskrouter.Workspace;

public class Example { 

  // Find your Account Sid and Token at twilio.com/user/account
  private static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  private static final String AUTH_TOKEN = "your_auth_token";
  private static final String WORKSPACE_SID = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  private static final String WORKFLOW_SID = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) throws TwilioRestException {
    TwilioTaskRouterClient client = new TwilioTaskRouterClient(ACCOUNT_SID, AUTH_TOKEN);

    Workflow workflow = client.getWorkflow(WORKSPACE_SID, WORKSPACE_SID);
    Map<String, String> params = new HashMap<String, String>();
    params.put("TaskReservationTimeout", "20");
    workflow.update(params);

    //alternatively
    Workspace workspace = client.getWorkspace(WORKSPACE_SID);
    workflow = workspace.getWorkflow(WORKFLOW_SID);
    workflow.update(params);
  }
}
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

workflow = client.taskrouter \
                 .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                 .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                 .update(task_reservation_timeout=20)

print(workflow.friendly_name)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.taskrouter.v1.workspace.Workflow;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Workflow workflow = Workflow.updater(
                "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
            .setTaskReservationTimeout(20).update();

        System.out.println(workflow.getFriendlyName());
    }
}
curl -X POST https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
--data-urlencode "TaskReservationTimeout=20" \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
  "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "assignment_callback_url": "http://example.com",
  "configuration": "task-routing:\n  - filter: \n      - 1 == 1\n    target:\n      - queue: WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n        set-priority: 0\n",
  "date_created": "2014-05-14T10:50:02Z",
  "date_updated": "2014-05-14T23:26:06Z",
  "document_content_type": "application/json",
  "fallback_assignment_callback_url": null,
  "friendly_name": "Default Fifo Workflow",
  "sid": "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "task_reservation_timeout": 20,
  "url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "links": {
    "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Statistics",
    "real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/RealTimeStatistics",
    "cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/CumulativeStatistics"
  },
  "workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
Update a Workflow

You may POST the following parameters.

POST Parameters

Parameter Description
FriendlyName A string representing a human readable name for this Workflow. Examples include 'Customer Support' or 'Sales Team'. (📇 PII )
AssignmentCallbackUrl A valid URL for the application that will process task assignment events. See Handling Task Assignment Callback for more details. (🏢 not PII )
FallbackAssignmentCallbackUrl If the request to the AssignmentCallbackUrl fails, the assignment callback will be made to this URL. (🏢 not PII )
Configuration JSON document configuring the rules for this Workflow. See Configuring Workflows for more information. (🏢 not PII )
TaskReservationTimeout An integer value controlling how long in seconds TaskRouter will wait for a confirmation response from your application after assigning a Task to a worker. Defaults to 120 seconds. Maximum value is 86400 (24 hours) (🏢 not PII )
ReEvaluateTasks A boolean value to control whether pending Tasks should be re-evaluated on a workflow update. Set to ‘true' to immediately re-evaluate all pending Tasks, or set ‘false' (default) to retain existing functionality, which is to re-evaluate Tasks on a timeout. NOTE: In order for this to be set to true, a Configuration value must also be set. (🏢 not PII )

Delete a Workflow

Resource URI

DELETE /v1/Workspaces/{WorkspaceSid}/Workflows/{WorkflowSid}

Deletes a Workflow. Will return an error if there are any pending or reserved Tasks still being controlled by this Workflow.

Example

Example for deleting a workflow.

Loading Code Samples...
Language
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const twilio = require('twilio');

const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const workspaceSid = 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const workflowSid = 'WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';

const client = new twilio.TaskRouterClient(accountSid, authToken, workspaceSid);

client.workspace.workflows(workflowSid).delete();
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.taskrouter.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                 .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                 .remove()
                 .then(workflow => console.log(workflow.sid))
                 .done();
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.TaskRouter;
class Example 
{
  static void Main(string[] args) 
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string WorkflowSid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    var client = new TaskRouterClient(AccountSid, AuthToken);

    client.DeleteWorkflow(WorkspaceSid, WorkflowSid);
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$authToken = "your_auth_token";
$workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$workflowSid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

$client = new TaskRouter_Services_Twilio($accountSid, $authToken, $workspaceSid);

$client->workspace->workflows->delete($workflowSid);
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'rubygems' # This line not needed for ruby > 1.8
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
workspace_sid = 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
workflow_sid = 'WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'

client = Twilio::REST::TaskRouterClient.new(account_sid,
                                            auth_token,
                                            workspace_sid)

workflow = client.workspace.workflows.get(workflow_sid)
workflow.delete
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Taskrouter.V1.Workspace;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        WorkflowResource.Delete(
            pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathSid: "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        );
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Auth Token at twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$twilio->taskrouter->v1->workspaces("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                       ->workflows("WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                       ->delete();
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioTaskRouterClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
workspace_sid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
activity_sid = "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

client = TwilioTaskRouterClient(account_sid, auth_token)

activity = client.activities(workspace_sid).get(activity_sid)
activity.delete()
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

@client.taskrouter.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                  .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                  .delete
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.TwilioTaskRouterClient;
import com.twilio.sdk.resource.instance.taskrouter.Workspace;

public class Example { 

  // Find your Account Sid and Token at twilio.com/user/account
  private static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  private static final String AUTH_TOKEN = "your_auth_token";
  private static final String WORKSPACE_SID = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  private static final String WORKFLOW_SID = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) throws TwilioRestException {
    TwilioTaskRouterClient client = new TwilioTaskRouterClient(ACCOUNT_SID, AUTH_TOKEN);

    client.deleteWorkflow(WORKSPACE_SID, WORKFLOW_SID);
  }
}
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

client.taskrouter.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                 .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                 .delete()
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.taskrouter.v1.workspace.Workflow;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Workflow.deleter(
                "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
            .delete();
    }
}
curl -X DELETE https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
Delete a Workflow

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.

Loading Code Samples...
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const twilio = require('twilio');

const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const workspaceSid = 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';

const client = new twilio.TaskRouterClient(accountSid, authToken, workspaceSid);

client.workspace.workflows.list((err, data) => {
  data.workflows.forEach(workflows => {
    console.log(workflows.friendly_name);
  });
});
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.taskrouter.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                 .workflows
                 .each(workflows => console.log(workflows.sid));
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.TaskRouter;
class Example 
{
  static void Main(string[] args) 
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    var client = new TaskRouterClient(AccountSid, AuthToken);

    WorkflowResult workflowResult = client.ListWorkflows(WorkspaceSid);
    foreach(Workflow workflow in workflowResult.Workflows) {
        Console.WriteLine(workflow.FriendlyName);
    }
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$authToken = "your_auth_token";
$workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

$client = new TaskRouter_Services_Twilio($accountSid, $authToken, $workspaceSid);

foreach($client->workspace->workflows as $workflow)
{
	echo $workflow->friendly_name;
}
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'rubygems' # This line not needed for ruby > 1.8
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
workspace_sid = 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

client = Twilio::REST::TaskRouterClient.new account_sid,
                                            auth_token,
                                            workspace_sid

client.workspace.workflows.list.each do |workflow|
  puts workflow.friendly_name
end
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Taskrouter.V1.Workspace;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var workflows = WorkflowResource.Read(
            pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        );

        foreach(var record in workflows)
        {
           Console.WriteLine(record.Sid);
        }
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Auth Token at twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$workflows = $twilio->taskrouter->v1->workspaces("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                    ->workflows
                                    ->read();

foreach ($workflows as $record) {
    print($record->sid);
}
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioTaskRouterClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
workspace_sid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

client = TwilioTaskRouterClient(account_sid, auth_token)

for workflow in client.workflows(workspace_sid).list():
    print(workflow.friendly_name)
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

workflows = @client.taskrouter
                   .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                   .workflows
                   .list

workflows.each do |record|
  puts record.sid
end
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.TwilioTaskRouterClient;
import com.twilio.sdk.resource.instance.taskrouter.Workflow;
import com.twilio.sdk.resource.instance.taskrouter.Workspace;
import com.twilio.sdk.resource.list.taskrouter.WorkflowList;

public class Example { 

  // Find your Account Sid and Token at twilio.com/user/account
  private static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  private static final String AUTH_TOKEN = "your_auth_token";
  private static final String WORKSPACE_SID = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) throws TwilioRestException {
    TwilioTaskRouterClient client = new TwilioTaskRouterClient(ACCOUNT_SID, AUTH_TOKEN);

    WorkflowList workflows = client.getWorkflows(WORKSPACE_SID);
    for(Workflow workflow : workflows) {
        System.out.println(workflow.getFriendlyName());
    }

    // alternatively
    Workspace workspace = client.getWorkspace(WORKSPACE_SID);
    workflows = workspace.getWorkflows();
    for(Workflow workflow : workflows) {
        System.out.println(workflow.getFriendlyName());
    }
  }
}
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

workflows = client.taskrouter \
                  .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                  .workflows \
                  .list()

for record in workflows:
    print(record.sid)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.taskrouter.v1.workspace.Workflow;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        ResourceSet<Workflow> workflows = 
            Workflow.reader("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
            .read();

        for(Workflow record : workflows) {
            System.out.println(record.getSid());
        }
    }
}
curl -X GET 'https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows' \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
  "meta": {
    "first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows?PageSize=50&Page=0",
    "key": "workflows",
    "last_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows?PageSize=50&Page=0",
    "next_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows?PageSize=50&Page=1",
    "page": 0,
    "page_size": 50,
    "previous_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows?PageSize=50&Page=0",
    "url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows?PageSize=50&Page=0"
  },
  "workflows": [
    {
      "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
      "assignment_callback_url": "http://example.com",
      "configuration": "task-routing:\n  - filter: \n      - 1 == 1\n    target:\n      - queue: WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n        set-priority: 0\n",
      "date_created": "2014-05-14T10:50:02Z",
      "date_updated": "2014-05-15T16:47:51Z",
      "document_content_type": "application/json",
      "fallback_assignment_callback_url": null,
      "friendly_name": "Default Fifo Workflow",
      "sid": "WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
      "task_reservation_timeout": 120,
      "url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
      "links": {
        "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Statistics",
        "real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/RealTimeStatistics",
        "cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/CumulativeStatistics"
      },
      "workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    }
  ],
  "workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const twilio = require('twilio');

const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const workspaceSid = 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';

const client = new twilio.TaskRouterClient(accountSid, authToken, workspaceSid);

const salesQueue = 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const marketingQueue = 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const supportQueue = 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const everyoneQueue = 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';

let configuration = {
  task_routing: {
    filters: [
      {
        targets: [
          {
            queue: salesQueue,
          },
        ],
        expression: 'type == "sales"',
      },
      {
        targets: [
          {
            queue: marketingQueue,
          },
        ],
        expression: 'type == "marketing"',
      },
      {
        targets: [
          {
            queue: supportQueue,
          },
        ],
        expression: 'type == "support"',
      },
    ],
    default_filter: {
      queue: everyoneQueue,
    },
  },
};

// or utilizing objects
const wb = require('twilio/lib/resources/task_router/WorkflowBuilder');

// sales
const salesTarget = new wb.WorkflowRuleTarget({
  queue: salesQueue,
});
const salesRule = new wb.WorkflowRule({
  expression: "type == 'sales'",
  targets: [salesTarget],
});

// marketing
const marketingTarget = new wb.WorkflowRuleTarget({
  queue: marketingQueue,
});
const marketingRule = new wb.WorkflowRule({
  expression: "type == 'marketing'",
  targets: [marketingTarget],
});

// support
const supportTarget = new wb.WorkflowRuleTarget({
  queue: supportQueue,
});
const supportRule = new wb.WorkflowRule({
  expression: "type == 'support'",
  targets: [supportTarget],
});

// default
const defaultTarget = new wb.WorkflowRuleTarget({
  queue: everyoneQueue,
});

// put all together
const taskRouting = new wb.TaskRoutingConfiguration({
  filters: [salesRule, marketingRule, supportRule],
  default_filter: defaultTarget,
});
const config = new wb.WorkflowConfiguration({
  taskRouting: taskRouting,
});

// convert to json
configuration = config.toJSON();

client.workspace.workflows.create({
  friendlyName: 'Sales, Marketing, Support Workflow',
  assignmentCallbackUrl: 'http://example.com',
  fallbackAssignmentCallbackUrl: 'http://example2.com',
  taskReservationTimeout: '30',
  configuration: configuration,
});
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.taskrouter.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
      .workflows
      .create({
         assignmentCallbackUrl: 'http://example.com',
         fallbackAssignmentCallbackUrl: 'http://example2.com',
         taskReservationTimeout: 30,
         friendlyName: 'Sales, Marketing, Support Workflow',
         configuration: JSON.stringify({
           task_routing: {
               filters: [
                 {
                     expression: `type=='sales'`,
                     targets: [
                       {
                           queue: 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
                       }
                     ]
                 },
                 {
                     expression: `type=='marketing'`,
                     targets: [
                       {
                           queue: 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
                       }
                     ]
                 },
                 {
                     expression: `type=='support'`,
                     targets: [
                       {
                           queue: 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
                       }
                     ]
                 }
               ],
               default_filter: {
                   queue: 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
               }
           }
       })
       })
      .then(workflow => console.log(workflow.sid))
      .done();
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using System.Collections.Generic;
using Twilio.TaskRouter;

class Example
{
  static void Main(string[] args)
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    string salesQueue = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string marketingQueue = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string supportQueue = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string everyoneQueue = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    var client = new TaskRouterClient(AccountSid, AuthToken);

    // sales
    var salesRule = new Filter()
    {
        FriendlyName = "Sales",
        Expression = "type == 'sales'",
        Targets = new List<Target>() {
            new Target {
                Queue = salesQueue
            }
        }
    };

    // marketing
    var marketingRule = new Filter()
    {
        FriendlyName = "Marketing",
        Expression = "type == 'marketing'",
        Targets = new List<Target>() {
            new Target {
                Queue = marketingQueue
            }
        }
    };

    // support
    var supportRule = new Filter
    {
        FriendlyName = "Support",
        Expression = "type == 'support'",
        Targets = new List<Target>() {
            new Target {
                Queue = supportQueue
            }
        }
    };

    var workflowConfiguration = new WorkflowConfiguration();

    workflowConfiguration.Filters.Add(salesRule);
    workflowConfiguration.Filters.Add(marketingRule);
    workflowConfiguration.Filters.Add(supportRule);
    workflowConfiguration.DefaultFilter = new Target() { Queue = everyoneQueue };

    // convert to json
    var workflowJSON = workflowConfiguration.ToString();

    // call rest api
    Workflow workflow = client.AddWorkflow(WorkspaceSid, "Sales, Marketing, Support Workflow", workflowJSON, "http://example.com", "http://example2.com", 30);
    Console.WriteLine(workflow.FriendlyName);
  }
}
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'rubygems' # This line not needed for ruby > 1.8
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
workspace_sid = 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

client = Twilio::REST::TaskRouterClient.new(account_sid,
                                            auth_token,
                                            workspace_sid)

# Queues
sales_sid = 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
marketing_sid = 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
support_sid = 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
everyone_sid = 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

sales_queue_target = Twilio::TaskRouter::WorkflowRuleTarget.new sales_sid
sales_queue_targets = [sales_queue_target]
sales_rule = Twilio::TaskRouter::WorkflowRule.new 'type == "sales"',
                                                  sales_queue_targets

marketing_target = Twilio::TaskRouter::WorkflowRuleTarget.new marketing_sid
marketing_targets = [marketing_target]
marketing_rule = Twilio::TaskRouter::WorkflowRule.new 'type == "marketing"',
                                                      marketing_targets

support_target = Twilio::TaskRouter::WorkflowRuleTarget.new support_sid
support_targets = [support_target]
support_rule = Twilio::TaskRouter::WorkflowRule.new 'type == "support"',
                                                    support_targets

rules = [sales_rule, marketing_rule, support_rule]
default_target = Twilio::TaskRouter::WorkflowRuleTarget.new everyone_sid

config = Twilio::TaskRouter::WorkflowConfiguration.new rules, default_target
json = config.to_json

workflow = client.workspace.workflows.create(
  friendly_name: 'Sales, Marketing, Support Workflow',
  assignment_callback_url: 'http://example.com',
  fallback_assignment_callback_url: 'http://example.2com',
  task_reservation_timeout: '30',
  configuration: json
)

puts workflow.friendly_name
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Taskrouter.V1.Workspace;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var configuration = JsonConvert.SerializeObject(new Dictionary<string, Object>()
        {
            {"task_routing", new Dictionary<string, Object>()
                {
                    {"filters", new object [] {
                        new Dictionary<string, Object>()
                        {
                            {"expression", "type=='sales'"},
                            {"targets", new object [] {
                                new Dictionary<string, Object>()
                                {
                                    {"queue", "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}
                                }
                            }}
                        },
                        new Dictionary<string, Object>()
                        {
                            {"expression", "type=='marketing'"},
                            {"targets", new object [] {
                                new Dictionary<string, Object>()
                                {
                                    {"queue", "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}
                                }
                            }}
                        },
                        new Dictionary<string, Object>()
                        {
                            {"expression", "type=='support'"},
                            {"targets", new object [] {
                                new Dictionary<string, Object>()
                                {
                                    {"queue", "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}
                                }
                            }}
                        }
                    }},
                    {"default_filter", new Dictionary<string, Object>()
                        {
                            {"queue", "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}
                        }}
                }}
        }, Formatting.Indented);

        var workflow = WorkflowResource.Create(
            assignmentCallbackUrl: new Uri("http://example.com"),
            fallbackAssignmentCallbackUrl: new Uri("http://example2.com"),
            taskReservationTimeout: 30,
            friendlyName: "Sales, Marketing, Support Workflow",
            configuration: configuration,
            pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        );

        Console.WriteLine(workflow.Sid);
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Auth Token at twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$workflow = $twilio->taskrouter->v1->workspaces("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                   ->workflows
                                   ->create("Sales, Marketing, Support Workflow", // friendlyName
                                            array(
                                                "task_routing" => array(
                                                    "filters" => array(
                                                        array(
                                                            "expression" => "type=='sales'",
                                                            "targets" => array(
                                                                array(
                                                                    "queue" => "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                                                                )
                                                            )
                                                        ),
                                                        array(
                                                            "expression" => "type=='marketing'",
                                                            "targets" => array(
                                                                array(
                                                                    "queue" => "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                                                                )
                                                            )
                                                        ),
                                                        array(
                                                            "expression" => "type=='support'",
                                                            "targets" => array(
                                                                array(
                                                                    "queue" => "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                                                                )
                                                            )
                                                        )
                                                    ),
                                                    "default_filter" => array(
                                                        "queue" => "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                                                    )
                                                )
                                            ), // configuration
                                            array(
                                                "assignmentCallbackUrl" => "http://example.com",
                                                "fallbackAssignmentCallbackUrl" => "http://example2.com",
                                                "taskReservationTimeout" => 30
                                            )
                                   );

print($workflow->sid);
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioTaskRouterClient
from twilio.task_router.workflow_ruletarget import WorkflowRuleTarget
from twilio.task_router.workflow_rule import WorkflowRule
from twilio.task_router.workflow_config import WorkflowConfig

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
workspace_sid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

client = TwilioTaskRouterClient(account_sid, auth_token)

rules = []

sales_queue_sid = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
marketing_queue_sid = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
support_queue_sid = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
everyone_queue_sid = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

salesRuleTargets = []
salesRuleTarget = WorkflowRuleTarget(sales_queue_sid, None, None, None)
salesRuleTargets.append(salesRuleTarget)
salesRule = WorkflowRule("type=='sales'", salesRuleTargets, None)

marketingRuleTargets = []
marketingRuleTarget = WorkflowRuleTarget(marketing_queue_sid, None, None, None)
marketingRuleTargets.append(marketingRuleTarget)
marketingRule = WorkflowRule("type=='marketing'", marketingRuleTargets, None)

supportRuleTargets = []
supportRuleTarget = WorkflowRuleTarget(support_queue_sid, None, None, None)
supportRuleTargets.append(supportRuleTarget)
supportRule = WorkflowRule("type=='support'", supportRuleTargets, None)

rules.append(salesRule)
rules.append(marketingRule)
rules.append(supportRule)

defaultTarget = WorkflowRuleTarget(everyone_queue_sid, None, None, None)
config = WorkflowConfig(rules, defaultTarget)
json = config.to_json()

workflow = client.workflows(workspace_sid).create(
    friendly_name='Sales, Marketing, Support Workflow',
    assignment_callback_url='http://example.com',
    fallback_assignment_callback_url='http://example2.com',
    task_reservation_timeout='30',
    configuration=json
)

print(workflow.friendly_name)
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

workflow = @client.taskrouter
  .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .workflows
  .create(
     assignment_callback_url: 'http://example.com',
     fallback_assignment_callback_url: 'http://example2.com',
     task_reservation_timeout: 30,
     friendly_name: 'Sales, Marketing, Support Workflow',
     configuration: {
       'task_routing' => {
           'filters' => [
               {
                   'expression' => "type=='sales'",
                   'targets' => [
                       {
                           'queue' => 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
                       },
                   ]
               },
               {
                   'expression' => "type=='marketing'",
                   'targets' => [
                       {
                           'queue' => 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
                       },
                   ]
               },
               {
                   'expression' => "type=='support'",
                   'targets' => [
                       {
                           'queue' => 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
                       },
                   ]
               },
           ],
           'default_filter' => {
               'queue' => 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
           }
       }
   }.to_json
   )

puts workflow.sid
// Install the Java helper library from twilio.com/docs/java/install
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import java.lang.Exception;
import com.twilio.sdk.TwilioTaskRouterClient;
import com.twilio.sdk.resource.instance.taskrouter.Workspace;
import com.twilio.sdk.resource.instance.taskrouter.Workflow;
import com.twilio.sdk.taskrouter.WorkflowRule;
import com.twilio.sdk.taskrouter.WorkflowRuleTarget;
import com.twilio.sdk.taskrouter.WorkflowConfiguration;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  private static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  private static final String AUTH_TOKEN = "your_auth_token";
  private static final String WORKSPACE_SID = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) throws Exception {
    TwilioTaskRouterClient client = new TwilioTaskRouterClient(ACCOUNT_SID, AUTH_TOKEN);

    Workspace workspace = client.getWorkspace(WORKSPACE_SID);

    //Construct a workflow
    List<WorkflowRule> rules = new ArrayList<WorkflowRule>();

    String salesQueueSid = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    String marketingQueueSid = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    String supportQueueSid = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    String defaultQueue = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

    // sales
    List<WorkflowRuleTarget> salesTargets = new ArrayList<WorkflowRuleTarget>();
    WorkflowRuleTarget salesTarget = new WorkflowRuleTarget(salesQueueSid);
    salesTargets.add(salesTarget);
    WorkflowRule salesRule = new WorkflowRule("type == \"sales\"", salesTargets);

    // marketing
    List<WorkflowRuleTarget> marketingTargets = new ArrayList<WorkflowRuleTarget>();
    WorkflowRuleTarget marketingTarget = new WorkflowRuleTarget(marketingQueueSid);
    marketingTargets.add(marketingTarget);
    WorkflowRule marketingRule = new WorkflowRule("type == \"marketing\"", marketingTargets);

    // support
    List<WorkflowRuleTarget> supportTargets = new ArrayList<WorkflowRuleTarget>();
    WorkflowRuleTarget supportTarget = new WorkflowRuleTarget(supportQueueSid);
    supportTargets.add(supportTarget);
    WorkflowRule supportRule = new WorkflowRule("type == \"support\"", supportTargets);

    // default filter
    WorkflowRuleTarget defaultTarget = new WorkflowRuleTarget(defaultQueue);

    // put rules together in order in which the workflow should process them
    rules.add(salesRule);
    rules.add(marketingRule);
    rules.add(supportRule);

    // build workflow & convert to json
    WorkflowConfiguration config = new WorkflowConfiguration(rules, defaultTarget);
    String workflowJSON = config.toJSON();

    Map<String, String> workflowParams = new HashMap<String, String>();
    workflowParams.put("Configuration", workflowJSON);
    workflowParams.put("FriendlyName", "Sales, Marketing, Support Workflow");
    workflowParams.put("AssignmentCallbackUrl", "http://example.com");
    workflowParams.put("FallbackAssignmentCallbackUrl", "http://example2.com");
    workflowParams.put("TaskReservationTimeout", "30");
    Workflow workflow = workspace.createWorkflow(workflowParams);
  }
}
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client
import json


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

workflow = client.taskrouter \
    .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
    .workflows \
    .create(
         assignment_callback_url='http://example.com',
         fallback_assignment_callback_url='http://example2.com',
         task_reservation_timeout=30,
         friendly_name='Sales, Marketing, Support Workflow',
         configuration=json.dumps({
             'task_routing': {
                 'filters': [
                     {
                         'expression': "type=='sales'",
                         'targets': [
                             {
                                 'queue': 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
                             }
                         ]
                     },
                     {
                         'expression': "type=='marketing'",
                         'targets': [
                             {
                                 'queue': 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
                             }
                         ]
                     },
                     {
                         'expression': "type=='support'",
                         'targets': [
                             {
                                 'queue': 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
                             }
                         ]
                     }
                 ],
                 'default_filter': {
                     'queue': 'WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
                 }
             }
         })
     )

print(workflow.sid)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.taskrouter.v1.workspace.Workflow;

import java.net.URI;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Workflow workflow = Workflow.creator(
                "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                "Sales, Marketing, Support Workflow",
                "{\"task_routing\": {\"filters\": [{\"expression\": \"type=='sales'\", \"targets\": [{\"queue\": \"WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"}]}, {\"expression\": \"type=='marketing'\", \"targets\": [{\"queue\": \"WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"}]}, {\"expression\": \"type=='support'\", \"targets\": [{\"queue\": \"WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"}]}], \"default_filter\": {\"queue\": \"WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"}}}")
            .setAssignmentCallbackUrl(
                URI.create("http://example.com"))
            .setFallbackAssignmentCallbackUrl(
                URI.create("http://example2.com"))
            .setTaskReservationTimeout(30)
            .create();

        System.out.println(workflow.getSid());
    }
}
CONFIGURATION=$(cat << EOF
{
    "task_routing": {
        "default_filter": {
            "queue": "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        },
        "filters": [
            {
                "expression": "type=='sales'",
                "targets": [
                    {
                        "queue": "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                    }
                ]
            },
            {
                "expression": "type=='marketing'",
                "targets": [
                    {
                        "queue": "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                    }
                ]
            },
            {
                "expression": "type=='support'",
                "targets": [
                    {
                        "queue": "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                    }
                ]
            }
        ]
    }
}
EOF
)

curl -X POST https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows \
--data-urlencode "AssignmentCallbackUrl=http://example.com" \
--data-urlencode "FallbackAssignmentCallbackUrl=http://example2.com" \
--data-urlencode "TaskReservationTimeout=30" \
--data-urlencode "FriendlyName=Sales, Marketing, Support Workflow" \
--data-urlencode "Configuration=$CONFIGURATION" \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
  "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "assignment_callback_url": "http://example.com",
  "configuration": {
    "task_routing": {
      "filters": [
        {
          "expression": "type=='sales'",
          "targets": [
            {
              "queue": "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            }
          ]
        },
        {
          "expression": "type=='marketing'",
          "targets": [
            {
              "queue": "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            }
          ]
        },
        {
          "expression": "type=='support'",
          "targets": [
            {
              "queue": "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            }
          ]
        }
      ],
      "default_filter": {
        "queue": "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
      }
    }
  },
  "date_created": "2014-05-14T10:50:02Z",
  "date_updated": "2014-05-14T23:26:06Z",
  "document_content_type": "application/json",
  "fallback_assignment_callback_url": "http://example2.com",
  "friendly_name": "Sales, Marketing, Support Workflow",
  "sid": "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "task_reservation_timeout": 30,
  "url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "links": {
    "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Statistics",
    "real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/RealTimeStatistics",
    "cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/CumulativeStatistics"
  }
}
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const twilio = require('twilio');

const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const workspaceSid = 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const workflowSid = 'WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';

const client = new twilio.TaskRouterClient(accountSid, authToken, workspaceSid);

client.workspace.workflows(workflowSid).get((err, workflow) => {
  console.log(workflow.friendly_name);
});
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.taskrouter.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                 .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                 .fetch()
                 .then(workflow => console.log(workflow.friendlyName))
                 .done();
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.TaskRouter;
class Example 
{
  static void Main(string[] args) 
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string WorkflowSid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    var client = new TaskRouterClient(AccountSid, AuthToken);

    Workflow workflow = client.GetWorkflow(WorkspaceSid, WorkflowSid);
    Console.WriteLine(workflow.FriendlyName);
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$authToken = "your_auth_token";
$workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$workflowSid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

$client = new TaskRouter_Services_Twilio($accountSid, $authToken, $workspaceSid);

$workflow = $client->workspace->workflows->get($workflowSid);
echo $workflow->friendly_name;
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'rubygems' # This line not needed for ruby > 1.8
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
workspace_sid = 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
workflow_sid = 'WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

client = Twilio::REST::TaskRouterClient.new(account_sid,
                                            auth_token,
                                            workspace_sid)

workflow = client.workspace.workflows.get(workflow_sid)
puts workflow.friendly_name
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Taskrouter.V1.Workspace;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var workflow = WorkflowResource.Fetch(
            pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathSid: "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        );

        Console.WriteLine(workflow.FriendlyName);
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Auth Token at twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$workflow = $twilio->taskrouter->v1->workspaces("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                   ->workflows("WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                   ->fetch();

print($workflow->friendlyName);
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioTaskRouterClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
workspace_sid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
workflow_sid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

client = TwilioTaskRouterClient(account_sid, auth_token)

workflow = client.workflows(workspace_sid).get(workflow_sid)
print(workflow.friendly_name)
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

workflow = @client.taskrouter
                  .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                  .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                  .fetch

puts workflow.friendly_name
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.TwilioTaskRouterClient;
import com.twilio.sdk.resource.instance.taskrouter.Workflow;
import com.twilio.sdk.resource.instance.taskrouter.Workspace;

public class Example {
  // Find your Account Sid and Token at twilio.com/user/account
  private static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  private static final String AUTH_TOKEN = "your_auth_token";
  private static final String WORKSPACE_SID = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  private static final String WORKFLOW_SID = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) throws TwilioRestException {
    TwilioTaskRouterClient client = new TwilioTaskRouterClient(ACCOUNT_SID, AUTH_TOKEN);

    Workflow workflow = client.getWorkflow(WORKSPACE_SID, WORKFLOW_SID);
    System.out.println(workflow.getFriendlyName());

    //alternatively
    Workspace workspace = client.getWorkspace(WORKSPACE_SID);
    workflow = workspace.getWorkflow(WORKFLOW_SID);
    System.out.println(workflow.getFriendlyName());
  }
}
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

workflow = client.taskrouter \
                 .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                 .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                 .fetch()

print(workflow.friendly_name)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.taskrouter.v1.workspace.Workflow;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Workflow workflow = Workflow.fetcher(
                "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
            .fetch();

        System.out.println(workflow.getFriendlyName());
    }
}
curl -X GET 'https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
  "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "assignment_callback_url": "http://example.com",
  "configuration": "task-routing:\n  - filter: \n      - 1 == 1\n    target:\n      - queue: WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n        set-priority: 0\n",
  "date_created": "2014-05-14T10:50:02Z",
  "date_updated": "2014-05-14T23:26:06Z",
  "document_content_type": "application/json",
  "fallback_assignment_callback_url": null,
  "friendly_name": "Default Fifo Workflow",
  "sid": "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "task_reservation_timeout": 120,
  "url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "links": {
    "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Statistics",
    "real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/RealTimeStatistics",
    "cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/CumulativeStatistics"
  }
}
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
Format:
  • JSON
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const twilio = require('twilio');

const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const workspaceSid = 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const workflowSid = 'WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';

const client = new twilio.TaskRouterClient(accountSid, authToken, workspaceSid);

client.workspace.workflows(workflowSid).update({
  taskReservationTimeout: '20',
}, (err, workflow) => {
  console.log(workflow.task_reservation_timeout);
});
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.taskrouter.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                 .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                 .update({taskReservationTimeout: 20})
                 .then(workflow => console.log(workflow.friendlyName))
                 .done();
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.TaskRouter;
class Example 
{
  static void Main(string[] args) 
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string WorkflowSid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    var client = new TaskRouterClient(AccountSid, AuthToken);

    client.UpdateWorkflow(WorkspaceSid, WorkflowSid, null, null, null, null, 20);
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$authToken = "your_auth_token";
$workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$workflowSid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

$client = new TaskRouter_Services_Twilio($accountSid, $authToken, $workspaceSid);

$workflow = $client->workspace->workflows->get($workflowSid);
$workflow->update(
	array(
		'TaskReservationTimeout' => '20'
	)
);
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'rubygems' # This line not needed for ruby > 1.8
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
workspace_sid = 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
workflow_sid = 'WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

client = Twilio::REST::TaskRouterClient.new account_sid,
                                            auth_token,
                                            workspace_sid

workflow = client.workspace.workflows.get(workflow_sid)
workflow = workflow.update(task_reservation_timeout: '20')
puts workflow.task_reservation_timeout
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Taskrouter.V1.Workspace;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var workflow = WorkflowResource.Update(
            taskReservationTimeout: 20,
            pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathSid: "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        );

        Console.WriteLine(workflow.FriendlyName);
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Auth Token at twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$workflow = $twilio->taskrouter->v1->workspaces("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                   ->workflows("WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                                   ->update(array(
                                                "taskReservationTimeout" => 20
                                            )
                                   );

print($workflow->friendlyName);
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioTaskRouterClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
workspace_sid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
workflow_sid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

client = TwilioTaskRouterClient(account_sid, auth_token)

workflow = client.workflows(workspace_sid).update(
    workflow_sid, task_reservation_timout='20'
)
print(workflow.task_reservation_timeout)

# alternatively
workflow = client.workflows(workspace_sid).get(workflow_sid)
workflow = workflow.update(task_reservation_timeout='20')
print(workflow.task_reservation_timeout)
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

workflow = @client.taskrouter
                  .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                  .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                  .update(task_reservation_timeout: 20)

puts workflow.friendly_name
// Install the Java helper library from twilio.com/docs/java/install
import java.util.HashMap;
import java.util.Map;

import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.TwilioTaskRouterClient;
import com.twilio.sdk.resource.instance.taskrouter.Workflow;
import com.twilio.sdk.resource.instance.taskrouter.Workspace;

public class Example { 

  // Find your Account Sid and Token at twilio.com/user/account
  private static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  private static final String AUTH_TOKEN = "your_auth_token";
  private static final String WORKSPACE_SID = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  private static final String WORKFLOW_SID = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) throws TwilioRestException {
    TwilioTaskRouterClient client = new TwilioTaskRouterClient(ACCOUNT_SID, AUTH_TOKEN);

    Workflow workflow = client.getWorkflow(WORKSPACE_SID, WORKSPACE_SID);
    Map<String, String> params = new HashMap<String, String>();
    params.put("TaskReservationTimeout", "20");
    workflow.update(params);

    //alternatively
    Workspace workspace = client.getWorkspace(WORKSPACE_SID);
    workflow = workspace.getWorkflow(WORKFLOW_SID);
    workflow.update(params);
  }
}
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

workflow = client.taskrouter \
                 .workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                 .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                 .update(task_reservation_timeout=20)

print(workflow.friendly_name)
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.taskrouter.v1.workspace.Workflow;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Workflow workflow = Workflow.updater(
                "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
            .setTaskReservationTimeout(20).update();

        System.out.println(workflow.getFriendlyName());
    }
}
curl -X POST https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
--data-urlencode "TaskReservationTimeout=20" \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
{
  "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "assignment_callback_url": "http://example.com",
  "configuration": "task-routing:\n  - filter: \n      - 1 == 1\n    target:\n      - queue: WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n        set-priority: 0\n",
  "date_created": "2014-05-14T10:50:02Z",
  "date_updated": "2014-05-14T23:26:06Z",
  "document_content_type": "application/json",
  "fallback_assignment_callback_url": null,
  "friendly_name": "Default Fifo Workflow",
  "sid": "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "task_reservation_timeout": 20,
  "url": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "links": {
    "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Statistics",
    "real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/RealTimeStatistics",
    "cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/CumulativeStatistics"
  },
  "workspace_sid": "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
SDK Version:
  • 4.x
  • 5.x
Response Format:
  • json
SDK Version:
  • 6.x
  • 7.x
SDK Version:
  • 2.x
  • 3.x
SDK Version:
  • 4.x
  • 5.x
SDK Version:
  • 5.x
  • 6.x
SDK Version:
  • 4.x
  • 5.x
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
const twilio = require('twilio');

const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const workspaceSid = 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const workflowSid = 'WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';

const client = new twilio.TaskRouterClient(accountSid, authToken, workspaceSid);

client.workspace.workflows(workflowSid).delete();
// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.taskrouter.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                 .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                 .remove()
                 .then(workflow => console.log(workflow.sid))
                 .done();
// Download the twilio-csharp library from twilio.com/docs/csharp/install
using System;
using Twilio.TaskRouter;
class Example 
{
  static void Main(string[] args) 
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string AuthToken = "your_auth_token";
    string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string WorkflowSid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    var client = new TaskRouterClient(AccountSid, AuthToken);

    client.DeleteWorkflow(WorkspaceSid, WorkflowSid);
  }
}
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$authToken = "your_auth_token";
$workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$workflowSid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

$client = new TaskRouter_Services_Twilio($accountSid, $authToken, $workspaceSid);

$client->workspace->workflows->delete($workflowSid);
# Get twilio-ruby from twilio.com/docs/ruby/install
require 'rubygems' # This line not needed for ruby > 1.8
require 'twilio-ruby'

# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
workspace_sid = 'WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
workflow_sid = 'WWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'

client = Twilio::REST::TaskRouterClient.new(account_sid,
                                            auth_token,
                                            workspace_sid)

workflow = client.workspace.workflows.get(workflow_sid)
workflow.delete
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Taskrouter.V1.Workspace;


class Program 
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        WorkflowResource.Delete(
            pathWorkspaceSid: "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathSid: "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        );
    }
}
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Auth Token at twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$twilio->taskrouter->v1->workspaces("WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                       ->workflows("WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                       ->delete();
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioTaskRouterClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
workspace_sid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
activity_sid = "WAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

client = TwilioTaskRouterClient(account_sid, auth_token)

activity = client.activities(workspace_sid).get(activity_sid)
activity.delete()
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'rubygems'
require 'twilio-ruby'

# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)

@client.taskrouter.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                  .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                  .delete
// Install the Java helper library from twilio.com/docs/java/install
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.TwilioTaskRouterClient;
import com.twilio.sdk.resource.instance.taskrouter.Workspace;

public class Example { 

  // Find your Account Sid and Token at twilio.com/user/account
  private static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  private static final String AUTH_TOKEN = "your_auth_token";
  private static final String WORKSPACE_SID = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  private static final String WORKFLOW_SID = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  public static void main(String[] args) throws TwilioRestException {
    TwilioTaskRouterClient client = new TwilioTaskRouterClient(ACCOUNT_SID, AUTH_TOKEN);

    client.deleteWorkflow(WORKSPACE_SID, WORKFLOW_SID);
  }
}
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)

client.taskrouter.workspaces('WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                 .workflows('WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
                 .delete()
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.taskrouter.v1.workspace.Workflow;

public class Example {
    // Find your Account Sid and Token at twilio.com/console
    public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    public static final String AUTH_TOKEN = "your_auth_token";

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Workflow.deleter(
                "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
            .delete();
    }
}
curl -X DELETE https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Workflows/WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token