The messaging API uses a **dynamic resource path** (:type) to categorize your messages (e.g.,
*notify*, *event*, *message*).
1. Message Submission (POST)
POST /v1/{type}?group_id=your_group_id&message_id=your_message_id&ttl=seconds
Submit JSON messages. The {type} segment (e.g., /v1/notify) determines the
message category.
The optional ttl (Time To Live) specifies the message validity. Default TTL is 1 hour.
2. Real-Time Subscription (WebSocket)
GET /ws?group_id=your_group_id
Establish a WebSocket connection to receive real-time messages for the specified group_id.
To embed the messaging iframe invisibly into your webpage, include the following HTML snippet:
<iframe class="messaging-iframe"
src="https://bildirim.live?group_id=yourGroupId&origin=yourParentOrigin"
style="display: none;"></iframe>
The iframe sends the structured message **message** directly in the format
**{status, type, records: []}**. Listen for these events in your main
page:
window.addEventListener('message', function(event) {
// 1. Validate the origin of the message for security purposes
if (event.origin !== "https://bildirim.live") {
console.warn("Received message from untrusted origin:", event.origin);
return;
}
// 2. Process the structured message data.
// 'event.data' is the server's {status, type, records: [...]}.
const message = event.data;
// Check for status and type fields directly.
if (message && message.status && message.type) {
console.log("Received data type:", message.type);
console.log("Status:", message.status);
if (message.status === "success" && message.records) {
// Process the records array (this is where your messages are)
message.records.forEach(record => {
console.log("Processing message ID:", record.messageId);
console.log("Message Body:", record.body);
// IMPLEMENT YOUR MESSAGE DISPLAY LOGIC HERE
});
} else if (message.status === "no_messages") {
console.log("No stored messages for this group.");
}
} else {
console.warn("Unknown or incomplete message format received:", message);
}
});
This listener processes messages based on the **status** field (e.g., success, no_messages) and iterates over the
**records** array to access individual message payloads.
The messaging system offers several advanced features:
group_id and categorized by a dynamic type (e.g., 'alert', 'chat', 'event'), allowing flexible delivery logic.
{status, type, records: [...]}, providing rich meta-data like messageId and timestamps.