Skip to main content

Push Message

Step 3 of the API flow. Send a message to a channel using your JWT token and connection ID.

Endpoint: POST /v1/push-message

Headers:

  • Content-Type: application/json
  • X-Org - Your organization identifier
  • Environment - Your environment name
  • ProjectKey - Your project key
  • Authorization: Bearer {token} - Your JWT token

Request Body:

{
"channel": "channel-name",
"event": "message",
"content": "Your message content",
"to": ["username1", "username2"],
"connection_id": "your_connection_id"
}

Response:

{
"status": 200,
"data": "Message processed successfully",
"message": "Message processed successfully"
}

Code Examples

// Push message to channel
const pushMessage = async (token, connectionId) => {
const response = await fetch('https://dev.arealtimetech.com/ws/v1/push-message', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Org': 'your_organization',
'Environment': 'your_environment',
'ProjectKey': 'your_project_key',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
channel: "your-channel-name",
event: "message",
content: "Hello from REST API!",
to: ["username1", "username2"],
connection_id: connectionId
})
});

const result = await response.json();
console.log('Message sent:', result);
return result;
};

// Call the function with your JWT token and connection ID
const result = await pushMessage('your_jwt_token', 'your_connection_id');