Contacts
Online and last seen
Asks WhatsApp for a contact’s presence: online now, or the time they were last seen. WhatsApp answers only when the contact shares their last seen and online status with your number; otherwise known is false. Numbers linked by QR code only (the Cloud API has no presence).
- Bearer API key
- Scope:
read, write or admin - or app session
- Workspace:
X-Tenant-ID(optional with a key)
Headers
AuthorizationstringrequiredYour API key as
Bearer <key>. The wordBearerand the space are case-sensitive. Browser clients signed in to the app use the session cookie instead.X-Tenant-IDuuidoptionalWorkspace id. Optional with an API key (a key always acts in its own workspace); if you send it, it must match the key’s workspace. Required with a session cookie. You can pass
?tenant=<id>instead.
Query parameters
contactstringrequiredThe contact’s phone number with country code (
919812345678,+91 98123 45678) or WhatsApp id (…@s.whatsapp.net).phoneis accepted as another name for it.
Response
200 OKapplication/json
jidstringThe contact’s WhatsApp id.
knownbooleanfalsewhen WhatsApp did not tell: the contact hides last seen and online from your number, or did not answer in time.onlineandlast_seenthen mean nothing.onlinebooleantruewhen the contact is online now.last_seentimestampnullableWhen the contact was last online (RFC 3339), or
null.checked_attimestampWhen WhatsApp answered. Answers are reused for up to 1 minute.
Status codes
- 200OK. The contact’s presence.
- 400Bad request.
contactis missing or is not a phone number with country code or a WhatsApp user id. - 401Unauthorized. The API key is unknown, revoked or expired (
invalid or expired API key), the key was blocked because it may have been leaked (code: "api_key_blocked"), or there is no key and no signed-in session (unauthorized). - 402Payment required. Only when subscriptions are enforced and the workspace has no active subscription. The body includes
code: "payment_required". - 403Forbidden. The
X-Tenant-IDheader ortenantquery does not match the API key’s workspace (API key belongs to a different workspace), a signed-in user is not a member of the workspace (forbidden), or the key is limited to other IP addresses (this API key is not allowed from your IP address, withcode: "ip_not_allowed"). - 409Conflict. No number is linked by QR code, or it is disconnected right now.
- 429Too many requests. More than 30 lookups in a minute for this workspace. Wait for the
Retry-Afterseconds and try again. - 504Gateway timeout. WhatsApp did not answer in time.
How does a lookup work?
Your number goes online for a few seconds, asks WhatsApp for the contact’s presence, waits up to 4 seconds for the answer and goes back offline, so your phone keeps getting notifications. While it is online, contacts may see your number as online. Lookups run one at a time per number, and an answer is reused for 1 minute.
Why is known false?
WhatsApp shares presence only with numbers the contact allows in Settings → Privacy → Last seen and online. If they chose "Nobody", or "My contacts" and your number is not saved in their phone, WhatsApp sends nothing.