# Creating accounts

## Prerequisites

You must have

- [created a user](/products/byol/guides/users/users_onboarding_create).
- [created an account group](/products/byol/guides/accounts/accounts_create_account_groups).


After the creation of the account group, you can now setup an account with:

**POST** [`/accounts`](/api/accounts/create_account)

**Example**

Example request

```json
{
  "user_id": "413715f2-5401-4b97-8055-034a6b879f8c",
  "account_group_id": "fa2414ed-8d62-46fd-85ed-565a340c81d6",
  "type": "TRADING",
  "name": "Main account"
}
```

Example response

```json
{
  "id": "ad45b27f-c0e7-4cfb-b48c-a83670dbdfbd",
  "created_at": "2020-08-24T14:15:22Z",
  "updated_at": "2020-08-24T14:15:22Z",
  "account_group_id": "fa2414ed-8d62-46fd-85ed-565a340c81d6",
  "type": "TRADING",
  "users": [
    {
      "id": "9c36af78-91a0-4174-a515-fc81214e3dab",
      "type": "OWNER"
    }
  ],
  "account_number": 1,
  "name": "Main account",
  "status": "ACTIVE"
}
```

| Parameter | Description |
|  --- | --- |
| `user_id` | The ID of the user to be associated with this account. |
| `account_group_id` | The ID of the account group to be associated with this account. |
| `type` | Specify the type `TRADING` or `PORTFOLIO` for this account. |
| `name` | Optionally, you can provide a nickname for the account that can be used for reporting purposes. |


The account will be created with the `PENDING_APPROVAL` status and switches to `ACTIVE` as soon as the user onboarding process is completed.

Furthermore, you will receive a webhook with the respective [account created event](/api/accounts/account_event). As soon as all prerequisites for activating the account are passed, you also receive an [account activated event](/api/accounts/account_event).

Webhooks notify you of events in business processes, not the success or failure of the initialisation of those processes.

Please be sure to check the [HTTP status](/api_errors) of the response to your requests and handle failure cases appropriately.

## Account status

The following status apply to an account:

| Status | Description |
|  --- | --- |
| `PENDING_APPROVAL` | Account approval is pending - the account is visible via our API but cannot be acted on. |
| `ACTIVE` | Account is active - full functionality of the Investment API is accessible. |
| `LOCKED` | Account is locked for all actions. |
| `CLOSING` | Account is closing - only sell orders or the transfer of positions out are permissible before the account is closed. |
| `CLOSED` | Account is closed with zero balance successfully. |


## Listing accounts

You can list all accounts of a specific user with

- **GET**[`/users/{user_ID}/accounts`](/api/accounts/list_user_accounts)


All accounts can be listed with

- **GET** [`/accounts`](/api/account-groups/list_account_groups)


## Next Steps

You are all set now: a user is onboarded and an account group as well as an account have been created. Your user is now ready to place the first order. Follow the [Orders guide](/products/byol/guides/orders/orders_introduction).