Evently.cloud Preview (1.2.0)

Download OpenAPI specification:Download

API for Evently clients to use to register new event types, append events and select existing events. Clients can subscribe to notifications of new events that match selectors.

Evently stores business events for later use in event sourcing applications. Events are stored in ledgers and retrieved with selectors. Clients can subscribe to real-time notifications of new events that match selectors. One can also download the ledger for other uses.

This API is grouped in the following sections:

  • Registry - Events must be registered before use
  • Append - Append events to the ledger
  • Selectors - Select events from the ledger that match criteria
  • Notifications - Subscribe to new event notifications
  • Ledgers - Manage ledgers that hold events

This API expresses capabilities using Level 3 REST profiles and patterns, a hypermedia API specification found at https://level3.rest.

ledgers

Manage event ledgers

Event Registration Form

Form to register an entity event. GET the schema, create a JSON object with it and POST it back this endpoint.

Authorizations:
opaque-token

Responses

Response samples

Content type
application/schema+json
true

Register an Event Type

Accepts a form object to register a new entity event type. This action is idempotent, so one can register the same event repeatedly without a failure response.

Authorizations:
opaque-token
Request Body schema: application/json
entity
required
string <= 80 characters ^[^\x00-\x1F\x80-\x9F]+$
event
required
string <= 80 characters ^[^\x00-\x1F\x80-\x9F]+$

Responses

Request samples

Content type
application/json
{
  • "entity": "account",
  • "event": "account-created"
}

Ledger Info

Information about the ledgers, including links to download and reset actions.

Responses

Response samples

Content type
application/hal+json
{
  • "_links": {
    },
  • "_embedded": {
    }
}

Download Ledger Form

Download the entire ledger or the ledger after a specified ledger mark / event ID.

Responses

Response samples

Content type
application/schema+json
true

Submit Download Ledger Form

Submit form to download a ledger either entirely or after a ledger mark / event ID.

Authorizations:
opaque-token
header Parameters
Prefer
string
Enum: "return=representation" "return=minimal"

Uses the "return" preference. Tells the download resource to send the ledger in response to the POST request instead of sending a redirect to the download URL.

Request Body schema: application/json
after
string^[0-9a-f]{24}(?:[0-9a-f]{8})?$

Download events that occur after this ledger mark or event ID.

limit
integer >= 1

Limit the number of returned events to this value.

Responses

Request samples

Content type
application/json
Example
{ }

Response samples

Content type
application/x-ndjson
null

Download a Ledger file

Download the ledger as configured by a download ledger form. The content is formatted as newline-delimited JSON and can be streamed to disk or through a streaming processor.

Authorizations:
opaque-token
path Parameters
download-info
required
string

Download info identifier

Responses

Response samples

Content type
application/x-ndjson
null

Reset Ledger Form

Create a ledger reset request with this form schema and POST it back.

Responses

Response samples

Content type
application/schema+json
true

Reset Ledger

Reset the ledger to remove events, either completely or after a specific point.

Authorizations:
opaque-token
Request Body schema: application/json

To reset the entire ledger, send an empty JSON object '{}'. To remove all events after a ledger mark or an event ID, send an object with an after property containing the mark/event ID.

after
string^[0-9a-f]{24}(?:[0-9a-f]{8})?$

Remove all events that occur after this ledger mark or event ID.

Responses

Request samples

Content type
application/json
Example
{ }

registry

Event registry to manage entity event types

Entities with Registered Events

Get links to entities that have registered events.

Authorizations:
opaque-token

Responses

Response samples

Content type
application/json+hal
{
  • "_links": {
    },
  • "_embedded": {
    }
}

An Entity's Events

Get links to events registered to an entity.

Authorizations:
opaque-token
path Parameters
entity
required
string

entity name

Responses

Response samples

Content type
application/json+hal
{
  • "_links": {
    },
  • "_embedded": {
    }
}

An Entity Event

Get a registered entity event.

Authorizations:
opaque-token
path Parameters
entity
required
string

entity name

event
required
string

event name

Responses

Response samples

Content type
application/json+hal
{
  • "_links": {
    },
  • "_embedded": {
    }
}

Delete Entity Event

Deletes this entity event registration. Only succeeds if no events of this type have been appended to the ledger.

Authorizations:
opaque-token
path Parameters
entity
required
string

entity name

event
required
string

event name

Responses

append

Append events to the ledger

Append Factual Event Form

Returns a JSON Schema form to append a factual event. Create an object matching this schema and POST it back.

Responses

Response samples

Content type
application/schema+json
true

Append a Factual Event

Append a factual event to the ledger. Factual events append without conditions such as selector state or entity sequence. Facts often capture external events like delivery service receipts and IoT signals.

If your client has uncertain connectivity and wants to append the event multiple times to ensure success, send a unique, client-created idempotencyKey to identify this specific event in subsequent append attempts. Evently recommends using Nano IDs.

Authorizations:
opaque-token
Request Body schema: application/json
entity
required
string

The name of the entity.

key
required
string

The entity's business identifier.

event
required
string

Name of the event being appended.

meta
required
object

Event metadata. Use properties that are common to all events, like correlationId, actor and causationId. Evently creates an append timestamp value automatically, so clients can omit putting a timestamp in meta.

data
required
string or number or boolean or object or array

Event data can be any type of data, from a string to an object with multiple values. The data is specific to the entity event.

idempotencyKey
string >= 2 characters

Unique key identifying the append event's idempotency. This key will instruct evently to ignore duplicate append submissions instead of sending an error response.

Responses

Request samples

Content type
application/json
{
  • "entity": "string",
  • "key": "string",
  • "event": "string",
  • "meta": { },
  • "data": "string",
  • "idempotencyKey": "string"
}

Response samples

Content type
application/json
{
  • "eventId": "string",
  • "idempotencyKey": "string"
}

Append Serial Event Form

Returns a JSON Schema form to append a serial event. Create an object matching this schema and POST it back.

Responses

Response samples

Content type
application/schema+json
true

Append a Serial Event

Append a serial event to the ledger. Serial events append only if they are the next event in an entity event sequence. The form requires a previousEventId for the latest event for an entity instance. This can be obtained from the result of a previous append operation or from a replay selector result.

In order to append a serial event, an event must already be appended for the entity instance. This can be done by atomically appending a event which appends an event if none have been appended already, or a simple factual event if the client is unconcerned with other attempts to append to the specific entity instance.

If your client has uncertain connectivity and wants to append the event multiple times to ensure success, send a unique, client-created idempotencyKey to identify this specific event in subsequent append attempts. Evently recommends using Nano IDs.

Authorizations:
opaque-token
Request Body schema: application/json
entity
required
string

The name of the entity.

key
required
string

The entity's business identifier.

event
required
string

Name of the event being appended.

meta
required
object

Event metadata. Use properties that are common to all events, like correlationId, actor and causationId. Evently creates an append timestamp value automatically, so clients can omit putting a timestamp in meta.

data
required
string or number or boolean or object or array

Event data can be any type of data, from a string to an object with multiple values. The data is specific to the entity event.

previousEventId
required
string

The event ID of the most recent event appended to this entity instance. This value is found in the last event of a replay selector result stream.

idempotencyKey
string >= 2 characters

Unique key identifying the append event's idempotency. This key will instruct evently to ignore duplicate append submissions instead of sending an error response.

Responses

Request samples

Content type
application/json
{
  • "entity": "string",
  • "key": "string",
  • "event": "string",
  • "meta": { },
  • "data": "string",
  • "previousEventId": "string",
  • "idempotencyKey": "string"
}

Response samples

Content type
application/json
{
  • "eventId": "string",
  • "idempotencyKey": "string"
}

Append Atomic Event Form

Returns a JSON Schema form to atomically append and event using a selector conditional. Create an object matching this schema and POST it back.

Responses

Response samples

Content type
application/schema+json
true

Atomic Append Event

Append an event atomically to the ledger using a selector conditional. These events append only if the provided selector is quiescent, meaning it has no new events. This selector's quiescence is the condition required to append the event. The form requires a selector object with a selectorId indicating the selector and mark pointing to the ledger mark where the selector has been read up to.

One can use either a replay or a filter selector as a condition for appending an event. The data for the selector object is found in the selector's footer object at the end of a selector event stream.

If your client has uncertain connectivity and wants to append the event multiple times to ensure success, send a unique, client-created idempotencyKey to identify this specific event in subsequent append attempts. Evently recommends using Nano IDs.

Authorizations:
opaque-token
Request Body schema: application/json
entity
required
string

The name of the entity.

key
required
string

The entity's business identifier.

event
required
string

Name of the event being appended.

meta
required
object

Event metadata. Use properties that are common to all events, like correlationId, actor and causationId. Evently creates an append timestamp value automatically, so clients can omit putting a timestamp in meta.

data
required
string or number or boolean or object or array

Event data can be any type of data, from a string to an object with multiple values. The data is specific to the entity event.

required
object

The selector used to atomically append this event. The data for this object is found in the footer of a selector event stream.

idempotencyKey
string >= 2 characters

Unique key identifying the append event's idempotency. This key will instruct evently to ignore duplicate append submissions instead of sending an error response.

Responses

Request samples

Content type
application/json
{
  • "entity": "string",
  • "key": "string",
  • "event": "string",
  • "meta": { },
  • "data": "string",
  • "selector": {
    },
  • "idempotencyKey": "string"
}

Response samples

Content type
application/json
{
  • "eventId": "string",
  • "idempotencyKey": "string"
}

selectors

Select events from the ledger

Replay Events Selector Lookup

Lookup control used to select entity events to replay. Construct an object that matches this schema and POST it back to this location.

Authorizations:
opaque-token

Responses

Response samples

Content type
application/schema+json
true

Replay Entity Events

Submit a filter request to stream events from the ledger that match filter criteria. Use after to catch up on a previously-fetched selector by setting it to a ledger mark or event ID. The limit property controls how many events are returned in the selector.

This resource redirects to a URL that contains the selector results. If the redirect approach is not suitable, send a Prefer header indicating your client wishes the selector result in the POST response.

The default redirect approach works well with shared entities that change infrequently as they contain caching instructions to share with other clients. If the entity instance changes often then sending Prefer: return=representation will improve selector performance by skipping the redirect step at the cost of not utilizing the internet's caching services.

The selector footer information (selectorId, mark) can be used to atomically append events using the /append/atomic endpoint.

Authorizations:
opaque-token
header Parameters
Prefer
string
Enum: "return=representation" "return=minimal"

Uses the "return" preference. Tells the selector to send the matching events in response to the POST request instead of sending a redirect to the fetch URL.

Request Body schema: application/json
entity
required
string

The name of the entity type.

keys
required
Array of strings

An array of entity keys identifying the entity instances to replay events from.

events
Array of strings

Filter the selected events to only include these event types. If this property is omitted, then all the event types for the entity are selected.

after
string^[0-9a-f]{24}(?:[0-9a-f]{8})?$

Fetch events that occur after this ledger mark or event ID.

limit
integer >= 1

Limit the number of returned events to this value.

Responses

Request samples

Content type
application/json
No sample

Response samples

Content type
application/x-ndjson
null

Filter Events Selector Lookup

Lookup control used to select filtered events across all entities in the ledger. Construct an object that matches this schema and POST it back to this location.

Authorizations:
opaque-token

Responses

Response samples

Content type
application/schema+json
true

Filter Events

Submit a filter selector request to stream events of specified entities from the ledger. Use after to catch up on a previously-fetched selector by setting it to a ledger mark or event ID. The limit property controls how many events are returned in the selector.

This resource redirects to a URL that contains the selector results. If the redirect approach is not suitable, send a Prefer header indicating your client wishes the selector result in the POST response.

The default redirect approach works well with shared entities that change infrequently as they contain caching instructions to share with other clients. If the entity instance changes often then sending Prefer: return=representation will improve selector performance by skipping the redirect step at the cost of not utilizing the internet's caching services.

The selector footer information (selectorId, mark) can be used to atomically append events using the /append/atomic endpoint.

Authorizations:
opaque-token
header Parameters
Prefer
string
Enum: "return=representation" "return=minimal"

Uses the "return" preference. Tells the selector to send the matching events in response to the POST request instead of sending a redirect to the fetch URL.

Request Body schema: application/json
object (sql-jsonpath-query)

SQL JSONPath statement to filter meta object values.

object

Filter by event data values. Keys are entity names; values are objects whose keys are event names and values are SQL JSONPath queries.

after
string^[0-9a-f]{24}(?:[0-9a-f]{8})?$

Fetch events that occur after this ledger mark or event ID.

limit
integer >= 1

Limit the number of returned events to this value.

Responses

Request samples

Content type
application/json
{
  • "data": {
    },
  • "meta": {
    },
  • "after": "0005d2bfb29a03795f574859cb0687dc",
  • "limit": 1
}

Response samples

Content type
application/x-ndjson
null

Fetch a Selector file

Fetch a selector result as configured by a selector lookup. This resource URI is provided by replay and filter selector lookups.

This resource returns a newline-delimited JSON stream of the events, ordered by their append sequence. The last line of the response is a footer object. The footer contains data about the selector and links to selectors that will fetch all the matching events from the start of the ledger as well as a link to the current events that match the selector, but occurred after this selector was fetched.

Authorizations:
opaque-token
path Parameters
selector-info
required
string

Selector info identifier

Responses

Response samples

Content type
application/x-ndjson
null

notify

Notifications of new events in the ledger that match selectors

Open Channel Action

POST an empty body to this resource to open a new notification channel.

Responses

Response samples

Content type
application/hal+json
{
  • "_links": {
    },
  • "_embedded": {
    }
}

Open Channel Action

Open a new notification channel.

Authorizations:
opaque-token

Responses

A Notification Channel

Get links to events registered to an entity.

Authorizations:
opaque-token
path Parameters
channelId
required
string

The channel identifier.

Responses

Response samples

Content type
application/json+hal
{
  • "_links": {
    },
  • "_embedded": {
    }
}

Notify Subscription Form

Form to subscribe to selector notifications. GET the schema, create a JSON object with it and POST it back this endpoint.

Authorizations:
opaque-token
path Parameters
channelId
required
string

The channel's identifier.

Responses

Response samples

Content type
application/schema+json
true

Subscribe to a Selector's Notifications

Accepts a form object to subscribe to notifications of new events that match the given selector. This action is idempotent, so one can subscribe to the same selector repeatedly without a failure response.

Authorizations:
opaque-token
path Parameters
channelId
required
string

The channel's identifier.

Request Body schema: application/json

This form accepts a selectorId from an existing selector.

selectorId
required
string <= 80 characters ^[0-9A-Za-z_-]+$

Responses

Request samples

Content type
application/json
{
  • "selectorId": "^0$"
}

A Channel's Selector Subscriptions

Get links to a channel's subscriptions.

Authorizations:
opaque-token
path Parameters
channelId
required
string

The channel identifier.

Responses

Response samples

Content type
{
  • "_links": {
    },
  • "_embedded": {
    }
}

A Channel Selector Subscription

Get a channel selector subscription.

Authorizations:
opaque-token
path Parameters
channelId
required
string

The channel identifier.

subscriptionId
required
string

The subscription identifier.

Responses

Response samples

Content type
application/json+hal
{
  • "_links": {
    },
  • "_embedded": {
    }
}

Unsubscribe from a Selector Notification Subscription

Unsubscribes from notifications of new events that match this selector.

Authorizations:
opaque-token
path Parameters
channelId
required
string

The channel identifier.

subscriptionId
required
string

The subscription identifier.

Responses

Notify Channel Server-Sent Events Stream

Listen to selector notification events. Each event is a comma-separated list of matching selectors from the subscription list. See https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events for details on how to consume this event stream.

Authorizations:
opaque-token
path Parameters
channelId
required
string

The channel identifier.

Responses