> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wappfy.com.br/llms.txt
> Use this file to discover all available pages before exploring further.

# Subscribe to Chat Presence Events

> Subscribe to receive presence notifications (online/offline) of a specific chat

## Description

This endpoint allows you to subscribe to receive presence updates (online/offline status) of a specific contact. After subscription, you will receive events whenever the contact goes online or offline.

## URL Parameters

<ParamField path="session" type="string" required>
  WhatsApp unique session ID
</ParamField>

<ParamField path="chatId" type="string" required>
  ID of the chat/contact in format `5511999999999@s.whatsapp.net`
</ParamField>

## Response

<ResponseExample>
  ```json Success Response theme={null}
  {
    "success": true,
    "message": "Presence subscription created successfully",
    "chatId": "5511999999999@s.whatsapp.net"
  }
  ```
</ResponseExample>

## Status Codes

* `200` - Subscription created successfully
* `400` - Invalid parameters
* `401` - Unauthorized
* `404` - Chat/Session not found

## Usage Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.wappfy.com.br/api/my-session/presence/5511999999999@s.whatsapp.net/subscribe
  ```

  ```javascript JavaScript theme={null}
  const session = 'my-session';
  const chatId = '5511999999999@s.whatsapp.net';
  const response = await fetch(`https://api.wappfy.com.br/api/${session}/presence/${chatId}/subscribe`, {
    method: 'POST'
  });
  const data = await response.json();
  console.log(data);
  ```

  ```python Python theme={null}
  import requests

  session = 'my-session'
  chat_id = '5511999999999@s.whatsapp.net'
  response = requests.post(
    f'https://api.wappfy.com.br/api/{session}/presence/{chat_id}/subscribe'
  )
  data = response.json()
  print(data)
  ```
</CodeGroup>

## Notas

* After subscribing, you will receive presence events through the event stream
* Use the `/api/events/stream/{sessionId}` endpoint to receive events in real time
* Events will inform when the contact goes online (`AVAILABLE`) or offline (`UNAVAILABLE`)
* Useful for implementing online status indicators in applications


## OpenAPI

````yaml viewer-en.json post /api/{session}/presence/{chatId}/subscribe
openapi: 3.1.0
info:
  title: Wappfy - WhatsApp HTTP API
  version: '2.0'
  contact: {}
servers:
  - url: https://{host}
    description: Customizable Server
    variables:
      host:
        default: api.wappfy.com.br
        description: Server URL (e.g., api.wappfy.com.br or your-server.com)
security:
  - api_key: []
tags:
  - name: 🖥️ Sessions
    description: Control WhatsApp sessions (accounts)
  - name: 🔑 Auth
    description: Authentication
  - name: 🆔 Profile
    description: Your profile information
  - name: 🖼️ Screenshot
    description: Get WhatsApp screenshot and display QR code
  - name: 📤 Chatting
    description: Conversation methods
  - name: 📢 Channels
    description: Channels (newsletters) methods
  - name: 🟢 Status
    description: Status (aka stories) methods
  - name: 💬 Chats
    description: Conversations methods
  - name: 👤 Contacts
    description: |-
      Contacts methods.<br>
                      Use phone number (without +) or phone number and `@c.us` at the end as `contactId`.<br>
                      E.g: `12312312310` OR `12312312310@c.us`<br>
  - name: 👥 Groups
    description: Groups methods.<br>
  - name: ✅ Presence
    description: Presence information
  - name: 📅 Events
    description: Event Message
  - name: 🏷️ Labels
    description: Labels - available only for WhatsApp Business accounts
  - name: 🔍 Observability
    description: Other methods
  - name: 🗄️ Storage
    description: Storage methods
externalDocs:
  description: Wappfy - WhatsApp API
  url: https://docs.wappfy.com.br/
paths:
  /api/{session}/presence/{chatId}/subscribe:
    post:
      tags:
        - ✅ Presence
      summary: Subscribe to presence events for the conversation
      description: The {session} parameter must be the session's instanceName.
      operationId: PresenceController_subscribe
      parameters:
        - name: chatId
          required: true
          in: path
          description: Conversation ID
          example: 123456789@c.us
          schema:
            type: string
      responses:
        '201':
          description: ''
      security:
        - api_key: []
components:
  securitySchemes:
    api_key:
      type: apiKey
      in: header
      name: apikey
      description: Your Wappfy API key (get it at dash.wappfy.com.br)

````