Skip to main content
POST
On-demand history sweep

Authorizations

Authorization
string
header
required

API Key for authentication. Format: <API_KEY>

Query Parameters

async

Body

sessionId
string
required

Session id.

Minimum string length: 1
chats
string[]

JIDs of the chats to sweep, e.g. 5511999999999@s.whatsapp.net or 120363000000000000@g.us. Without chats, sweeps the maxChats chats with the most recent message.

Maximum array length: 1000
Minimum string length: 1
maxChats
integer
default:200

How many chats to sweep (also caps chats). Default 200, maximum 1000.

Required range: 1 <= x <= 1000
count
integer
default:50

Messages requested per page. Default 50.

Required range: 1 <= x <= 100
maxPagesPerChat
integer
default:20

Maximum pages per chat. Default 20. A chat also stops earlier, when the phone returns nothing.

Required range: 1 <= x <= 200
intervalMs
integer
default:3000

Interval between requests to the phone, in milliseconds. Default 3000.

Required range: 1000 <= x <= 60000
requestFull
boolean
default:false

Also asks for a FULL_HISTORY_SYNC_ON_DEMAND. Only WhatsApp Business accepts it; personal WhatsApp answers ERROR_REQUEST_ON_NON_SMB_PRIMARY.

days
integer
default:3650

How many days of history to ask for with requestFull. Default 3650.

Required range: 1 <= x <= 3650
cancel
boolean
default:false

Stops the sweep in progress. The other fields are ignored.

webhook
boolean
default:false

Delivers the new messages fetched by the sweep in the history.on_demand.messages event, in batches of up to 100 per chat, to the URL that receives messages.received in the session. Without that URL and without webhookUrl, the route answers 400.

webhookUrl
string<uri>

URL that receives the history.on_demand.messages event for this request. It already turns delivery on, with no need for webhook: true. Must be http or https and point to a public address.

Response

Sweep started (or cancelled, with cancel)

success
boolean
required
sessionId
string
required
commandId
string
requestId
string

Request id. It comes in every batch of the history.on_demand.messages event (data.requestId), to match the messages to this call. Not returned with cancel.

data
object
timestamp
string