WhatsApp Gateway
API referenceSessions

Get history import status

GET
/api/v1/sessions/{session}/history-sync

Show how the import of chat history from the phone is going. When a device is linked or relinked, the phone sends the chat history it still has; the gateway imports up to historySyncDays days of it.

The response has the session's import setting, whether the session was relinked to a different phone number, and the latest import run. run is absent until the phone sends history. While run.status is running, compare batchesApplied with batches and use progress (percent reported by the phone). run.stalled turns true when a running import has had no activity for 10 minutes.

Imported messages are stored like received messages with origin set to history. They do not trigger message webhooks; subscribe to history.sync (progress) or history.batch (the imported data, opt-in) instead.

Requires read capability. Errors: not_found (404), unauthorized (401), forbidden (403).

Authorization

AuthorizationBearer <token>

Send Authorization: Bearer <token>. The token can be a login JWT from the frontend or an api-key for a script. JWT access comes from the person's organization role. Api-key access comes from the permissions saved on the key.

In: header

Path Parameters

session*string

Session ID within your organization. Unknown or cross-organization sessions return not_found (404).

Example"sess_01HZX8K3M9"

Response Body

application/json

application/json

curl -X GET "https://example.com/api/v1/sessions/sess_01HZX8K3M9/history-sync"
{  "accountChanged": false,  "accountChangedAt": 1719662400000,  "accountJid": "6281234567890@s.whatsapp.net",  "historySyncDays": 30,  "run": {    "accountJid": "6281234567890@s.whatsapp.net",    "batches": 12,    "batchesApplied": 12,    "chunks": 3,    "conversations": 40,    "cutoffAt": 1717000000000,    "error": "history blob expired on WhatsApp servers",    "finishedAt": 1719662700000,    "messages": 1830,    "messagesDropped": 20,    "messagesExisting": 110,    "messagesImported": 1700,    "progress": 45,    "runId": "hsr_01J9ZX3K8Q2W5V7B4N6M1C0D9E",    "sessionId": "01J9ZX8K2QHV0M3T6R7P4N5W8C",    "skipped": 25,    "stalled": false,    "startedAt": 1719662400000,    "status": "running",    "syncType": "recent",    "updatedAt": 1719662460000  }}
{  "error": {    "code": "not_found",    "details": {      "property1": null,      "property2": null    },    "message": "session not found"  }}