# Studio Flows API Quickstart

The quickest way to get started with the [Studio Flows API](/docs/studio/rest-api/v2) is to create a Flow using the [Studio Canvas in Console](https://www.twilio.com/console/studio) and then use the Flows API to fetch and update the Flow's JSON Definition.

**Note:** The examples in this quickstart use cURL, but complete code samples for the [Twilio SDKs](/docs/libraries) and the [Twilio CLI](/docs/twilio-cli/quickstart) are available in the [Studio REST API v2 docs](/docs/studio/rest-api/v2/flow).

## Create a new Flow from a template

Start by creating a new Flow in [Console](https://www.twilio.com/console/studio). Select the **Start from scratch** template and click **Next**, which will automatically create and load a new blank Flow in the Studio Canvas.

![New Flow template options: Start from scratch, Appointment Reminders, IVR / Phone Tree, SMS Chatbot.](https://docs-resources.prod.twilio.com/9b51bbc76d911361edfef269207f00dbe5d1632c044f26a98f1f631b4ef7deeb.png)

## Fetch the newly created Flow via the API

Use the Flow SID from the newly created Flow's URL to [fetch the definition from the API](/docs/studio/rest-api/v2/flow#fetch-a-flow-resource).

Example using cURL:

```bash
curl https://studio.twilio.com/v2/Flows/FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -u ACCOUNT_SID:TOKEN 
```

Results:

```bash
{
   "status" : "published",
   "friendly_name" : "My first flow",
   "sid" : "FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
   "revision" : 1,
   "date_updated" : null,
   "account_sid" : "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
   "errors" : [],
   "url" : "https://studio.twilio.com/v2/Flows/FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
   "date_created" : "2020-01-15T18:17:38Z",
   "links" : {
      "revisions" : "https://studio.twilio.com/v2/Flows/FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Revisions"
   },
   "commit_message" : null,
   "definition" : {
      "flags" : {
         "allow_concurrent_calls" : true
      },
      "initial_state" : "Trigger",
      "description" : "A New Flow",
      "states" : [
         {
            "properties" : {
               "offset" : {
                  "y" : 0,
                  "x" : 0
               }
            },
            "transitions" : [],
            "name" : "Trigger",
            "type" : "trigger"
         }
      ]
   },
   "valid" : true
}

```

## Modify the Flow via the REST API

Add a [Say/Play Widget](/docs/studio/rest-api/v2/flow-definition#sayplay) to the definition and run a [Flow update command](/docs/studio/rest-api/v2/flow#fetch-a-flow-resource).

To connect the Say/Play Widget, add its JSON as a new item in the `states` array, and set the Widget's friendly name to the `next` property of the Trigger's `incomingCall` transition:

```javascript
...
{
  "next" : "say_play_1",
  "event" : "incomingCall"
}
...
```

**Complete code example:**

```bash
DEFINITION=$(cat << EOF
{
      "flags" : {
         "allow_concurrent_calls" : true
      },
      "description" : "A New Flow",
      "states" : [
         {
            "properties" : {
               "offset" : {
                  "x" : 0,
                  "y" : 0
               }
            },
            "name" : "Trigger",
            "type" : "trigger",
            "transitions" : [
               {
                  "event" : "incomingMessage"
               },
               {
                  "next" : "say_play_1",
                  "event" : "incomingCall"
               },
               {
                  "event" : "incomingRequest"
               }
            ]
         },
         {
            "transitions" : [
               {
                  "event" : "audioComplete"
               }
            ],
            "type" : "say-play",
            "properties" : {
               "loop" : 1,
               "say" : "Hello World",
               "offset" : {
                  "x" : 100,
                  "y" : 200
               }
            },
            "name" : "say_play_1"
         }
      ],
      "initial_state" : "Trigger"
   }
EOF
)

curl -X POST https://studio.twilio.com/v2/Flows/FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
--data-urlencode "CommitMessage=First update" \
--data-urlencode "Definition=$DEFINITION" \
--data-urlencode "Status=published" \
-u ACCOUNT_SID:TOKEN

```

> \[!NOTE]
>
> To import the Flow into another account or subaccount, just change the credentials to use the receiving account's Account SID and Token.

## Reload the Flow in Console to view the changes

Now that the Flow has been updated via the API, reload the Flow in the Studio Canvas to see the updated layout with the new Widget in place.

![Twilio Studio flow with trigger and say\_play\_1 node saying 'Hello World'.](https://docs-resources.prod.twilio.com/ea8c0291d5bb12bc5c7ede3a548c86d5dc48c4dc68deb5959e03efee1112a1c4.png)

## That's It

Now you're ready to try some real world examples for your use case. Be sure to download the latest version of our [server-side SDK](/docs/libraries) for your language — or update your [Twilio CLI](/docs/twilio-cli/quickstart) — and [explore the rest of the API](/docs/studio/rest-api/v2).
