Skip to main content
POST/data-streams/user/{streamSlug}/publish

Publish to Stream

Appends one message to a user stream. data is any JSON value; the optional subject is a routing suffix under the stream's subjectPrefix, so a publish never leaves the stream's own namespace.

Answers 202 once the broker has stored the message, with the full subject and the payload size.

Needs PROJECT_ADMIN.

Parameters
streamSlug *path

The stream's slug, unique in the project.

projectSlug *path

The project's slug: the path segment after @.

It is unique within the org.

Request body
data *any

The event payload: any JSON value (object, array, string, number, boolean or null).

It is stored as JSON and delivered to consumers unchanged.

subjectstring

An optional routing suffix appended under the stream's subjectPrefix: up to 8 dot-separated segments, each 1 to 64 characters of a-z, 0-9, _ or - (no wildcards).

Omitted, the message is published on <subjectPrefix>._.

Responses
HTTPK9O CodeDescription
202Accepted
400K9O_STREAM_INVALIDThe publish subject is malformed (too many segments, or an invalid segment).
403K9O_RBAC_DENYPublishing to a Pulse Stream requires PROJECT_ADMIN (or org-cascade).
404K9O_STREAM_NOT_FOUNDNo active Pulse Stream with that slug in this project.
503K9O_STREAM_UNAVAILABLEPulse Stream messaging is not configured in this deployment, or the project's stream account is not provisioned, so the message was not stored. Retry later.
Response body (202)
data *object

The message was stored on the stream.

streamSlug *string

The stream the message was published to.

subject *string

The full subject the message was published on.

bytes *integer

The size of the stored payload: the UTF-8 bytes of data serialized as JSON.

accepted *true

Always true: the broker acknowledged the message.

meta *any
TypeScript
// const k9o = new K9o({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })
const { data } = await k9o.streams.publish('<streamSlug>', {})

Showing example in TypeScript

Request example
{
  "subject": "string"
}
Response example (202)
{
  "data": {
    "streamSlug": "string",
    "subject": "string",
    "bytes": 0,
    "accepted": true
  }
}

More in Realtime Feeds & Streams