An automatic message one system sends to another's web address when an event happens. In trading, a webhook can pass a signal from an external source to a bot, which then opens or closes a position by its rules.
A webhook is a push notification between two apps: when an event happens, the sending app makes an HTTP request to a URL the receiving app gave it, and the receiver acts on the message. In trading, the event is usually an alert from charting or alert tools or a rule in your own script, and the receiver is a webhook trading bot that turns the message into an order on your exchange account.
What is a webhook and how does it work
A webhook, also called a web callback or HTTP push, works in four steps:
- The receiver creates a URL. A trading bot shows you its webhook URL, and you paste it into the tool that sends the signals.
- An event happens at the sender. An alert condition is met, a payment clears or a message arrives.
- The sender makes an HTTP request. It is usually a POST request whose body, the payload, describes the event in a short message, often JSON or plain text.
- The receiver checks the request and acts. It answers with a status code: 2xx when the request is accepted, 4xx when it is refused.
If the receiver is offline at that moment, some senders retry and others give up, so a message can be lost.
Webhook vs API
With an API, the app that needs data asks for it, and has to keep asking to catch a change (polling). A webhook reverses the direction, which is why it is sometimes called a reverse API.
| API request | Webhook | |
|---|---|---|
| Who starts it | The app that needs the data | The app where the event happened |
| When data arrives | When the app asks | Right after the event |
| When nothing happens | Requests are wasted | Nothing is sent |
| Trading example | Reading a balance, placing an order | Passing an entry or exit signal to a bot |
In a trading bot the two work together: the signal arrives by webhook, and the bot places the order through the exchange API with your API key.
Webhook examples
- Payments: a payment service tells an online shop that an order was paid.
- Software: a code repository starts a build after every change.
- Trading: an alert tool sends an entry or exit signal to a trading bot.
A trading example, with hypothetical numbers that only show the arithmetic. An alert fires when the 1-hour candle closes above 100 and sends the bot a POST request with a short message: open a long, take profit at 106, stop-loss at 97. The bot buys at the market price, say 100.50, so the stop sits 3.50 below the entry. If the bot sizes trades from a fixed risk of 15 USDT, the position is 15 ÷ 3.50 = 4.29 coins, about 431 USDT, and a fill at exactly 97 loses 15 USDT before fees.
How a webhook trading bot works
A webhook trading bot splits the job in two: the signal source decides when to trade, and the bot decides how, from the pair and the position size to the take profit, the stop-loss and the orders it sends to the exchange. Plan for three weak points:
- Late or lost signals: a bot cannot act on a request that never arrived.
- Blind execution: the bot executes any valid signal at once, including a wrong one.
- Testing: the entry logic lives in the signal source, so the bot's own backtesting cannot replay it.
What to check in a webhook trading platform
Before you connect an external signal source to a webhook trading platform, check:
- URLs: one per bot, or separate URLs for opening and closing a position.
- Message: which fields it needs, and which exits come from the message rather than the bot settings.
- Sizing: a fixed amount, or a size worked out from a risk amount and the stop; see position sizing.
- Stopped bots: what happens to a signal that arrives while the bot is off.
- Funds: whether your trading capital stays in your own exchange account.
Webhook security
A trading webhook URL works like a password: whoever has it can send your bot a signal. Keep it out of screenshots, chats and public code, paste it only into tools you trust, and keep API keys and passwords out of the message.
Webhooks on Freya
On Freya Finance, signal bots open trades only on webhook signals sent to them; indicator entry conditions belong to DCA bots. Signal bots trade on Binance, Bybit and OKX, on spot and futures, in two modes:
| Custom Signal | Risk Ratio | |
|---|---|---|
| Webhook URLs | Two: Open and Close | One, for opening |
| Take profit and stop-loss | Percentages you set in the bot | Prices carried in the webhook message |
| Position size | The amount you set | Sized from a fixed risk amount |
- Freya accepts webhook signals only as POST requests. If the bot is not active, an open signal is rejected, while a close signal is still processed.
- Webhook signal strategies cannot be backtested on Freya; test the strategy where its signals are generated.
- A webhook is also one of the entry condition types of a DCA bot.
- Freya does not take signals from Telegram. Telegram is used only for account linking and notifications.
Setup: how to create a signal bot, Risk Ratio mode and DCA bot vs signal bot. Strategy: the signal bot strategy guide.
A bot acts on a valid signal at once, so a wrong or late signal becomes a real trade on your account. The numbers on this page are hypothetical. Trading involves risk. Only invest what you can afford to lose.
Frequently Asked Questions
What is a webhook in trading?
A webhook in trading is an HTTP request that carries a signal from charting or alert tools, or from your own script, to a trading bot at the moment the signal fires. The bot reads the message and trades on your exchange account according to its settings.
How does a webhook trading bot work?
It waits for requests on its webhook URL. When a valid signal arrives, it places orders through the exchange API, with the size, take profit and stop-loss taken from its settings or from the message. On Freya, signal bots open trades only on webhook signals.
What is an example of a webhook?
A payment service telling an online shop that an order was paid is the classic example. In trading, an alert tool sends a POST request to a bot's URL when the price closes above a level, and the bot opens the trade.
Can you backtest a webhook trading strategy?
Not inside the bot, because the entry logic lives in the signal source. On Freya, webhook signal strategies cannot be backtested, so test the strategy where its signals are generated, including fees and slippage. DCA bots built on Freya's own entry conditions can be backtested.
Does Freya take trading signals from Telegram?
No. Freya does not read Telegram channels or take signals from Telegram; Telegram is used only for account linking and notifications. A signal bot acts only on requests sent to its webhook URLs.