Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page
Looking for more inspiration?Visit the

REST API v1


Studio REST API v2 is Generally Available

The Studio REST API v2 supports Flow publishing and lets you programmatically create and update Flows.

We recommend all customers use the v2 API to take advantage of the latest features.

Switch to V2(link takes you to an external page)

The Studio v1 REST API lets you trigger flows programmatically and also retrieve information about your flows and executions. The Incoming Request Trigger on your flow will fire when you create an Execution via the REST API. Important: When triggering flows with the API, configure your phone number(link takes you to an external page) with your Studio flow. If you don't configure the phone number, users won't be able to reply to your messages or interact with your IVR.

HTTP POST to create an Execution

To trigger a new Execution of your Flow via the REST API, make an HTTP POST request to:

https://studio.twilio.com/v1/Flows/{FlowSid}/Executions

POST Parameters

Required Parameters

ParameterDescription
ToThe Contact phone number (or other identifier) to start a Studio Flow Execution, available as variable {{contact.channel.address}}
FromThe Twilio phone number (or other identifier such as a SID of a Messaging Service) to send messages or initiate calls from during the Flow Execution, available as variable {{flow.channel.address}}

Important: The To and From phone numbers must be formatted as E.164 (e.g. +1xxxxxxxxxx) to ensure a Contact's session is tracked correctly.

Optional Parameters

ParameterDescription
ParametersJSON data that will be added to your flow's context and can be accessed as variables inside your flow. For example, if you pass in Parameters={"name":"Zeke"} then inside a widget you can reference the variable {{flow.data.name}} which will return the string "Zeke". Note: the JSON value must explicitly be passed as a string, not as a hash object. Depending on your particular HTTP library, you may need to add quotes or URL encode your JSON string. See curl examples below.

Quick Examples:

Using curl on the command line, you can trigger a flow like so:

Trigger a Flow Execution with curlLink to code sample: Trigger a Flow Execution with curl
1
curl -X POST "https://studio.twilio.com/v1/Flows/FW9d816f0b90d2a10b913868462e339d29/Executions" \
2
--data-urlencode "To=+1646221xxxx" \
3
--data-urlencode "From=+1331481xxxx" \
4
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN

To pass in additional custom data to your flow, add a Parameters= parameter.

Trigger a Flow Execution with custom parametersLink to code sample: Trigger a Flow Execution with custom parameters
1
PARAMETERS_OBJ=$(cat << EOF
2
{
3
"name": "zeke"
4
}
5
EOF
6
)
7
curl -X POST "https://studio.twilio.com/v1/Flows/FW9d816f0b90d2a10b913868462e339d29/Executions" \
8
--data-urlencode "To=+1646221xxxx" \
9
--data-urlencode "From=+1331481xxxx" \
10
--data-urlencode "Parameters=$PARAMETERS_OBJ" \
11
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN

If you are using a Twilio SDK, you can trigger a flow like so:

Ruby:

Trigger a Flow Execution in Ruby

trigger-a-flow-execution-in-ruby page anchor
Twilio::REST::Client.new(ACCOUNT_SID, AUTH_TOKEN).studio.v1.flows('FW9d816f0b90d2a10b913868462e339d29').executions.create(from: '+1331481xxxx', to: '1646221xxxx', parameters: '{"name":"Clément"}')

NodeJS:

Trigger a Flow Execution in Node.js

trigger-a-flow-execution-in-nodejs page anchor
TwilioClient.studio.v1.flows('FW9d816f0b90d2a10b913868462e339d29').executions.create({ to: '+1646221xxxx', from: '+1331481xxxx', parameters: JSON.stringify({name: "Clément"})}).then(function(execution) { console.log(execution.sid); });

PHP:

Trigger a Flow Execution in PHP

trigger-a-flow-execution-in-php page anchor
$twilio->studio->v1->flows("FW9d816f0b90d2a10b913868462e339d29")->executions->create("+1646221xxxx", "+1331481xxxx", array("parameters" => array("foo" => "bar")));

The Executions resource page documents examples in other languages. For information on the other resources, check out the full REST API documentation for each resource below.


Studio REST API resources

studio-rest-api-resources page anchor
ResourceDescription
FlowAllows you to retrieve a list of Flows created in your account.
ExecutionAllows you to create Executions that will act on the incoming REST API trigger for the Flow specified.
Execution ContextThe execution context gives a JSON representation of your flow and its widgets at the time of execution.
StepEach move through your flow is a Step. The Steps resource allows you to retrieve the steps for a given execution.
Step ContextStep context ties a JSON representation of data parsed as part of an individual widget.

To authenticate requests to the Twilio APIs, Twilio supports HTTP Basic authentication(link takes you to an external page). Use your API key as the username and your API key secret as the password. You can create an API key either in the Twilio Console or using the API.

Note: Twilio recommends using API keys for authentication in production apps. For local testing, you can use your Account SID as the username and your Auth token as the password. You can find your Account SID and Auth Token in the Twilio Console(link takes you to an external page).

Learn more about Twilio API authentication.


If you use one of our SDKs for C#(link takes you to an external page), Java(link takes you to an external page), Node.js(link takes you to an external page), PHP(link takes you to an external page), Python, or Ruby(link takes you to an external page); you needn't worry about the URL for the API or how to do HTTP Basic authentication. The SDKs take care of it for you.


Engagements name change and deprecation

engagements-name-change-and-deprecation page anchor

During the beta of Twilio Studio (prior to August 1, 2018), Flow Executions were named Engagements, and the API for creating them used the /Engagements endpoint. Engagements were renamed to Executions across the Studio product and API. The /Engagements endpoint is deprecated and no longer functions; use the /Executions endpoint instead, available via REST and the Twilio SDKs. There is no functional difference between the two endpoints.


To handle API response error 429: "Too Many Requests"(link takes you to an external page) during traffic spikes or unexpected usage, follow REST API best practices, such as retries with exponential backoff.

When API rate limits are calculated, they are averaged over 10 seconds. This calculation method means that our REST APIs can handle rate spikes as long as the average number of requests over 10 seconds remains within the per-second rate limit.