Skip to contentSkip to navigationSkip to topbar
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.


Validate Properties

validate-properties page anchor
Property nameTypeRequiredDescriptionChild properties
validboolean

Optional

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
Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
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

Optional

Description of change made in the revision.

Validate FlowLink to code sample: Validate Flow
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function updateFlowValidate() {
11
const flowValidate = await client.studio.v2.flowValidate.update({
12
definition: {
13
description: "A New Flow",
14
flags: {
15
allow_concurrent_calls: true,
16
},
17
initial_state: "Trigger",
18
states: [
19
{
20
name: "Trigger",
21
properties: {
22
offset: {
23
x: 0,
24
y: 0,
25
},
26
},
27
transitions: [],
28
type: "trigger",
29
},
30
],
31
},
32
friendlyName: "Test Flow",
33
status: "published",
34
});
35
36
console.log(flowValidate.valid);
37
}
38
39
updateFlowValidate();

Output

1
{
2
"valid": true
3
}

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:

1
client.studio.v2.flowValidate
2
.update({
3
friendlyName: 'Test Flow',
4
status: 'published',
5
definition: {
6
description: 'A New Flow',
7
flags: {
8
allow_concurrent_calls: true
9
},
10
initial_state: 'test', // changed from Trigger -> test for demonstration
11
states: [
12
{
13
name: 'Trigger',
14
properties: {
15
offset: {
16
x: 0,
17
y: 0
18
}
19
},
20
transitions: [
21
],
22
type: '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
{
2
errors: [
3
{
4
message: 'must match a widget name',
5
property_path: '#/initial_state'
6
}
7
],
8
warnings: []
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.

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.