publish

Sends a real-time message to Kuzzle. The message will be dispatched to all clients with subscriptions matching the index, the collection and the message content.

A _kuzzle_info object will be added to the message content, with the following properties:

  • author: sender kuid (or -1 if the message is sent by an anonymous connection)
  • createdAt: message timestamp, using the Epoch-millis format

Note: real-time messages are not persisted in the database.


Query Syntax

HTTP

Copied to clipboard!
URL: http://kuzzle:7512/<index>/<collection>/_publish
Method: POST
Body:
Copied to clipboard!
{
  // message content
}

Other protocols

Copied to clipboard!
{
  "index": "<index>",
  "collection": "<collection>",
  "controller": "realtime",
  "action": "publish",
  "body": {
    // message content
  }
}

Arguments

  • collection: collection name
  • index: index name

Body properties

Message content.


Response

Returns the sent message.

Copied to clipboard!
{
  "error": null,
  "status": 200,
  "index": "<index>",
  "collection": "<collection>",
  "controller": "realtime",
  "action": "publish",
  "requestId": "<unique request identifier>",
  "result": {
    "published": true
  }
}