> ## Documentation Index
> Fetch the complete documentation index at: https://s2.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Streams

> Streams are durable, ordered sequences of records you can append to, seek through, and follow live.

Streams are always durable and totally ordered.

Every stream has a URI: `s2://{basin}/{stream}`. Basins can hold unlimited streams.

Appends always land at the tail, atomically – either all the records in a batch or none.

Reads can start from any position and optionally follow for live updates.

## Positions

We talk about the **head** and **tail** of a stream.

The head is the beginning, and the tail is where the next record to be appended will go.

Each record on a stream has an associated sequence number and timestamp.

* sequence number increases strictly monotonically
* timestamp increases monotonically, and may be identical between records

<Tip>
  The *tail* position is `(next_seq_num, last_record_timestamp)`.

  Both will be `0` for an empty stream!
</Tip>

## Lifecycle automation

You can automate the creation and deletion of streams. This is very useful for patterns with many dynamic streams, like one per session or job.

### Creation

Streams can be created explicitly, or automatically on first use.

If a basin has `create_stream_on_append` or `create_stream_on_read` [configured](/concepts/configs#basin-config), streams will be created with the basin's default config the first time they're accessed.

### Deletion

Streams can be [configured](/concepts/configs#delete-on-empty) to automatically delete once they become empty. The `min_age_secs` threshold requires the stream to have been empty for a minimum duration before auto-deletion kicks in.

## See also

<CardGroup cols={2}>
  <Card title="Stream SDK" icon="code" href="/sdk/stream-resources">
    Create, configure, list, and delete streams from SDK clients.
  </Card>

  <Card title="Stream API" icon="globe" href="/api/streams/create">
    Review the stream management endpoints.
  </Card>
</CardGroup>
