> 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/alerts.md).

# Alerts

The Alerts mechanism allows users to set up notifications based on specific market conditions or price movements. This section describes the Alerts creation and management process. Possible requests are described below.

## Get alerts

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

Returns all available alerts with their IDs. Alerts can be filtered by specified parameters such as account ID, action type, instrument ID, user ID, or user login. This means you can request alerts for the required account only, etc.

**Query**

| Name                   | Type   | Description                                                                       |
| ---------------------- | ------ | --------------------------------------------------------------------------------- |
| `accountId`            | string | Filter by account (using its ID).                                                 |
| `actionType`           | string | Filter alerts by action type. Valid values: 0 - Place order + Notify, 1 - Notify. |
| `userId`               | string | Filter by user (using its ID).                                                    |
| `userLogin`            | string | Filter by user (using its login).                                                 |
| `tradableInstrumentId` | string | Filter alerts by Instrument (by its ID).                                          |

**CURL**

{% code overflow="wrap" %}

```json
curl -X GET "http://sandbox.traderevolution.com:8443/proftrading/rest/alerts?accountId=679276" -H "accept: application/json" -H "Authorization: Bearer eyItMTY5MTQ4…4dKUXjSFiimZszelFwniqSizRKCOCTgWR9y-ulCCY-ypRlTD2Gs7EbVzG6FZBQlR2ohehCKZq7GGW8drJI_n7GjXSEuRYH_5DOuaVTG2EI3j6_zfkNoav39Q_eFS6QEAAA.Z8fScxB7fofh6HMePQAyJ5iud7_k7WUblGV_deQ5ydc"
```

{% endcode %}

**Response**

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

```json
[
  {
    "id": 264939
  }
]
```

{% endtab %}
{% endtabs %}

Since the account ID filter is applied to the request, in the response we can receive all alerts for the account with `ID = 679276`, which has one active alert. The response contains only the alert ID, its settings can be requested by using the separate <mark style="color:blue;">`GET`</mark>`/alerts/{alertId}` request.

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

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

## Create new alert

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

This method is used for creating a new alert on the server. Various parameters can be configured here, they will subsequently be applied to the newly created alerts. All parameters are given in the request body example below.&#x20;

**Body**

<table><thead><tr><th width="258">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>accountId</code></td><td>integer</td><td>The account for whom the alert will be created</td></tr><tr><td><code>action*</code></td><td>integer</td><td>Action applied after alert execution. Valid values: 0 - Place order + Notify, 1 - Notify. </td></tr><tr><td><code>afterExecute*</code></td><td>integer</td><td>After execute parameter of alert. Example: 0. Valid values: 0 - Stop, 1 - Remove. </td></tr><tr><td><code>alertMessage*</code></td><td>string</td><td>Notification text that will be sent to the user when the alert is executed.</td></tr><tr><td><code>alertType*</code></td><td>integer</td><td>Type of alert. Example: 0. Valid values: 0 - Ask, 1 - Bid, 2 - Last, 3 - Change%, 4 - Volume.</td></tr><tr><td><code>condition*</code></td><td>integer</td><td>The condition under which an alert is executed. Example: 0. Valid values: 0 - >, 1 - &#x3C;, 2 - >=, 3 - &#x3C;=. </td></tr><tr><td><code>expiration*</code></td><td>string</td><td>Expiration date of alert. Example: 1233555668</td></tr><tr><td><code>importance*</code></td><td>integer</td><td>Alert importance. Example: 5. Valid values: 1 - High, 5 - Medium, 10 - Low</td></tr><tr><td><code>notification*</code></td><td>integer</td><td>Notification type. </td></tr><tr><td><code>orderParameters*</code></td><td>array</td><td>Parameters of the order that will be placed by this alert. Full ist see in the request body example. Required parameters here are side, tif, and type. </td></tr><tr><td><code>routeId*</code></td><td>integer</td><td>ID of the route where the alert should be placed. </td></tr><tr><td><code>tradableInstrumentId*</code></td><td>integer</td><td>Identifier of the instrument that is used for trading purposes. </td></tr><tr><td><code>userId</code></td><td>integer</td><td>ID of the user. </td></tr><tr><td><code>value*</code></td><td>double</td><td>Alert value. Example: 100</td></tr></tbody></table>

**Request body example**

```json
{
  "accountId": 456,
  "action": 0,
  "afterExecute": 0,
  "alertMessage": "string",
  "alertType": 0,
  "condition": 0,
  "expiration": 1233555668,
  "importance": 5,
  "notification": 0,
  "orderParameters": {
    "accountId": 0,
    "amount": 0,
    "cashAmount": 0,
    "clOrderId": "string",
    "comment": "string",
    "commissionType": 0,
    "createdDate": 1483228800000,
    "crossPrice": 0,
    "executionVenue": "ADM",
    "expireDate": 1483228800000,
    "leverage": 0,
    "poaId": 0,
    "price": 0,
    "receivedBy": 8,
    "routeId": 0,
    "side": 0,
    "slLimitPrice": 0,
    "slPrice": 0,
    "slPriceType": "0",
    "slTpTriggerPrice": "1 - for Ask, 2 - for Bid, -1 - if is not used",
    "slTriggerPrice": "1 - for Ask, 2 - for Bid, -1 - if is not used",
    "spreadMeasure": 0,
    "spreadType": 0,
    "spreadValue": 0,
    "stopPrice": 0,
    "tif": 1,
    "tpPrice": 0,
    "tpPriceType": "0",
    "tpTriggerPrice": "1 - for Ask, 2 - for Bid, -1 - if is not used",
    "tradableInstrumentId": 0,
    "tradingMode": 0,
    "tradingSignalId": 0,
    "trailingStopOffset": 0,
    "type": 3
  },
  "routeId": 123,
  "tradableInstrumentId": 123,
  "userId": 123,
  "value": 100
}
```

**CURL**

{% code overflow="wrap" %}

```json
curl -X POST "http://sandbox.traderevolution.com:8443/proftrading/rest/alerts" -H "accept: application/json" -H "Authorization: Bearer eyItMTY5MTQ…J5iud7_k7WUblGV_deQ5ydc" -H "Content-Type: application/json" -d "{ \"accountId\": 456, \"action\": 0, \"afterExecute\": 0, \"alertMessage\": \"string\", \"alertType\": 0, \"condition\": 0, \"expiration\": 1233555668, \"importance\": 5, \"notification\": 0, \"orderParameters\": { \"accountId\": 0, \"amount\": 0, \"cashAmount\": 0, \"clOrderId\": \"string\", \"comment\": \"string\", \"commissionType\": 0, \"createdDate\": 1483228800000, \"crossPrice\": 0, \"executionVenue\": \"ADM\", \"expireDate\": 1483228800000, \"leverage\": 0, \"poaId\": 0, \"price\": 0, \"receivedBy\": 8, \"routeId\": 0, \"side\": 0, \"slLimitPrice\": 0, \"slPrice\": 0, \"slPriceType\": \"0\", \"slTpTriggerPrice\": 1, \"slTriggerPrice\": 1, \"spreadMeasure\": 0, \"spreadType\": 0, \"spreadValue\": 0, \"stopPrice\": 0, \"tif\": 1, \"tpPrice\": 0, \"tpPriceType\": \"0\", \"tpTriggerPrice\": 1, \"tradableInstrumentId\": 0, \"tradingMode\": 0, \"tradingSignalId\": 0, \"trailingStopOffset\": 0, \"type\": 3, \"routeId\": 123, \"tradableInstrumentId\": 123, \"userId\": 123, \"value\": 100}"
```

{% endcode %}

**Response**

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

```json
[
  {
    "id": 256299
  }
]
```

{% endtab %}
{% endtabs %}

In the response, you will simply receive the ID of the newly created alert if your operation was successful.

{% hint style="success" %}
You can try this method of BO REST API here:

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

## Remove alert

<mark style="color:red;">`DELETE`</mark>`/alerts/{alertId}`

This method is used to remove the alert from the server. It requires only one query parameter - the ID of the alert that should be deleted.

**Path**

| Name      | Type    | Description                                             |
| --------- | ------- | ------------------------------------------------------- |
| `alertId` | integer | ID of the alert that should be removed from the server. |

**CURL**

{% code overflow="wrap" %}

```json
curl -X DELETE "http://sandbox.traderevolution.com:8443/proftrading/rest/alerts/264941" -H "accept: application/json" -H "Authorization: Bearer eyItMTY5MTQ4NTM2NyI6LTE2OTE0O…ZBQlR2ohehCKZq7GGW8drJI_n7GjXSEuRYH_5DOuaVTG2EI3j6_zfkNoav39Q_eFS6QEAAA.Z8fScxB7fofh6HMePQAyJ5iud7_k7WUblGV_deQ5ydc"
```

{% endcode %}

**Response**

The OK (200) status is simply received in the response if your operation was successful.&#x20;

{% hint style="success" %}
You can try this method of BO REST API by following the link:

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

## Modify alert

<mark style="color:green;">`PATCH`</mark>`/alerts/{alertId}`

This method is used to update the alert existing on the server. It requires the ID of the alert in the path and the same request body as for the alert creation method.&#x20;

**Parameters**

| Name      | Type         | Description                                                                                                                             |
| --------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------- |
| `alertId` | integer/path | ID of the alert that will be updated.                                                                                                   |
| `body`    | body         | The request body contains [similar parameters](#create-new-alert) as required for adding new alert. You can find above in this article. |

**CURL**

{% code overflow="wrap" %}

```json
curl -X PATCH "http://sandbox.traderevolution.com:8443/proftrading/rest/alerts/264943" -H "accept: application/json" -H "Authorization: Bearer eyItMTY5MTQ…J5iud7_k7WUblGV_deQ5ydc" -H "Content-Type: application/json" -d "{ \"accountId\": 456, \"action\": 0, \"afterExecute\": 0, \"alertMessage\": \"string\", \"alertType\": 0, \"condition\": 0, \"expiration\": 1233555668, \"importance\": 5, \"notification\": 0, \"orderParameters\": { \"accountId\": 0, \"amount\": 0, \"cashAmount\": 0, \"clOrderId\": \"string\", \"comment\": \"string\", \"commissionType\": 0, \"createdDate\": 1483228800000, \"crossPrice\": 0, \"executionVenue\": \"ADM\", \"expireDate\": 1483228800000, \"leverage\": 0, \"poaId\": 0, \"price\": 0, \"receivedBy\": 8, \"routeId\": 0, \"side\": 0, \"slLimitPrice\": 0, \"slPrice\": 0, \"slPriceType\": \"0\", \"slTpTriggerPrice\": 1, \"slTriggerPrice\": 1, \"spreadMeasure\": 0, \"spreadType\": 0, \"spreadValue\": 0, \"stopPrice\": 0, \"tif\": 1, \"tpPrice\": 0, \"tpPriceType\": \"0\", \"tpTriggerPrice\": 1, \"tradableInstrumentId\": 0, \"tradingMode\": 0, \"tradingSignalId\": 0, \"trailingStopOffset\": 0, \"type\": 3, \"routeId\": 123, \"tradableInstrumentId\": 123, \"userId\": 123, \"value\": 100}"
```

{% endcode %}

**Response**

The OK (200) status is simply received in the response if your `PATCH` operation was successful.&#x20;

{% hint style="success" %}
You can play with this method of BO REST API here:

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