> For the complete documentation index, see [llms.txt](https://guide.traderevolution.com/traderevolution-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guide.traderevolution.com/traderevolution-api/traderevolution-apis/backoffice-api/account-operations.md).

# Account operations

This section describes methods that are used for performing actions with account operations (deposit/withdrawal/transfer/adjustment/etc).

Each account operation should be assigned to a specific account ID. Please note that one user (user ID) could have many trading accounts (account ID), so it is required to specify the exact account for which the operation should be created.

## Create account operation

<mark style="color:green;">`POST`</mark> `/accountOperations`

This method is used to create an account operation.&#x20;

**Body**

| Name              | Type    | Description                                                                                                                                                                                                                                                                          |
| ----------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `accountId`       | integer | ID of the account for which the operation will be created (whose funds are withdrawn, etc.)                                                                                                                                                                                          |
| `amount`          | float   | Amount of the account operation. Please note that operation side (debit\credit) is defined by the +\\- sign.                                                                                                                                                                         |
| `operationTypeId` | integer | <p>Defines account operation type. For examplу, the following IDs are responsible for such operation types:<br>Trading - 1<br>Transfer - 17<br>Dividends - 13<br>Deposit - 2<br>Withdrawal - 3<br>Adjustment - 12<br>All IDs can be found in Swagger -> Models for this method. </p> |

**Request body**

```json
{
 "accountId": 3243753,
 "amount": 1000,
 "operationTypeId": 2
}
```

**CURL**

{% code overflow="wrap" %}

```json
curl -X POST "https://sandbox.traderevolution.com:8443/proftrading/rest/accountOperations" -H "accept: application/json" -H "Authorization: Bearer eyI1MDQ5MTA4NDAiOjUwNDkxMDg...-c0hxfFY1TTpzT-rDDFCdVh0ZQbvP4DocV-nV8_wC-dQCPU7Pbxv4R4_O5X6K_v8vyoR01fbqY" -H "Content-Type: application/json" -d "{ \"accountId\": 3243753, \"amount\": 1000, \"operationTypeId\": 2}"
```

{% endcode %}

This request example contains the minimum set of required parameters for creating a *deposit (type=2)* account operation.&#x20;

**Note**: you can add any useful information to the account operation which may be later available on frontends. To do this, you must include the `frontendComment` field in the request body.&#x20;

{% hint style="warning" %}
The `frontendComment field` supports no more than 128 characters!
{% endhint %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "operationId": 346523
}
```

{% endtab %}
{% endtabs %}

The response will contain the ID of the newly created account operation.&#x20;

{% hint style="success" %}
A full list of parameters available for account operation can be found here:

<https://sandbox.traderevolution.com:8443/proftrading/rest/swagger-ui.html#/Account_operations/createAccountOperationUsingPOST>
{% endhint %}

## Get account operations

<mark style="color:blue;">`GET`</mark>`/accountOperations`

This method is used for getting a list of account operations. Please note that you can apply various filters for this method (by adding them to query): account name or ID, currencyId, operationType, positionId, etc.

**Query**

| Name        | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                               |
| ----------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `isSettled` | string | <p>Filter operations by settlement type: </p><p><em>false</em> - unsettled operations will be shown.</p><p><em>true</em> - settled operations will be shown.</p><p><em><mark style="color:orange;">Required parameter\*</mark></em></p>                                                                                                                                                                   |
| `sort`      | string | <p>Sort operations (ascending/descending) by a given field. Available fields for sorting: <em>createdDate, accountId, amount, valueDate</em>. For ascending order sign ‘+’ is used before specified field. For descending ‘-’<br>By default, descending order by createdDate is used:</p><p><em>Default value</em> : +createdDate<br><em><mark style="color:orange;">Required parameter\*</mark></em></p> |

**CURL example (operations are filtered by account ID)**

{% code overflow="wrap" %}

```json
curl -X GET "https://sandbox.traderevolution.com:8443/proftrading/rest/accountOperations?isSettled=true&sort=-createdDate" -H "accept: application/json" -H "Authorization: Bearer eyItNjcyMTMwNjE4IjotNjcy...c782NfNKSy2DC8yZTbhKXp9No7rWCD6bXobsA9mMLGLpY3CB6XRIIdCqmBCl3-Y9BWf8E35-AdtJOqSRAQAA.WHM7UoSPwIO66mG3lVlI0hiuWLQB4EHH7yuKBUsRVWY"
```

{% endcode %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
[
  {
    "operationTypeId": 4,
    "operationId": 1138836,
    "accountId": 404521
  },
  {
    "operationTypeId": 2,
    "operationId": 1140595,
    "accountId": 404521
  },
  {
    "operationTypeId": 7,
    "operationId": 1139787,
    "accountId": 404521
  },
  {
    "operationTypeId": 12,
    "operationId": 461156,
    "accountId": 404521
  }
]
```

{% endtab %}
{% endtabs %}

The response will contain all account operations available for this account.&#x20;

{% hint style="success" %}
A full list of parameters available for this method can be found here:

<https://sandbox.traderevolution.com:8443/proftrading/rest/swagger-ui.html#/Account_operations/getAccountOperationsUsingGET_1>
{% endhint %}

## Delete account operation by ID

<mark style="color:red;">`DELETE`</mark>`/accountOperations/{accountOperationId}`

This method is used for removing the specified account operation from the server.&#x20;

**Path**

| Name                 | Type   | Description                                               |
| -------------------- | ------ | --------------------------------------------------------- |
| `accountOperationId` | string | Identifier of the account operation that will be deleted. |

**CURL**

{% code overflow="wrap" %}

```json
curl -X DELETE "https://sandbox.traderevolution.com:8443/proftrading/rest/accountOperations/458191" -H "accept: application/json" -H "Authorization: Bearer eyI2ODAxNzI0MzUiOjY4MDE3MjQzNSwiMTI3MDE4MzM3OSI6MTI3MDE4MzM3OSwiODEzMjU1MjA4Ijo4MTMyNTUyMDgsIjE1MTA0M...v8w8oJzt_XEJSKaiaLI6bnr3-hNOH3DzRwJGHcAQAA.rHYqSC44fMhzHdPgwjry8aB35hsKmrydP2K2TQkBEnc"
```

{% endcode %}

You will receive the `204 (No content)` code in the response, meaning the account operation has been deleted successfully.&#x20;
