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/jsonX-Org- Your organization identifierEnvironment- Your environment nameProjectKey- Your project keyAuthorization: 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
- JavaScript
- cURL
// 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');
curl -X POST "https://dev.arealtimetech.com/ws/v1/push-message" \
-H "Content-Type: application/json" \
-H "X-Org: your_organization" \
-H "Environment: your_environment" \
-H "ProjectKey: your_project_key" \
-H "Authorization: Bearer your_jwt_token" \
-d '{
"channel": "your-channel-name",
"event": "message",
"content": "Hello from REST API!",
"to": ["username1", "username2"],
"connection_id": "your_connection_id"
}'