---
source_url: https://www.pubnub.com/docs/sdks/rest-api/publish-message-to-channel-1
title: Publish message to channel
---

# Publish message to channel

> For AI agents: documentation index at https://www.pubnub.com/llms-full.txt

Publish JSON to a channel using the POST request.

| Path Parameters |
| --- |
| `pub_key`string—**REQUIRED**You app’s publish key from Admin Portal.Example: pub-c-50264475-1902-558x-b37b-56d7fb64bf45 |
| `sub_key`string—**REQUIRED**Your app's subscribe key from Admin Portal.Example: sub-c-50264475-1902-558x-d213-7p19052012n2 |
| `channel`string—**REQUIRED**The channel ID to perform the operation on.Example: myChannel |
| `callback`string—**REQUIRED**The JSONP callback name to wrap the function in. Use 0 for no callback.Example (myCallback): myCallbackExample (zero): 0 |

| Query Parameters |
| --- |
| `store`integerThis parameter overrides the default account configuration on message saving. 1 to save, 0 not to save. |
| `auth`stringString which is either the auth key (Access Manager legacy) or a valid token (Access Manager) used to authorize the operation if access control is enabled.Example: myAuthKey |
| `meta`stringJSON with additional information. Contains additional information about the message, which can be used for stream filtering. Value must be a JSON stringified and URI encoded string.Example (meta sample): %7B%22cool%22%3A%22meta%22%7D |
| `uuid`stringA UTF-8 encoded string of up to 92 characters used to identify the client.Example: myUniqueUserId |
| `ttl`numberSet a per-message time-to-live in Message Persistence.This parameter accepts both integer and floating-point numbers.For Integer values:If store = 1, and ttl = 0, the message is stored with your subscribe key’s configured TTL., If store = 1, and ttl = X (X is an Integer value), the message is stored with an expiry time of X hours unless you have message retention set to Unlimited on your keyset configuration in the Admin Portal., If store = 0, the ttl parameter is ignored., If ttl is not specified, expiration of the message defaults back to the expiry value of the subscribe key.For Float values:If store = 1, and ttl <= 0, the message is stored with your subscribe key's configured TTL., If store = 1, and ttl >= your subscribe key's configured TTL, the message is stored with your subscribe key's configured TTL., If store = 1, and ttl = X (X is a Float value), the message is stored with an expiry time of X hours (e.g., 0.5 = 30 minutes) unless you have message retention set to Unlimited on your keyset configuration in the Admin Portal., If store = 0, the ttl parameter is ignored., If ttl is not specified, expiration of the message defaults back to the expiry value of the subscribe key.Example: 0.5 |
| `signature`stringSignature used to verify that the request was signed with the secret key associated with the subscribe key.If Access Manager is enabled, either a valid authorization token or a signature are required. Check Access Manager documentation for details on how to compute the signature. |
| `timestamp`integerUnix epoch timestamp used as a nonce for signature computation. Must have no more than ± 60 seconds offset from NTP.Required if the signature parameter is supplied. |
| `custom_message_type`stringPossible values: 3 ≤ length ≤ 50User-specified message type string - limited by 3-50 case-sensitive alphanumeric characters with only - and _ special characters allowed.[a-zA-Z0-9-_*] |

| Request Body—**REQUIRED**Contains a message to be published on a channel. |
| --- |
| `message`string |

| Responses |
| --- |
| `200`OKSchema — OPTIONAL undefined[] | Schema—**OPTIONAL** | undefined[] |
| Schema—**OPTIONAL** |
| undefined[] |
| `400`Bad RequestSchema — OPTIONAL undefined[] | Schema—**OPTIONAL** | undefined[] |
| Schema—**OPTIONAL** |
| undefined[] |
| `403`ForbiddenSchema — OPTIONAL undefined[] | Schema—**OPTIONAL** | undefined[] |
| Schema—**OPTIONAL** |
| undefined[] |
| `413`Message payload is too large (>=32KiB)Schema — OPTIONAL undefined[] | Schema—**OPTIONAL** | undefined[] |
| Schema—**OPTIONAL** |
| undefined[] |
| `429`Request rate limit exceededSchema — OPTIONALstatus integer — OPTIONALerror boolean — OPTIONALmessage string — OPTIONAL | Schema—**OPTIONAL** | `status`integer—**OPTIONAL** | `error`boolean—**OPTIONAL** | `message`string—**OPTIONAL** |
| Schema—**OPTIONAL** |
| `status`integer—**OPTIONAL** |
| `error`boolean—**OPTIONAL** |
| `message`string—**OPTIONAL** |

pub_key
*
Type:
string
You app’s publish key from
[Admin Portal](https://admin.pubnub.com)
.
sub_key
*
Type:
string
Your app's subscribe key from
[Admin Portal](https://admin.pubnub.com)
.
channel
*
Type:
string
The channel ID to perform the operation on.
callback
*
Type:
string
The JSONP callback name to wrap the function in. Use
0
for no callback.
store
Type:
integer
This parameter overrides the default account configuration on message saving.
1
to save,
0
not to save.
auth
Type:
string
String which is either the auth key (Access Manager legacy) or a valid token (
[Access Manager](https://www.pubnub.com/docs/security/access-control/overview.md)
) used to authorize the operation if access control is enabled.
meta
Type:
string
JSON with additional information.

Contains additional information about the message, which can be used for stream filtering. Value must be a JSON stringified and URI encoded string.
uuid
Type:
string
A UTF-8 encoded string of up to 92 characters used to
[identify the client](https://www.pubnub.com/docs/architecture/core-concepts.md)
.
ttl
Type:
number
Set a per-message time-to-live in Message Persistence.

This parameter accepts both integer and floating-point numbers.

For Integer values:

* If store =
1
, and
ttl
=
0
, the message is stored with your subscribe key’s configured TTL.

* If store =
1
, and
ttl
=
X
(
X
is an Integer value), the message is stored with an expiry time of
X
hours unless you have message retention set to
Unlimited
on your keyset configuration in the Admin Portal.

* If store =
0
, the
ttl
parameter is ignored.

* If
ttl
is not specified, expiration of the message defaults back to the expiry value of the subscribe key.

For Float values:

* If store =
1
, and
ttl
<=
0
, the message is stored with your subscribe key's configured TTL.

* If store =
1
, and
ttl
>=
your subscribe key's configured TTL, the message is stored with your subscribe key's configured TTL.

* If store =
1
, and
ttl
=
X
(
X
is a Float value), the message is stored with an expiry time of
X
hours (e.g.,
0.5
= 30 minutes) unless you have message retention set to
Unlimited
on your keyset configuration in the Admin Portal.

* If store =
0
, the
ttl
parameter is ignored.

* If
ttl
is not specified, expiration of the message defaults back to the expiry value of the subscribe key.
signature
Type:
string
Signature used to verify that the request was signed with the secret key associated with the subscribe key.

If Access Manager is enabled, either a valid authorization token or a signature are required.

Check
[Access Manager documentation](https://www.pubnub.com/docs/sdks/rest-api/access-manager-introduction.md)
for details on how to compute the signature.
timestamp
Type:
integer
Unix epoch timestamp used as a nonce for signature computation. Must have no more than ± 60 seconds offset from NTP.

Required if the
signature
parameter is supplied.
custom_message_type
Type:
string
User-specified message type string - limited by 3-50 case-sensitive alphanumeric characters with only
-
and
_
special characters allowed.

[a-zA-Z0-9-_*]
Contains a message to be published on a channel.
message
Type:
string
Example Request

```
{
  "message": "There is no place like 127.0.0.1"
}
```

Example Response

```
[
  1,
  "Sent",
  "14375220012064619"
]
```

Example Response

```
[
  0,
  "Wildcard maximum depth exceeded",
  "16866840224081436"
]
```

Example Response

```
[
  0,
  "Forbidden"
]
```

Example Response

```
[
  0,
  "Request Entity Too Large"
]
```
