WhatsApp Status Upload API

Upload an image, video, or text-only WhatsApp Status directly from your connected session using Baileys REST Mongo API.

This endpoint supports external webhooks and Hybrid Authentication (API Keys + JWT).

๐Ÿ”— Endpoint

POST https://api.walytic.com/api/whatsapp/:sessionId/update-status

Uploads a new WhatsApp status update (text, image, or video) for the connected WhatsApp session.

๐Ÿ” Required Headers

Header

Type

Required

Description

x-api-key

String

โœ… Yes

Your API key (for external API integrations).

Authorization

String

Optional

JWT Bearer token (for logged-in dashboard users).

Content-Type

String

โœ… Yes

Must be application/json.


๐Ÿ“ค Request Body Parameters

Field

Type

Required

Description

fileUrl

String

โŒ Optional

Publicly accessible URL of the media (image or video). Required for media statuses.

caption

String

โŒ Optional

Optional caption text for the status. If fileUrl is not provided, caption alone will be posted as a text-only status.

backgroundColor

string

#101010

font

SANS_SERIF

{
  "fileUrl": "https://res.cloudinary.com/demo/image/upload/sample.jpg",
  "caption": "My weekend vibes ๐ŸŒด",
  "backgroundColor": "#101010",
  "font": "SANS_SERIF"
}


โš™๏ธ Supported Media Types

Media Type

Description

image/*

JPEG, PNG, or WEBP images.

video/*

MP4 or MOV video formats.

Text only

When only caption is sent and no fileUrl is provided.


๐Ÿง  Internal Workflow (For Developers)

  1. Request hits
    controllers/whatsappController.js โ†’ updateStatus()

  2. Retrieves the active Baileys session via
    sessionManager.getSession(sessionId)

  3. Downloads the media (if fileUrl is present) using axios.get(fileUrl)

  4. Detects MIME type โ†’ validates it as image/* or video/*

  5. Sends the status via Baileys:

    sock.sendMessage("status@broadcast", content)
    
  6. Triggers the configured external webhook with metadata:

    {
      "event": "statusUpdated",
      "sessionId": "session-919876543210",
      "mediaType": "image",
      "fileUrl": "https://example.com/image.jpg",
      "caption": "Hello everyone ๐Ÿ‘‹",
      "timestamp": "2025-10-27T06:21:11Z"
    }
    

๐Ÿงฉ Example Request (Node.js)

const axios = require("axios");

async function uploadWhatsAppStatus() {
  try {
    const response = await axios.post(
      "https://api.walytic.com/api/whatsapp/session-919876543210/update-status",
      {
        fileUrl: "https://example.com/myvideo.mp4",
        caption: "Weekend vibes! ๐Ÿ˜Ž"
      },
      {
        headers: {
          "x-api-key": "YOUR_API_KEY",
          "Content-Type": "application/json"
        }
      }
    );

    if (response.data.success) {
      console.log("โœ… Status uploaded successfully!");
      console.log(response.data);
    } else {
      console.log("โŒ Error:", response.data.error);
    }
  } catch (error) {
    console.error("Request failed:", error.response?.data || error.message);
  }
}

uploadWhatsAppStatus();

๐Ÿงพ Example Request (cURL)

$curl -X POST https://api.walytic.com/api/whatsapp/session-919876543210/update-status \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "fileUrl": "https://example.com/pic.jpg",
  "caption": "Good Morning ๐ŸŒž"
}'

๐Ÿ“ฆ Example Response (โœ… Success)

{
  "success": true,
  "message": "WhatsApp status updated successfully",
  "data": {
    "sessionId": "session-919876543210",
    "mediaType": "image",
    "caption": "Good Morning ๐ŸŒž",
    "timestamp": "2025-10-27T06:21:11Z"
  }
}

โŒ Example Response (Error)

{
  "success": false,
  "message": "Failed to update status",
  "error": "Session not found or not connected"
}

or

{
  "success": false,
  "message": "Only image or video types allowed for status"
}

๐Ÿ“ก Webhook Event Examples

โœ… Status Updated Event

{
  "event": "statusUpdated",
  "sessionId": "session-919876543210",
  "mediaType": "image",
  "fileUrl": "https://example.com/pic.jpg",
  "caption": "Good Morning ๐ŸŒž",
  "timestamp": "2025-10-27T06:21:11Z"
}

๐Ÿ“ Text-only Status Event

{
  "event": "statusUpdated",
  "sessionId": "session-919876543210",
  "mediaType": "text",
  "caption": "Just checking in ๐Ÿ‘‹",
  "timestamp": "2025-10-27T06:25:11Z"
}

๐Ÿ”’ Authentication Flow

Source

Auth Method

Header

External Clients

API Key

x-api-key

Internal Dashboard

JWT

Authorization: Bearer <token>

Middleware hybridAuth validates either method before routing to the controller.


โš™๏ธ Notes

  • Works only if the WhatsApp session is connected (/api/whatsapp/:sessionId/status can be used to check).

  • Supports text, image, or video status updates.

  • Triggers webhook updates automatically when status is uploaded.

  • Uses Baileys WebSocket for WhatsApp Web protocol handling.

  • Media must be accessible via public HTTPS URLs.

  • Upload limits depend on WhatsApp (max ~30 seconds for video).