# How delivery works

> How a command travels from your TradingView alert to MT5: the queue, polling, expiry, at-most-once delivery and what you see at each stage.

Source: https://zb-connector.com/docs/reliability/how-delivery-works/

ZB Connector delivers each command to your EA at most once, and only while it is still fresh. This page explains why, and what you see when something goes wrong.

**Simple version**

The API queues each command for your license. Your EA collects the whole queue once per second. A command is handed over once: if the EA stops before it acts, the command is not sent again, because a retry could open the same trade twice. A command the EA does not collect within 5 minutes expires and is never run late. In the dashboard you see the stage in Command History.

The life of a command:

1.  Webhook accepts it, license and command are checked. Then: HTTP 200
2.  Queued for your license, waits up to 5 minutes. Then: EA polls
3.  EA collects the queue, once per second, then it is delivered. Then: MT5 places the order
4.  EA executes and reports, result shows in the dashboard

**Advanced version**

## Stage by stage

1.  **Webhook.** TradingView sends the message. The API checks the license first: HTTP 401 for a missing or unknown license, 403 for an expired or blocked one, 429 above 120 messages per minute. A body that is not a JSON object gets 400, and an invalid command gets 422. Nothing is queued for these. A valid command is queued and answered with **HTTP 200**.
2.  **Queue.** The command waits in a queue for your license. There is no size limit. While your EA is offline the commands stay there until they expire, 5 minutes after they were queued.
3.  **Poll.** The EA asks for new commands every second by default. Each poll also marks the license **Online** for 8 seconds. One poll collects every command that is still valid, skips the expired ones, and empties the queue.
4.  **Execution.** The EA runs the commands in order and reports results back: that is what turns a row in Command History to **Executed** or **Failed**.

## At most once

Because the queue is emptied when the EA collects it, a command that was handed to an EA that then crashed, lost its connection mid-reply or restarted is **not sent again**. This is deliberate. Resending after a lost reply could open the same trade twice, and for trading a missing order is safer than a duplicate one.

To make such a case visible, ZB Connector watches for commands that were delivered but show no sign of execution after 10 minutes. It then raises one notification, **Trade command unconfirmed**. It is a warning, not proof that the command failed: check MT5 and your positions.

## Why commands expire

A stale signal can be worse than none. A command that waited longer than 5 minutes is dropped when the EA returns and shows **Expired** in Command History. It is never run late.

## What you see

| Command History status | Meaning |
| --- | --- |
| Pending | Queued. The EA has not collected it yet. |
| Delivered | The EA collected it. A successful open normally stays here; look at MT5 and **Accounts** for the trade. |
| Executed | The EA reported success for a close or a stop change. |
| Failed | The EA reported a failure. Hover the badge for the reason, for example “Invalid stops in the request”. |
| Expired | Nobody collected it within 5 minutes. It will never run. |

Account figures and open positions in the dashboard come from the EA’s periodic update, every 15 seconds by default, so they can lag behind MT5.

HTTP 200 is not proof

HTTP 200 only says the command passed the checks and was queued. Only the later stages show whether the trade ran.

## Related

-   [If something goes offline](https://zb-connector.com/docs/reliability/if-something-goes-offline/)
-   [Known limitations](https://zb-connector.com/docs/reliability/known-limitations/)
-   [Find where an alert stopped](https://zb-connector.com/docs/troubleshooting/find-where-it-stopped/)
