> For a complete page index, fetch https://docs.synthflow.ai/llms.txt. For full documentation content, fetch https://docs.synthflow.ai/llms-full.txt.

# Create a subaccount

POST https://api.synthflow.ai/v2/subaccounts
Content-Type: application/json



Reference: https://docs.synthflow.ai/api-reference/platform-api/subaccounts/create-subaccount

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Synthflow APIs
  version: 1.0.0
paths:
  /subaccounts:
    post:
      operationId: create-subaccount
      summary: Create a subaccount
      description: ''
      tags:
        - ''
      parameters:
        - name: Authorization
          in: header
          description: Bearer authentication
          required: true
          schema:
            type: string
      responses:
        '200':
          description: '200'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/create-subaccount_Response_200'
        '400':
          description: '400'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Create-subaccountRequestBadRequestError'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                subaccount_name:
                  type: string
                  description: >-
                    The name for the new subaccount. This should be a unique
                    identifier that distinguishes it from other subaccounts
                    within the main account.
                user_email:
                  type: string
                  description: >-
                    This is the email address of the user you wish to invite to
                    the subaccount. When this optional parameter is filled in, a
                    "sign in" link will be generated and sent back in the
                    response. The user can use this link to sign in and set up
                    their account.
                twilio_account_sid:
                  type: string
                  description: This is the Twilio SID of the subaccount.
                twilio_auth_token:
                  type: string
                  description: This is the Twilio Token of the subaccount.
                concurrency:
                  type: integer
                  description: >-
                    The maximum number of calls the subaccount can handle at the
                    same time.
                max_agents:
                  type:
                    - integer
                    - 'null'
                  description: >-
                    The maximum number of agents the subaccount is allowed to
                    create. Null if no limit is set.
                max_minutes:
                  type:
                    - integer
                    - 'null'
                  description: >-
                    The maximum number of minutes allocated to this subaccount.
                    Null if no limit is set.
                max_workflow_runs:
                  type:
                    - integer
                    - 'null'
                  description: >-
                    The maximum number of workflow runs allocated to this
                    subaccount. Null if no limit is set.
                grant_permissions:
                  type: array
                  items:
                    $ref: >-
                      #/components/schemas/SubaccountsPostRequestBodyContentApplicationJsonSchemaGrantPermissionsItems
                  description: >-
                    Permissions to grant to the subaccount. Duplicate values are
                    not allowed, and any value also present in
                    `revoke_permissions` is rejected by the API.
                revoke_permissions:
                  type: array
                  items:
                    $ref: >-
                      #/components/schemas/SubaccountsPostRequestBodyContentApplicationJsonSchemaRevokePermissionsItems
                  description: >-
                    Permissions to revoke from the subaccount. Duplicate values
                    are not allowed, and any value also present in
                    `grant_permissions` is rejected by the API.
              required:
                - subaccount_name
servers:
  - url: https://api.synthflow.ai/v2
    description: Global
  - url: https://api.us.synthflow.ai/v2
    description: United States
  - url: https://api.eu.synthflow.ai/v2
    description: European Union
components:
  schemas:
    SubaccountsPostRequestBodyContentApplicationJsonSchemaGrantPermissionsItems:
      type: string
      enum:
        - inbound
        - outbound
        - widget
        - chat
        - assistants
        - knowledge_base
        - actions
        - workflows
        - contacts
        - phone_numbers
        - logs
        - simulations
        - analytics
      title: >-
        SubaccountsPostRequestBodyContentApplicationJsonSchemaGrantPermissionsItems
    SubaccountsPostRequestBodyContentApplicationJsonSchemaRevokePermissionsItems:
      type: string
      enum:
        - inbound
        - outbound
        - widget
        - chat
        - assistants
        - knowledge_base
        - actions
        - workflows
        - contacts
        - phone_numbers
        - logs
        - simulations
        - analytics
      title: >-
        SubaccountsPostRequestBodyContentApplicationJsonSchemaRevokePermissionsItems
    status:
      type: string
      description: Whether the request was successful.
      title: status
    subaccount_id:
      type: string
      description: Subaccount ID.
      title: subaccount_id
    SubaccountsPostResponsesContentApplicationJsonSchemaResponse:
      type: object
      properties:
        subaccount_id:
          $ref: '#/components/schemas/subaccount_id'
        api_key:
          type: string
          description: Subaccount API key.
        user_email:
          type: string
          description: Subaccount email.
        sign_in_link:
          type: string
          description: The invite link that can be used to log in to the account.
        twilio_connected_successfully:
          type: boolean
          description: Whether a successful Twilio connection was established.
      title: SubaccountsPostResponsesContentApplicationJsonSchemaResponse
    create-subaccount_Response_200:
      type: object
      properties:
        status:
          $ref: '#/components/schemas/status'
        response:
          $ref: >-
            #/components/schemas/SubaccountsPostResponsesContentApplicationJsonSchemaResponse
      title: create-subaccount_Response_200
    Create-subaccountRequestBadRequestError:
      type: object
      properties: {}
      title: Create-subaccountRequestBadRequestError
  securitySchemes:
    sec0:
      type: http
      scheme: bearer

```

## Examples



**Request**

```json
{
  "subaccount_name": "string",
  "user_email": "subaccount@example.com",
  "concurrency": 10,
  "max_agents": 5,
  "max_minutes": 1000,
  "max_workflow_runs": 500,
  "grant_permissions": [
    "inbound",
    "outbound",
    "logs"
  ],
  "revoke_permissions": [
    "widget",
    "phone_numbers"
  ]
}
```

**Response**

```json
{
  "status": "ok",
  "response": {
    "subaccount_id": "1726005822670x239735712159542050",
    "api_key": "1739402187001x558120349876512300",
    "user_email": "onboarding+acme@synthflow.ai",
    "sign_in_link": "https://fine-tuner.ai/invite/1739402199888x447700112233445500",
    "twilio_connected_successfully": true
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.synthflow.ai/v2/subaccounts"

payload = {
    "subaccount_name": "string",
    "user_email": "subaccount@example.com",
    "concurrency": 10,
    "max_agents": 5,
    "max_minutes": 1000,
    "max_workflow_runs": 500,
    "grant_permissions": ["inbound", "outbound", "logs"],
    "revoke_permissions": ["widget", "phone_numbers"]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.synthflow.ai/v2/subaccounts"

	payload := strings.NewReader("{\n  \"subaccount_name\": \"string\",\n  \"user_email\": \"subaccount@example.com\",\n  \"concurrency\": 10,\n  \"max_agents\": 5,\n  \"max_minutes\": 1000,\n  \"max_workflow_runs\": 500,\n  \"grant_permissions\": [\n    \"inbound\",\n    \"outbound\",\n    \"logs\"\n  ],\n  \"revoke_permissions\": [\n    \"widget\",\n    \"phone_numbers\"\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.synthflow.ai/v2/subaccounts")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"subaccount_name\": \"string\",\n  \"user_email\": \"subaccount@example.com\",\n  \"concurrency\": 10,\n  \"max_agents\": 5,\n  \"max_minutes\": 1000,\n  \"max_workflow_runs\": 500,\n  \"grant_permissions\": [\n    \"inbound\",\n    \"outbound\",\n    \"logs\"\n  ],\n  \"revoke_permissions\": [\n    \"widget\",\n    \"phone_numbers\"\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.synthflow.ai/v2/subaccounts")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"subaccount_name\": \"string\",\n  \"user_email\": \"subaccount@example.com\",\n  \"concurrency\": 10,\n  \"max_agents\": 5,\n  \"max_minutes\": 1000,\n  \"max_workflow_runs\": 500,\n  \"grant_permissions\": [\n    \"inbound\",\n    \"outbound\",\n    \"logs\"\n  ],\n  \"revoke_permissions\": [\n    \"widget\",\n    \"phone_numbers\"\n  ]\n}")
  .asString();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.synthflow.ai/v2/subaccounts");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"subaccount_name\": \"string\",\n  \"user_email\": \"subaccount@example.com\",\n  \"concurrency\": 10,\n  \"max_agents\": 5,\n  \"max_minutes\": 1000,\n  \"max_workflow_runs\": 500,\n  \"grant_permissions\": [\n    \"inbound\",\n    \"outbound\",\n    \"logs\"\n  ],\n  \"revoke_permissions\": [\n    \"widget\",\n    \"phone_numbers\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "subaccount_name": "string",
  "user_email": "subaccount@example.com",
  "concurrency": 10,
  "max_agents": 5,
  "max_minutes": 1000,
  "max_workflow_runs": 500,
  "grant_permissions": ["inbound", "outbound", "logs"],
  "revoke_permissions": ["widget", "phone_numbers"]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.synthflow.ai/v2/subaccounts")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```