Webhook alerts: send SuperCharting alerts to your own URL as JSON
Webhook alerts post your alert message to an https URL when it fires. Learn the request format, JSON messages, placeholders, retries and limits.
A webhook alert sends an HTTP POST request to a URL you choose every time the alert fires. In SuperCharting you paste the address into Notifications > Webhook URL in the Create alert dialog; the message you wrote, with its placeholders filled in, becomes the request body. This lets a spreadsheet script, a chat bot or your own trading journal react to alerts without anyone watching the screen.
What gets sent
When an alert with a webhook fires, the SuperCharting server sends one POST request to your URL with the header Content-Type: application/json. The body depends on how your message starts:
- Message starts with
{: the message is sent exactly as written, after placeholders are replaced. Use this when your receiver expects its own JSON fields. - Any other message: SuperCharting wraps it in a small JSON object with three fields.
{"symbol": "NSE:RELIANCE", "message": "RELIANCE Crossing Up 2950.00", "time": 1793436125.4}
symbol is the full symbol with its exchange, message is your alert text, and time is the moment it fired in Unix seconds.
The webhook is sent whether or not a browser is open, because alerts run on the server, not in your tab.
Placeholders you can use
Placeholders are written in double curly brackets and replaced when the alert fires. Names the alert does not know are left exactly as typed, so a typo shows up in the received text instead of disappearing.
| Placeholder | Value | Available in |
|---|---|---|
{{ticker}} | symbol without the exchange, e.g. RELIANCE | every alert |
{{exchange}} | exchange prefix, e.g. NSE | every alert |
{{interval}} | the chart timeframe of the alert, e.g. 15 or D | every alert |
{{timenow}} | firing time, UTC, ISO format | every alert |
{{close}} | last price | single price alerts, strategy alerts |
{{open}} {{high}} {{low}} {{volume}} {{time}} | values of the bar | strategy alerts |
{{strategy.order.action}} | buy or sell | strategy alerts |
{{strategy.order.contracts}} {{strategy.order.price}} | fill size and price | strategy alerts |
{{strategy.order.id}} {{strategy.order.comment}} {{strategy.order.alert_message}} | from the order in your script | strategy alerts |
{{strategy.position_size}} {{strategy.market_position}} {{strategy.prev_market_position}} | position after and before the fill | strategy alerts |
A strategy alert is created from the Strategy Tester or by choosing a strategy as the condition source. It sends one notification per new order fill and its default message is {{strategy.order.action}} @ {{strategy.order.contracts}} filled on {{ticker}}. The new strategy position is {{strategy.position_size}}. Fills on historical bars never notify; only fills that happen after the alert is created do.
How to add a webhook to an alert in SuperCharting
- Open the chart, for example XAUUSD on the 1-hour timeframe, and press Alert (or Alt + A).
- Set the condition, say Price, Crossing, 4,150.
- Click the Message row. Give the alert a name and type the body your receiver expects, for example:
{"pair": "{{ticker}}", "price": "{{close}}", "tf": "{{interval}}", "at": "{{timenow}}", "note": "gold at 4150"}
- Click the Notifications row and paste your address into Webhook URL. It must start with
https://. - Press Ok, then Create. If the address is refused you see the reason straight away and the alert is not created.
The Message dialog of a strategy alert lists the strategy placeholders under the text box, so you do not have to remember them.
Rules for the webhook URL
To keep accounts from reaching private networks, SuperCharting accepts a webhook URL only when:
- it uses https (plain http is refused), and
- every address its host name resolves to is a public internet address. Local addresses such as 127.0.0.1, 192.168.x.x or a company intranet are refused with "Webhook URL must be https and reach a public address."
Other details of the request:
- The URL may be up to 500 characters; the message up to 2,000.
- Redirects are not followed, so give the final address.
- The connection waits about 3 seconds to connect and 10 seconds for an answer.
- Requests to one host are paced at about two a second, with short bursts allowed.
Delivery, retries and errors
Webhook requests go into a queue and are sent in the background. When your server answers with a 5xx error or 429 (too many requests), or the network fails, the request is retried with growing pauses. If a host keeps failing, sending to it is paused for a while and then tried again. A delivery that finally fails is written to the Log tab of the Alerts panel as "webhook ... failed" with the reason, so check there first when something does not arrive.
An alert that triggers more than 15 times in 3 minutes is stopped, which also stops its webhooks. Choose a trigger of Once per bar or Once only for anything that could fire repeatedly; see price alerts for how triggers work.
Practical tips
- Test the receiver first. Create a short-lived alert on a liquid symbol such as EURUSD with a level next to the current price and Every time, then confirm the request arrives. Switch to the real settings afterwards.
- Use the alert name. When several alerts post to one URL, put
{{ticker}}and a short label in each message. - Combine conditions with multi-condition alerts when only a full setup should post.
- Keep secrets out of messages. Anything in the message is sent in the body; if your receiver needs a key, keep it on the receiving side.
SuperCharting sends the message and nothing more. It does not place orders anywhere; what your receiver does with a message is up to you. Scripts and backtests are for study, and past results do not guarantee future results.
Frequently asked questions
Can I use an http address?
No. Only https URLs that resolve to public addresses are accepted.
Is the request body always JSON?
The Content-Type header is always JSON. If your message starts with { it is sent as you wrote it, so make sure it is valid. Otherwise your text is wrapped in the symbol, message and time fields.
Why is {{close}} not replaced in my indicator alert?
{{close}} is filled for single price alerts and strategy alerts. In indicator and multi-condition alerts use {{ticker}}, {{exchange}}, {{interval}} and {{timenow}}.
Where do I see failed webhooks?
In the Log tab of the Alerts panel, which keeps the last 200 events.
Can one alert send to several URLs?
No, each alert has one Webhook URL. Create a second alert, or forward the request from your own receiver.