{
  "schema_version": 2,
  "id": "commands/spublish",
  "title": "SPUBLISH",
  "url": "https://redis.io/docs/latest/commands/spublish/",
  "summary": "Post a message to a shard channel",
  "since": "7.0.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-18T16:45:25+01:00",
  "page_type": "content",
  "content_hash": "ce188dfaedf31e5d2a89992d0ac37836ebb16fd266cb0eb23fc5ca2cc3fe5771",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Posts a message to the given shard channel.\n\nIn Redis Cluster, shard channels are assigned to slots by the same algorithm used to assign keys to slots.\nA shard message must be sent to a node that owns the slot the shard channel is hashed to. \nThe cluster makes sure that published shard messages are forwarded to all the nodes in the shard, so clients can subscribe to a shard channel by connecting to any one of the nodes in the shard.\n\nFor more information about sharded pubsub, see [Sharded Pubsub](https://redis.io/docs/latest/develop/pubsub#sharded-pubsub)."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>shardchannel</code></summary>\n\nThe shard channel to publish to.\n\n</details>\n\n<details open><summary><code>message</code></summary>\n\nThe message to publish.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "For example the following command publishes to the `orders` channel with a subscriber already waiting for message(s).\n    \n[code example]"
    },
    {
      "id": "redis-software-and-redis-cloud-compatibility",
      "title": "Redis Software and Redis Cloud compatibility",
      "role": "content",
      "text": "| Redis<br />Software | Redis<br />Cloud | <span style=\"min-width: 9em; display: table-cell\">Notes</span> |\n|:----------------------|:-----------------|:------|\n| <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> | <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\n[Integer reply](../../develop/reference/protocol-spec#integers): the number of clients that the message was sent to. Note that in a Redis Cluster, only clients that are connected to the same node as the publishing client are included in the count\n\n**RESP3:**\n\n[Integer reply](../../develop/reference/protocol-spec#integers): the number of clients that the message was sent to. Note that in a Redis Cluster, only clients that are connected to the same node as the publishing client are included in the count"
    }
  ],
  "examples": [
    {
      "id": "examples-ex0",
      "language": "plaintext",
      "code": "> spublish orders hello\n(integer) 1",
      "section_id": "examples"
    }
  ]
}
