# Create a TradingView alert hook

URL: https://docs.fxapis.com/api-reference/alerts/create-a-tradingview-alert-hook

> Create a TradingView alert hook. Returns a secret url to paste into a TradingView alert's Webhook URL.

`POST https://api.fxapis.com/v1/alert-hooks`

Returns a secret `url` to paste into a TradingView alert's **Webhook URL**. Every alert sent to it becomes an order on the hook's accounts: one account places an ordinary order, several place a multi-account order.

**The URL is returned once**, here, and is a credential: anyone who has it can trade these accounts. We store only a hash of it. Lost or leaked, rotate it.

`defaults` fill in what an alert leaves out and translate TradingView's symbols to your broker's. See the TradingView guide for the message format.

Several accounts need a plan with multi-account orders; that is checked here, and again on every alert.

Authentication: `Authorization: Bearer <API key>`.

#### Request body (application/json, required)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | yes | Example: `"Gold breakout strategy"` |
| `accountIds` | string (uuid)[] | yes | Example: `["2b0c7c1e-5d0b-4d8e-9a53-0e6f3b1c9a10"]` |
| `defaults` | object | no |  |
| `defaults.volume` | string | no | Lots, used when an alert does not send `volume`. Example: `"0.10"` |
| `defaults.deviationPoints` | null \| integer | no | Maximum slippage in points. Null leaves it to the terminal. Example: `20` |
| `defaults.symbolMap` | object | no | TradingView symbol (after the exchange prefix is removed) → your broker's symbol. Checked before the suffix. Example: `{"XAUUSD":"XAUUSD.a","US30":"DJ30"}` |
| `defaults.symbolSuffix` | string | no | Appended to symbols the map does not name — for brokers that decorate every symbol, like `EURUSD.a`. Example: `".a"` |
| `defaults.stripExchangePrefix` | boolean | no | Turn `OANDA:XAUUSD` into `XAUUSD`. On by default. |
| `defaults.allowClose` | boolean | no | Whether `close`, `flat` and `close_all` alerts are acted on. On by default. |
| `defaults.onlyTradingViewIps` | boolean | no | Refuse alerts that do not come from TradingView's published webhook addresses. On by default. |

#### Responses

- `201`
- `400`
- `401`
- `402`
- `403`
- `404`
- `409`

Failures return `{ "error": { "code", "message" } }`; every code is listed at https://docs.fxapis.com/errors.

#### 201 response fields

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | object | no |  |
| `data.id` | string (uuid) | no |  |
| `data.name` | string | no |  |
| `data.accountIds` | string (uuid)[] | no | One account places an ordinary order; several place a multi-account order. |
| `data.defaults` | object | no |  |
| `data.defaults.volume` | string | no | Lots, used when an alert does not send `volume`. Example: `"0.10"` |
| `data.defaults.deviationPoints` | null \| integer | no | Maximum slippage in points. Null leaves it to the terminal. Example: `20` |
| `data.defaults.symbolMap` | object | no | TradingView symbol (after the exchange prefix is removed) → your broker's symbol. Checked before the suffix. Example: `{"XAUUSD":"XAUUSD.a","US30":"DJ30"}` |
| `data.defaults.symbolSuffix` | string | no | Appended to symbols the map does not name — for brokers that decorate every symbol, like `EURUSD.a`. Example: `".a"` |
| `data.defaults.stripExchangePrefix` | boolean | no | Turn `OANDA:XAUUSD` into `XAUUSD`. On by default. |
| `data.defaults.allowClose` | boolean | no | Whether `close`, `flat` and `close_all` alerts are acted on. On by default. |
| `data.defaults.onlyTradingViewIps` | boolean | no | Refuse alerts that do not come from TradingView's published webhook addresses. On by default. |
| `data.enabled` | boolean | no |  |
| `data.urlHint` | string | no | The URL with its secret elided, for telling hooks apart. The full URL is returned only by create and rotate. Example: `"https://api.fxapis.com/hooks/tradingview/…Qx4w"` |
| `data.lastUsedAt` | null \| string (date-time) | no | When an alert last arrived, to the minute. |
| `data.createdAt` | string (date-time) | no |  |
| `data.url` | string | no | Paste this into the alert's Webhook URL. Shown here and never again — anyone holding it can trade the hook's accounts. Lost or leaked: rotate. Example: `"https://api.fxapis.com/hooks/tradingview/3q2-7ZkT0d8m1sQe9yVbW4nX6pLr5aHcUgJf0oKxQx4w"` |