Append events to a stream
POST /api/event-stores/{eventStoreName}/streams/{streamId}
Appends one or more events to an event stream. Events are stored in chronological order and can be used to track state changes over time.
The stream version is used for optimistic concurrency control. If expectedStreamVersion is provided, the operation will fail if the current version doesn’t match.
expectedStreamVersion can be:
- A specific version number
- ‘no_stream’ (expects the stream does not exist)
- ‘stream_exists’ (expects the stream exists, any version)
- ‘any’ (no version checking, will append regardless of stream state)
Authorizations
Section titled “Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ”Event store name (automatically scoped to your organization)
Event store name (automatically scoped to your organization)
Unique identifier for the event stream (e.g., “user-123”, “order_456”, “product:789”). Supports hyphen (-), underscore (_), or colon (:) as delimiters. The first segment before the delimiter is used as the stream type.
Unique identifier for the event stream (e.g., “user-123”, “order_456”, “product:789”). Supports hyphen (-), underscore (_), or colon (:) as delimiters. The first segment before the delimiter is used as the stream type.
Request Body
Section titled “Request Body ”object
object
object
object
Examples
Single event append
{ "events": [ { "type": "user.created", "data": { "userId": "123", "email": "user@example.com" }, "metadata": { "correlationId": "abc-123" }, "schemaVersion": "1.0.0" } ], "options": { "expectedStreamVersion": 0 }}Multiple events append
{ "events": [ { "type": "user.created", "data": { "userId": "123", "email": "user@example.com" }, "metadata": { "correlationId": "abc-123" }, "schemaVersion": "1.0.0" }, { "type": "user.updated", "data": { "userId": "123", "email": "user1@example.com" }, "metadata": { "correlationId": "abc-123" } } ], "options": { "expectedStreamVersion": 0 }}Using enum value for expectedStreamVersion
{ "events": [ { "type": "user.created", "data": { "userId": "123", "email": "user@example.com" }, "metadata": { "correlationId": "abc-123" } } ], "options": { "expectedStreamVersion": "no_stream" }}Responses
Section titled “ Responses ”Events were successfully appended to the stream. Returns the new stream version and count of events written.
object
Examples
{ "success": true, "nextExpectedStreamVersion": 1, "eventsWritten": 1}The request was invalid. This can occur if the event data is malformed or required fields are missing.
object
object
Unauthorized: Organization ID not found in authentication context
object
Examples
{ "error": "UNAUTHORIZED", "message": "Unauthorized: Organization ID not found in authentication context"}A version conflict occurred. This happens when the expectedStreamVersion doesn’t match the current stream version, indicating potential concurrent modifications.
object
Examples
{ "error": "Version conflict", "details": "Expected version 0 but stream is at version 1", "currentVersion": 1, "expectedVersion": 0}