How to connect trading agents to webhooks and automation in 2026
Learn how to connect trading agents to webhooks and automation in 2026 using a single API, scoped keys, and non custodial controls that keep funds in your wallet.
- 01Webhooks allow trading agents to receive event driven updates instead of polling, reducing latency and API load.
- 02Every automation rule should start in paper trading and graduate to live only after explicit owner authorization of a scoped key.
- 03Scoped API keys, budget caps, and a kill switch are the minimum safety layer for any automated trading agent.
- 04The Felix API normalizes webhook payloads across stocks, crypto, perps, options, and prediction markets into a single shape.
- 05Trading can lose money, including everything, so automation logic must include exit plans and position limits before any real capital is deployed.
Webhooks let a trading agent receive event driven notifications instead of constantly polling for price changes or fill updates. In 2026, this pattern is the standard way to trigger automation logic across stocks, crypto, perpetual futures, options, and prediction markets. When you connect an agent to the Felix API, you register a webhook endpoint that receives normalized payloads whenever relevant events occur, such as order fills or price thresholds crossing. The agent can then decide what to do next without wasting requests on empty data.
What are webhooks and why do agents need them?
Before webhooks became the default integration pattern, most automated systems relied on polling. An agent would repeatedly ask a stock broker or a perps venue for the latest price, order book depth, or fill status. This approach wastes bandwidth, exhausts rate limits, and adds latency because the agent only learns about changes at the interval of its timer. In fast markets, that delay can mean the difference between a filled order and a missed level. In 2026, most venues and brokers support push notifications, but the formats vary widely. Felix absorbs this variance so your agent sees one schema. Webhooks solve the polling problem by inverting the flow. Instead of the agent asking for updates, the API pushes a notification to the agent the moment a relevant event occurs. The payload is normalized, so a handler written for crypto spot events does not need to be rewritten for options greeks or prediction market odds. How trading agents use webhooks and automation in 2026 covers the broader architectural shift. For a trading agent, the benefit is immediate. The agent can sleep until something happens, then wake, validate the signal, and decide whether to act. This event driven model reduces API load and keeps logic simple. You subscribe only to the events you need, such as fills, price thresholds, or margin calls. The rest of the time, your infrastructure sits idle. That efficiency matters when you run multiple agents or when you pay for compute by the millisecond.
How do you register a webhook with the Felix API?
Registration begins with an endpoint you control. It must use HTTPS and be reachable from the public internet. You cannot use a local host address or an unencrypted endpoint. You provide the URL, the list of events you want, and a verification secret that the API will use to sign each payload. This signature lets your handler confirm that the event genuinely came from Felix and not from an attacker probing your endpoint. You can register through the REST API or through an MCP tool if your agent is managed inside Claude, Cursor, or another MCP client. The exact request schema is in the docs; the shape looks like this.
{
"url": "https://your-server.com/webhook",
"events": ["fill", "price.threshold"],
"secret": "YOUR_VERIFICATION_SECRET"
}After you submit the registration, the API sends a test event to verify connectivity. Your handler should validate the signature, return a 200 status code quickly, and ignore any event types it does not recognize. This defensive coding style is important because the API may add new event types over time. If your handler throws an exception on an unknown field, you risk missing a critical fill or margin alert. Keep the handler stateless. Store positions, budgets, and pending orders in a database or cache, not in memory. Serverless functions are ideal here because they scale to zero between events and wake only when a webhook arrives. If you use a persistent server, consider a queue between the webhook handler and the order logic so that a slow decision does not block the HTTP response. Once the endpoint is confirmed, the agent begins receiving normalized events across stocks, crypto, perps, options, and prediction markets. You do not need to register separate hooks for each venue. The single API handles routing and formatting, which keeps your integration surface small and auditable.
What safety controls should you enable before going live?
Automation magnifies mistakes. A logic bug that would cost one manual trade can loop through a webhook stream and generate dozens of orders in seconds. You should therefore treat the agent as the least trusted component in your stack and wrap it in controls that the infrastructure enforces. The essential layers include the following.
- ·Scoped API keys that can trade but cannot withdraw funds. Withdrawal addresses are owner approved only, so a compromised agent cannot steal capital.
- ·Budget caps that act as a hard ceiling on daily or weekly losses. Once the cap is reached, the API rejects further orders.
- ·Position limits that restrict the maximum notional size per market and per side. This prevents concentration in a single volatile instrument.
- ·Exit plans that trigger flattening when a drawdown threshold is breached. These rules should be evaluated by the API, not by the agent.
- ·A panic switch that flattens all positions and revokes the scoped key in one action. How to add a kill switch to your MCP trading agent describes the mechanics.
Hard limits must live outside the agent because the agent is the component most likely to fail. How to set hard limits that stock trading agents cannot cross explains why infrastructure level enforcement is safer than trusting the agent to police itself. Trading can lose money, including everything, so these controls are not optional extras. They are the minimum viable safety layer for any automated system trading real money.
How does paper trading differ from live automation?
Felix provides paper trading so you can test webhooks and automation logic without risking capital. The webhook payloads in paper mode are identical in shape to live payloads. Your handler code does not need to branch based on environment. However, the execution path diverges behind the scenes. Paper trades simulate fills against current market data, while live trades route to real venues and carry slippage, latency, and liquidity constraints. This distinction is important because an agent that appears profitable in paper may fail in live trading. It might assume perfect fills at the mid price, ignore market impact on large orders, or behave differently when the emotional reality of real money is present. How paper trading changes when AI agents trade real money explores this gap in depth. To move from paper to live, you must explicitly authorize a scoped key for real trading. The system will not let an agent graduate on its own. You should run the agent in paper long enough to cover different market regimes, including high volatility and low liquidity. Only after you observe stable behavior and confirm that your safety controls trigger correctly should you authorize live access. Even then, start with a small budget cap and increase it only after additional observation. Never assume that a strategy which works in simulation will work in production.
What does a basic automation flow look like?
Consider a hypothetical agent that manages risk across a multi market portfolio. It does not predict prices. It simply enforces rules you have written. Suppose the agent receives a webhook indicating that a long position in a perps venue has crossed a maintenance margin threshold. The payload includes the market identifier, the current margin ratio, and the position size in US dollar terms. The agent parses this, then queries its internal state to confirm two things. First, flattening the position will not breach the daily budget cap. Second, the resulting portfolio delta will remain within the total exposure limit. If both checks pass, the agent submits a reduce only order sized in plain US dollars. The API normalizes the venue specific contract math and routes the order. The agent does not need to know the contract size, tick size, or margin formula. A second webhook arrives when the fill occurs, carrying the executed price, fee, and realized profit or loss. The agent updates its ledger and waits for the next event. This same flow works for stocks, crypto spot, options, or prediction markets. Because the API abstracts venue details, one handler can manage cross market logic. This example is hypothetical. Real world automation must also handle partial fills, network latency, and funding rate changes that alter margin calculations between events. The agent never touches the underlying wallet. Funds sit in a wallet you control, and the agent can spend within limits but can never withdraw to itself.
How do you monitor and shut down an automated agent?
An automated agent can outpace human reaction time, which is both its strength and its danger. You need external monitoring that watches the agent rather than trusting the agent to report on itself. Set up alerts for webhook delivery failure rates, budget cap consumption speed, and unexpected order rejection rates. You should also measure the lag between the webhook timestamp and the handler action. If your agent takes too long to decide, the market may have moved past the price that triggered the event. If your endpoint starts returning 500 errors, the agent may be receiving events it cannot parse, or it may be sending orders that violate your hard limits. Either case demands a pause. Log every incoming webhook payload and every outgoing order decision to an immutable store. When you need to diagnose a sequence of trades, the log is your source of truth. Keep the log separate from the agent so that a compromised or buggy agent cannot erase its tracks. The fastest way to stop a runaway agent is the kill switch. It flattens all open positions and revokes the scoped API key, which simultaneously stops new orders and disables the webhook stream. You can also rotate the webhook secret or change the endpoint URL to break the loop temporarily while you inspect the code. Review your setup carefully before you increase capital. Automation is only as safe as the controls you wrap around it, and those controls require human attention even after they are configured.
Frequently asked questions
Yes. You need a publicly reachable HTTPS endpoint. Serverless functions or a small cloud instance work well. The endpoint must return a 200 status promptly so the API knows the event was delivered.
You can use the same URL, but the payloads include an environment flag. Your handler should inspect this flag and route orders to the correct execution path. Never assume paper mode is active.
Events may queue briefly, but you should not rely on this. Build your agent to reconcile its state with the REST API periodically. Design handlers to be idempotent so duplicate events do not cause duplicate orders.
Use the panic switch. It flattens all open positions and revokes the scoped API key. This is faster than editing code and safer than hoping the agent self corrects.
No. Funds remain in a wallet you control. The agent can spend within the limits you set, but it cannot withdraw to itself or to any address you have not pre approved.
Yes. The Felix API normalizes the payload shape. A single endpoint can receive events for stocks, crypto, perps, options, and prediction markets. Your handler parses the market type field and acts accordingly.
Give your agent a key.
One key to trade stocks, crypto, perps, options, and prediction markets. Live after owner authorization.
Most traders assume that keeping funds in their own wallet means they must manually approve every trade. In reality, non-custodial agentic trading lets you set programmatic limits that are stronger than manual checks.
Running a trading agent from Claude step by step seems simple, but small errors in prompts, keys, or sizing often lead to unexpected positions and losses.