# Create a TradingView alert for ZB Connector

> Set up a TradingView alert that sends a JSON command to ZB Connector: the webhook URL, the message, the license field and a checklist for valid JSON.

Source: https://zb-connector.com/docs/tradingview/alert-basics/

A ZB Connector alert is a TradingView alert with a **Webhook URL** and a **JSON message** that names your license and the command to run. This page shows how to set both up and how to check that the message is valid.

> **Use a demo account first.** Run every step on a MetaTrader 5 demo account. Switch to a live account only after the go-live checklist is done.

**Before you start:** a TradingView plan with webhooks and two-factor authentication switched on ([requirements](https://zb-connector.com/docs/get-started/requirements/)), and your [license key](https://zb-connector.com/docs/get-started/create-account-and-license/).

1.  In TradingView, open the alert dialog for the chart or strategy you want to automate.
    
2.  In the alert’s notification options, tick **Webhook URL** and enter:
    
    `https://dev.api.zb-connector.com/webhook/`
    
    TradingView sends a POST request to this address every time the alert triggers. Webhooks only use port 80 or 443; this address uses the standard HTTPS port.
    
3.  In the message box, replace the text with a JSON command:
    
    **Alert message**
    
    ```json
    {
      "license": "YOUR_LICENSE_KEY",
      "action": "long",
      "symbol": "EURUSD",
      "volume": 0.01,
      "positionID": "my_strategy_1"
    }
    ```
    
    -   `license` is your license key. The field is called `license`.
    -   `action` is the command to run. The [commands overview](https://zb-connector.com/docs/commands/overview/) lists them.
    -   The other fields depend on the command: see its page in the [cheat sheet](https://zb-connector.com/docs/commands/cheatsheet/).
4.  Create the alert and let it fire.
    
    > **What you should see:** The TradingView alert log shows the alert, and its Webhook status shows that the request was accepted. In the dashboard, Command History lists the command.
    

## Check your message is valid JSON

TradingView sends the message as `application/json` when it is valid JSON, and as `text/plain` otherwise. ZB Connector reads the body as JSON in both cases, so a message that is not valid JSON is refused with HTTP 400. Check these points:

-   [ ]  Straight double quotes (`"`) around every name and every text value, not curly quotes.
-   [ ]  No comma after the last field.
-   [ ]  Numbers such as `volume` and `sl` are not in quotes (numeric text such as `"0.01"` is also accepted).
-   [ ]  `positionID` is text, so it **is** in quotes. A number there is rejected.
-   [ ]  Your license key is spelled exactly as in the dashboard.
-   [ ]  The message is one JSON object, not a list.

## What the webhook answers

The webhook checks the license and the command before it queues anything. It answers **HTTP 200** when the command is queued, which does not mean the trade ran. An invalid command is refused with **HTTP 422** and a message that names the problem, and nothing is queued. TradingView cancels a request that takes longer than 3 seconds. All the replies are listed in [webhook HTTP codes](https://zb-connector.com/docs/troubleshooting/webhook-http-codes/).

## If it does not work

-   **No row in the TradingView alert log:** the alert did not fire. Check its condition and that it is active.
-   **A row, but the webhook status is an error:** find the code in [webhook HTTP codes](https://zb-connector.com/docs/troubleshooting/webhook-http-codes/).
-   **Webhook status is a success, but nothing in Command History:** make sure the dashboard shows the license you used in the message.
-   Still stuck? Follow [find where the alert stopped](https://zb-connector.com/docs/troubleshooting/find-where-it-stopped/).

## Next step

[Use placeholders](https://zb-connector.com/docs/tradingview/placeholders/) to fill values from the chart, then send a [test alert](https://zb-connector.com/docs/get-started/send-a-test-alert/).
