# Create a Flex instance programmatically

This page outlines how to authenticate and get started with the Flex Instances APIs. The Instances API lets you programmatically install Flex for existing Twilio accounts.

## Authentication

Twilio supports HTTP Basic authentication. Include the **Basic Authentication** header, where the `username:password` pair is one of the following:

| Username    | Password       | Best practice                                                                                             |
| ----------- | -------------- | --------------------------------------------------------------------------------------------------------- |
| API Key     | API Key Secret | **Recommended**: When a key is compromised or no longer in use, revoke it to prevent unauthorized access. |
| Account SID | AuthToken      | Limits your use to local testing.                                                                         |

For more information, see [Twilio API requests](/docs/usage/requests-to-twilio).

## Base URL

```bash
https://flex-api.twilio.com
```

## Create a Flex instance

Create a Flex instance by sending a `POST` request to the following endpoint:

```bash
POST "https://flex-api.twilio.com/v2/Instances"
```

### Header

| Header                  | Value type   | Description      |
| ----------------------- | ------------ | ---------------- |
| `I-Twilio-Auth-Account` | ACCOUNT\_SID | Your account SID |

### Request body

The following example shows a request to create a Flex instance:

```json
{
   "conversations": {
      "default": true
   }
}
```

| Input                   | Type    | Description                                                                                                                |
| ----------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------- |
| `conversations.default` | Boolean | If `true`, the Flex conversation service created during provisioning is set as the account's default conversation service. |

### Response body

A successful request returns a `201 Created` status code and the following response:

```json
{
  "flex_instance_sid": "GOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "status": "creation-in-progress",
  "date_created": "2016-08-01T22:10:40Z",
  "date_updated": "2016-08-01T22:10:40Z"
}
```

## Get Flex instance

Fetch information about a Flex instance by sending a `GET` request to the following endpoint:

```bash
GET "https://flex-api.twilio.com/v2/Instances/INSTANCE_SID"
```

### Header

| Header                  | Value type   | Description      |
| ----------------------- | ------------ | ---------------- |
| `I-Twilio-Auth-Account` | ACCOUNT\_SID | Your account SID |

### Response body

A successful request returns a `200 OK` status code and the following response:

```json
{
  "flex_instance_sid": "GOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "status": "ready",
  "date_created": "2016-08-01T22:10:40Z",
  "date_updated": "2016-08-01T22:10:40Z"
}
```
