Skip to content

GOWA - WhatsApp REST API with support for UI, Multi Account, Webhooks, and MCP, and Chatwoot. Built with Golang for efficient memory use.

docs: update API and webhook documentation

Aldino Kemal8b73125c7612
diff --git a/docs/openapi.yaml b/docs/openapi.yaml
index 5948f0a0..b94063bc 100644
--- a/docs/openapi.yaml
+++ b/docs/openapi.yaml
@@ -1,7 +1,7 @@
openapi: "3.0.0"
info:
title: WhatsApp API MultiDevice
- version: 8.3.1
+ version: 8.9.0
description: |
This API is used for sending whatsapp via API.
@@ -35,6 +35,29 @@ security:
- basicAuth: []
paths:
+ /health:
+ get:
+ operationId: health
+ tags:
+ - app
+ summary: Health check
+ description: Public health probe registered at `/health`; it is not prefixed by `APP_BASE_PATH`.
+ security: []
+ responses:
+ '200':
+ description: Service healthy
+ content:
+ text/plain:
+ schema:
+ type: string
+ example: OK
+ '503':
+ description: Service unavailable
+ content:
+ text/plain:
+ schema:
+ type: string
+ example: Service Unavailable
/app/login:
get:
operationId: appLogin
@@ -444,8 +467,14 @@ paths:
operationId: loginDevice
tags:
- device
- summary: Login device with QR code
- description: Initiate QR code login for a specific device
+ summary: Reserved device QR login route (not implemented)
+ deprecated: true
+ description: |
+ This route is registered, but the current usecase returns
+ "device login per ID is not implemented yet".
+
+ To pair a specific device slot today, call `GET /app/login` with
+ `X-Device-Id: <device_id>` or `?device_id=<device_id>`.
parameters:
- name: device_id
in: path
@@ -454,12 +483,6 @@ paths:
type: string
description: Device ID
responses:
- '200':
- description: OK
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/LoginResponse'
'404':
description: Device not found
content:
@@ -467,7 +490,7 @@ paths:
schema:
$ref: '#/components/schemas/ErrorNotFound'
'500':
- description: Internal Server Error
+ description: Not implemented by the current usecase
content:
application/json:
schema:
@@ -478,8 +501,14 @@ paths:
operationId: loginDeviceWithCode
tags:
- device
- summary: Login device with pairing code
- description: Initiate pairing code login for a specific device
+ summary: Reserved device pairing-code login route (not implemented)
+ deprecated: true
+ description: |
+ This route is registered, but the current usecase returns
+ "device login with code is not implemented yet".
+
+ To pair a specific device slot today, call `GET /app/login-with-code`
+ with `X-Device-Id: <device_id>` or `?device_id=<device_id>`.
parameters:
- name: device_id
in: path
@@ -495,12 +524,6 @@ paths:
example: '628912344551'
description: Phone number to pair with
responses:
- '200':
- description: OK
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/LoginWithCodeResponse'
'404':
description: Device not found
content:
@@ -508,7 +531,7 @@ paths:
schema:
$ref: '#/components/schemas/ErrorNotFound'
'500':
- description: Internal Server Error
+ description: Not implemented by the current usecase
content:
application/json:
schema:
@@ -624,8 +647,8 @@ paths:
operationId: getDeviceWebhook
tags:
- device
- summary: Get device webhook URL
- description: Get the webhook URL configured for a specific device. Returns empty if no device-specific webhook is set.
+ summary: Get device webhook configuration
+ description: Get the webhook configuration for a specific device. Returns empty values if no device-specific webhook is set.
parameters:
- name: device_id
in: path
@@ -661,6 +684,18 @@ paths:
type: string
description: The configured webhook URL (empty if not set)
example: 'https://example.com/webhook'
+ webhook_secret:
+ type: string
+ description: Secret used to sign payloads for this device webhook
+ example: 'super-secret-key'
+ webhook_events:
+ type: string
+ description: Comma-separated event whitelist for this device webhook
+ example: 'message,message.ack'
+ webhook_insecure_skip_verify:
+ type: boolean
+ description: Whether TLS verification is skipped for this device webhook
+ example: false
'404':
description: Device not found
content:
@@ -677,10 +712,11 @@ paths:
operationId: updateDeviceWebhook
tags:
- device
- summary: Set device webhook URL
+ summary: Set device webhook configuration
description: |
- Set a custom webhook URL for a specific device. When set, webhook events for this device
- will be sent to this URL instead of the global webhook URL.
+ Set a custom webhook configuration for a specific device. When set, webhook events for this device
+ will be sent to this URL instead of the global webhook URL. Device-level `webhook_secret`,
+ `webhook_events`, and `webhook_insecure_skip_verify` override the global webhook settings for this device.
Set to empty string to clear and use the global webhook.
parameters:
@@ -701,6 +737,18 @@ paths:
type: string
description: Custom webhook URL to use for this device. Set to empty string to clear.
example: 'https://example.com/webhook'
+ webhook_secret:
+ type: string
+ description: Optional secret used to sign payloads for this device webhook.
+ example: 'super-secret-key'
+ webhook_events:
+ type: string
+ description: Optional comma-separated event whitelist for this device webhook. Empty means all events.
+ example: 'message,message.ack'
+ webhook_insecure_skip_verify:
+ type: boolean
+ description: Optional. Skip TLS certificate verification for this device webhook.
+ example: false
required:
- webhook_url
responses:
@@ -731,6 +779,18 @@ paths:
type: string
description: The configured webhook URL
example: 'https://example.com/webhook'
+ webhook_secret:
+ type: string
+ description: Secret used to sign payloads for this device webhook
+ example: 'super-secret-key'
+ webhook_events:
+ type: string
+ description: Comma-separated event whitelist for this device webhook
+ example: 'message,message.ack'
+ webhook_insecure_skip_verify:
+ type: boolean
+ description: Whether TLS verification is skipped for this device webhook
+ example: false
'400':
description: Bad Request
content:
@@ -1102,8 +1162,8 @@ paths:
description: Whether this is a forwarded message
duration:
type: integer
- example: 3600
- description: Disappearing message duration in seconds (optional)
+ example: 86400
+ description: "Disappearing message duration in seconds. Allowed values: 0 (no expiry), 86400 (24h), 604800 (7d), 7776000 (90d)."
mentions:
type: array
items:
@@ -1175,8 +1235,8 @@ paths:
description: Compress image
duration:
type: integer
- example: 3600
- description: Disappearing message duration in seconds (optional)
+ example: 86400
+ description: "Disappearing message duration in seconds. Allowed values: 0 (no expiry), 86400 (24h), 604800 (7d), 7776000 (90d)."
is_forwarded:
type: boolean
example: false
@@ -1226,6 +1286,10 @@ paths:
type: string
example: https://example.com/audio.mp3
description: Audio URL to send
+ ptt:
+ type: boolean
+ example: false
+ description: Send as a WhatsApp voice note. When true, ffmpeg is required to transcode to OGG Opus.
reply_message_id:
type: string
example: 3EB089B9D6ADD58153C561
@@ -1236,8 +1300,8 @@ paths:
description: Whether this is a forwarded message
duration:
type: integer
- example: 3600
- description: Disappearing message duration in seconds (optional)
+ example: 86400
+ description: "Disappearing message duration in seconds. Allowed values: 0 (no expiry), 86400 (24h), 604800 (7d), 7776000 (90d)."
responses:
'200':
description: OK
@@ -1287,14 +1351,18 @@ paths:
type: string
format: binary
description: File to send
+ file_url:
+ type: string
+ example: https://example.com/document.pdf
+ description: File URL to download and send
is_forwarded:
type: boolean
example: false
description: Whether this is a forwarded message
duration:
type: integer
- example: 3600
- description: Disappearing message duration in seconds (optional)
+ example: 86400
+ description: "Disappearing message duration in seconds. Allowed values: 0 (no expiry), 86400 (24h), 604800 (7d), 7776000 (90d)."
responses:
'200':
description: OK
@@ -1343,8 +1411,8 @@ paths:
description: URL of sticker image to send
duration:
type: integer
- example: 3600
- description: Disappearing message duration in seconds (optional)
+ example: 86400
+ description: "Disappearing message duration in seconds. Allowed values: 0 (no expiry), 86400 (24h), 604800 (7d), 7776000 (90d)."
is_forwarded:
type: boolean
example: false
@@ -1416,8 +1484,8 @@ paths:
description: Display video as GIF (looping, silent, autoplay)
duration:
type: integer
- example: 3600
- description: Disappearing message duration in seconds (optional)
+ example: 86400
+ description: "Disappearing message duration in seconds. Allowed values: 0 (no expiry), 86400 (24h), 604800 (7d), 7776000 (90d)."
is_forwarded:
type: boolean
example: false
@@ -1473,8 +1541,8 @@ paths:
description: Whether this is a forwarded message
duration:
type: integer
- example: 3600
- description: Disappearing message duration in seconds (optional)
+ example: 86400
+ description: "Disappearing message duration in seconds. Allowed values: 0 (no expiry), 86400 (24h), 604800 (7d), 7776000 (90d)."
responses:
'200':
description: OK
@@ -1526,8 +1594,8 @@ paths:
description: Whether this is a forwarded message
duration:
type: integer
- example: 3600
- description: Disappearing message duration in seconds (optional)
+ example: 86400
+ description: "Disappearing message duration in seconds. Allowed values: 0 (no expiry), 86400 (24h), 604800 (7d), 7776000 (90d)."
responses:
'200':
description: OK
@@ -1579,8 +1647,8 @@ paths:
description: Whether this is a forwarded message
duration:
type: integer
- example: 3600
- description: Disappearing message duration in seconds (optional)
+ example: 86400
+ description: "Disappearing message duration in seconds. Allowed values: 0 (no expiry), 86400 (24h), 604800 (7d), 7776000 (90d)."
responses:
'200':
description: OK
@@ -1635,8 +1703,8 @@ paths:
example: 2
duration:
type: integer
- example: 3600
- description: Disappearing message duration in seconds (optional)
+ example: 86400
+ description: "Disappearing message duration in seconds. Allowed values: 0 (no expiry), 86400 (24h), 604800 (7d), 7776000 (90d)."
required:
- phone
- question
@@ -2371,75 +2439,6 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ErrorInternalServer'
- /chat/{chat_jid}/label:
- post:
- operationId: labelChat
- tags:
- - chat
- summary: Label or unlabel a chat
- description: Apply or remove a label from a chat conversation
- parameters:
- - $ref: '#/components/parameters/DeviceIdHeader'
- - in: path
- name: chat_jid
- schema:
- type: string
- required: true
- description: Chat JID (e.g., [email protected] for individual or [email protected] for group)
- example: '[email protected]'
- requestBody:
- content:
- application/json:
- schema:
- type: object
- properties:
- label_id:
- type: string
- example: 'label_123'
- description: Unique identifier for the label
- label_name:
- type: string
- example: 'Important'
- description: Display name for the label
- labeled:
- type: boolean
- example: true
- description: Whether to apply (true) or remove (false) the label
- required:
- - label_id
- - label_name
- - labeled
- responses:
- '200':
- description: OK
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/LabelChatResponse'
- '400':
- description: Bad Request
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/ErrorBadRequest'
- '401':
- description: Unauthorized
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/ErrorUnauthorized'
- '404':
- description: Chat Not Found
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/ErrorNotFound'
- '500':
- description: Internal Server Error
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/ErrorInternalServer'
/chat/{chat_jid}/pin:
post:
operationId: pinChat
@@ -4066,7 +4065,41 @@ components:
type: integer
example: 200
results:
- $ref: '#/components/schemas/DeviceInfo'
+ type: object
+ properties:
+ id:
+ type: string
+ example: 'my-device-id'
+ display_name:
+ type: string
+ example: 'John Doe'
+ state:
+ type: string
+ enum: [disconnected, connecting, connected, logged_in]
+ example: 'disconnected'
+ jid:
+ type: string
+ example: '[email protected]'
+ created_at:
+ type: string
+ format: date-time
+ example: '2024-01-01T00:00:00Z'
+ webhook_url:
+ type: string
+ description: Device-specific webhook URL echoed when provided on create
+ example: 'https://device-webhook.example.com/handler'
+ webhook_secret:
+ type: string
+ description: Device-specific webhook secret echoed when provided on create
+ example: 'super-secret-key'
+ webhook_events:
+ type: string
+ description: Device-specific event whitelist echoed when provided on create
+ example: 'message,message.ack'
+ webhook_insecure_skip_verify:
+ type: boolean
+ description: Device-specific TLS verification setting echoed when provided on create
+ example: false
DeviceInfoResponse:
type: object
properties:
@@ -4119,15 +4152,11 @@ components:
example: 'John Doe'
state:
type: string
- enum: [disconnected, connected, logged_in]
+ enum: [disconnected, connecting, connected, logged_in]
example: 'logged_in'
jid:
type: string
example: '[email protected]'
- webhook_url:
- type: string
- description: Device-specific webhook URL (empty if not set)
- example: 'https://device-webhook.example.com/handler'
created_at:
type: string
format: date-time
@@ -4806,34 +4835,6 @@ components:
example: '2024-01-15T10:31:00Z'
description: When the reaction was received
- LabelChatResponse:
- type: object
- properties:
- code:
- type: string
- example: SUCCESS
- message:
- type: string
- example: Chat labeled successfully with label 'Important'
- results:
- type: object
- properties:
- status:
- type: string
- example: success
- message:
- type: string
- example: Chat labeled successfully with label 'Important'
- chat_jid:
- type: string
- example: '[email protected]'
- label_id:
- type: string
- example: 'label_123'
- labeled:
- type: boolean
- example: true
-
PinChatResponse:
type: object
properties:
diff --git a/docs/per-device-webhook-plan.md b/docs/per-device-webhook-plan.md
index 954bcf73..cbcd2d30 100644
--- a/docs/per-device-webhook-plan.md
+++ b/docs/per-device-webhook-plan.md
@@ -31,10 +31,10 @@ Add per-device webhook support where each device can have its own webhook URL. I
│ webhook_forward.go :: forwardPayloadToConfiguredWebhooks() │
│ ┌───────────────────────────────────────────────────────────────────────┐ │
│ │ STEP 1: Extract device JID from payload["device_id"] │ │
-│ │ STEP 2: Call getWebhookURLsForDevice(deviceJID) │ │
+│ │ STEP 2: Call getWebhookConfigForDevice(deviceJID) │ │
│ │ - Looks up device record by JID │ │
-│ │ - If device has custom webhook_url, return it only │ │
-│ │ - Otherwise return global config.WhatsappWebhook │ │
+│ │ - If device has custom webhook_url, return device config │ │
+│ │ - Otherwise return global config.WhatsappWebhook settings │ │
│ └───────────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
│
@@ -43,15 +43,15 @@ Add per-device webhook support where each device can have its own webhook URL. I
│ │
▼ ▼
┌──────────────────┐ ┌────────────────────────┐
- │ Device has custom │ │ Device webhook is NULL │
- │ webhook_url? │ │ or empty? │
+ │ Device has custom │ │ Device webhook URL is │
+ │ webhook config? │ │ NULL or empty? │
└──────────────────────┘ └─────────────────────────┘
│ │
YES │ │ YES
▼ ▼
┌────────────────────────┐ ┌─────────────────────────┐
- │ Use device webhook URL │ │ Use global config │
- │ (override global) │ │ WhatsappWebhook[] │
+ │ Use device webhook │ │ Use global config │
+ │ config (override) │ │ WhatsappWebhook[] │
└────────────────────────┘ └─────────────────────────┘
│ │
└───────────────┬───────────────┘
@@ -80,11 +80,12 @@ Add per-device webhook support where each device can have its own webhook URL. I
Client REST API UseCase Repository
│ │ │ │
│ PATCH /devices/:id/webhook│ │ │
- │ { "webhook_url": "..." } │ │ │
+ │ { "webhook_url": "...", │ │ │
+ │ "webhook_secret": "..."} │ │
│─────────────────────────>│ │ │
- │ │ SetDeviceWebhook() │ │
+ │ │ SetDeviceWebhookConfig() │ │
│ │──────────────────────────>│ │
- │ │ │ SetDeviceWebhookURL() │
+ │ │ │ SetDeviceWebhookConfig() │
│ │ │────────────────────────>│
│ │ │ │
│ │ │ │
@@ -97,14 +98,14 @@ Client REST API UseCase R
| File | Change |
|------|--------|
-| `domains/chatstorage/chatstorage.go` | Added `WebhookURL *string` to `DeviceRecord` struct |
-| `domains/chatstorage/interfaces.go` | Added `GetDeviceRecordByJID`, `SetDeviceWebhookURL`, `GetDeviceWebhookURL` |
-| `infrastructure/chatstorage/sqlite_repository.go` | Added migration #17, updated queries, implemented new methods |
+| `domains/chatstorage/chatstorage.go` | Added webhook URL, secret, event whitelist, and TLS-skip fields plus `DeviceWebhookConfig` |
+| `domains/chatstorage/interfaces.go` | Added `GetDeviceRecordByJID`, URL-only helpers, and full webhook config helpers |
+| `infrastructure/chatstorage/sqlite_repository.go` | Added migrations #31-#34, updated queries, implemented new methods |
| `infrastructure/whatsapp/chatstorage_wrapper.go` | Added wrapper methods for new interface methods |
-| `infrastructure/whatsapp/webhook_forward.go` | Added `getWebhookURLsForDevice()`, updated forwarding logic |
+| `infrastructure/whatsapp/webhook_forward.go` | Added `getWebhookConfigForDevice()`, device event filtering, and updated forwarding logic |
| `infrastructure/whatsapp/device_manager.go` | Added `GetStorage()` method |
-| `domains/device/interfaces.go` | Added `SetDeviceWebhook`, `GetDeviceWebhook` to `IDeviceUsecase` |
-| `usecase/device.go` | Implemented `SetDeviceWebhook`, `GetDeviceWebhook` |
+| `domains/device/interfaces.go` | Added URL-only and full-config webhook methods to `IDeviceUsecase` |
+| `usecase/device.go` | Implemented URL-only and full-config webhook methods |
| `ui/rest/device.go` | Added `PATCH /devices/:device_id/webhook`, `GET /devices/:device_id/webhook` |
| `infrastructure/whatsapp/webhook_forward_test.go` | Added per-device webhook tests |
| `usecase/device_test.go` | Added device service tests |
@@ -112,38 +113,45 @@ Client REST API UseCase R
## Database Changes
-**Migration #17** adds `webhook_url TEXT DEFAULT ''` column to `devices` table.
+Migrations #31-#34 add the per-device webhook fields to the `devices` table:
+
+- `webhook_url TEXT DEFAULT NULL`
+- `webhook_secret TEXT DEFAULT ''`
+- `webhook_events TEXT DEFAULT ''`
+- `webhook_insecure_skip_verify BOOLEAN DEFAULT FALSE`
## API Endpoints
-- `PATCH /devices/{device_id}/webhook` - Set device-specific webhook URL
- - Body: `{ "webhook_url": "https://example.com/webhook" }`
+- `PATCH /devices/{device_id}/webhook` - Set device-specific webhook configuration
+ - Body: `{ "webhook_url": "https://example.com/webhook", "webhook_secret": "secret", "webhook_events": "message,message.ack", "webhook_insecure_skip_verify": false }`
- Set to empty string `""` to clear and use global webhook
-- `GET /devices/{device_id}/webhook` - Get device-specific webhook URL
- - Returns empty string if not set (use global)
+- `GET /devices/{device_id}/webhook` - Get device-specific webhook configuration
+ - Returns empty values if not set (use global)
## Testing
### Unit Tests
**`infrastructure/whatsapp/webhook_forward_test.go`:**
-- `TestGetWebhookURLsForDevice_NoDeviceJID` - Returns global webhook when device JID is empty
-- `TestGetWebhookURLsForDevice_DeviceNotFound` - Falls back to global when device not found
-- `TestGetWebhookURLsForDevice_FallbackToGlobal` - Falls back to global when device has no custom webhook
+- `TestGetWebhookConfigForDevice_NoDeviceID` - Returns global webhook config when device JID is empty
+- `TestGetWebhookConfigForDevice_DeviceNotFound` - Falls back to global when device not found
+- `TestGetWebhookConfigForDevice_FallbackToGlobal` - Falls back to global when device has no custom webhook
+- `TestGetWebhookConfigForDevice_DeviceSpecificOverride` - Uses the full device-specific webhook config when set
- `TestForwardPayloadToConfiguredWebhooks_WithDeviceSpecificWebhook` - Uses device-specific webhook when set
- `TestForwardPayloadToConfiguredWebhooks_DeviceWebhookCleared_FallsBackToGlobal` - Falls back to global when device webhook is cleared
+- `TestForwardPayloadToConfiguredWebhooks_DeviceWebhookOnly_NoGlobal` - Uses device-specific webhook with no global webhook
+- `TestSQLiteRepositoryGetsDeviceWebhookConfigByJID` - Persists and resolves the full device webhook config
+- `TestAddDevice_ForwardsFullWebhookConfig` - Accepts full webhook config when creating a device
**`usecase/device_test.go`:**
- `TestDeviceServiceInterface` - Verifies interface implementation
- `TestSetDeviceWebhook_InvalidManager` - Error handling for nil manager
- `TestGetDeviceWebhook_InvalidManager` - Error handling for nil manager
-- `TestGetDeviceWebhook_DeviceNotFound` - Error handling for missing device
-- `TestSetDeviceWebhook_DeviceNotFound` - Error handling for missing device
## OpenAPI Documentation
Added to `docs/openapi.yaml`:
-- `GET /devices/{device_id}/webhook` - Get device webhook URL
-- `PATCH /devices/{device_id}/webhook` - Set device webhook URL
+- `GET /devices/{device_id}/webhook` - Get device webhook configuration
+- `PATCH /devices/{device_id}/webhook` - Set device webhook configuration
diff --git a/docs/webhook-payload.md b/docs/webhook-payload.md
index f5821683..33721faa 100644
--- a/docs/webhook-payload.md
+++ b/docs/webhook-payload.md
@@ -23,6 +23,8 @@ The following events can be received via webhook:
| `chat_presence` | Typing and recording indicators from contacts |
| `group.participants` | Group member join/leave/promote/demote events |
| `group.joined` | You were added to a group |
+| `label.edit` | WhatsApp label metadata changed |
+| `label.association` | Label applied to or removed from a chat |
| `newsletter.joined` | You subscribed to a newsletter/channel |
| `newsletter.left` | You unsubscribed from a newsletter |
| `newsletter.message` | New message(s) posted in a newsletter |
@@ -48,6 +50,9 @@ WHATSAPP_WEBHOOK_EVENTS=message,message.reaction,message.revoked,message.edited,
# Receive only group events
WHATSAPP_WEBHOOK_EVENTS=group.participants
+# Receive label events
+WHATSAPP_WEBHOOK_EVENTS=label.edit,label.association
+
# Receive newsletter events
WHATSAPP_WEBHOOK_EVENTS=newsletter.joined,newsletter.left,newsletter.message,newsletter.mute
@@ -140,7 +145,7 @@ All webhook payloads follow a consistent top-level structure:
| **Field** | **Type** | **Description** |
|--------------|----------|---------------------------------------------------------------------------------------------------------------------|
-| `event` | string | Event type: `message`, `message.reaction`, `message.revoked`, `message.edited`, `message.ack`, `message.deleted`, `chat_presence`, `group.participants`, `group.joined`, `newsletter.joined`, `newsletter.left`, `newsletter.message`, `newsletter.mute`, `call.offer` |
+| `event` | string | Event type: `message`, `message.reaction`, `message.revoked`, `message.edited`, `message.ack`, `message.deleted`, `chat_presence`, `group.participants`, `group.joined`, `label.edit`, `label.association`, `newsletter.joined`, `newsletter.left`, `newsletter.message`, `newsletter.mute`, `call.offer` |
| `device_id` | string | JID of the device that received this event (e.g., `[email protected]`) |
| `session_id` | string | Session ID registered via `POST /devices` (e.g., `org_2`), for correlating the event back to a tenant. Omitted when the JID can't be mapped to a session. |
| `payload` | object | Event-specific payload data |
@@ -381,6 +386,73 @@ Triggered when a user starts typing in a group chat.
| `payload.media` | string | Media type: `""` (text message) or `"audio"` (voice recording) |
| `payload.is_group` | boolean | Whether this is a group chat |
+## Label Events
+
+Label events are triggered when WhatsApp label metadata changes or a label is applied to or removed from a chat. These
+events come from WhatsApp app-state sync and are forwarded as `label.edit` or `label.association`.
+
+### Label Edit
+
+Triggered when a WhatsApp label is created, renamed, reordered, activated/deactivated, or deleted.
+
+```json
+{
+ "event": "label.edit",
+ "device_id": "[email protected]",
+ "timestamp": "2026-01-22T12:03:00Z",
+ "payload": {
+ "label_id": "9",
+ "name": "Important",
+ "color": 2,
+ "predefined_id": "1",
+ "deleted": false,
+ "order_index": 1,
+ "is_active": true,
+ "type": "CUSTOM",
+ "is_immutable": false,
+ "mute_end_time_ms": 0
+ }
+}
+```
+
+### Label Association
+
+Triggered when a chat-level label is applied to or removed from a chat.
+
+```json
+{
+ "event": "label.association",
+ "device_id": "[email protected]",
+ "timestamp": "2026-01-22T12:04:00Z",
+ "payload": {
+ "label_id": "9",
+ "labeled": true,
+ "chat_id": "[email protected]"
+ }
+}
+```
+
+### Label Event Fields
+
+| **Field** | **Type** | **Description** |
+|--------------------------|----------|----------------------------------------------------------------------------------|
+| `event` | string | `"label.edit"` for label metadata changes, or `"label.association"` for chat labels |
+| `device_id` | string | JID of the device that received this event |
+| `timestamp` | string | RFC3339 formatted timestamp from the app-state event, or processing time fallback |
+| `payload.label_id` | string | WhatsApp label identifier |
+| `payload.name` | string | Label display name (only when included by WhatsApp on `label.edit`) |
+| `payload.color` | number | Label color value (only when included by WhatsApp on `label.edit`) |
+| `payload.predefined_id` | string | Predefined label identifier (only when included by WhatsApp on `label.edit`) |
+| `payload.deleted` | boolean | Whether the label was deleted (only when included by WhatsApp on `label.edit`) |
+| `payload.order_index` | number | Label ordering value (only when included by WhatsApp on `label.edit`) |
+| `payload.is_active` | boolean | Whether the label is active (only when included by WhatsApp on `label.edit`) |
+| `payload.type` | string | WhatsApp label type (only when included by WhatsApp on `label.edit`) |
+| `payload.is_immutable` | boolean | Whether the label is immutable (only when included by WhatsApp on `label.edit`) |
+| `payload.mute_end_time_ms` | number | Label mute end time in milliseconds (only when included by WhatsApp on `label.edit`) |
+| `payload.labeled` | boolean | Whether the label was applied (`true`) or removed (`false`) on `label.association` |
+| `payload.chat_id` | string | Chat JID associated with the label on `label.association` |
+| `payload.chat_lid` | string | Original LID chat identifier when WhatsApp supplied a LID before normalization |
+
## Group Events
Group events are triggered when group metadata changes, including member join/leave events, admin promotions/demotions,
diff --git a/readme.md b/readme.md
index f33bd596..ebdaea4e 100644
--- a/readme.md
+++ b/readme.md
@@ -62,7 +62,7 @@ Download:
## Feature
-- Send WhatsApp message via http API, [docs/openapi.yml](./docs/openapi.yaml) for more details
+- Send WhatsApp message via http API, [docs/openapi.yaml](./docs/openapi.yaml) for more details
- **MCP (Model Context Protocol) Server Support** - Integrate with AI agents and tools using standardized protocol
- Mention someone
- `@phoneNumber`
@@ -143,8 +143,11 @@ Download:
| `message.edited` | Edited messages |
| `message.ack` | Delivery and read receipts |
| `message.deleted` | Messages deleted for the user |
+ | `chat_presence` | Typing and recording indicators from contacts |
| `group.participants` | Group member join/leave/promote/demote events |
| `group.joined` | You were added to a group |
+ | `label.edit` | WhatsApp label metadata changed |
+ | `label.association` | Label applied to or removed from a chat |
| `newsletter.joined` | You subscribed to a newsletter/channel |
| `newsletter.left` | You unsubscribed from a newsletter |
| `newsletter.message` | New message(s) posted in a newsletter |
@@ -204,15 +207,17 @@ To use environment variables:
| `APP_PORT` | Application port | `3000` | `APP_PORT=8080` |
| `APP_HOST` | Host address to bind the server | `0.0.0.0` | `APP_HOST=127.0.0.1` |
| `APP_DEBUG` | Enable debug logging | `false` | `APP_DEBUG=true` |
-| `APP_OS` | OS name (device name in WhatsApp) | `Chrome` | `APP_OS=MyApp` |
+| `APP_OS` | OS name (device name in WhatsApp) | `GOWA` | `APP_OS=MyApp` |
| `APP_BASIC_AUTH` | Basic authentication credentials | - | `APP_BASIC_AUTH=user1:pass1,user2:pass2` |
| `APP_BASE_PATH` | Base path for subpath deployment | - | `APP_BASE_PATH=/gowa` |
| `APP_TRUSTED_PROXIES` | Trusted proxy IP ranges for reverse proxy | - | `APP_TRUSTED_PROXIES=0.0.0.0/0` |
-| `DB_URI` | Database connection URI | `file:storages/whatsapp.db?_foreign_keys=on` | `DB_URI=postgres://user:pass@host/db` |
+| `DB_URI` | Database connection URI | `file:storages/whatsapp.db` | `DB_URI=postgres://user:pass@host/db` |
| `DB_KEYS_URI` | Optional database URI for encryption/session key cache. Leave blank to use `DB_URI`; avoid in-memory storage in production because restarts can lose WhatsApp session state. | - | `DB_KEYS_URI=file:storages/whatsapp-keys.db?_foreign_keys=on` |
+| `CHAT_STORAGE_MAX_OPEN_CONNS` | Max concurrent SQLite connections for chat storage | `5` | `CHAT_STORAGE_MAX_OPEN_CONNS=10` |
| `WHATSAPP_AUTO_REPLY` | Auto-reply message | - | `WHATSAPP_AUTO_REPLY="Auto reply message"` |
| `WHATSAPP_AUTO_MARK_READ` | Auto-mark incoming messages as read | `false` | `WHATSAPP_AUTO_MARK_READ=true` |
| `WHATSAPP_AUTO_DOWNLOAD_MEDIA` | Auto-download media from incoming messages | `true` | `WHATSAPP_AUTO_DOWNLOAD_MEDIA=false` |
+| `WHATSAPP_AUTO_REJECT_CALL` | Auto-reject incoming WhatsApp calls | `false` | `WHATSAPP_AUTO_REJECT_CALL=true` |
| `WHATSAPP_WEBHOOK` | Webhook URL(s) for events (comma-separated) | - | `WHATSAPP_WEBHOOK=https://webhook.site/xxx` |
| `WHATSAPP_WEBHOOK_SECRET` | Webhook secret for validation | `secret` | `WHATSAPP_WEBHOOK_SECRET=super-secret-key` |
| `WHATSAPP_WEBHOOK_INSECURE_SKIP_VERIFY` | Skip TLS verification for webhooks (insecure) | `false` | `WHATSAPP_WEBHOOK_INSECURE_SKIP_VERIFY=true` |
@@ -232,6 +237,20 @@ To use environment variables:
| `CHATWOOT_DAYS_LIMIT_IMPORT_MESSAGES` | Days of history to import | `3` | `CHATWOOT_DAYS_LIMIT_IMPORT_MESSAGES=7` |
| `CHATWOOT_IMPORT_DB_URI` | Direct Chatwoot PostgreSQL URI for history sync | - | `CHATWOOT_IMPORT_DB_URI=postgresql://user:pass@host:5432/chatwoot_production?sslmode=disable` |
| `CHATWOOT_IMPORT_PLACEHOLDER_MEDIA_MESSAGE` | Insert text placeholders for media rows during direct DB import | `true` | `CHATWOOT_IMPORT_PLACEHOLDER_MEDIA_MESSAGE=true` |
+| `CHATWOOT_IMPORT_MEDIA_WITH_REST` | Upload direct-DB import media rows through Chatwoot REST | `false` | `CHATWOOT_IMPORT_MEDIA_WITH_REST=true` |
+| `CHATWOOT_AUTO_CREATE` | Auto-create or reuse the Chatwoot API inbox at startup | `false` | `CHATWOOT_AUTO_CREATE=true` |
+| `CHATWOOT_INBOX_NAME` | Inbox name used when auto-create is enabled | `WhatsApp` | `CHATWOOT_INBOX_NAME=WhatsApp Support` |
+| `CHATWOOT_WEBHOOK_URL` | Public GOWA Chatwoot reply webhook URL | - | `CHATWOOT_WEBHOOK_URL=https://api.example.com/chatwoot/webhook?secret=shared` |
+| `CHATWOOT_WEBHOOK_SECRET` | Shared secret required for incoming Chatwoot webhooks | - | `CHATWOOT_WEBHOOK_SECRET=shared` |
+| `CHATWOOT_REOPEN_CONVERSATION` | Reopen resolved Chatwoot conversations for returning contacts | `true` | `CHATWOOT_REOPEN_CONVERSATION=false` |
+| `CHATWOOT_CONVERSATION_PENDING` | Create new Chatwoot conversations as pending | `false` | `CHATWOOT_CONVERSATION_PENDING=true` |
+| `CHATWOOT_IGNORE_JIDS` | JIDs or wildcards to exclude from Chatwoot forwarding | - | `[email protected],[email protected]` |
+| `CHATWOOT_SIGN_MSG` | Prefix Chatwoot agent replies with the agent name | `false` | `CHATWOOT_SIGN_MSG=true` |
+| `CHATWOOT_SIGN_DELIMITER` | Delimiter between Chatwoot agent signature and message body | `\n\n` | `CHATWOOT_SIGN_DELIMITER=" - "` |
+| `CHATWOOT_FORWARD_EDITS` | Mirror WhatsApp edits into Chatwoot threaded notes | `true` | `CHATWOOT_FORWARD_EDITS=false` |
+| `CHATWOOT_FORWARD_DELETES` | Mirror WhatsApp delete-for-everyone events into Chatwoot notes | `true` | `CHATWOOT_FORWARD_DELETES=false` |
+| `CHATWOOT_MESSAGE_READ` | Sync read state for linked WhatsApp/Chatwoot messages | `false` | `CHATWOOT_MESSAGE_READ=true` |
+| `CHATWOOT_MESSAGE_DELETE` | Delete linked opposite-side messages when deletion is reported | `false` | `CHATWOOT_MESSAGE_DELETE=true` |
**Documentation:**
@@ -246,7 +265,7 @@ Note: Command-line flags will override any values set in environment variables o
### System Requirements
-- **Go 1.24.0 or higher** (for building from source)
+- **Go 1.25.5 or higher** (for building from source)
- **FFmpeg** (for media processing)
### Platform Support
@@ -358,7 +377,11 @@ protocol. Below is the complete list of available tools:
- `whatsapp_send_link` - Send links with custom captions
- `whatsapp_send_location` - Send location coordinates (latitude/longitude)
- `whatsapp_send_image` - Send images with captions, compression, and view-once options
+- `whatsapp_send_video` - Send videos from URLs with captions, compression, view-once, and GIF playback options
- `whatsapp_send_sticker` - Send stickers with automatic WebP conversion (supports JPG/PNG/GIF)
+- `whatsapp_send_document` - Send document/file messages from URLs
+- `whatsapp_send_audio` - Send audio files from URLs, including voice-note mode
+- `whatsapp_send_poll` - Send WhatsApp polls
##### **📋 Chat & Contact Management**
@@ -367,6 +390,12 @@ protocol. Below is the complete list of available tools:
- `whatsapp_get_chat_messages` - Fetch messages from specific chats with time/media filtering
- `whatsapp_download_message_media` - Download images/videos from messages
- `whatsapp_archive_chat` - Archive or unarchive a chat conversation
+- `whatsapp_react_message` - React to a WhatsApp message
+- `whatsapp_edit_message` - Edit a previously sent WhatsApp message
+- `whatsapp_revoke_message` - Delete a WhatsApp message for everyone
+- `whatsapp_delete_message` - Delete a WhatsApp message for the current account only
+- `whatsapp_mark_as_read` - Mark a WhatsApp message as read
+- `whatsapp_star_message` - Star or unstar a WhatsApp message
##### **👥 Group Management**
@@ -488,7 +517,7 @@ services:
- APP_PORT=3000
- APP_DEBUG=true
- APP_OS=Chrome
- - APP_ACCOUNT_VALIDATION=false
+ - WHATSAPP_ACCOUNT_VALIDATION=false
volumes:
whatsapp:
@@ -511,7 +540,7 @@ services:
- APP_PORT=3000
- APP_DEBUG=true
- APP_OS=Chrome
- - APP_ACCOUNT_VALIDATION=false
+ - WHATSAPP_ACCOUNT_VALIDATION=false
volumes:
whatsapp:
@@ -529,23 +558,24 @@ You can fork or edit this source code !
- MCP server provides standardized tools for AI agents to interact with WhatsApp
- Supports Server-Sent Events (SSE) transport
-- Available tools: `whatsapp_send_text`, `whatsapp_send_contact`, `whatsapp_send_link`, `whatsapp_send_location`
+- Available tools are listed in the "Available MCP Tools" section above.
- Compatible with MCP-enabled AI tools and agents
### HTTP REST API
-- Check [docs/openapi.yml](./docs/openapi.yaml) for detailed API specifications.
+- Check [docs/openapi.yaml](./docs/openapi.yaml) for detailed API specifications.
- Use [SwaggerEditor](https://editor.swagger.io) to visualize the API.
- Generate HTTP clients using [openapi-generator](https://openapi-generator.tech/#try).
| Feature | Menu | Method | URL |
|----------|----------------------------------------|--------|-------------------------------------|
+| ✅ | Health Check | GET | /health |
| ✅ | List Devices | GET | /devices |
| ✅ | Add Device | POST | /devices |
| ✅ | Get Device Info | GET | /devices/:device_id |
| ✅ | Remove Device | DELETE | /devices/:device_id |
-| ✅ | Login Device (QR) | GET | /devices/:device_id/login |
-| ✅ | Login Device (Code) | POST | /devices/:device_id/login/code |
+| ❌ | Login Device (QR, reserved) | GET | /devices/:device_id/login |
+| ❌ | Login Device (Code, reserved) | POST | /devices/:device_id/login/code |
| ✅ | Logout Device | POST | /devices/:device_id/logout |
| ✅ | Reconnect Device | POST | /devices/:device_id/reconnect |
| ✅ | Get Device Status | GET | /devices/:device_id/status |
@@ -590,6 +620,7 @@ You can fork or edit this source code !
| ✅ | Star Message | POST | /message/:message_id/star |
| ✅ | Unstar Message | POST | /message/:message_id/unstar |
| ✅ | Download Message Media | GET | /message/:message_id/download |
+| ✅ | Reject Call | POST | /call/reject |
| ✅ | Join Group With Link | POST | /group/join-with-link |
| ✅ | Group Info From Link | GET | /group/info-from-link |
| ✅ | Group Info | GET | /group/info |
@@ -614,10 +645,12 @@ You can fork or edit this source code !
| ✅ | Get Newsletter Messages | GET | /newsletter/messages |
| ✅ | Get Chat List | GET | /chats |
| ✅ | Get Chat Messages | GET | /chat/:chat_jid/messages |
-| ✅ | Label Chat | POST | /chat/:chat_jid/label |
| ✅ | Pin Chat | POST | /chat/:chat_jid/pin |
| ✅ | Archive Chat | POST | /chat/:chat_jid/archive |
| ✅ | Set Disappearing Messages | POST | /chat/:chat_jid/disappearing |
+| ✅ | Chatwoot Sync History | POST | /chatwoot/sync |
+| ✅ | Chatwoot Sync Status | GET | /chatwoot/sync/status |
+| ✅ | Chatwoot Reply Webhook | POST | /chatwoot/webhook |
```
✅ = Available
@@ -628,6 +661,9 @@ You can fork or edit this source code !
**Notes:**
- `*User My Groups`: Returns a maximum of 500 groups due to WhatsApp protocol limitation. This is enforced by WhatsApp servers, not this API. See [whatsmeow source](https://github.com/tulir/whatsmeow/blob/main/group.go) for details.
+- `/health` is public and always registered at the root path, even when `APP_BASE_PATH` is set.
+- Device-specific login routes are reserved by the router but not implemented by the current usecase. Use `/app/login` or `/app/login-with-code` with `X-Device-Id` or `device_id` to pair a specific slot.
+- Chatwoot routes are registered only when `CHATWOOT_ENABLED=true`.
## User Interface