Information
- OpenAPI version:
3.0.3
The API SDKs speak, served under /sdk/v1. A server SDK downloads its
environment’s ruleset and evaluates locally; a client SDK (a browser or
a mobile app) never receives a ruleset and asks the server to evaluate
for it. Both hold the ruleset stream and post events. Every change to
this API is additive: an SDK released against it keeps working with
every later server.
Keys. Every operation authenticates an SDK key of one environment as
a bearer in Authorization: a server key (fn_srv_…) belongs in a
backend, a client key (fn_cli_…) ships inside apps and browsers. A
browser’s EventSource cannot set headers, and neither can
navigator.sendBeacon, so the stream and events also accept a client
key as the query parameter sdk_key; a server key there is refused
403 server_key_in_query. No key is 401 sdk_key_missing with
a plain WWW-Authenticate: Bearer; a malformed or unknown key
sdk_key_invalid, a revoked one sdk_key_revoked and one whose
rotation overlap has ended sdk_key_expired, each 401 with
WWW-Authenticate: Bearer error="invalid_token". A key that cannot be
checked because the server cannot reach its store is
503 unavailable with Retry-After.
Browsers. A preflight OPTIONS on any path of this API is answered
204 without a key, allowing GET, POST and OPTIONS and the headers
Authorization, Content-Type, Content-Encoding,
Flagnetic-Schema-Version and Last-Event-ID, cached for a day. Every
answer exposes ETag, Retry-After, RateLimit-Limit,
RateLimit-Remaining, RateLimit-Reset, Deprecation and Sunset to scripts and allows any
origin (Access-Control-Allow-Origin: *), unless a client key lists
allowed origins: then a listed origin is echoed with Vary: Origin and
any other refused 403 origin_not_allowed. A server key sent with an
Origin header is refused 403 server_key_from_browser. Credentials are
never allowed.
Schema versions. Every request for a document and every events batch
carries Flagnetic-Schema-Version, the highest document schema the SDK
reads. Absent, or 1 and above, is served schema 1; below 1 or not an
integer is 406 schema_version_unsupported.
SDK identity. The server lists the SDKs that use an environment
and counts the evaluations it answers per SDK. An SDK that can set
User-Agent sends flagnetic-<sdk>/<version> (<platform>) on every
request, such as flagnetic-go/1.4.0 (linux). A browser cannot set
User-Agent and EventSource no header at all, so an SDK names itself
in what it posts as well: on evaluate the context’s standard
attributes sdk, sdk_version and platform (strings, sdk holding
the same name as the User-Agent, such as flagnetic-js), on events
the envelope’s sdk. A User-Agent naming an SDK wins over both. A
request identified by neither is unknown, and so is a ruleset fetch
or a stream without such a User-Agent.
Rate limits. Each operation is limited per key in fixed one-minute
windows counted by each replica (a client key per key and client IP).
A limited answer carries RateLimit-Limit and RateLimit-Remaining; a
refusal is 429 rate_limited with Retry-After and RateLimit-Reset in
whole seconds and the problem’s retry_after. Malformed and unknown
keys are limited per client IP: past the limit, a key the replica does
not hold already is refused before it is looked up.
Bodies. A request body may be gzip (Content-Encoding: gzip); every
size limit counts the body after decompression. A body over its limit
is 413 request_too_large, one that is not JSON 400 invalid_request,
one sent as another media type than application/json (or, for
events, text/plain) 415 unsupported_media_type. An answer is gzip when the request accepts
it.
Unknown members. The server ignores what it does not know in a
request, so an SDK released later that sends a new optional member or
query parameter is answered as if it had not: a member of a request
body at any level (the evaluate body and its context, the events
envelope and its sdk, each event, each summary row) and a query
parameter of any operation. Context attributes keep their own rule: one
the project does not declare is listed in ignored_attributes for a
server key.
Problems. Every error is a problem document (RFC 9457) in the same
shape as the management API’s: type (urn:flagnetic:problem:<code>),
title, status, a stable code, detail for humans, the
request_id of the request, and for a refused body errors, each a
violation with a JSON Pointer into the request body, a code, a
detail and the params of the rule broken. An SDK branches on the
status and code alone. A path this API does not serve is
404 not_found, a method a path does not accept
405 method_not_allowed with Allow.
A server key (fn_srv_…) or a client key (fn_cli_…) of one environment.
Security scheme type: http