Agent-TS API Reference
The Agent-TS service exposes REST endpoints for WhatsApp integration, health monitoring, and internal notifications.Base URL
Endpoints Overview
| Method | Endpoint | Description | Auth |
|---|---|---|---|
GET | /health | Health check | None |
DELETE | /api/v1/conversation/:phone | Clear conversation | None |
GET | /api/v1/webhooks/whatsapp | Meta webhook verification | Verify Token |
POST | /api/v1/webhooks/whatsapp | Meta WhatsApp messages | None |
POST | /api/v1/external/whatsapp | External client messages | None |
POST | /api/v1/notifications/whatsapp | Internal notifications | HMAC |
Health Check
/health
Check if the agent service is running and healthy.
Response
Example
Clear Conversation
/api/v1/conversation/:phone
Clear the conversation history for a specific user.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
phone | string | Phone number (E.164 or local format) |
Response
- Success (200)
- Not Found (404)
Example
External WhatsApp Webhook
/api/v1/external/whatsapp
Receive messages from external WhatsApp clients (whatsapp-web.js, Baileys).
Request Body
Event type:
message, connected, disconnectedText message content
Sender JID (e.g.,
23279123456@c.us)Phone in E.164 format (e.g.,
+23279123456)Message type:
text, image, documentWhether message contains media
Media object with
data, mimetype, filename, sizeText Message Request
Image Message Request (KYC)
Response
Example
Meta WhatsApp Webhook (Verification)
/api/v1/webhooks/whatsapp
Verify webhook with Meta WhatsApp Business API.
Query Parameters
| Parameter | Type | Description |
|---|---|---|
hub.mode | string | Must be subscribe |
hub.verify_token | string | Your verify token |
hub.challenge | string | Challenge to echo back |
Response
Returns thehub.challenge value on success, or 403 on failure.
Example
Meta WhatsApp Webhook (Messages)
/api/v1/webhooks/whatsapp
Receive messages from Meta WhatsApp Business API.
Request Body
Standard Meta webhook format:Response
Returns200 OK on success.
Internal Notifications
/api/v1/notifications/whatsapp
Send transaction notifications via WhatsApp (internal service use only).
Authentication
HMAC service authentication required:Request Body
Recipient phone in E.164 format
Notification message text
Transaction type for receipt generation
Transaction metadata for receipt
Transaction Types
| Type | Description |
|---|---|
pos_payment | POS terminal payment |
pos_refund | POS refund |
agent_cash_in | Agent cash-in |
p2p_transfer | Peer-to-peer transfer |
cash_out | Cash withdrawal |
Request Example
Response
Example
Error Responses
Standard Error Format
Common Errors
| Status | Error | Description |
|---|---|---|
| 400 | Phone number required | Missing phoneE164 |
| 401 | Service authentication failed | Invalid HMAC |
| 500 | Error processing webhook | Internal error |
| 503 | Agent not initialized | Service starting |