> For the complete documentation index, see [llms.txt](https://docs.sprinthub.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sprinthub.com/en/topics/integrations/integrations-z-api/z-api-queue-system.md).

# Z-API - Queue System

The Z-API has a queue system responsible for organizing and controlling the sending of messages made through the API. This mechanism ensures that messages are processed in an orderly manner and helps maintain the stability of deliveries, especially in scenarios where the device linked to WhatsApp has connection instability.

***

### How does the queue work?

Whenever a message is sent to Z-API, it is not forwarded immediately to WhatsApp. First, it is added to a processing queue, where it waits its turn to be sent.

In simplified terms, the flow works as follows:

1. The system sends the message to Z-API.
2. Z-API adds the message to the queue.
3. The instance processes the queue and sends it to WhatsApp.
4. The webhooks inform the status of the processing and delivery of the message.

### Operation during instability

The queue system also acts as a protection layer when the phone connected to the instance becomes temporarily unavailable, whether due to lack of internet, the device being turned off, or other instabilities.

In these cases, the messages remain stored in the queue and, as soon as the connection is restored, the pending sends will be processed automatically.

***

### How to disable the queue

If you do not want to use the queue system, you need to disable this feature directly in the settings of the **Z-API Web Instance**.

{% hint style="danger" %}
**Important:** when disabling the queue, messages will not be stored if the instance is disconnected. Thus, any send attempt made during a period of unavailability may fail and will not be resent automatically after reconnection.
{% endhint %}

It is recommended to carefully evaluate this setting before disabling it.

<figure><img src="/files/3e91bde52f1e5ab9718d57ce5150093faac7dc3d" alt=""><figcaption></figcaption></figure>

### Important recommendation

Before reconnecting an instance, Z-API recommends checking whether there are any pending messages in the queue.

<figure><img src="/files/e1f3c30baface6be85825defd214723701bcaef9" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/c2cd5c31062b93e59c30bfdc0a9b7b6db09c9902" alt=""><figcaption></figcaption></figure>

This is important because, when the instance reconnects, the queue will run automatically and all pending messages will be sent. Depending on the context, these messages may no longer make sense for the recipient.

For this reason, it is recommended that the user be informed about the existence of these messages and decide whether they want to keep them or discard them before reconnecting.

### Queue limit

Z-API allows storing up to **1,000 messages** in the queue while the phone is disconnected. Once this limit is reached, new messages will begin to be rejected until there is space available in the queue.

***

### Official reference

For more information, see the official Z-API documentation:

<https://developer.z-api.io/queue/introduction>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.sprinthub.com/en/topics/integrations/integrations-z-api/z-api-queue-system.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
