# Settings

## Accounts

### Get accounts

<mark style="color:green;">`GET`</mark> `/frontoffice/api/v3/accounts`

#### Summary

Use this method to retrieve a list of all trading accounts with their basic information including account type and total balance.

#### Request

{% columns %}
{% column width="60%" %}
*No request parameters.*
{% endcolumn %}

{% column width="40%" %}
{% code title="Request example" %}

```http
GET /frontoffice/api/v3/accounts HTTP/1.1
Host: {host}
Authorization: Bearer JWT
Accept: */*
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

#### Response

{% columns %}
{% column width="60%" %}
In case of success, an array of objects will be returned.

Each object contains the following information:

**`accountId`** `string`

The trading account identifier.

**`publicAccountId`** `integer`

The public account identifier for display purposes.

**`accountName`** `string`

The account name.

**`accountType`** `string`

The account type.

Possible values:

* `Hedging`
* `Netting`

**`totalBalanceInRAT`** `decimal string`

The total balance, in RAT.

**`isCopyTradingAccount`** `boolean`

Indicates if the account is `Copy`.
{% endcolumn %}

{% column width="40%" %}
{% code title="Response example — 200: OK" %}

```json
[
  {
    "accountId": "685a7eaa360f9e7416221a61",
    "publicAccountId": 1234567,
    "accountName": "B2PRIME Hedging account",
    "accountType": "Hedging",
    "totalBalanceInRAT": "6020.12",
    "isCopyTradingAccount": false
  },
  {
    "accountId": "6891e70db552ff9c6fbbccf5",
    "publicAccountId": 1234568,
    "accountName": "B2PRIME Netting account",
    "accountType": "Netting",
    "totalBalanceInRAT": "10987.39",
    "isCopyTradingAccount": false
  }
]
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

## Assets

### Get assets

<mark style="color:green;">`GET`</mark> `/frontoffice/api/v3/assets`

#### Summary

Use this method to retrieve a list of available assets on the platform.

#### Request

{% columns %}
{% column width="60%" %}
*No request parameters.*
{% endcolumn %}

{% column width="40%" %}
{% code title="Request example" %}

```http
GET /frontoffice/api/v3/assets HTTP/1.1
Host: {host}
Authorization: Bearer JWT
Accept: */*
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

#### Response

{% columns %}
{% column width="60%" %}
In case of success, an array of objects will be returned.

Each object contains the following information:

**`assetId`** `string`

The asset identifier.

**`assetName`** `string`

The asset display name.

**`isRootAsset`** `boolean`

Indicates whether this is a root asset.
{% endcolumn %}

{% column width="40%" %}
{% code title="Response example — 200: OK" %}

```json
[
  {
    "assetId": "usdt",
    "assetName": "Tether",
    "isRootAsset": true
  },
  {
    "assetId": "xrp",
    "assetName": "Ripple",
    "isRootAsset": false
  }
]
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

## Markets

### Get markets

<mark style="color:green;">`GET`</mark> `/frontoffice/api/v6/markets`

#### Summary

Use this method to retrieve a list of available markets with their type, subtype, and favorite status.

#### Request

{% columns %}
{% column width="60%" %}
**Query parameters**

**`categoryId`**

The market category identifier.

**`dynamicCommissionGroupId`**

The dynamic commission group identifier.

**`isFavorite`** `boolean`

Filter by favorite status. If set to `true`, only markets marked as favorites are returned.
{% endcolumn %}

{% column width="40%" %}
{% code title="Request example" %}

```http
GET /frontoffice/api/v6/markets?isFavorite=true HTTP/1.1
Host: {host}
Authorization: Bearer JWT
accountId: {accountId}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

#### Response

{% columns %}
{% column width="60%" %}
In case of success, an array of market objects is returned.

Each market object contains the following information:

**`marketId`** `string`

The market identifier, in the following format: `{marketType}.{baseAssetId}_{quoteAssetId}`, for example: `cfd.eth_eur`.

**`displayName`** `string`

The market ticker.

**`fullName`** `string | nullable`

The market full name or description.

**`type`** `string`

The market type.

Possible values:

* `Spot`
* `Cfd`
* `Perp`

**`subtype`** `string | nullable`

*Applicable to CFD markets only.*

The market subtype.

Possible values:

* `Crypto`
* `Fx`
* `Metals`
* `Indices`
* `Energies`
* `Ndf`
* `Shares`
* `Etf`

**`isFavorite`** `boolean`

Indicates whether the market is marked as a favorite by the current user.
{% endcolumn %}

{% column width="40%" %}
{% code title="Response example — 200: OK" %}

```json
[
  {
    "marketId": "spot.btc_usdt",
    "displayName": "BTC/USDT",
    "fullName": null,
    "type": "Spot",
    "subtype": null,
    "isFavorite": true
  },
  {
    "marketId": "cfd.eth_btc",
    "displayName": "ETH/BTC",
    "fullName": "Ethereum to Bitcoin",
    "type": "Cfd",
    "subtype": "Crypto",
    "isFavorite": false
  },
  {
    "marketId": "perp.trx_usdt",
    "displayName": "TRX/USDT",
    "fullName": "TRX to Tether Perpetual",
    "type": "Perpetual",
    "subtype": null,
    "isFavorite": false
  }
]
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

### Get market

<mark style="color:green;">`GET`</mark> `/frontoffice/api/v6/markets/`<mark style="color:blue;">`{marketId}`</mark>

#### Summary

Use this method to retrieve detailed information about a specific market using its market identifier.

#### Request

{% columns %}
{% column width="60%" %}
**Path parameters**

**`marketId`** <mark style="color:red;">`required`</mark>

The market identifier, in the following format: `{marketType}.{baseAssetId}_{quoteAssetId}`, for example: `cfd.eth_eur`.
{% endcolumn %}

{% column width="40%" %}
{% code title="Request example" %}

```http
GET /frontoffice/api/v6/markets/{marketId} HTTP/1.1
Host: {host}
Authorization: Bearer JWT
Accept: */*
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

#### Response

{% columns %}
{% column width="60%" %}
In case of success, an object will be returned.

Each object contains the following information:

**`marketId`** `string`

The market identifier, in the following format: `{marketType}.{baseAssetId}_{quoteAssetId}`, for example: `cfd.eth_eur`.

**`displayName`** `string`

The market ticker.

**`fullName`** `string | nullable`

The market full name or description (optional).

**`baseAssetId`** `string`

The base asset identifier.

**`quoteAssetId`** `string`

The quote asset identifier.

**`minAmount`** `decimal string | nullable`

*Applicable to Spot markets only.*

The minimum tradable amount of the base asset.

**`maxBaseAmount`** `decimal string | nullable`

The maximum tradable amount of the base asset.

**`priceDeviation`** `decimal string`

The allowed price deviation for Limit orders placed on the market.

Supports decimal values in the range `[0, 1]`, with up to 4 decimal places, for example:

* `0.1` = 10%
* `0.01` = 1%
* `0.001` = 0.1%
* `0.0001` = 0.01%

If set to `0`, no restriction is applied, the price deviation is ignored.

**`priceScale`** `integer`

The price precision, which is the number of digits after a decimal separator. Also determines the minimum allowed trade price.

Supports only integer values in the range `[2, 8]`. For example, `2` means the following price format: `0.01`, and `8`: `0.00000001`.

**`amountScale`** `integer | nullable`

*Applicable to Spot markets only.*

The amount precision, which is the number of digits after a decimal separator. Also determines the minimum trade amount.

Supports only integer values in the range `[0, 8]`. For example:

* `0` means `1` (no digits after the decimal separator)
* `5` means `0.00001` (five digits after the decimal separator)
* `8` means `0.00000001` (eight digits after the decimal separator)

**`type`** `string`

The market type.

Possible values:

* `Spot`
* `Cfd`
* `Perp`

**`subtype`** `string | nullable`

*Applicable to CFD markets only.*

The market subtype.

Possible values:

* `Crypto`
* `Fx`
* `Metals`
* `Indices`
* `Energies`
* `Ndf`
* `Shares`
* `Etf`

**`swapSettings`** `object | nullable`

*Applicable to CFD markets only.*

The fee type charged for holding open positions overnight. The amount can be negative for rebates.

Possible values:

* `FixPerLot`: The fixed amount per lot.
* `Percent`: The fixed amount in points which is applied to the position size, in the range `[-1, 1]`, with up to 5 decimal places.
* `Points`: The fixed amount of percents which is applied to the position size, with up to 3 decimal places.

Structure:

* **`type`** `string` — Swap calculation type. Possible values: `FixPerLot`, `Percent`, `Points`.
* **`shortPositionSettings`** `object` — Settings for Short positions:
  * **`size`** `decimal string`
  * **`assetId`** `string | nullable`
* **`longPositionSettings`** `object` — Settings for Long positions:
  * **`size`** `decimal string`
  * **`assetId`** `string | nullable`

**`lotSize`** `integer | nullable`

*Not applicable to Spot markets.*

The standardized quantity of the base asset per lot.

Supports only integer values in the range `[1, 1000000]`.

**`minLotAmount`** `decimal string | nullable`

*Not applicable to Spot markets.*

The minimum order amount, in lots, that can be placed and executed.

Supports values in the range `[0.00000001, 1]`.

**`maxLotAmount`** `integer | nullable`

*Not applicable to Spot markets.*

The maximum order amount, in lots, that can be placed and executed.

Supports only integer values in the range `[1, 10000]`.

**`tickSize`** `decimal string | nullable`

*Not applicable to Spot markets.*

The minimum price increment.

**`lotStep`** `decimal string | nullable`

*Not applicable to Spot markets.*

The minimum lot amount increment.

Supports values in the range `[0.00000001, 1]`. By default, equals to the `minLotAmount`.

**`slippageRate`** `decimal string`

The expected slippage, that is, the difference between the expected execution price and the actual one. This value is used as a multiplier to calculate the funds to be put on hold for a market order execution.

Supports values in the range `[1, 10]`, including decimal values with up to 4 decimal places. The default value is `1` which means that only the current bid/ask price is put on hold. For example, `1.1` means that the current bid or ask price + 10% is put on hold for each order, to cover the 10% slippage.

**Mind that** the total amount funds to be held depends on the order parameters and takes into account many conditions, the slippage rate is only one of them.

**`calendar`** `object`

The trading calendar defining market trading hours.

Structure:

* **`timeZoneId`** `string` — IANA time zone identifier.
* **`tradingSessions`** `array` — Weekly trading sessions:
  * **`dayOfWeek`** `string` — One of: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.
  * **`timeIntervals`** `array` — List of intervals with:
    * **`start`** `string` (time) — Start time in `calendar.timeZoneId`.
    * **`end`** `string` (time) — End time in `calendar.timeZoneId`.
* **`sessionOverrides`** `array` — Optional specific-date overrides:
  * **`date`** `string` (date) — In `YYYY-MM-DD` format.
  * **`timeIntervals`** `array | nullable` — Intervals for that date.

**`fundingStartTime`** `string | nullable`

*Applicable to Perpetual markets only.*

The time of the first funding settlement, in the following format: `HH:MM:SS`.

**`fundingIntervalInHours`** `integer | nullable`

*Applicable to Perpetual markets only.*

The funding settlement interval, in hours.

Possible values: 1, 2, 3, 4, 6, 8, 12, 24.

**`leverageProfile`** `object`

*Not applicable to Spot markets.*

The leverage profile.

Structure:

* **`leverageType`** `string` — Leverage type. Possible values: `Fixed`, `Dynamic`.
* **`leverage`** `object`
  * **`useOnlyMaxLeverage`** `boolean`
  * **`maxLeverage`** `integer` — For `Fixed` leverage type only.
  * **`tiers`** `array` — For `Dynamic` leverage type only.
    * **`maxLeverage`** `integer` — The maximum allowed leverage for this tier.
    * **`maxNotionalValueInRAT`** `string | nullable` — The maximum position notional for this tier.

**`commissionSettings`** `object`

The commission settings.

Structure:

* **`type`** `string` — Leverage type. Possible values: `Fixed`, `Dynamic`.
* **`charge`** `object`
  * **`type`** `string` — Possible values: `Percent`, `FixPerLot`.
  * **`assetId`** `string | nullable` — For `Fixed` commission type only.
  * **`size`** `decimal string` — For `Fixed` commission type only.
  * **`tiers`** `array` — For `Dynamic` commission type only.
    * **`size`** `string` — The commission amount for this tier.
    * **`minTradingVolumeInRAT`** `string` — The minimum required trading volume for this tier.
  * **`minCommissionInRAT`** `decimal string | nullable`
* **`dynamicCommissionGroupId`**

**`isFavorite`** `boolean`

Indicates whether the market is marked as a favorite by the current user.
{% endcolumn %}

{% column width="40%" %}
{% code title="Response example — 200: OK" %}

```json
{
  "marketId": "string",
  "displayName": "string",
  "fullName": "string",
  "baseAssetId": "string",
  "quoteAssetId": "string",
  "minAmount": "string",
  "maxBaseAmount": "string",
  "minQuoteAmount": "string",
  "priceDeviation": "string",
  "priceScale": 0,
  "amountScale": 0,
  "type": "Spot",
  "subtype": "Cash",
  "swapSettings": {
    "type": "FixPerLot",
    "shortPositionSettings": {
      "size": "string",
      "assetId": "string"
    },
    "longPositionSettings": {
      "size": "string",
      "assetId": "string"
    }
  },
  "lotSize": 0,
  "minLotAmount": "string",
  "maxLotAmount": 0,
  "tickSize": "string",
  "lotStep": "string",
  "slippageRate": "string",
  "calendar": {
    "timeZoneId": "string",
    "tradingSessions": [
      {
        "dayOfWeek": "Monday",
        "timeIntervals": [
          {
            "start": "string",
            "end": "string"
          }
        ]
      }
    ],
    "sessionOverrides": [
      {
        "date": "2025-12-18",
        "timeIntervals": [
          {
            "start": "string",
            "end": "string"
          }
        ]
      }
    ]
  },
  "fundingStartTime": "string",
  "fundingIntervalInHours": 0,
  "leverageProfile": {
    "leverageType": "Fixed",
    "leverage": {
      "useOnlyMaxLeverage": true,
      "maxLeverage": 0
    }
  },
  "commissionSettings": {
    "type": "Dynamic",
    "сharge": {
      "type": "Percent",
      "tiers": [
        {
          "size": "string",
          "minTradingVolumeInRAT": "string"
        },
        {
          "size": "string",
          "minTradingVolumeInRAT": "string"
        }
      ],
      "minCommissionInRAT": "string"
    },
    "dynamicCommissionGroupId": "string"
  },
  "isFavorite": true
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

***

### Add favorite market

<mark style="color:green;">`POST`</mark> `/frontoffice/api/v6/markets/favorites/add`

#### Summary

Add a market to the current user's favorites list.

#### Request

{% columns %}
{% column width="60%" %}
**Body**

**`marketId`** `string` <mark style="color:red;">`required`</mark>

The market identifier to add to favorites.
{% endcolumn %}

{% column width="40%" %}
{% code title="Request example" %}

```http
POST /frontoffice/api/v6/markets/favorites/add HTTP/1.1
Host: {host}
Authorization: Bearer JWT
Content-Type: application/json

{
  "marketId": "spot.btc_usdt"
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

#### Response

In case of success (`200`), an empty object is returned.

***

### Remove favorite market

<mark style="color:green;">`POST`</mark> `/frontoffice/api/v6/markets/favorites/delete`

#### Summary

Remove a market from the current user's favorites list.

#### Request

{% columns %}
{% column width="60%" %}
**Body**

**`marketId`** `string` <mark style="color:red;">`required`</mark>

The market identifier to remove from favorites.
{% endcolumn %}

{% column width="40%" %}
{% code title="Request example" %}

```http
POST /frontoffice/api/v6/markets/favorites/delete HTTP/1.1
Host: {host}
Authorization: Bearer JWT
Content-Type: application/json

{
  "marketId": "spot.btc_usdt"
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

#### Response

In case of success (`200`), an empty object is returned.

## Account margin settings

### Get margin assets

<mark style="color:green;">`GET`</mark> `/frontoffice/api/v4/account-margin-settings/assets`

#### Summary

Use this method to retrieve a list of assets that can be used as collateral for margin trading.

#### Request

{% columns %}
{% column width="60%" %}
*No request parameters.*
{% endcolumn %}

{% column width="40%" %}
{% code title="Request example" %}

```http
GET /frontoffice/api/v4/account-margin-settings/assets HTTP/1.1
Host: {host}
Authorization: Bearer JWT
Accept: */*
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

#### Response

{% columns %}
{% column width="60%" %}
In case of success, an object will be returned.

Each object contains the following information:

**`assets`** `array`

A list of assets that can be used as a collateral for margin trading.

Each array item contains:

**`assetId`** `string`

The asset identifier.

**`assetName`** `string`

The asset display name.

**`available`** `decimal string`

The available asset balance.

This value is calculated as *Total balance* – *Locked balance*.

**`total`** `decimal string`

The overall amount of the asset, including locked funds.

**`marginRatio`** `decimal string`

The percentage of the asset value used as a collateral.

Supports values in the range `[0, 1]`, where `1` represents 100.00%.

**`isSelected`** `boolean`

Indicates whether the asset is selected to be used as collateral.

Can be `true` only for assets with the `marginRatio` more than `0`.
{% endcolumn %}

{% column width="40%" %}
{% code title="Response example — 200: OK" %}

```json
{
  "assets": [
    {
      "assetId": "btc",
      "assetName": "btc",
      "available": "0.031",
      "total": "0.031",
      "marginRatio": "1",
      "isSelected": true
    },
    {
      "assetId": "eth",
      "assetName": "eth",
      "available": "0",
      "total": "0",
      "marginRatio": "1",
      "isSelected": false
    }
  ]
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

### Select margin asset

<mark style="color:blue;">`POST`</mark> `/frontoffice/api/v4/account-margin-settings/assets/`<mark style="color:blue;">`{assetId}`</mark>

#### Summary

Use this method to enable a particular asset to be used as collateral for margin trading.

Only assets with the `marginRatio` more than `0` can be selected.

#### Request

{% columns %}
{% column width="60%" %}
**Path parameters**

**`assetId`** <mark style="color:red;">`required`</mark>

The asset identifier.
{% endcolumn %}

{% column width="40%" %}
{% code title="Request example" %}

```http
POST /frontoffice/api/v4/account-margin-settings/assets/usdt HTTP/1.1
Host: {host}
Authorization: Bearer JWT
Content-Type: application/json
Accept: */*

{}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

#### Response

{% columns %}
{% column width="60%" %}
In case of success, an empty object will be returned.
{% endcolumn %}

{% column width="40%" %}
{% code title="Response example — 200: OK" %}

```json
{}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

### Disable margin asset

<mark style="color:red;">`DELETE`</mark> `/frontoffice/api/v4/account-margin-settings/assets/`<mark style="color:blue;">`{assetId}`</mark>

#### Summary

Use this method to prohibit a specific asset from being used as collateral for margin trading.

#### Request

{% columns %}
{% column width="60%" %}
**Path parameters**

**`assetId`** <mark style="color:red;">`required`</mark>

The asset identifier.
{% endcolumn %}

{% column width="40%" %}
{% code title="Request example" %}

```http
DELETE /frontoffice/api/v4/account-margin-settings/assets/usdt HTTP/1.1
Host: {host}
Authorization: Bearer JWT
Accept: */*
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

#### Response

{% columns %}
{% column width="60%" %}
In case of success, an empty object will be returned.
{% endcolumn %}

{% column width="40%" %}
{% code title="Response example — 200: OK" %}

```json
{}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

## Info

### Get server info

<mark style="color:green;">`GET`</mark> `/frontoffice/api/v3/info`

#### Summary

Use this method to retrieve current server time and timezone information.

#### Request

{% columns %}
{% column width="60%" %}
*No request parameters.*
{% endcolumn %}

{% column width="40%" %}
{% code title="Request example" %}

```http
GET /frontoffice/api/v3/info HTTP/1.1
Host: {host}
Authorization: Bearer JWT
Accept: */*
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

#### Response

{% columns %}
{% column width="60%" %}
In case of success, an object will be returned.

Each object contains the following information:

**`serverTime`** `string`

The server time, in the Unix timestamp format.

**`serverTimeZone`** `string`

The server time zone.
{% endcolumn %}

{% column width="40%" %}
{% code title="Response example — 200: OK" %}

```json
{
  "serverTime": "1755190380",
  "serverTimeZone": "+00:00"
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

### Get server time zones

<mark style="color:green;">`GET`</mark> `/frontoffice/api/v3/info/time-zones`

#### Summary

Use this method to retrieve available server time zones.

#### Request

{% columns %}
{% column width="60%" %}
*No request parameters.*
{% endcolumn %}

{% column width="40%" %}
{% code title="Request example" %}

```http
GET /frontoffice/api/v3/info/time-zones HTTP/1.1
Host: {host}
Authorization: Bearer JWT
Accept: */*
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

#### Response

{% columns %}
{% column width="60%" %}
In case of success, an array of objects will be returned.

Each object contains the following information:

**`id`** `string`

The time zone identifier.

**`offset`** `string`

The UTC offset, in the following format: `HH:MM:SS`.

**`offsetInMinutes`** `integer · int32`

The UTC offset in minutes.

**`shortLabel`** `string`

The short label for the time zone.

**`label`** `string`

The display label for the time zone.
{% endcolumn %}

{% column width="40%" %}
{% code title="Response example — 200: OK" %}

```json
[
  {
    "id": "Africa/Abidjan",
    "offset": "00:00:00",
    "offsetInMinutes": 0,
    "shortLabel": "Africa/Abidjan",
    "label": "(UTC+00:00) Côte d’Ivoire Time"
  },
  {
    "id": "Africa/Algiers",
    "offset": "01:00:00",
    "offsetInMinutes": 60,
    "shortLabel": "Africa/Algiers",
    "label": "(UTC+01:00) Central European Time (Algiers)"
  },
  {
    "id": "Africa/Bissau",
    "offset": "00:00:00",
    "offsetInMinutes": 0,
    "shortLabel": "Africa/Bissau",
    "label": "(UTC+00:00) Guinea-Bissau Time"
  }, 
  ...
]
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

## Webhooks

### Create webhook API key

<mark style="color:green;">`POST`</mark> `/frontoffice/api/v3/webhook/api-keys`

#### Summary

Create a new webhook API key for receiving TradingView alerts.

#### Request

{% columns %}
{% column width="60%" %}
**Header parameters**

**`Authorization`** <mark style="color:red;">`required`</mark>

Bearer JWT token with `trading-ui` permission.

**Body**

**`name`** `string` <mark style="color:red;">`required`</mark>

A descriptive name for the API key, up to 100 characters.
{% endcolumn %}

{% column width="40%" %}
{% code title="Request example" %}

```http
POST /frontoffice/api/v3/webhook/api-keys HTTP/1.1
Host: {host}
Authorization: Bearer JWT
Content-Type: application/json

{
  "name": "My TradingView Key"
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

#### Response

{% columns %}
{% column width="60%" %}
In case of success (`201`), the created API key object is returned.

**`id`** `string`

The unique identifier of the API key.

**`apiKey`** `string`

The full API key value. The key is shown only once at creation.

**`name`** `string`

The name assigned to the key.

**`userId`** `string`

The user identifier the key is bound to.

**`status`** `string`

The key status: `Active`.

**`createdAt`** `string`

The timestamp when the key was created.

**`expiresAt`** `string`

The timestamp when the key expires (one year from creation).
{% endcolumn %}

{% column width="40%" %}
{% code title="Response example" %}

```json
{
  "id": "01JZ3CVZKN20410JPYYH1YZJSK",
  "apiKey": "wh_key_abc123def456...",
  "name": "My TradingView Key",
  "userId": "01JZ3CVZKN20410JPYYH1YZJSK",
  "status": "Active",
  "createdAt": "2026-02-02T12:00:00Z",
  "expiresAt": "2027-02-02T00:00:00Z"
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

{% hint style="warning" %}
The API key is shown only once in the creation response. It can't be retrieved again after this call.
{% endhint %}

***

### List webhook API keys

<mark style="color:blue;">`GET`</mark> `/frontoffice/api/v3/webhook/api-keys`

#### Summary

Retrieve all webhook API keys for the authenticated user along with the webhook URL.

#### Request

{% columns %}
{% column width="60%" %}
**Header parameters**

**`Authorization`** <mark style="color:red;">`required`</mark>

Bearer JWT token with `trading-ui` permission.
{% endcolumn %}

{% column width="40%" %}
{% code title="Request example" %}

```http
GET /frontoffice/api/v3/webhook/api-keys HTTP/1.1
Host: {host}
Authorization: Bearer JWT
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

#### Response

{% columns %}
{% column width="60%" %}
In case of success (`200`), the webhook URL and a list of API keys are returned.

**`webhookUrl`** `string`

The webhook URL to configure in TradingView alerts.

**`apiKeys`** `array of objects`

The list of API keys.

**`apiKeys[].id`** `string`

The unique identifier of the API key.

**`apiKeys[].name`** `string`

The name assigned to the key.

**`apiKeys[].status`** `string`

The key status.

Possible values:

* `Active`
* `Revoked`
* `Expired`

**`apiKeys[].createdAt`** `string`

The timestamp when the key was created.

**`apiKeys[].expiresAt`** `string`

The timestamp when the key expires.
{% endcolumn %}

{% column width="40%" %}
{% code title="Response example" %}

```json
{
  "webhookUrl": "https://trading.example.com/frontoffice/api/v3/webhook/alerts/01JZ3...",
  "apiKeys": [
    {
      "id": "01JZ3CVZKN20410JPYYH1YZJSK",
      "name": "My TradingView Key",
      "status": "Active",
      "createdAt": "2026-02-02T12:00:00Z",
      "expiresAt": "2027-02-02T00:00:00Z"
    }
  ]
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

***

### Revoke webhook API key

<mark style="color:red;">`DELETE`</mark> `/frontoffice/api/v3/webhook/api-keys/{id}`

#### Summary

Revoke an active webhook API key. After revocation, the key can no longer be used to authenticate webhook requests.

#### Request

{% columns %}
{% column width="60%" %}
**Header parameters**

**`Authorization`** <mark style="color:red;">`required`</mark>

Bearer JWT token with `trading-ui` permission.

**Path parameters**

**`id`** `string` <mark style="color:red;">`required`</mark>

The unique identifier of the API key to revoke.
{% endcolumn %}

{% column width="40%" %}
{% code title="Request example" %}

```http
DELETE /frontoffice/api/v3/webhook/api-keys/01JZ3CVZKN20410JPYYH1YZJSK HTTP/1.1
Host: {host}
Authorization: Bearer JWT
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

#### Response

{% columns %}
{% column width="60%" %}
In case of success (`200`), a confirmation object is returned.

**`success`** `boolean`

Indicates whether the key was revoked successfully.

**`message`** `string`

A description of the result.
{% endcolumn %}

{% column width="40%" %}
{% code title="Response example" %}

```json
{
  "success": true,
  "message": "API key revoked successfully"
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

***

### Receive TradingView alert

<mark style="color:green;">`POST`</mark> `/frontoffice/api/v3/webhook/alerts/{userId}`

#### Summary

Accept a webhook alert from TradingView and place an order on the specified trading account. TradingView calls this endpoint when an alert triggers.

#### Request

{% columns %}
{% column width="60%" %}
**Path parameters**

**`userId`** `string` <mark style="color:red;">`required`</mark>

The B2PRIME user identifier (ULID format).

**Body**

**`apiKey`** `string` <mark style="color:red;">`required`</mark>

The webhook API key for authentication.

**`accountId`** `string` <mark style="color:red;">`required`</mark>

The trading account identifier.

**`symbol`** `string` <mark style="color:red;">`required`</mark>

The market symbol with a type prefix (`spot.`, `cfd.`, or `perp.`) followed by the pair name. For example: `spot.btc_usdt`, `cfd.eur_usd`, `perp.btc_usdt`.

**`side`** `string` <mark style="color:red;">`required`</mark>

The order side.

Possible values:

* `buy`
* `sell`

**`quantity`** `decimal string` <mark style="color:red;">`required`</mark>

The order quantity in the base asset.

**`orderType`** `string`

The order type. Default: `market`.

Possible values:

* `market`
* `limit`
* `stop`
* `stop_limit`

**`price`** `decimal string`

The limit price. Required for `limit` and `stop_limit` orders.

**`stopPrice`** `decimal string`

The stop price. Required for `stop` and `stop_limit` orders.

**`leverage`** `decimal string`

The leverage ratio. Applicable to CFD and Perpetual Futures markets only.

**`takeProfit`** `decimal string`

The take profit trigger price.

**`stopLoss`** `decimal string`

The stop loss trigger price.

**`timeInForce`** `string`

The time-in-force policy. Default: `gtc`.

Possible values:

* `gtc`
* `ioc`
* `fok`
* `day`

**`comment`** `string`

A custom comment, up to 256 characters.

**`deduplicationId`** `string`

A UUID for idempotency. Duplicate requests with the same ID within five minutes return a cached response.
{% endcolumn %}

{% column width="40%" %}
{% code title="Request example" %}

```http
POST /frontoffice/api/v3/webhook/alerts/01JZ3CVZKN... HTTP/1.1
Host: {host}
Content-Type: application/json

{
  "apiKey": "wh_key_abc123def456...",
  "accountId": "01JZ3CVZKN20410JPYYH1YZJSK",
  "symbol": "spot.btc_usdt",
  "side": "buy",
  "quantity": "0.01",
  "comment": "TV Strategy Signal"
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

#### Response

{% columns %}
{% column width="60%" %}
In case of success (`200`), an order confirmation is returned.

**`success`** `boolean`

Indicates whether the order was placed successfully.

**`orderId`** `string`

The unique identifier of the created order.

**`orderStatus`** `string`

The initial status of the order.

**`message`** `string`

A description of the result.

**`timestamp`** `string`

The timestamp of the response.
{% endcolumn %}

{% column width="40%" %}
{% code title="Response example" %}

```json
{
  "success": true,
  "orderId": "01JZ3CVZKN20410JPYYH1YZJSK",
  "orderStatus": "Working",
  "message": "Order placed successfully",
  "timestamp": "2026-02-02T12:34:56.789Z"
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

#### Rate limits

Webhook requests are limited to five requests per second per user. If the limit is exceeded, the response returns a `429` status code with the following headers:

* `X-RateLimit-Limit`: Maximum requests per window
* `X-RateLimit-Remaining`: Remaining requests in the current window
* `X-RateLimit-Reset`: Unix timestamp when the window resets


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://api-docs.b2prime.com/rest-api/settings.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
