Quick Start
GET /v1/events
One WebSocket carries every checklist event for your tenant as it is stored. You open the
socket with an AppStore bearer token, send a single subscribe
frame, and then receive event frames until the socket closes.
Every frame in both directions is one JSON object of UTF-8 text — no binary, no
compression, no subprotocol. The path is configurable per environment; the default is
/v1/events, over wss://.
Connect, subscribe, receive
The smallest client that works. Copy it, set a token, run it.
# pip install "websockets>=14"
import asyncio, json, os, websockets
URL = "wss://<host>/v1/events"
async def main():
headers = {"Authorization": "Bearer " + os.environ["MARANICS_FEED_TOKEN"]}
# max_size matters: server frames go up to 4 MiB, the library default is 1 MiB.
# additional_headers needs websockets 14+; on 12/13 the same argument is called extra_headers.
async with websockets.connect(URL, additional_headers=headers, max_size=8 * 1024 * 1024) as ws:
await ws.send(json.dumps({"type": "subscribe"})) # no "from" = live only, no history
async for raw in ws:
msg = json.loads(raw)
if msg["type"] == "event":
e = msg["data"]
print(e["sequence"], e["eventType"], e["eventId"])
elif msg["type"] == "heartbeat":
await ws.send(json.dumps({"type": "pong"}))
asyncio.run(main())
Not a WebSocket request? A plain GET on the
feed path without an upgrade header returns 426 Upgrade Required
with the body "The event feed is a WebSocket endpoint; upgrade the connection."
Authentication happens before the upgrade, so every refusal is an ordinary HTTP
status with a readable body — not a close frame.
Three Things to Get Right
1. sequence is ingest order,
occurredAt is business time — they are not correlated.
sequence is allocated per tenant when the event is stored and is
the only ordering you may rely on. occurredAt is when the thing
happened on the vessel or device; a vessel that was offline for days sends its backlog when the
link returns, so days-old occurredAt values arriving at the live
tail are normal and not a fault. Sort, resume and deduplicate on
sequence; use occurredAt only as
data.
2. Resume means persisting the last sequence to disk and sending it back as
from. Write the cursor somewhere durable after you have
processed the event, and send {"type":"subscribe","from":<cursor>}
on every reconnect — you then receive everything with
sequence > from. A cursor held only in memory silently loses
every event between your last checkpoint and the restart, with nothing in either log to show for
it. The ack frame does not do this for you: the
server parses and logs it, and it drives nothing. Your own persisted cursor is the only source of
truth.
3. Reconnect-and-resume is routine, not exceptional. Every deployment restarts
the process and closes every open socket with 1001. A correct
client reconnects immediately (with jitter), resumes from its cursor, and logs nothing alarming.
Build the reconnect loop first, not last — a client that treats a close as an error will
page someone every release.
Getting Credentials
In UserManagement → Application Catalogue → Installed apps, choose
Add new. Give the application a name and grant it at least one scope —
Use Insight Center API is the one this feed needs. At least one
scope is mandatory; without it the token is rejected.
You are then shown three things, once: a client id, a
client secret, and a ready-made access token. The token works
immediately, so you can connect and test without minting anything. The secret is never displayed
again — it can only be regenerated.
Tenant scope: the application belongs to the tenant you were logged into when you
created it, and that cannot be changed or widened afterwards. This is what limits which events the
feed will ever hand you.
Minting a new token
Tokens last 365 days. When you need another, request one with your client id and secret. The
/internal suffix matters — the plain
/connect/token endpoint rejects an application created this way.
POST https://<appstore-host>/connect/token/internal
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials&scope=openid&client_id=<client id>&client_secret=<secret>
Which host? You do not need to ask. Decode the token you were given and read its
iss claim — that is the AppStore host to call, already
correct for your environment.
The response is JSON; the value you want is access_token. To revoke
access, disable the application in the Application Catalogue — tokens are not individually
revocable before they expire.
Authentication
Send an AppStore bearer token in the Authorization header on the
handshake request: Authorization: Bearer <token>. This is the
only accepted form — there is no query-string token and no in-band re-authentication once the
socket is open. The token's tenant grants are resolved live from the AppStore on every handshake,
so a revoked grant stops the next connection rather than an already-open one.
| Status | Meaning | What to do |
| 401 | No token, unreadable token, expired token, or no client id in it | Refresh the token and retry |
| 403 | Authenticated but not entitled — client id not allowed, no granted tenant, or ?tenant= naming a tenant you do not hold | Do not retry; contact us |
| 503 | The permissions lookup failed — a dependency outage on our side, not a decision about you | Retry after the Retry-After header (30s) |
Choosing a tenant
If your token grants exactly one tenant, it is used automatically and you need to do nothing. If it
grants several, add ?tenant=<name> to the socket URL naming one
you already hold — connecting without it is a 403, and so is
naming a tenant you do not hold. The parameter can only select among your grants; it can never widen
them. Tenant headers, cookies and claims are deliberately ignored.
The Subscribe Frame
The server sends nothing until it receives this frame, and you have 10 seconds from the socket
opening to send it. Exactly one per connection.
Resume from a cursor, filtered to task events at one location
{
"type": "subscribe",
"from": 104200,
"eventTypes": ["flow.task.*"],
"locationIds": ["e7c3a1b2-4f5d-4e6a-8b9c-1d2e3f4a5b6c"]
}
| Field | Type | Meaning |
| type | string | Required. Must be exactly subscribe on the first frame. |
| from | int64? | Optional resume cursor — you receive sequence > from. Omit it for live-only with no history. Negative, or higher than the tenant's latest sequence, closes the socket with 4400; equal to the latest is valid and simply waits. |
| eventTypes | string[]? | Optional. Shell-style globs over the dotted eventType, matched case-insensitively, where * matches any run of characters including dots and ? matches exactly one. |
| locationIds | string[]? | Optional. Exact, case-sensitive match against subject.locationId. An event whose locationId is null never matches this filter. |
Filters only ever narrow. The two are combined with AND, and neither can widen the
stream past what your token grants. An empty or all-blank array is treated exactly like an absent
field — it narrows nothing. Any JSON property the server does not recognise is ignored
silently, with one exception below.
There is no imo filter. Our events carry no IMO
number, so filtering by one is impossible and is rejected loudly rather than ignored: the mere
presence of an imo key — even
"imo": [] — closes the socket with
4400 and the reason
UNSUPPORTED_FILTER:imo; use locationIds. Identify vessels by
subject.locationId.
Other Frames You Can Send
| Frame | Meaning |
| {"type":"pong"} | The answer to a heartbeat. Any inbound frame proves liveness, but this is the one the server asks for. |
| {"type":"ack","sequence":104233} | Optional progress report. It is parsed and logged and drives nothing — your own persisted cursor is what resumes the stream. |
Anything else closes the socket with 4400. A first frame that is not
subscribe, a second subscribe, an
unrecognised type, a frame that is not valid JSON or not a JSON
object, or a frame over 64 KiB. These are client bugs, so do not retry on
4400 — fix the frame.
Server Messages
Four message types, distinguished by type. All JSON is camelCase,
and null fields are omitted entirely rather than sent as null.
Timestamps are RFC 3339 with an explicit +00:00 offset.
subscribed
Sent exactly once, before anything else, as soon as the subscription is accepted
{
"type": "subscribed",
"from": 104200,
"replaying": true,
"filtered": false,
"oldestAvailable": 98311,
"latest": 104987,
"serverTime": "2026-09-21T08:14:02.118+00:00"
}
| Field | Meaning |
| from | The cursor actually adopted, which can be higher than the one you asked for when your cursor had fallen outside the replay window. Trust this one, not yours. |
| replaying | True when the connection starts behind the live tail, i.e. history is coming first. |
| filtered | True when any filter is in force — and therefore when sequence numbers are legitimately sparse. |
| oldestAvailable | Lowest sequence still inside the replay window at subscribe time. |
| latest | The tenant's highest sequence at subscribe time, so you can measure your own lag. |
| serverTime | The server clock, to measure skew against. |
event
One envelope. The envelope is described in full below.
{
"type": "event",
"data": {
"eventId": "9f1c2f0e-6b2a-4a1f-9d8e-3c5b7a1e4d20",
"sequence": 104233,
"eventType": "flow.task.completed",
"schemaVersion": "1.0",
"occurredAt": "2026-09-21T08:14:02.118+00:00",
"source": "maranics.flowapp",
"subject": {
"locationId": "e7c3a1b2-4f5d-4e6a-8b9c-1d2e3f4a5b6c",
"locationGlobalId": "3a9f61c4-0f2b-4c7d-9a3e-5b8c2d1f6e40",
"locationName": "MV Example",
"flowId": "8b1d47e0-3c92-4f18-b6a5-77d0c9e2a134"
},
"payload": {
"flowName": "Daily Engine Round",
"sectionName": "Main Engine",
"taskName": "Jacket water temperature",
"value": "82",
"displayValue": "82 °C",
"action": "Task_Complete",
"timestampUtc": "2026-09-21T08:14:02.118+00:00"
}
}
}
heartbeat
Sent after every 30 seconds of outbound silence, only once subscribed — a busy feed may never send one. Answer it with {"type":"pong"}.
{"type": "heartbeat", "ts": "2026-09-21T08:14:32.004+00:00"}
error — GAP
Events this socket will never deliver. The connection stays open and the stream continues from the oldest available sequence.
{
"type": "error",
"code": "GAP",
"message": "Events 98000-98310 are outside the RetentionDays replay window and cannot be delivered; replay resumes at the oldest available sequence.",
"detail": { "skippedFrom": 98000, "skippedTo": 98310, "oldestAvailable": 98311 }
}
error — OVERSIZE_EVENT
One event was too large to put on the wire. The connection stays open, and a flow.meta.oversize placeholder follows at that same sequence.
{
"type": "error",
"code": "OVERSIZE_EVENT",
"message": "Event 9f1c2f0e-6b2a-4a1f-9d8e-3c5b7a1e4d20 at sequence 104233 is larger than the 4194304 byte frame limit; a placeholder was sent at its sequence and the payload can be fetched over OData.",
"detail": { "eventId": "9f1c2f0e-6b2a-4a1f-9d8e-3c5b7a1e4d20", "sequence": 104233, "bytes": 5242880 }
}
Branch on code, never on
message. The message is human text for an operator's log
and its wording varies — a GAP raised at the retention boundary reads differently from one
raised over a sequence genuinely missing from the store, and both carry the same three
detail keys.
Order at subscribe time: subscribed is sent first,
then a GAP error frame if your requested cursor fell outside the
replay window, then the events. Take your expected next sequence from
subscribed.from, which is already clamped.
The Event Envelope
The envelope is transport-independent by design: it is routing identity plus the native event as
payload. payload is exactly the
object the OData API serves — see Event Data Model above for its full field
list and source mappings.
| Field | Type | Meaning |
| eventId | string | UUID string. Your deduplication key — stable across replays and redeliveries. Opaque: it is not sortable and carries no ordering. |
| sequence | int64 | Per-tenant, gap-free, strictly increasing, allocated inside the transaction that stores the event. The only ordering you may rely on, and the resume cursor. |
| eventType | string | The dotted name of the action, from the vocabulary below. A frozen contract: a name may be deprecated alongside a replacement, never renamed. |
| schemaVersion | string | SemVer of the payload schema for that eventType. Every type is 1.0 today and they can diverge independently. |
| occurredAt | string | RFC 3339 business time — when it happened, taken from payload.timestampUtc, falling back to payload.serverTimestamp and, when the event carries neither, to 0001-01-01T00:00:00+00:00. Not ordered with respect to sequence. |
| source | string | Always the constant maranics.flowapp. |
| payload | object? | The flat native event, untranslated — the same shape the OData API serves. Null only on an oversize placeholder. |
| payloadOmitted | bool? | Present and true only on an oversize placeholder. Absent — not false — on every normal event. |
| subject.locationId | string? | The tenant-local location (vessel, site) id. The only field locationIds filters on. |
| subject.locationGlobalId | string? | Cross-tenant stable id for the same location. |
| subject.locationName | string? | Display name. Do not key on it. |
| subject.flowId | string? | The checklist instance the event belongs to. |
Careful: payload.eventType is the control
type (Text, Number, Form, List) — not the envelope's
eventType, which is the action. They are different fields with the
same name at different levels.
Treat unknown fields as ignorable. A replay re-projects the stored event through
today's mapping, so a field added after an event was stored appears on that event when it is
replayed. Sensitive tasks are delivered
in full —
payload.sensitiveData is
true and
nothing is redacted, so handle those payloads accordingly. The JSON Schema for the payload is served
at
/schemas/checklist-event/v1.json
(
urn:maranics:insightcenter:checklist-event:v1); the feed's payload
does not carry
$schema inline.
eventType Vocabulary
The complete set. Each maps to one Maranics action from Supported Event Actions
above. Use these names in eventTypes globs.
| eventType | Maranics action |
| flow.flow.created | Flow_Create |
| flow.flow.started | Flow_Start |
| flow.flow.completed | Flow_Complete |
| flow.flow.discarded | Flow_Discard |
| flow.flow.dueTimeMissed | Flow_DueTimeMissed |
| flow.flow.updated | Flow_Update |
| flow.section.started | Section_Start |
| flow.section.commented | Section_Comment |
| flow.section.commentCompleted | Section_CommentComplete |
| flow.section.overridden | Section_Override |
| flow.section.completed | Section_Complete |
| flow.section.cleared | Section_Clear |
| flow.task.updated | Task_Update |
| flow.task.modified | Task_Modify |
| flow.task.cleared | Task_Clear |
| flow.task.commented | Task_Comment |
| flow.task.commentCompleted | Task_CommentComplete |
| flow.task.overridden | Task_Override |
| flow.task.reminded | Task_Reminder |
| flow.task.listUpdated | Task_ListUpdate |
| flow.task.confirmed | Task_Confirm |
| flow.task.completed | Task_Complete — synthesized by InsightCenter |
| flow.task.listRowUpdated | Task_ListRowUpdated — synthesized by InsightCenter |
| flow.meta.unmapped | An action the vocabulary has no name for. Emitted anyway, payload intact, so the sequence stays contiguous. A boot-time completeness check makes this close to impossible. |
| flow.meta.oversize | Placeholder for an event too large to send. Carries the real eventId, sequence and subject, no payload, and payloadOmitted: true. |
Not carried in v1: flow deletions and restores. There is no
flow.flow.deleted or
flow.flow.restored — those actions are not stored as events and
so cannot be delivered. Anything outside the actions listed above is discarded before it becomes an
event; it does not even arrive as flow.meta.unmapped.
flow.task.listRowUpdated fires on edits too. The source app sends the same
Task_ListUpdate whether a row is new or an existing row was changed,
and the message carries no created-versus-modified marker. A consumer that wants only genuinely new
rows must remember the row ids it has already seen.
Close Codes
Every close carries a reason string of the form TOKEN:human text,
truncated at 123 bytes. Branch on the code, not the text.
| Code | Meaning | What to do |
| 1000 | Normal — the connection ended | Reconnect and resume |
| 1001 | Going away — the server is shutting down. Every deploy does this. | Reconnect immediately with jitter, and resume |
| 1011 | Internal error — an integrity fault on our side | Reconnect with backoff, and resume |
| 1013 | Try again later — your outbound buffer stayed full for 30s and you were evicted. Nothing is lost. | Reconnect with backoff and read faster |
| 4400 | Protocol error — a malformed, oversized or unsupported frame, including any imo key | Do not retry. Fix the client |
| 4401 | Token expired mid-connection. There is no in-band re-auth. | Reconnect with a fresh token, and resume |
| 4403 | Forbidden — authenticated but not entitled. (At handshake time the same condition is an HTTP 403.) | Do not retry. Contact us |
| 4408 | Timeout — either no subscribe within 10s, or no pong within 60s of a heartbeat | Reconnect, and answer heartbeats |
| 4429 | Rate limited — more than 5 concurrent connections. Arrives as a close after the upgrade, not as an HTTP 429. | Back off, then reconnect with fewer sockets |
Limits
| Limit | Value | Notes |
| Inbound frame size | 64 KiB | Exceeding it closes 4400 |
| Outbound frame size | 4 MiB | Set your library's frame limit above this. Exceeding it does not skip the sequence — an OVERSIZE_EVENT error and a flow.meta.oversize placeholder take its place |
| Concurrent connections | 5 | Per AppStore client id. One socket is the intended shape |
| Subscribe deadline | 10 s | From the socket opening → 4408 |
| Heartbeat | 30 s | After 30s of outbound silence. A busy feed may never send one |
| Pong deadline | 60 s | Measured from when the heartbeat was sent → 4408 |
| Slow-consumer grace | 30 s | 1000 frames are buffered per connection; 30s with a full buffer → 1013 |
| Replay window | 7 days | A read policy — nothing is deleted, and events behind a GAP stay queryable over OData |
| Live latency | up to ~500 ms | The feed polls its own store every 500 ms once it has caught up, so live events arrive within one poll |
Keep-alive: the connection also runs WebSocket ping/pong at the protocol level every
20 seconds. Any proxy between you and us must allow long-lived upgraded connections with an idle
timeout well above 30 seconds.
Delivery and Ordering
Gap-free within the tenant. The sequence number is allocated in the same
transaction that stores the event, so per tenant, sequence order is commit order. On an
unfiltered subscription the numbers you receive are contiguous, with exactly two
announced exceptions: a GAP error frame, which always names the
skipped range, and an oversize placeholder, which occupies its sequence and so is not a hole at all.
A hole with neither is a bug — report it.
At-least-once. Deduplicate on eventId, which is
stable across replays and redeliveries. One duplicate case it will not catch: the vessel-to-cloud
bridge can republish the same business event as a genuinely new message, which becomes a second
stored event with a different eventId and sequence. If that matters
to you, deduplicate additionally on the natural key
payload.flowId + sectionId +
itemId + action +
timestampUtc + value.
Replay and live are the same loop. The server reads a page after your cursor,
delivers it, and waits when the page is empty. There is no phase switch and no window in which an
event can fall between replay and live.
Filtering makes the stream sparse — and ages your cursor. On a filtered
subscription the sequence numbers are legitimately non-contiguous
(subscribed.filtered tells you so), which means contiguity can no
longer be used to detect loss. Worse, your cursor only advances on events actually delivered, so a
narrow filter that matches nothing for a week leaves the cursor outside the 7-day window and produces
a GAP on the next reconnect even though nothing was missed. For v1
we recommend subscribing unfiltered and filtering on your side.
What GAP means. Either your requested from was
older than the replay window, or a sequence went permanently missing from the store. In both cases
the connection stays open and the stream resumes, but those events will never arrive on this socket
— treat a GAP as an incident, not a log line. The events
themselves are not deleted and remain queryable over OData.
What the promise does not cover. Everything that reaches InsightCenter is delivered
in order and gap-free — between the store and the socket there is no sampling, dropping or rate
limiting. That is narrower than "everything that happens on a vessel": a vessel's events reach the
cloud only when it has connectivity, and the feed cannot tell a quiet vessel from a dead link. The
feed's history also begins at its deployment; events stored before that have no sequence and are
available only over OData.
Health and Status
Two plain HTTP endpoints sit beside the socket, on the same path.
GET /v1/events/health
Anonymous liveness probe. 200 while the process is serving,
503 once it has begun shutting down. No body, ever — it needs
to be reachable without a token.
GET /v1/events/status
Behind the same token as the socket, and scoped to your tenant only. Useful for checking your lag
without opening a connection.
{
"tenant": "example-tenant",
"latest": 104987,
"oldestAvailable": 98311,
"activeConnections": 1,
"secondsSinceLastIngest": 42.7,
"serverTime": "2026-09-21T08:14:02.118+00:00"
}
| Field | Meaning |
| tenant | The tenant this document describes — your own, resolved from the token exactly as the socket resolves it |
| latest | Your tenant's highest sequence; 0 when nothing has been produced yet |
| oldestAvailable | Lowest sequence still inside the replay window |
| activeConnections | Open feed sockets for your tenant on that server process |
| secondsSinceLastIngest | Age of the newest stored event; null when the tenant has no sequenced events at all |
| serverTime | The server clock |
Reference Client
A complete consumer: durable cursor, reconnect with backoff and jitter, heartbeat answers, and the
two close codes that must never be retried. Everything in it is load-bearing.
# pip install "websockets>=14" # 14+ for additional_headers; on 12/13 it is extra_headers
import asyncio, json, os, random, tempfile
import websockets
URL = "wss://<host>/v1/events"
CURSOR = "feed-cursor.json" # MUST be on disk: an in-memory cursor loses events across a restart
MAX_SIZE = 8 * 1024 * 1024 # server frames reach 4 MiB; the library default of 1 MiB is too small
FATAL = (4400, 4403) # client bug / not entitled - retrying cannot help
def read_cursor():
try:
return json.load(open(CURSOR))["lastSequence"]
except FileNotFoundError:
return None
def commit_cursor(sequence):
fd, tmp = tempfile.mkstemp(dir=".")
with os.fdopen(fd, "w") as f:
json.dump({"lastSequence": sequence}, f)
os.replace(tmp, CURSOR) # atomic: a crash mid-write cannot truncate the cursor
def handle(envelope):
# Idempotent on envelope["eventId"] - delivery is at-least-once.
if envelope.get("payloadOmitted"): # flow.meta.oversize: fetch the body over OData if you need it
print("oversize", envelope["sequence"], envelope["eventId"])
return
payload = envelope.get("payload", {})
print(envelope["sequence"], envelope["eventType"], payload.get("flowName"), payload.get("value"))
async def consume(get_token):
backoff = 1.0
while True:
try:
headers = {"Authorization": "Bearer " + get_token()}
async with websockets.connect(URL, additional_headers=headers, max_size=MAX_SIZE) as ws:
frame = {"type": "subscribe"}
cursor = read_cursor()
if cursor is not None:
frame["from"] = cursor # omit for live-only. Never send an "imo" key: it closes 4400
await ws.send(json.dumps(frame))
backoff = 1.0
async for raw in ws:
msg = json.loads(raw)
kind = msg["type"]
if kind == "event":
handle(msg["data"])
commit_cursor(msg["data"]["sequence"]) # persist AFTER processing
elif kind == "heartbeat":
await ws.send(json.dumps({"type": "pong"}))
elif kind == "subscribed":
# "from" may be higher than we asked for; a GAP frame follows when it is.
print("subscribed from", msg["from"], "latest", msg["latest"], "filtered", msg["filtered"])
elif kind == "error":
# GAP means events this socket will never deliver. Alert on it.
print("ERROR", msg["code"], msg["message"], msg.get("detail"))
except websockets.ConnectionClosed as exc:
if exc.code in FATAL:
print("fatal close", exc.code, exc.reason)
raise
if exc.code in (1001, 4401): # deploy, or expired token - get_token() returns a fresh one
backoff = 1.0
except OSError as exc:
print("transport error", exc)
await asyncio.sleep(min(backoff, 60) * (0.5 + random.random()))
backoff *= 2
asyncio.run(consume(lambda: os.environ["MARANICS_FEED_TOKEN"]))