Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Flow Validate


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.


FlowValidate Properties

flowvalidate-properties page anchor
validboolean
Not PII

Boolean if the flow definition is valid.


POST https://studio.twilio.com/v2/Flows/Validate

Request body parameters

request-body-parameters page anchor
FriendlyNamestringrequired

The string that you assigned to describe the Flow.


Statusenum<string>required

The status of the Flow. Can be: draft or published.

Possible values:
draftpublished

Definitionobjectrequired

JSON representation of flow definition.


CommitMessagestring

Description of change made in the revision.

Validate Flow

validate-flow-1 page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_34
// Download the helper library from https://www.twilio.com/docs/node/install
_34
// Find your Account SID and Auth Token at twilio.com/console
_34
// and set the environment variables. See http://twil.io/secure
_34
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_34
const authToken = process.env.TWILIO_AUTH_TOKEN;
_34
const client = require('twilio')(accountSid, authToken);
_34
_34
client.studio.v2.flowValidate
_34
.update({
_34
friendlyName: 'Test Flow',
_34
status: 'published',
_34
definition: {
_34
description: 'A New Flow',
_34
flags: {
_34
allow_concurrent_calls: true
_34
},
_34
initial_state: 'Trigger',
_34
states: [
_34
{
_34
name: 'Trigger',
_34
properties: {
_34
offset: {
_34
x: 0,
_34
y: 0
_34
}
_34
},
_34
transitions: [
_34
],
_34
type: 'trigger'
_34
}
_34
]
_34
}
_34
})
_34
.then(flow_validate => console.log(flow_validate.valid));

Output

_10
{
_10
"valid": true
_10
}


Troubleshoot using error details

troubleshoot-using-error-details page anchor

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:


_28
client.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.


Rate this page: