The Flow Validate endpoint will validate a Flow definition without creating a new Flow. It accepts the same parameters as the Create Flow method and returns {"valid":true}
in the response payload if no errors were found; otherwise, if the definition fails validation, the endpoint returns an error response.
Boolean if the flow definition is valid.
POST https://studio.twilio.com/v2/Flows/Validate
application/x-www-form-urlencoded
The status of the Flow. Can be: draft
or published
.
draft
published
Description of change made in the revision.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function updateFlowValidate() {11const flowValidate = await client.studio.v2.flowValidate.update({12definition: {13description: "A New Flow",14flags: {15allow_concurrent_calls: true,16},17initial_state: "Trigger",18states: [19{20name: "Trigger",21properties: {22offset: {23x: 0,24y: 0,25},26},27transitions: [],28type: "trigger",29},30],31},32friendlyName: "Test Flow",33status: "published",34});3536console.log(flowValidate.valid);37}3839updateFlowValidate();
1{2"valid": true3}
An error response will be returned if the given Flow definition fails validation. Use the details
object in the error response to find all errors present within the definition. Each error contains a message along with the path of where the issue took place.
For example, the initial_state
parameter for this Flow definition has been changed to an invalid value:
1client.studio.v2.flowValidate2.update({3friendlyName: 'Test Flow',4status: 'published',5definition: {6description: 'A New Flow',7flags: {8allow_concurrent_calls: true9},10initial_state: 'test', // changed from Trigger -> test for demonstration11states: [12{13name: 'Trigger',14properties: {15offset: {16x: 0,17y: 018}19},20transitions: [21],22type: 'trigger'23}24]25}26})27.then(flow_validate => console.log(flow_validate))28.catch(e => console.log(e.details));
If an error response is delivered, the details will be logged to console. After the API request is made, the console logs this information:
1{2errors: [3{4message: 'must match a widget name',5property_path: '#/initial_state'6}7],8warnings: []9}
The message indicates that the name must be a valid Widget name. This property is located at #/initial_state
, which was where the invalid value was inputted for this example.