Create Stream
Creates a new stream with the specified configuration.
Subject
$JS.API.STREAM.CREATE.{stream}
Where {stream} is the name of the stream to create.
Request
A request to the JetStream $JS.API.STREAM.CREATE API
All of the following:
namestring
A unique name for the Stream, empty for Stream Templates.
Pattern:
^[^.*>]*$Min length:
0descriptionstring
A short description of the purpose of this stream
Max length:
4096subjectsstring[]
A list of subjects to consume, supports wildcards. Must be empty when a mirror is configured. May be empty when sources are configured.
Min length:
0subject_transformobject
Subject transform to apply to matching messages
retentionstringrequired
How messages are retained in the Stream, once this is exceeded old messages are removed.
Allowed values:
limitsinterestworkqueueDefault:
limitsmax_consumersintegerrequired
How many Consumers can be defined for a given Stream. -1 for unlimited.
integer with a dynamic bit size depending on the platform the cluster runs on, can be up to 64bit
Minimum:
-1Maximum:
9223372036854776000Default:
-1max_msgsintegerrequired
How many messages may be in a Stream, oldest messages will be removed if the Stream exceeds this size. -1 for unlimited.
signed 64 bit integer
Minimum:
-1Maximum:
9223372036854776000Default:
-1max_msgs_per_subjectinteger
For wildcard streams ensure that for every unique subject this many messages are kept - a per subject retention limit
signed 64 bit integer
Minimum:
-1Maximum:
9223372036854776000Default:
-1max_bytesintegerrequired
How big the Stream may be, when the combined stream size exceeds this old messages are removed. -1 for unlimited.
signed 64 bit integer
Minimum:
-1Maximum:
9223372036854776000Default:
-1max_ageintegerrequired
Maximum age of any message in the stream, expressed in nanoseconds. 0 for unlimited.
nanoseconds depicting a duration in time, signed 64 bit integer
Minimum:
0Maximum:
9223372036854776000Default:
0max_msg_sizeinteger
The largest message that will be accepted by the Stream. -1 for unlimited.
signed 32 bit integer
Minimum:
-1Maximum:
2147483647Default:
-1storagestringrequired
The storage backend to use for the Stream.
Allowed values:
filememoryDefault:
filecompressionstring
Optional compression algorithm used for the Stream.
Allowed values:
nones2Default:
nonefirst_seqinteger
A custom sequence to use for the first message in the stream
unsigned 64 bit integer
Minimum:
0Maximum:
18446744073709552000num_replicasintegerrequired
How many replicas to keep for each message.
integer with a dynamic bit size depending on the platform the cluster runs on, can be up to 64bit
Minimum:
1Maximum:
5Default:
1no_ackboolean
Disables acknowledging messages that are received by the Stream.
Default:
falsetemplate_ownerstring
When the Stream is managed by a Stream Template this identifies the template that manages the Stream.
discardstring
When a Stream reach it's limits either old messages are deleted or new ones are denied
Allowed values:
oldnewDefault:
oldduplicate_windowinteger
The time window to track duplicate messages for, expressed in nanoseconds. 0 for default
nanoseconds depicting a duration in time, signed 64 bit integer
Minimum:
0Maximum:
9223372036854776000Default:
0placementobject
Placement directives to consider when placing replicas of this stream, random placement when unset
mirrorobject
Maintains a 1:1 mirror of another stream with name matching this property. When a mirror is configured subjects and sources must be empty.
sourcesobject[]
List of Stream names to replicate into this Stream
sealedboolean
Sealed streams do not allow messages to be deleted via limits or API, sealed streams can not be unsealed via configuration update. Can only be set on already created streams via the Update API
Default:
falsedeny_deleteboolean
Restricts the ability to delete messages from a stream via the API. Cannot be changed once set to true
Default:
falsedeny_purgeboolean
Restricts the ability to purge messages from a stream via the API. Cannot be change once set to true
Default:
falseallow_rollup_hdrsboolean
Allows the use of the Nats-Rollup header to replace all contents of a stream, or subject in a stream, with a single new message
Default:
falseallow_directboolean
Allow higher performance, direct access to get individual messages
Default:
falseallow_atomicboolean
Allow atomic batched publishes
Default:
falseallow_msg_counterboolean
Configures a stream to be a counter and to reject all other messages
Default:
falseallow_msg_schedulesboolean
Allows the scheduling of messages
Default:
falsemirror_directboolean
Allow higher performance, direct access for mirrors as well
Default:
falserepublishobject
Rules for republishing messages from a stream with subject mapping onto new subjects for partitioning and more
discard_new_per_subjectboolean
When discard policy is new and the stream is one with max messages per subject set, this will apply the new behavior to every subject. Essentially turning discard new from maximum number of subjects into maximum number of messages in a subject.
Default:
falsemetadata{ [key: string]: string }
Additional metadata for the Stream
consumer_limitsobject
Limits of certain values that consumers can set, defaults for those who don't set these settings
allow_msg_ttlboolean
Enables per-message TTL using headers
Default:
falsesubject_delete_marker_ttlinteger
Enables and sets a duration for adding server markers for delete, purge and max age limits
nanoseconds depicting a duration in time, signed 64 bit integer
Minimum:
0Maximum:
9223372036854776000persist_modestring
Sets a specific persistence mode for writing to the Stream
Allowed values:
defaultasyncDefault:
pedanticboolean
Enables pedantic mode where the server will not apply defaults or change the request
Default:
falseResponse
A response from the JetStream $JS.API.STREAM.CREATE API
One of the following:
Option 1 (object)
configobjectrequired
The active configuration for the Stream
stateobjectrequired
Detail about the current State of the Stream
createdstring<date-time>required
Timestamp when the stream was created
A point in time in RFC3339 format including timezone, though typically in UTC
tsstring<date-time>
The server time the stream info was created
A point in time in RFC3339 format including timezone, though typically in UTC
clusterobject
mirrorobject
Information about an upstream stream source in a mirror
sourcesobject[]
Streams being sourced into this Stream
alternatesobject[]
List of mirrors sorted by priority
Option 2 (object)
errorobjectrequired
typeconst: "io.nats.jetstream.api.v1.stream_create_response"required