# Registering Subaccounts

## Create a New Subaccount

<mark style="color:green;">`POST`</mark> `https://live.betaapp.com/v1/subaccount`

Register a subaccount for a user.

#### Headers

| Name                                            | Type   | Description            |
| ----------------------------------------------- | ------ | ---------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer {access\_token} |
| accept<mark style="color:red;">\*</mark>        | String | application/json       |

#### Request Body

| Name                                                | Type   | Description                                                                                                           |
| --------------------------------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------- |
| tax\_id\_number<mark style="color:red;">\*</mark>   | Number | *Number of the tax ID*                                                                                                |
| tax\_id\_type<mark style="color:red;">\*</mark>     | String | <p>For Brasil: CPF or CNPJ<br>For Mexico: RFC</p><p>For Argentina: CUIT</p><p>For Colombia: NIT</p>                   |
| e-mail<mark style="color:red;">\*</mark>            | String | User's e-mail                                                                                                         |
| Full name<mark style="color:red;">\*</mark>         | String | User's full name                                                                                                      |
| country<mark style="color:red;">\*</mark>           | String | Check coverage page for more details. Follow [ISO 3166](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes) |
| local\_id\_type                                     | String | Passport, National ID, Driver's License, Foreigner ID Card                                                            |
| local\_id\_number<mark style="color:red;">\*</mark> | String | Document information                                                                                                  |
| post\_code                                          | String | User's postal code                                                                                                    |
| city                                                | String | User's city                                                                                                           |
| address                                             | String | User's address                                                                                                        |
| phone                                               | String | Phone number with country code                                                                                        |

{% tabs %}
{% tab title="201: Created Sucess" %}

```json
{
  "message": "string"
  "subaccount_id": "uuid"
}
```

{% endtab %}

{% tab title="400: Bad Request Error message " %}

```json
{
  "message": "string"
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

```json
{
  "message": "string"
}
```

{% endtab %}
{% endtabs %}

**Request Example:**

{% code overflow="wrap" %}

```json
curl -X 'POST' \
  'https://live.betaapp.com/v1/subaccount' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6InJlaEF1NURPY...ctfx2I4g' \
  -H 'Content-Type: application/json' \
  -d '{
  "address": "Rua Francisco Rocha 198",
  "city": "Curitiba",
  "country": "Brazil",
  "email": "testing@betaapp.com",
  "local_id_number": "99999999",
  "local_id_type": "National ID",
  "name": "Testing Beta Ramps",
  "phone": "5541111111111",
  "post_code": "80420130",
  "tax_id_number": "77777777777",
  "tax_id_type": "CPF"
}'
```

{% endcode %}

{% hint style="info" %}
Check our supported countries guidelines for more instructions on the accepted inputs for the subaccount fields.
{% endhint %}

**Response Example:**

```json
{
  "id": "fe2f30db...5b5e7c",
  "account_id": "a2b6b539...484097",
  "name": "Testing Beta Ramps",
  "email": "testing@betaapp.com",
  "is_active": true,
  "country": "Brazil",
  "city": "Curitiba",
  "address": "Rua Francisco Rocha 198",
  "tax_id_type": "CPF",
  "tax_id_number": "77777777777",
  "local_id_type": "Driver's License",
  "local_id_number": "99999999",
  "phone": "5541111111111",
  "post_code": "80420130"
}
```

## Retrieve Sub Account Detail

<mark style="color:blue;">`GET`</mark> `https://live.betaapp.com/v1/subaccount`

Retrieve subaccount information

#### Headers

| Name                                               | Type   | Description            |
| -------------------------------------------------- | ------ | ---------------------- |
| Authorization<mark style="color:red;">\*</mark>    | String | Bearer {access\_token} |
| accept<mark style="color:red;">\*</mark>           | String | application/json       |
| x-sub-account-id<mark style="color:red;">\*</mark> | String | Subaccount ID          |

{% tabs %}
{% tab title="200: OK Sucess" %}

```json
[
  {
    "account_type_id": "string",
    "account_type_name": "string",
    "address": "string",
    "city": "string",
    "country": "string",
    "created_at": "string",
    "deleted_at": "string",
    "id": "string",
    "is_active": true,
    "local_id_number": "string",
    "local_id_type": "string",
    "message": "string",
    "name": "string",
    "post_code": "string",
    "tax_id_number": "string",
    "tax_id_type": "string",
    "updated_at": "string"
  }
]
```

{% endtab %}

{% tab title="400: Bad Request Error message " %}

```json
{
  "message": "string"
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

```json
{
  "message": "string"
}
```

{% endtab %}
{% endtabs %}

**Request Example:**

{% code overflow="wrap" %}

```json
curl -X 'GET' \
  'https://live.betaapp.com/v1/subaccount' \
  -H 'accept: application/json' \
  -H 'X-sub-account-id: fe2f30db...5b5e7c' \
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6InJlaEF1NURPY...ctfx2I4g' \
```

{% endcode %}

**Response Example:**

```json
{
  "id": "fe2f30db...5b5e7c",
  "account_id": "a2b6b539...484097",
  "name": "Testing Beta Ramps",
  "email": "testing@betaapp.com",
  "is_active": true,
  "country": "Brazil",
  "city": "Curitiba",
  "address": "Rua Francisco Rocha 198",
  "tax_id_type": "CPF",
  "tax_id_number": "77777777777",
  "local_id_type": "Local ID",
  "local_id_number": "99999999",
  "phone": "5541111111111",
  "post_code": "80420130"
}
```

## Retrieve Sub-account List

<mark style="color:blue;">`GET`</mark> `https://live.betaapp.com/v1/subaccounts`

Retrieve a list of all your subaccounts

#### Query Parameters

| Name | Type    | Description               |
| ---- | ------- | ------------------------- |
| page | Integer | Page number of your query |
| size | Integer | Number of items per page  |

#### Headers

| Name                                            | Type   | Description            |
| ----------------------------------------------- | ------ | ---------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer {access\_token} |
| accept<mark style="color:red;">\*</mark>        | String | application/json       |

{% tabs %}
{% tab title="200: OK Sucess" %}

```json
[
  {
    "account_type_id": "string",
    "account_type_name": "string",
    "address": "string",
    "city": "string",
    "country": "string",
    "created_at": "string",
    "deleted_at": "string",
    "id": "string",
    "is_active": true,
    "local_id_number": "string",
    "local_id_type": "string",
    "message": "string",
    "name": "string",
    "post_code": "string",
    "tax_id_number": "string",
    "tax_id_type": "string",
    "updated_at": "string"
  }
]
```

{% endtab %}

{% tab title="400: Bad Request Error message " %}

```json
{
  "message": "string"
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

```json
{
  "message": "string"
}
```

{% endtab %}
{% endtabs %}

**Request Example:**

{% code overflow="wrap" %}

```json
curl -X 'GET' \
  'https://live.betaapp.com/v1/subaccounts' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6InJlaEF1NURPY...ctfx2I4g'
```

{% endcode %}

**Response Example:**

```json
{
  "list": [
    {
      "id": "fe2f30db...d5b5e7c",
      "account_id": "a2b6b539...99484097",
      "name": "Testing Beta Ramps",
      "email": "testing@betaapp.com",
      "is_active": true,
      "country": "Brazil",
      "city": "Curitiba",
      "address": "Rua Francisco Rocha 198",
      "tax_id_type": "CPF",
      "tax_id_number": "77777777777",
      "local_id_type": "Local ID",
      "local_id_number": "99999999",
      "phone": "5541111111111",
      "post_code": "80420130"
    }
  ]
}
```

## Update an User

<mark style="color:purple;">`PATCH`</mark> `https://live.betaapp.com/v1/subaccount`

Update subaccount details

#### Headers

| Name                                            | Type   | Description            |
| ----------------------------------------------- | ------ | ---------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer {access\_token} |
| accept<mark style="color:red;">\*</mark>        | String | application/json       |

#### Request Body

| Name                                               | Type   | Description   |
| -------------------------------------------------- | ------ | ------------- |
| e-mail<mark style="color:red;">\*</mark>           | String | User's e-mail |
| x-sub-account-id<mark style="color:red;">\*</mark> | String | Subaccount ID |

{% tabs %}
{% tab title="200: OK Sucess" %}

```json
{
  "message": "string"
}
```

{% endtab %}

{% tab title="400: Bad Request Error message " %}

```json
{
  "message": "string"
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

```json
{
  "message": "string"
}
```

{% endtab %}
{% endtabs %}
