Skip to main content
Use XADD to append an entry to a stream, creating the stream when it does not exist. An entry is a set of field and value pairs identified by an ID of the form <milliseconds>-<sequence>. Passing * lets the server build the ID from the current time, which guarantees that IDs only ever increase; an explicit ID must be greater than the last one in the stream. The reply is the ID the entry was stored under. NOMKSTREAM skips creating a stream that does not exist yet and returns null instead. The trimming options cap the stream in the same call, which is how a stream is kept from growing without bound. MAXLEN limits the number of entries and MINID drops entries with an ID below a threshold, which is the way to trim by age since IDs start with a timestamp. ~ makes the trim approximate, stopping at a convenient boundary, which is much cheaper than the exact = and is what most workloads should use; LIMIT caps how many entries a single call may evict. KEEPREF, DELREF, and ACKED decide what happens to consumer group references of the entries that trimming removes: KEEPREF, the default, leaves those references in place, DELREF removes them as well, and ACKED only removes entries that every group has read and acknowledged.

Syntax

Arguments

Response

The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.
Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.

Examples

TCP examples use the TLS REDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.