Events — K8 HQ Content API
Events operations for K8 HQ Content API. Requests, permissions and responses.
Version 1OpenAPI description (JSON)
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 URL | For |
https://api.k8hq.com/v1 | API 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)
| Field | Type | Description |
eventTypes required | EventType[] | |
Responses
| Status | Body | Meaning |
| 200 | JSON | The catalog. |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too 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)
| Field | Type | Description |
description required | string | |
name required | string | Pattern: ^ext\.[a-z][a-z0-9_]*\.[a-z][a-z0-9_]*$. |
data | object[] | |
version | integer | |
{"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)
| Field | Type | Description |
class required | string | |
data required | object[] | The data fields. |
dataSchema required | object | JSON Schema for the event's data. |
description required | string | |
name required | string | |
source required | string | |
status required | experimental | stable | deprecated | |
version required | integer | |
visibility required | string | |
subject | string | What the event's subject holds. |
Responses
| Status | Body | Meaning |
| 201 | EventType | The registered type. |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 402 | application/problem+json | The 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. |
| 403 | application/problem+json | The token lacks events:write. |
| 422 | application/problem+json | Invalid, or an incompatible change within a version. |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too 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. |
| 503 | application/problem+json | Temporary 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
| Name | Type | Description |
cursor (query) | string | Return events after it: the nextCursor of the previous page, a published event's cursor, or an event's stream id. |
types (query) | string | Comma-separated types or prefixes ending in .*, e.g. message.*,ext.order.shipped. |
containers (query) | string | Comma-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) | boolean | true includes audit-only events (needs audit:read). |
limit (query) | integer | Page size, up to 500. |
Last-Event-ID (header) | string | Live streams: resume after this cursor. |
wait (query) | integer | Milliseconds (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)
| Field | Type | Description |
events required | Event[] | |
nextCursor required | string | Continue 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
| Status | Body | Meaning |
| 200 | JSON, text/event-stream | A page, or the live stream. |
| 400 | application/problem+json | The web app must name inboxes. |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 403 | application/problem+json | Missing scope (events:read, or audit:read for audit=true). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too 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
| Name | Type | Description |
Idempotency-Key (header) | string | Up to 255 characters; the same key from the same token returns the first event. |
Request body (JSON)
| Field | Type | Description |
type required | string | A registered ext.* type. |
container | string | A container it concerns (ibx_…), if any. |
data | object | Fields as the type defines them; up to 4 KB. |
subject | string | What 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)
| Field | Type | Description |
duplicate | true | |
id | string | |
Responses
| Status | Body | Meaning |
| 200 | JSON | A retry with the same Idempotency-Key: the first event. |
| 201 | JSON | Published. |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 402 | application/problem+json | The 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. |
| 403 | application/problem+json | The token lacks events:write. |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 413 | application/problem+json | data is over 4 KB. |
| 422 | application/problem+json | Unregistered type, or data that doesn't match it. |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too 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. |
| 503 | application/problem+json | Temporary failure; try again (unavailable). |