> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.useroot.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.useroot.com/_mcp/server.

# Create a new subaccount

POST https://api.useroot.com/api/subaccounts
Content-Type: application/json

Creates a new subaccount for fund segregation within your root entity's main account.

**Request Body**

| Field | Type | Required | Description | Validation Rules |
|-------|------|----------|-------------|-----------------|
| `name` | String | Yes | Name of the subaccount | Must be between 1 and 100 characters |

**Response Body**

| Field | Type | Description |
|-------|------|-------------|
| `id` | UUID | Unique identifier of the subaccount |
| `name` | String | Name of the subaccount |
| `account_number` | String | Account number for deposits |
| `routing_number` | String | Deprecated: use `routing_numbers.ach`. Kept for backward compatibility |
| `routing_numbers` | Object | Routing numbers per rail (see below) |
| `routing_numbers.ach` | String | ACH routing number for ACH transfers |
| `routing_numbers.wire` | String | Wire routing number for wire transfers. For JPM VRNs with separate wire config, differs from ach. For other banks, same as ach. |
| `total_incoming_in_minor_units` | Integer | Total incoming funds in the smallest unit of the account's currency (settled payins + incoming moves) - initially 0 |
| `total_outgoing_in_minor_units` | Integer | Total outgoing funds in the smallest unit of the account's currency (settled/debited payouts + outgoing moves) - initially 0 |
| `created_at` | DateTime | ISO 8601 timestamp when the subaccount was created |
| `updated_at` | DateTime | ISO 8601 timestamp when the subaccount was last updated |

**Virtual Banking Details**

Upon creation, each subaccount is assigned virtual banking details that can be shared with payers for direct deposits:
- **Account Number**: Unique account number for receiving deposits
- **Routing Numbers**: Use `routing_numbers.ach` for ACH transfers. For JPM VRNs, use `routing_numbers.wire` for wire transfers (same account number, different routing number per rail).

Use these details to configure payment processors to route funds to specific subaccounts.

**Error Responses**

| Status | error_code | When |
|--------|------------|------|
| 400 | VALIDATION_ERROR | Request body failed validation (e.g. invalid or missing `name`) |
| 400 | VALIDATION_ERROR | Subaccounts are not supported for your operating account currency (e.g. non-USD main account while that capability is unavailable) |

Reference: https://docs.useroot.com/api-reference/subaccounts-api/create-subaccount

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: '[Code Generated] Root - Instant Account to Account Money Movement'
  version: 1.0.0
paths:
  /api/subaccounts:
    post:
      operationId: create-subaccount
      summary: Create a new subaccount
      description: >-
        Creates a new subaccount for fund segregation within your root entity's
        main account.


        **Request Body**


        | Field | Type | Required | Description | Validation Rules |

        |-------|------|----------|-------------|-----------------|

        | `name` | String | Yes | Name of the subaccount | Must be between 1 and
        100 characters |


        **Response Body**


        | Field | Type | Description |

        |-------|------|-------------|

        | `id` | UUID | Unique identifier of the subaccount |

        | `name` | String | Name of the subaccount |

        | `account_number` | String | Account number for deposits |

        | `routing_number` | String | Deprecated: use `routing_numbers.ach`.
        Kept for backward compatibility |

        | `routing_numbers` | Object | Routing numbers per rail (see below) |

        | `routing_numbers.ach` | String | ACH routing number for ACH transfers
        |

        | `routing_numbers.wire` | String | Wire routing number for wire
        transfers. For JPM VRNs with separate wire config, differs from ach. For
        other banks, same as ach. |

        | `total_incoming_in_minor_units` | Integer | Total incoming funds in
        the smallest unit of the account's currency (settled payins + incoming
        moves) - initially 0 |

        | `total_outgoing_in_minor_units` | Integer | Total outgoing funds in
        the smallest unit of the account's currency (settled/debited payouts +
        outgoing moves) - initially 0 |

        | `created_at` | DateTime | ISO 8601 timestamp when the subaccount was
        created |

        | `updated_at` | DateTime | ISO 8601 timestamp when the subaccount was
        last updated |


        **Virtual Banking Details**


        Upon creation, each subaccount is assigned virtual banking details that
        can be shared with payers for direct deposits:

        - **Account Number**: Unique account number for receiving deposits

        - **Routing Numbers**: Use `routing_numbers.ach` for ACH transfers. For
        JPM VRNs, use `routing_numbers.wire` for wire transfers (same account
        number, different routing number per rail).


        Use these details to configure payment processors to route funds to
        specific subaccounts.


        **Error Responses**


        | Status | error_code | When |

        |--------|------------|------|

        | 400 | VALIDATION_ERROR | Request body failed validation (e.g. invalid
        or missing `name`) |

        | 400 | VALIDATION_ERROR | Subaccounts are not supported for your
        operating account currency (e.g. non-USD main account while that
        capability is unavailable) |
      tags:
        - subaccountsApi
      parameters:
        - name: x-api-key
          in: header
          description: >-
            RootPay API key sent in the x-api-key header. Keys are
            environment-scoped: live_* for production, test_* for sandbox.
          required: true
          schema:
            type: string
      responses:
        '201':
          description: Subaccount created successfully
          content:
            application/json:
              schema:
                description: Any type
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubaccountRequest'
servers:
  - url: https://api.useroot.com
    description: Production
components:
  schemas:
    SubaccountRequest:
      type: object
      properties:
        name:
          type: string
          description: Name of the subaccount
      required:
        - name
      description: Request to create a new subaccount.
      title: SubaccountRequest
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        RootPay API key sent in the x-api-key header. Keys are
        environment-scoped: live_* for production, test_* for sandbox.

```

## Examples

### Basic subaccount creation



**Request**

```json
{
  "name": "Nike Store Operations"
}
```

**Response**

```json
{
  "data": {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "name": "Nike Store Operations",
    "account_number": "1234567890",
    "routing_number": "111000025",
    "routing_numbers": {
      "ach": "111000025",
      "wire": "111000025"
    },
    "currency_code": "USD",
    "total_incoming_cents": 0,
    "total_outgoing_cents": 0,
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-15T10:30:00Z"
  }
}
```

**SDK Code**

```python Basic subaccount creation
import requests

url = "https://api.useroot.com/api/subaccounts"

payload = { "name": "Nike Store Operations" }
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Basic subaccount creation
const url = 'https://api.useroot.com/api/subaccounts';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"name":"Nike Store Operations"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Basic subaccount creation
package main

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

func main() {

	url := "https://api.useroot.com/api/subaccounts"

	payload := strings.NewReader("{\n  \"name\": \"Nike Store Operations\"\n}")

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

	req.Header.Add("x-api-key", "<apiKey>")
	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 Basic subaccount creation
require 'uri'
require 'net/http'

url = URI("https://api.useroot.com/api/subaccounts")

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

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"Nike Store Operations\"\n}"

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

```java Basic subaccount creation
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.useroot.com/api/subaccounts")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Nike Store Operations\"\n}")
  .asString();
```

```php Basic subaccount creation
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.useroot.com/api/subaccounts', [
  'body' => '{
  "name": "Nike Store Operations"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Basic subaccount creation
using RestSharp;

var client = new RestClient("https://api.useroot.com/api/subaccounts");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Nike Store Operations\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Basic subaccount creation
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["name": "Nike Store Operations"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.useroot.com/api/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()
```

### Minimal name



**Request**

```json
{
  "name": "Store A"
}
```

**Response**

```json
{
  "data": {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "name": "Nike Store Operations",
    "account_number": "1234567890",
    "routing_number": "111000025",
    "routing_numbers": {
      "ach": "111000025",
      "wire": "111000025"
    },
    "currency_code": "USD",
    "total_incoming_cents": 0,
    "total_outgoing_cents": 0,
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-15T10:30:00Z"
  }
}
```

**SDK Code**

```python Minimal name
import requests

url = "https://api.useroot.com/api/subaccounts"

payload = { "name": "Store A" }
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Minimal name
const url = 'https://api.useroot.com/api/subaccounts';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"name":"Store A"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Minimal name
package main

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

func main() {

	url := "https://api.useroot.com/api/subaccounts"

	payload := strings.NewReader("{\n  \"name\": \"Store A\"\n}")

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

	req.Header.Add("x-api-key", "<apiKey>")
	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 Minimal name
require 'uri'
require 'net/http'

url = URI("https://api.useroot.com/api/subaccounts")

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

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"Store A\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.useroot.com/api/subaccounts")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Store A\"\n}")
  .asString();
```

```php Minimal name
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.useroot.com/api/subaccounts', [
  'body' => '{
  "name": "Store A"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Minimal name
using RestSharp;

var client = new RestClient("https://api.useroot.com/api/subaccounts");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Store A\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Minimal name
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["name": "Store A"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.useroot.com/api/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()
```

### Descriptive name



**Request**

```json
{
  "name": "Regional Distribution Center - East Coast Operations"
}
```

**Response**

```json
{
  "data": {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "name": "Nike Store Operations",
    "account_number": "1234567890",
    "routing_number": "111000025",
    "routing_numbers": {
      "ach": "111000025",
      "wire": "111000025"
    },
    "currency_code": "USD",
    "total_incoming_cents": 0,
    "total_outgoing_cents": 0,
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-15T10:30:00Z"
  }
}
```

**SDK Code**

```python Descriptive name
import requests

url = "https://api.useroot.com/api/subaccounts"

payload = { "name": "Regional Distribution Center - East Coast Operations" }
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Descriptive name
const url = 'https://api.useroot.com/api/subaccounts';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"name":"Regional Distribution Center - East Coast Operations"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Descriptive name
package main

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

func main() {

	url := "https://api.useroot.com/api/subaccounts"

	payload := strings.NewReader("{\n  \"name\": \"Regional Distribution Center - East Coast Operations\"\n}")

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

	req.Header.Add("x-api-key", "<apiKey>")
	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 Descriptive name
require 'uri'
require 'net/http'

url = URI("https://api.useroot.com/api/subaccounts")

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

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"Regional Distribution Center - East Coast Operations\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.useroot.com/api/subaccounts")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Regional Distribution Center - East Coast Operations\"\n}")
  .asString();
```

```php Descriptive name
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.useroot.com/api/subaccounts', [
  'body' => '{
  "name": "Regional Distribution Center - East Coast Operations"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Descriptive name
using RestSharp;

var client = new RestClient("https://api.useroot.com/api/subaccounts");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Regional Distribution Center - East Coast Operations\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Descriptive name
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["name": "Regional Distribution Center - East Coast Operations"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.useroot.com/api/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()
```