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
The status of the Flow. Can be: draft
or published
.
draft
published
Description of change made in the revision.
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:
_28client.studio.v2.flowValidate_28 .update({_28 friendlyName: 'Test Flow',_28 status: 'published',_28 definition: {_28 description: 'A New Flow',_28 flags: {_28 allow_concurrent_calls: true_28 },_28 initial_state: 'test', // changed from Trigger -> test for demonstration_28 states: [_28 {_28 name: 'Trigger',_28 properties: {_28 offset: {_28 x: 0,_28 y: 0_28 }_28 },_28 transitions: [_28 ],_28 type: 'trigger'_28 }_28 ]_28 }_28 })_28 .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:
_10{_10 errors: [_10 {_10 message: 'must match a widget name',_10 property_path: '#/initial_state'_10 }_10 ],_10 warnings: []_10}
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.