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.
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:
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
- Payload
{- "entity": "account",
- "event": "account-created"
}
Response samples
- 200
{- "_links": {
- "curies": {
- "href": "string",
- "templated": true,
- "type": "string",
- "deprecation": "string",
- "name": "string",
- "profile": "string",
- "title": "string",
- "hreflang": "string"
}, - "property1": {
- "href": "string",
- "templated": true,
- "type": "string",
- "deprecation": "string",
- "name": "string",
- "profile": "string",
- "title": "string",
- "hreflang": "string"
}, - "property2": {
- "href": "string",
- "templated": true,
- "type": "string",
- "deprecation": "string",
- "name": "string",
- "profile": "string",
- "title": "string",
- "hreflang": "string"
}
}, - "_embedded": {
- "property1": { },
- "property2": { }
}
}
Submit Download Ledger Form
Submit form to download a ledger either entirely or after a ledger mark / event ID.
Authorizations:
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
- Payload
{ }
Response samples
- 200
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:
path Parameters
download-info required | string Download info identifier |
Responses
Response samples
- 200
null
Reset Ledger
Reset the ledger to remove events, either completely or after a specific point.
Authorizations:
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
- Payload
{ }
Entities with Registered Events
Get links to entities that have registered events.
Authorizations:
Responses
Response samples
- 200
{- "_links": {
- "curies": {
- "href": "string",
- "templated": true,
- "type": "string",
- "deprecation": "string",
- "name": "string",
- "profile": "string",
- "title": "string",
- "hreflang": "string"
}, - "property1": {
- "href": "string",
- "templated": true,
- "type": "string",
- "deprecation": "string",
- "name": "string",
- "profile": "string",
- "title": "string",
- "hreflang": "string"
}, - "property2": {
- "href": "string",
- "templated": true,
- "type": "string",
- "deprecation": "string",
- "name": "string",
- "profile": "string",
- "title": "string",
- "hreflang": "string"
}
}, - "_embedded": {
- "property1": { },
- "property2": { }
}
}
An Entity's Events
Get links to events registered to an entity.
Authorizations:
path Parameters
entity required | string entity name |
Responses
Response samples
- 200
{- "_links": {
- "curies": {
- "href": "string",
- "templated": true,
- "type": "string",
- "deprecation": "string",
- "name": "string",
- "profile": "string",
- "title": "string",
- "hreflang": "string"
}, - "property1": {
- "href": "string",
- "templated": true,
- "type": "string",
- "deprecation": "string",
- "name": "string",
- "profile": "string",
- "title": "string",
- "hreflang": "string"
}, - "property2": {
- "href": "string",
- "templated": true,
- "type": "string",
- "deprecation": "string",
- "name": "string",
- "profile": "string",
- "title": "string",
- "hreflang": "string"
}
}, - "_embedded": {
- "property1": { },
- "property2": { }
}
}
An Entity Event
Get a registered entity event.
Authorizations:
path Parameters
entity required | string entity name |
event required | string event name |
Responses
Response samples
- 200
{- "_links": {
- "curies": {
- "href": "string",
- "templated": true,
- "type": "string",
- "deprecation": "string",
- "name": "string",
- "profile": "string",
- "title": "string",
- "hreflang": "string"
}, - "property1": {
- "href": "string",
- "templated": true,
- "type": "string",
- "deprecation": "string",
- "name": "string",
- "profile": "string",
- "title": "string",
- "hreflang": "string"
}, - "property2": {
- "href": "string",
- "templated": true,
- "type": "string",
- "deprecation": "string",
- "name": "string",
- "profile": "string",
- "title": "string",
- "hreflang": "string"
}
}, - "_embedded": {
- "property1": { },
- "property2": { }
}
}
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:
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 |
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
- Payload
{- "entity": "string",
- "key": "string",
- "event": "string",
- "meta": { },
- "data": "string",
- "idempotencyKey": "string"
}
Response samples
- 201
{- "eventId": "string",
- "idempotencyKey": "string"
}
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:
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 |
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
- Payload
{- "entity": "string",
- "key": "string",
- "event": "string",
- "meta": { },
- "data": "string",
- "previousEventId": "string",
- "idempotencyKey": "string"
}
Response samples
- 201
- 409
{- "eventId": "string",
- "idempotencyKey": "string"
}
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:
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 |
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
- Payload
{- "entity": "string",
- "key": "string",
- "event": "string",
- "meta": { },
- "data": "string",
- "selector": {
- "selectorId": "string",
- "mark": "string"
}, - "idempotencyKey": "string"
}
Response samples
- 201
- 409
{- "eventId": "string",
- "idempotencyKey": "string"
}
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:
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
- Payload
Response samples
- 200
null
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:
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
- Payload
{- "data": {
- "thermostat": {
- "temperature-recorded": {
- "query": "$.celsius ? (@ < 10.0)"
}
}
}, - "meta": {
- "query": "$.correlationId (@==$cId)",
- "vars": {
- "cId": "44rugtj5nfgn445"
}
}, - "after": "0005d2bfb29a03795f574859cb0687dc",
- "limit": 1
}
Response samples
- 200
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:
path Parameters
selector-info required | string Selector info identifier |
Responses
Response samples
- 200
null
Open Channel Action
POST an empty body to this resource to open a new notification channel.
Responses
Response samples
- 200
{- "_links": {
- "curies": {
- "href": "string",
- "templated": true,
- "type": "string",
- "deprecation": "string",
- "name": "string",
- "profile": "string",
- "title": "string",
- "hreflang": "string"
}, - "property1": {
- "href": "string",
- "templated": true,
- "type": "string",
- "deprecation": "string",
- "name": "string",
- "profile": "string",
- "title": "string",
- "hreflang": "string"
}, - "property2": {
- "href": "string",
- "templated": true,
- "type": "string",
- "deprecation": "string",
- "name": "string",
- "profile": "string",
- "title": "string",
- "hreflang": "string"
}
}, - "_embedded": {
- "property1": { },
- "property2": { }
}
}
A Notification Channel
Get links to events registered to an entity.
Authorizations:
path Parameters
channelId required | string The channel identifier. |
Responses
Response samples
- 200
{- "_links": {
- "curies": {
- "href": "string",
- "templated": true,
- "type": "string",
- "deprecation": "string",
- "name": "string",
- "profile": "string",
- "title": "string",
- "hreflang": "string"
}, - "property1": {
- "href": "string",
- "templated": true,
- "type": "string",
- "deprecation": "string",
- "name": "string",
- "profile": "string",
- "title": "string",
- "hreflang": "string"
}, - "property2": {
- "href": "string",
- "templated": true,
- "type": "string",
- "deprecation": "string",
- "name": "string",
- "profile": "string",
- "title": "string",
- "hreflang": "string"
}
}, - "_embedded": {
- "property1": { },
- "property2": { }
}
}
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:
path Parameters
channelId required | string The channel's identifier. |
Responses
Response samples
- 200
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:
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
- Payload
{- "selectorId": "^0$"
}
A Channel's Selector Subscriptions
Get links to a channel's subscriptions.
Authorizations:
path Parameters
channelId required | string The channel identifier. |
Responses
Response samples
- 200
{- "_links": {
- "curies": {
- "href": "string",
- "templated": true,
- "type": "string",
- "deprecation": "string",
- "name": "string",
- "profile": "string",
- "title": "string",
- "hreflang": "string"
}, - "property1": {
- "href": "string",
- "templated": true,
- "type": "string",
- "deprecation": "string",
- "name": "string",
- "profile": "string",
- "title": "string",
- "hreflang": "string"
}, - "property2": {
- "href": "string",
- "templated": true,
- "type": "string",
- "deprecation": "string",
- "name": "string",
- "profile": "string",
- "title": "string",
- "hreflang": "string"
}
}, - "_embedded": {
- "property1": { },
- "property2": { }
}
}
A Channel Selector Subscription
Get a channel selector subscription.
Authorizations:
path Parameters
channelId required | string The channel identifier. |
subscriptionId required | string The subscription identifier. |
Responses
Response samples
- 200
{- "_links": {
- "curies": {
- "href": "string",
- "templated": true,
- "type": "string",
- "deprecation": "string",
- "name": "string",
- "profile": "string",
- "title": "string",
- "hreflang": "string"
}, - "property1": {
- "href": "string",
- "templated": true,
- "type": "string",
- "deprecation": "string",
- "name": "string",
- "profile": "string",
- "title": "string",
- "hreflang": "string"
}, - "property2": {
- "href": "string",
- "templated": true,
- "type": "string",
- "deprecation": "string",
- "name": "string",
- "profile": "string",
- "title": "string",
- "hreflang": "string"
}
}, - "_embedded": {
- "property1": { },
- "property2": { }
}
}
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:
path Parameters
channelId required | string The channel identifier. |