Skip to content

Watch the model's refs for changes

GET
/models/{modelId}/events
curl --request GET \
--url https://api.modeldesk.io/models/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/events \
--header 'Authorization: Bearer <token>'

Open a server-sent event stream announcing every creation, head move and deletion of the refs of this model that the caller may see: the model’s shared branches, and the caller’s own draft, whose handoff for review is announced as well. Another user’s draft produces no event and appears in no listing, so a caller cannot tell one from the absence of a draft. For a service account the caller is the account itself: it sees the drafts it created and never those of the person who operates it. Authorization runs once, as the stream opens, through the same light read as GET /models/{modelId}/delta, so an unreadable or missing model is answered there exactly as it is answered here.

An event carries ids and nothing else: no content, no names, no commit actions and no user ids. Acting on one means fetching what moved through a route that authorizes the read again.

The response begins with a retry: 2000 field and then sends named events whose data line is one of the schemas below. The first event of every connection is a heads event listing where every visible ref points, and another follows on every heartbeat, every 25 seconds. The heartbeat is kept per model rather than per connection, so the first one a new connection receives can come sooner than that. A heads event is read from the store rather than from what the stream remembers.

Delivery is best effort, and a client owes something in return. Diff every heads event against what you hold and treat a difference as the change you did not receive; that one rule covers the first event, the heartbeat that catches a dropped announcement, and a reconnect. Fetch on resync, which says the server lost its place and cannot say what it missed. Keep a slow poll for the case where the stream itself is gone. No id: field is sent and Last-Event-ID is ignored: closing a gap with one heads event and one fetch is cheaper and more honest than replaying a best-effort source.

The connection ends with the access token that opened it, without warning and without a final event, and in no case later than 15 minutes after it opened. The server may end it sooner, for instance when the client stops reading; a client treats every end the same way and reconnects. Nothing re-validates mid-stream; reconnecting with a fresh token runs the authorization again. A token with five seconds of life left or less buys no stream at all and is answered 401: an event source cannot see a status, so a stream that opened and ended at once would be retried immediately rather than backed off from.

One caller may hold up to 32 streams on one server before further connections are refused with 429, whose body states the ceiling as limit. The ceiling is counted per server instance, so a deployment behind a load balancer tolerates that many per instance. It is counted against the party that authenticated: a person’s streams against that person, and a service account’s against the account.

modelId
required
string format: uuid

An open event stream. Each frame is event: <name> plus a single data line holding the JSON below; the name says which shape it is, and each schema names the event it belongs to in x-sse-event. Two events carry the same body, { refId }: ref-deleted and draft-handoff. The data alone therefore cannot say which event a frame is, so the list is an anyOf and a client selects the schema by the event name, never by the body.

Every event schema is closed (additionalProperties: false), and a heads entry is closed too. An event carries ids and nothing else, so a field the schema does not list is never an extension to tolerate: it is the server announcing something it must not, such as the owner of a draft. A client that validates against these schemas is entitled to treat such a frame as a defect.

Media typetext/event-stream
Any of:
heads

The data of a heads event: where every ref this caller may see points right now. Sent as the first event of every connection and on every heartbeat. A subscriber diffs it against what it holds, which is how an announcement that never arrived heals.

object
heads
required

Every visible ref. Written even when empty, which is a real answer: a model whose refs are being rewritten has a moment with none at all.

Array<object>
object
refId
required
string format: uuid
kind
required
string
Allowed values: BRANCH DRAFT
headCommitId
required
string format: uuid
resets
required

How often this ref’s head was moved somewhere other than forward. A count that differs from the one you hold means what you hold cannot be walked up to this head and has to be reseeded.

integer
Cache-Control
string

Always no-cache, no-transform.

X-Accel-Buffering
string

Always no. A proxy that buffers this response holds frames back until some byte threshold is reached, which destroys the timeliness the stream exists for.

No access token was sent, or the one sent is unusable: invalid, expired, or unable to bound this stream because it carries no expiry or has five seconds of life left or less. Every unusable token is answered with the same body, so a client cannot tell which of those it was and does not need to. Back off and open the stream again with a fresh token.

Media typeapplication/problem+json

An RFC 9457 problem document, always sent as application/problem+json.

object
type

Present only on a typed refusal, whose own schema requires it and fixes its value. An untyped problem omits it, which RFC 9457 defines as about:blank: the status and title are all there is to branch on.

string format: uri
title
required
string
status
required
integer
detail
required
string
instance

The path of the request that was refused. Absent when the request was refused before it reached the application’s handlers: a 401 for a missing or unusable access token, and a 403 for a service account whose scopes do not reach the route.

string
violations

Present on a 400 raised by request-body validation, and on a 422 that refuses named fields (a malformed slug or namespace prefix). Each entry names the rejected property, so a client can attach the message to the field that caused it rather than showing one error for the whole form.

Array<object>
object
property
required
string
message
required
string

Example generated

{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "example",
"violations": [
{
"property": "example",
"message": "example"
}
]
}

The model is a platform model, such as a metamodel, which only a platform administrator may read; or the caller is a service account whose scopes do not reach model:read, which is refused before the model is looked at. The same answer GET /models/{modelId}/delta gives, in the same words. Any other model the caller may not read is answered 404. Or the caller is an agent acting for a person, and the organization that owns the model has not enabled the agent’s AI platform, answered as AgentPlatformNotEnabledProblem.

Media typeapplication/problem+json
Any of:

A Problem answered when an agent acting for a person reached a model whose owning organization has not enabled the AI platform the agent runs on, which its token names. Model content reaches the platform an agent runs on, so the organization decides: until an organization admin turns the platform on in the organization’s AI agent platforms setting, every route on the model refuses the agent, conditional reads and the events stream included, and the model list and every page that names other models leave the organization’s models out. A change of the setting applies to new requests within a minute; an events stream that is already open ends at its token’s expiry, at most ten minutes later.

object
type
required

Present only on a typed refusal, whose own schema requires it and fixes its value. An untyped problem omits it, which RFC 9457 defines as about:blank: the status and title are all there is to branch on.

string format: uri
title
required
string
status
required
integer
detail
required
string
instance

The path of the request that was refused. Absent when the request was refused before it reached the application’s handlers: a 401 for a missing or unusable access token, and a 403 for a service account whose scopes do not reach the route.

string
violations

Present on a 400 raised by request-body validation, and on a 422 that refuses named fields (a malformed slug or namespace prefix). Each entry names the rejected property, so a client can attach the message to the field that caused it rather than showing one error for the whole form.

Array<object>
object
property
required
string
message
required
string
type
required

Stable constant a client branches on, which is what tells this 403 from the plain one the same routes answer for a model the caller may not read.

string format: uri
Allowed values: https://modeldesk.io/problems/agent-platform-not-enabled

Example

{
"type": "https://modeldesk.io/problems/agent-platform-not-enabled"
}

No such model, one that is soft deleted, or one the caller may not read: another organization’s, one whose metamodel they hold no active seat for, or an individual-access model someone else created. The three are answered alike, so the stream cannot be used to learn whether a model exists. The same answer GET /models/{modelId}/delta gives.

Media typeapplication/problem+json

An RFC 9457 problem document, always sent as application/problem+json.

object
type

Present only on a typed refusal, whose own schema requires it and fixes its value. An untyped problem omits it, which RFC 9457 defines as about:blank: the status and title are all there is to branch on.

string format: uri
title
required
string
status
required
integer
detail
required
string
instance

The path of the request that was refused. Absent when the request was refused before it reached the application’s handlers: a 401 for a missing or unusable access token, and a 403 for a service account whose scopes do not reach the route.

string
violations

Present on a 400 raised by request-body validation, and on a 422 that refuses named fields (a malformed slug or namespace prefix). Each entry names the rejected property, so a client can attach the message to the field that caused it rather than showing one error for the whole form.

Array<object>
object
property
required
string
message
required
string

Example generated

{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "example",
"violations": [
{
"property": "example",
"message": "example"
}
]
}

This caller already holds as many streams on this server as it may.

Media typeapplication/problem+json

A Problem answered when a caller opens more event streams on one server than it may. The request is not wrong and the caller may read the model it asked for; what refuses it is how many streams it already holds, so waiting for one of its own to end is all it takes.

object
type
required

Present only on a typed refusal, whose own schema requires it and fixes its value. An untyped problem omits it, which RFC 9457 defines as about:blank: the status and title are all there is to branch on.

string format: uri
title
required
string
status
required
integer
detail
required
string
instance

The path of the request that was refused. Absent when the request was refused before it reached the application’s handlers: a 401 for a missing or unusable access token, and a 403 for a service account whose scopes do not reach the route.

string
violations

Present on a 400 raised by request-body validation, and on a 422 that refuses named fields (a malformed slug or namespace prefix). Each entry names the rejected property, so a client can attach the message to the field that caused it rather than showing one error for the whole form.

Array<object>
object
property
required
string
message
required
string
type
required

Stable constant a client branches on, which is what tells this 429 from a rate limit imposed in front of the application.

string format: uri
Allowed values: https://modeldesk.io/problems/event-connection-limit
limit
required

How many streams one caller may hold on one server, so a client that opens streams programmatically can size its pool rather than discover the number by being refused.

integer

Example

{
"type": "https://modeldesk.io/problems/event-connection-limit"
}
Retry-After
integer

Seconds to wait before opening another stream. Always 30.

Error

Media typeapplication/problem+json

An RFC 9457 problem document, always sent as application/problem+json.

object
type

Present only on a typed refusal, whose own schema requires it and fixes its value. An untyped problem omits it, which RFC 9457 defines as about:blank: the status and title are all there is to branch on.

string format: uri
title
required
string
status
required
integer
detail
required
string
instance

The path of the request that was refused. Absent when the request was refused before it reached the application’s handlers: a 401 for a missing or unusable access token, and a 403 for a service account whose scopes do not reach the route.

string
violations

Present on a 400 raised by request-body validation, and on a 422 that refuses named fields (a malformed slug or namespace prefix). Each entry names the rejected property, so a client can attach the message to the field that caused it rather than showing one error for the whole form.

Array<object>
object
property
required
string
message
required
string

Example generated

{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "example",
"violations": [
{
"property": "example",
"message": "example"
}
]
}