# How to Get, Add, and Delete Accounts (EMS Managed Cloud REST API)

## How to Get, Add, and Delete Accounts (EMS Managed Cloud REST API)

This tutorial shows how to manage **exchange accounts (order destinations)** in the **CoinAPI EMS Managed Cloud REST API**: list accounts, add/update an account, delete a single account, or delete all accounts.

## What you need before you start

* ✅ A CoinAPI EMS API Key
* ✅ An EMS Trading API subscription
* ✅ Any HTTP client:
  * Terminal (`curl`)
  * Postman / Insomnia
  * Browser (for simple GET requests)
* ✅ Prerequisites from specific exchanges
* ✅ Completed tutorial on “**[How to List EMS-Supported Exchanges and Their Required Login Parameters](https://www.coinapi.io/learn/academy/tutorials/how-to-list-ems-supported-exchanges)”** 

## Authentication

For the EMS **Managed Cloud REST**, you can authenticate using the `X-CoinAPI-Key` header.

Example header:

```
-H"X-CoinAPI-Key: YOUR_API_KEY"
```

  


## 1) Get accounts (list all, or fetch one by exchange id)

**Endpoint**

* `GET /v1/accounts`

**Optional query parameter**

* `filter_exchange_id` — returns a single specific account instead of the full list.

### List all accounts

```sh
curl-sS-X GET"<https://ems-mgmt.coinapi.io/v1/accounts>" \\
-H"X-CoinAPI-Key: YOUR_API_KEY"
```



### Get one account (by exchange id)

```sh
curl-sS-X GET"<https://ems-mgmt.coinapi.io/v1/accounts?filter_exchange_id=BINANCE>" \\
-H"X-CoinAPI-Key: YOUR_API_KEY"
```

**Response (shape)**

Returns an array of objects like:

* `exchange_id` (can include an optional tag for multiple accounts on the same exchange)
* `parameters` (key/value pairs with exchange-specific configuration)

## 2) Add or update an account

**Endpoint**

* `POST /v1/accounts`

**Body fields**

* `exchange_id` — exchange identifier, optionally with a tag (for multiple accounts on the same exchange).
* `parameters` — array of `{ key, value }` entries required to log in to that exchange.

> Tip: The tag format is supported via separators (docs list several allowed separators) so you can do things like `BITSTAMP/<tag>` when managing multiple accounts for the same venue.

### Example: create/update an account

```sh
curl-sS-X POST"<https://ems-mgmt.coinapi.io/v1/accounts>" \\
-H"X-CoinAPI-Key: YOUR_API_KEY" \\
-H"Content-Type: application/json" \\
-d'{
    "exchange_id": "BINANCE",
    "parameters": [
      { "key": "PublicApiKey", "value": "YOUR_PUBLIC_KEY_VALUE" }
    ]
  }'
```

**Common responses**

* `400` / `405` for invalid exchange id or validation errors.



## 3) Delete one account

**Endpoint**

* `DELETE /v1/accounts`

**Required query parameter**

* `exchange_id` — exchange identifier of the account to delete.

### Example: delete a specific account

```sh
curl-sS-X DELETE"<https://ems-mgmt.coinapi.io/v1/accounts?exchange_id=BITSTAMP>" \\
-H"X-CoinAPI-Key: YOUR_API_KEY"
```

**Common responses**

* `404` if the exchange account is not found.



## 4) Delete all accounts

**Endpoint**

* `DELETE /v1/accounts/all`

### Example: delete everything

```sh
curl-sS-X DELETE"<https://ems-mgmt.coinapi.io/v1/accounts/all>" \\
-H"X-CoinAPI-Key: YOUR_API_KEY"
```

  
**Response**

* `200 OK`

## Quick troubleshooting

* **Auth fails**: confirm you’re sending `X-CoinAPI-Key` and that you’re calling the **Managed Cloud REST** base URL (`https://ems-mgmt.coinapi.io`).
* **Delete returns 404**: verify the `exchange_id` matches exactly what you see from `GET /v1/accounts` (including any tag, if you used one).

## 🎉 Congratulations!

You’ve successfully learned how to:

* ✅ Retrieve your configured EMS accounts
* ➕ Add or update an exchange account
* ❌ Delete a specific account
* 🧹 Remove all accounts when needed

You now have full control over managing exchange connections within the EMS Managed Cloud REST API.

From here, you can proceed to:

* Connecting accounts to trading workflows
* Managing orders and positions
* Automating account setup as part of your deployment pipeline

Happy building with CoinAPI EMS! 🚀