Send Message via API

Send a message to a chat room on behalf of a specific user.

POST /external/message/send

Authentication

This endpoint is available for external integrations only.

Required headers:

x-api-key: <API_KEY>
Authorization: Bearer <TOKEN>
Content-Type: application/json
  • Requires role: EXTERNAL
  • Requests without valid credentials will be rejected

Request Body

{
  "userId": "string",
  "roomId": "string",
  "text": "string"
}

Fields

FieldTypeRequiredDescription
userIdstringID of the user sending the message
roomIdstringTarget chat room ID
textstringMessage content

How it works

  • The message is sent to the specified room
  • The message is created as the provided user
  • In the UI, it appears exactly like a regular user message

Success Response

{
  "success": true
}

Errors

401 Unauthorized

{
  "error": "Unauthorized"
}

403 Forbidden

{
  "error": "Forbidden"
}

400 Bad Request

{
  "error": "Invalid request payload"
}

Security

  • The endpoint is protected against impersonation
  • Only authorized integrations can send messages
  • userId must belong to a valid and accessible context

Example

curl -X POST https://chatbackend.watchers.io/external/message/send \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "userId": "12345",
    "roomId": "67890",
    "text": "Hello from external API"
  }'

Use cases

  • Bots and automated messaging
  • External systems (CRM, betting engines, etc.)
  • Event-driven messages (notifications, triggers)

Notes

  • This endpoint bypasses UI input and works programmatically
  • Recommended for server-to-server integrations
  • Rate limits may apply depending on your plan