Broadcasts a message onto a specific channel. options contains channel name, message, and callback values. The message may be any valid JSON type including objects, arrays, strings, and integers.

Code Example

PUBNUB.publish({    channel  : "hello_world",    message  : "Hi!",    callback : function(response) { log(response) }})


RESTful Example

When this request is made, the server will hold the connection until the message is successfully published.

_ NOTE _ : It is critical that you make sure that all special characters are URL-encoded to ensure proper operation.

URL and Parameters


PUBLISH_KEY is your assigned publish key. Publish keys begin with the prefix "pub-"

SUBSCRIBE_KEY is your assigned subscribe key. Subscribe keys begin with the prefix "sub-"

SECRET_KEY (Optional) is your assigned secret key. Secret keys begin with the prefix "sec-".

_ NOTE _ : If you are not using a secret key, use 0 as a placeholder.

CHANNEL is the specific channel you wish to publish messages to.

JSONP_CALLBACK (Optional) is the name of the callback function you wish to wrap the response around.

_ NOTE: _ If you are not using a JSONP callback, use 0 as a placeholder.

MESSAGE is the JSON encoded message you wish to publish to all subscribers of the CHANNEL.

Request / Response Example

$ curl[1,"Sent","13573504535416542"]

Successful Response


Failure Response

[0,"Error description here"]