Skip to content

The ruleset stream

GET
/stream
curl --request GET \
--url https://example.com/sdk/v1/stream \
--header 'Authorization: Bearer <token>'

A server-sent event stream telling the SDK each new ruleset version of its environment, as soon as this replica has loaded it. It carries versions only, never a document: the SDK fetches the ruleset (server key) or evaluates again (client key) when it hears one.

The first frame is retry: 3000. Each version is a frame event: ruleset, id: <version>, data: {"version":<version>}. The current version is sent at once when it is above Last-Event-ID (an unreadable one counts as none), and the versions sent only increase. A comment : hb every 15 seconds tells a quiet stream from a dead one; on each the key is checked again, and a refused key ends the stream. The server closes a stream after about an hour (60 minutes plus up to 5 of jitter) and when it shuts down; the SDK reconnects with Last-Event-ID. A replica that is already shutting down answers a new stream 503 unavailable with Retry-After rather than open it and close it at once.

Last-Event-ID
string

The last version the SDK heard.

sdk_key
string

A client key, for a browser EventSource, which cannot set Authorization.

The stream, held open.

Media typetext/event-stream
string
Cache-Control
string

no-cache.

X-Accel-Buffering
string

no, so a proxy passes each frame on at once.

RateLimit-Limit
integer

The requests the window allows.

RateLimit-Remaining
integer

The requests left in the window.

sdk_key_missing without a key, with WWW-Authenticate: Bearer; sdk_key_invalid, sdk_key_revoked or sdk_key_expired, with WWW-Authenticate: Bearer error="invalid_token".

Media typeapplication/problem+json

A problem document (RFC 9457). Code-specific values are further members.

object
type
required
string
title
required
string
status
required
integer
code
required

Stable snake_case name of the problem, which an SDK branches on.

string
detail

An English explanation for humans; never what an SDK branches on.

string
request_id
required
string
retry_after

Seconds to wait before retrying, for rate_limited, ruleset_unavailable and unavailable.

integer
errors
Array<object>
object
pointer
required

JSON Pointer into the request body.

string
code
required

The rule broken, such as too_long, too_many or duplicate.

string
detail
required
string
params

The values of the rule broken, such as max, for a client to explain the violation in its own language.

object
key
additional properties
any

Example generated

{
"type": "example",
"title": "example",
"status": 1,
"code": "example",
"detail": "example",
"request_id": "example",
"retry_after": 1,
"errors": [
{
"pointer": "example",
"code": "example",
"detail": "example",
"params": {}
}
]
}
WWW-Authenticate
string

key_kind_not_allowed (a client key at the ruleset), server_key_in_query, server_key_from_browser or origin_not_allowed.

Media typeapplication/problem+json

A problem document (RFC 9457). Code-specific values are further members.

object
type
required
string
title
required
string
status
required
integer
code
required

Stable snake_case name of the problem, which an SDK branches on.

string
detail

An English explanation for humans; never what an SDK branches on.

string
request_id
required
string
retry_after

Seconds to wait before retrying, for rate_limited, ruleset_unavailable and unavailable.

integer
errors
Array<object>
object
pointer
required

JSON Pointer into the request body.

string
code
required

The rule broken, such as too_long, too_many or duplicate.

string
detail
required
string
params

The values of the rule broken, such as max, for a client to explain the violation in its own language.

object
key
additional properties
any

Example generated

{
"type": "example",
"title": "example",
"status": 1,
"code": "example",
"detail": "example",
"request_id": "example",
"retry_after": 1,
"errors": [
{
"pointer": "example",
"code": "example",
"detail": "example",
"params": {}
}
]
}

rate_limited: the window is spent.

Media typeapplication/problem+json

A problem document (RFC 9457). Code-specific values are further members.

object
type
required
string
title
required
string
status
required
integer
code
required

Stable snake_case name of the problem, which an SDK branches on.

string
detail

An English explanation for humans; never what an SDK branches on.

string
request_id
required
string
retry_after

Seconds to wait before retrying, for rate_limited, ruleset_unavailable and unavailable.

integer
errors
Array<object>
object
pointer
required

JSON Pointer into the request body.

string
code
required

The rule broken, such as too_long, too_many or duplicate.

string
detail
required
string
params

The values of the rule broken, such as max, for a client to explain the violation in its own language.

object
key
additional properties
any

Example generated

{
"type": "example",
"title": "example",
"status": 1,
"code": "example",
"detail": "example",
"request_id": "example",
"retry_after": 1,
"errors": [
{
"pointer": "example",
"code": "example",
"detail": "example",
"params": {}
}
]
}
Retry-After
integer

Seconds to wait before trying again, at least 1.

RateLimit-Limit
integer

The requests the window allows.

RateLimit-Remaining
integer

The requests left in the window.

RateLimit-Reset
integer

Seconds until the window ends, at least 1.

ruleset_unavailable (this replica cannot load the environment’s ruleset yet) or unavailable (the key could not be checked, or this replica is shutting down and takes no new stream), with Retry-After.

Media typeapplication/problem+json

A problem document (RFC 9457). Code-specific values are further members.

object
type
required
string
title
required
string
status
required
integer
code
required

Stable snake_case name of the problem, which an SDK branches on.

string
detail

An English explanation for humans; never what an SDK branches on.

string
request_id
required
string
retry_after

Seconds to wait before retrying, for rate_limited, ruleset_unavailable and unavailable.

integer
errors
Array<object>
object
pointer
required

JSON Pointer into the request body.

string
code
required

The rule broken, such as too_long, too_many or duplicate.

string
detail
required
string
params

The values of the rule broken, such as max, for a client to explain the violation in its own language.

object
key
additional properties
any

Example generated

{
"type": "example",
"title": "example",
"status": 1,
"code": "example",
"detail": "example",
"request_id": "example",
"retry_after": 1,
"errors": [
{
"pointer": "example",
"code": "example",
"detail": "example",
"params": {}
}
]
}
Retry-After
integer

Seconds to wait before trying again, at least 1.