K8 HQ

Events — K8 HQ Content API

Events operations for K8 HQ Content API. Requests, permissions and responses.

Version 1OpenAPI description (JSON)

Browse operation groups

Before making requests, read the authentication and request requirements.

Read the organization's events, and register and publish your own event types.

Base URL

Base URLFor
https://api.k8hq.com/v1API tokens and the K8 HQ web app

Endpoints

Events

List event types

GET/event-types

The event catalog: every event type K8 HQ records, with its JSON Schema. Audit-only types are listed with their visibility; they can't trigger rules. API tokens also get their organization's own types (ext.*).

For API tokens and the web app.

Response body (JSON)

FieldTypeDescription
eventTypes requiredEventType[]

Responses

StatusBodyMeaning
200JSONThe catalog.
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response.

Register an event type

POST/event-types

Registers one of the organization's own event types, ext.<thing>.<past-tense verb>, or updates it compatibly: within a version, data fields may only be added, and only as optional. Anything else needs a new version.

For API tokens with events:write.

Request body (JSON)

FieldTypeDescription
description requiredstring
name requiredstringPattern: ^ext\.[a-z][a-z0-9_]*\.[a-z][a-z0-9_]*$.
dataobject[]
versioninteger
{"data":[{"description":"The shop's order ID.","name":"orderId","required":true,"type":"string"}],"description":"An order left the warehouse.","name":"ext.order.shipped"}

Response body (JSON)

FieldTypeDescription
class requiredstring
data requiredobject[]The data fields.
dataSchema requiredobjectJSON Schema for the event's data.
description requiredstring
name requiredstring
source requiredstring
status requiredexperimental | stable | deprecated
version requiredinteger
visibility requiredstring
subjectstringWhat the event's subject holds.

Responses

StatusBodyMeaning
201EventTypeThe registered type.
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
402application/problem+jsonThe organization is read-only (read_only, design note 0024): it has been out of credit for 60 days, so nothing can be changed until an owner adds credit.
403application/problem+jsonThe token lacks events:write.
422application/problem+jsonInvalid, or an incompatible change within a version.
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response.
503application/problem+jsonTemporary failure; try again (unavailable).

Read the organization's events

GET/events

Every event of the organization, oldest first, across its inboxes and the organization itself: a page after a cursor (nextCursor continues it; wait makes an empty page wait for the next event). A page reads a stretch of the feed at a time, so with types or containers a page can be empty, or hold fewer than limit events, while more lie further on: keep reading from nextCursor; you're at the end when it comes back equal to the cursor you sent. To start from the present instead, open the stream and take the cursor it sends on connecting, or with Accept: text/event-stream a live stream that resumes from Last-Event-ID. Each event's id: line in the stream is its cursor; the stream also sends the cursor (an id: with no data) on connecting and with each keepalive, so a filtered stream that matched nothing can still resume where it was. You see inbox events for inboxes you may use; organization-level events (access, domains, sending) need org:read; audit-only events (who read what) need audit:read and audit=true. Paged reads return events a few seconds old, so none arrive later behind the cursor; live streams send at once and may repeat an event after reconnecting, so dedupe by event id. The web app must name its containers and sees read state without who read it.

For API tokens with events:read and the web app.

Parameters

NameTypeDescription
cursor (query)stringReturn events after it: the nextCursor of the previous page, a published event's cursor, or an event's stream id.
types (query)stringComma-separated types or prefixes ending in .*, e.g. message.*,ext.order.shipped.
containers (query)stringComma-separated container IDs: only their events (and no organization-level ones). A person signed in to K8 HQ may include their own personal notice inbox for their current membership, unless suspended. All named containers must belong to one organization and be readable by the caller; otherwise the whole request returns 404. API tokens and assistants cannot read personal notice inboxes.
audit (query)booleantrue includes audit-only events (needs audit:read).
limit (query)integerPage size, up to 500.
Last-Event-ID (header)stringLive streams: resume after this cursor.
wait (query)integerMilliseconds (up to 20000) an empty page may wait for the next matching event, so you can read your own writes without sleeping. Larger values are clamped to 20000.

Response body (JSON)

FieldTypeDescription
events requiredEvent[]
nextCursor requiredstringContinue from here. The same as the cursor sent at the end of the feed; it can move on past a page with no events.

Responses

StatusBodyMeaning
200JSON, text/event-streamA page, or the live stream.
400application/problem+jsonThe web app must name inboxes.
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
403application/problem+jsonMissing scope (events:read, or audit:read for audit=true).
404application/problem+jsonNot found, or not yours (not_found).
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response.

Publish an event

POST/events

Publishes one event of a type the organization registered. Events are plaintext and kept until the organization is deleted, so keep them thin: IDs and small facts, never message content or secrets (data up to 4 KB). Send Idempotency-Key to make retries safe: the same key from the same token within 24 hours returns the first event.

For API tokens with events:write.

Parameters

NameTypeDescription
Idempotency-Key (header)stringUp to 255 characters; the same key from the same token returns the first event.

Request body (JSON)

FieldTypeDescription
type requiredstringA registered ext.* type.
containerstringA container it concerns (ibx_…), if any.
dataobjectFields as the type defines them; up to 4 KB.
subjectstringWhat the event is about, in your terms (e.g. an order number).
{"data":{"orderId":"1001"},"subject":"order 1001","type":"ext.order.shipped"}

Response body (JSON)

FieldTypeDescription
duplicatetrue
idstring

Responses

StatusBodyMeaning
200JSONA retry with the same Idempotency-Key: the first event.
201JSONPublished.
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
402application/problem+jsonThe organization is read-only (read_only, design note 0024): it has been out of credit for 60 days, so nothing can be changed until an owner adds credit.
403application/problem+jsonThe token lacks events:write.
404application/problem+jsonNot found, or not yours (not_found).
413application/problem+jsondata is over 4 KB.
422application/problem+jsonUnregistered type, or data that doesn't match it.
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response.
503application/problem+jsonTemporary failure; try again (unavailable).