Queue
curl --request POST \
--url https://api.z-api.io/instances/{instanceId}/token/{token}/queue \
--header 'Client-Token: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"pageSize": 123,
"pagingState": "<string>"
}
'import requests
url = "https://api.z-api.io/instances/{instanceId}/token/{token}/queue"
payload = {
"pageSize": 123,
"pagingState": "<string>"
}
headers = {
"Client-Token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Client-Token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({pageSize: 123, pagingState: '<string>'})
};
fetch('https://api.z-api.io/instances/{instanceId}/token/{token}/queue', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.z-api.io/instances/{instanceId}/token/{token}/queue",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'pageSize' => 123,
'pagingState' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Client-Token: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.z-api.io/instances/{instanceId}/token/{token}/queue"
payload := strings.NewReader("{\n \"pageSize\": 123,\n \"pagingState\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Client-Token", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.z-api.io/instances/{instanceId}/token/{token}/queue")
.header("Client-Token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"pageSize\": 123,\n \"pagingState\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.z-api.io/instances/{instanceId}/token/{token}/queue")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Client-Token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"pageSize\": 123,\n \"pagingState\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"messages": [
{}
],
"pagingState": "<string>",
"hasMore": true
}Message Queue
Queue
Returns messages from the queue awaiting processing with cursor-based pagination
POST
/
instances
/
{instanceId}
/
token
/
{token}
/
queue
Queue
curl --request POST \
--url https://api.z-api.io/instances/{instanceId}/token/{token}/queue \
--header 'Client-Token: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"pageSize": 123,
"pagingState": "<string>"
}
'import requests
url = "https://api.z-api.io/instances/{instanceId}/token/{token}/queue"
payload = {
"pageSize": 123,
"pagingState": "<string>"
}
headers = {
"Client-Token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Client-Token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({pageSize: 123, pagingState: '<string>'})
};
fetch('https://api.z-api.io/instances/{instanceId}/token/{token}/queue', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.z-api.io/instances/{instanceId}/token/{token}/queue",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'pageSize' => 123,
'pagingState' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Client-Token: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.z-api.io/instances/{instanceId}/token/{token}/queue"
payload := strings.NewReader("{\n \"pageSize\": 123,\n \"pagingState\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Client-Token", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.z-api.io/instances/{instanceId}/token/{token}/queue")
.header("Client-Token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"pageSize\": 123,\n \"pagingState\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.z-api.io/instances/{instanceId}/token/{token}/queue")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Client-Token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"pageSize\": 123,\n \"pagingState\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"messages": [
{}
],
"pagingState": "<string>",
"hasMore": true
}Overview
This method returns messages in the queue awaiting processing, with cursor-based pagination support. Unlike the GET endpoint, this one allows more efficient pagination usingpagingState.
Attributes
Required
Body (Optional)
Pagination cursor. When not provided, returns the first page. Use the value returned in the response to fetch the next pages.
Request Body
First page:{}
{
"pageSize": 20,
"pagingState": "eyJidWNrZXQiOjI5MzQsInBhZ2VTdGF0ZSI6IjAw..."
}
Response
200
{
"messages": [
{
"_id": "019D44XXXXXXXXXXXXXXXXX68DA6",
"DelayMessage": -1,
"Message": "Test message",
"InstanceId": "3E98XXXXXXXXXXXXXXXXXXXF5DDF",
"Phone": "5511999999999",
"ZaapId": "019D44XXXXXXXXXXXXXXXXX68DA6",
"DelayTyping": 0,
"MessageId": "ECFXXXXXXXXXXXXXX39",
"Created": 1774968031776,
"CreatedAt": "2026-03-31T14:40:31.776+00:00",
"Beta": false,
"IsTrial": false
}
],
"pagingState": "eyJi...",
"hasMore": true
}
Pagination
- If you don’t send
pagingState, the first page will be returned automatically - If you don’t provide
pageSize, the default value of 20 messages will be used - The maximum number of messages that can be returned per page is 30
- Use the returned
pagingStateto fetch the next pages - When
hasMoreisfalse, there are no more messages available