Skip to content

Decide a batch of features (browser)

POST
/edgekit/v1/decide
curl --request POST \
--url https://your-tenant-host/edgekit/v1/decide \
--header 'Content-Type: application/json' \
--header 'x-edgekit-site-id: site_example' \
--data '{ "features": [ "paywall", "newsletter-prompt" ], "content": { "payload": "{\"article_id\":\"a-1\",\"section\":\"news\",\"paywall_level\":\"2\"}", "signature": "example" }, "context": { "additionalProperty": "example" }, "userId": "0199a4c2-7b1e-7c3d-9a4f-2e8b5d6c1a90", "giftLink": "example", "newsletterLink": "example", "castleRequestToken": "example" }'

One request carries the facts once and a list of feature names. Every feature evaluates against one immutable fact snapshot, and effects are deduped and applied after every feature has resolved — so a batch is order-independent and replayable from the request alone. Rate limited to 2,000 requests per 10 seconds per API key on /v1/decide, or 200 per 10 seconds per client per site on /edgekit/v1/decide — one flat window, no separate burst. Exceeding it returns 429 with Retry-After. A retry is not free: every call ticks the meters its rules charge (a seen-set meter counts one article once, a count meter every call).

x-edgekit-site-id
required

The site this request is for, within this tenant. Every official EdgeKit SDK sets it from the client you configured; set it yourself only when calling this API directly.

string
>= 1 characters <= 128 characters

Example

site_example

The site this request is for, within this tenant. Every official EdgeKit SDK sets it from the client you configured; set it yourself only when calling this API directly.

x-edgekit-preview

A short-lived preview token for this site. When valid, the decision evaluates against the staged preview document instead of the live one, and the response’s preview field is true. Without this header, the edgekit_preview cookie is read instead. An absent, expired or invalid token falls back to the live document, with no error.

string

A short-lived preview token for this site. When valid, the decision evaluates against the staged preview document instead of the live one, and the response’s preview field is true. Without this header, the edgekit_preview cookie is read instead. An absent, expired or invalid token falls back to the live document, with no error.

Media typeapplication/json
object
features
required

The features to evaluate, named by the caller. A feature enabled in the console does not start evaluating — or ticking meters — because somebody saved a draft.

Array<string>
>= 1 items <= 32 items

Example

[
"paywall",
"newsletter-prompt"
]
content

The signed content descriptor. Absent means the decision reads no content facts, and a feature that reads one then routes to its error slot — which may not allow.

object
payload
required

The content descriptor, serialised. Signed as these exact bytes — there is no canonicalisation step, because a canonicalising scheme is a second parser that has to agree with the first.

string
>= 1 characters

Example

{"article_id":"a-1","section":"news","paywall_level":"2"}
signature
required

Base64url HMAC-SHA256 of payload under this site’s content key.

string
>= 1 characters
context

Unverified passthrough. Never merged with the signed facts, and a rule that allows on one of these is a bypass the organization wrote itself.

object
key
additional properties
userId

Who this decision is for. Accepted on the keyed route only, and refused outright (403) on /edgekit/v1/decide — a site-pinned key is a server credential and asserting an identity is what one is for, while a browser asserting one would let anyone on the page decide as any user. On the browser route the identity comes from the signed access cookie and nowhere else.

string format: uuid
>= 1 characters

Example

0199a4c2-7b1e-7c3d-9a4f-2e8b5d6c1a90
giftLink

The page’s ?_gt gift-link token, verbatim. Verified here with no read; an invalid, forged, expired or overlong token reads as no gift and the answer is still 200.

string
newsletterLink

The page’s ?ek_nl newsletter link, verbatim: <user id>.<list id>.<signature>, as an edition’s link template wrote it. It says who the link was sent to, not who is clicking: read only when the request is otherwise anonymous, it fills newsletter_link.* and counts on that user’s meters, and never signs anyone in. An invalid, forged or unknown one reads as none and the answer is still 200.

string
castleRequestToken

A fresh Castle request token from castle.js on the page, for the castle.* facts. Each token is good for one request. On the keyed route, your server forwards the token its page minted. Without one, castle.* has no value and a rule reading it routes to the feature’s error outcome. The answer is still 200.

string

One entry per feature that resolved.

Media typeapplication/json
object
decisions
required
object
key
additional properties
object
outcome
required

The id the site switches on.

string | null
value

The winning outcome’s own named fields, flattened to plain JSON — never a stringified blob. Absent for a plain outcome, where the id is the whole answer. A ref field resolves to a curated catalog object (never a bare id) carrying exactly the keys its select named.

type

Present iff the matched outcome declared one. allow/deny is an access verdict; redirect names a destination (see GET /decide/forward); data is neither. Open: accept a member not listed.

string
reason
required
string
reasonDetail
string
meters

The meter reads this feature’s rules made, keyed by meter name, as read — before this request’s own ticks. allowance - count is what was left going in. Absent when no rule read a meter. Under an outcome preview pin the pinned feature still carries the reads its unpinned rules make for this request, and nothing counts.

object
key
additional properties
object
count
required
integer
allowance
required
integer
checkoutPageUrls

The checkout page URL of each offer_token field whose outcome sells on a checkout page, keyed by the field name. The URL carries the token, so link to it as it is. Absent when no field names a checkout page.

object
key
additional properties
string
experience

What the site shows for this outcome, drawn by the browser client beside the decision. Absent when the site has none for it.

object
url
required

The module, root-relative and immutable: resolve it against the page’s own origin.

string
contract
required

The module contract it was written against.

integer
display
required
object
kind
required

Open: accept a member not listed. Known: modal, banner, slide-in, inline.

string
edge

A banner’s edge.

string
corner

A slide-in’s corner.

string
width

An inline’s width; column when absent.

string
dismiss

How long a closed modal, banner or slide-in stays closed: none (it cannot be closed), page (until the next page; also when absent), session or forever.

string
trigger
required
object
kind
required

Open: accept a member not listed. Known: immediate, delay, scroll, exit-intent.

string
seconds

A delay’s seconds, 1–600.

integer
percent

A scroll’s percent of the page, 1–100.

integer
brand
required

The site’s brand, or null when it has none.

object
logo
required
string | null
colors
required
object
key
additional properties
string
font
required
string | null
unknown
required

Names that were asked for and not answered — unpublished, disabled, or not running on this site. Reported rather than thrown: one typo must not fail the other five in the batch.

Array<string>
preview
required

Whether this answer came from the preview document rather than the live one.

boolean
previewHash

When preview, the hash of the staged document that answered. Compare it with the hash the preview link expects: for about a minute after a restage, the previous preview can still answer.

string
pin

When the preview token pins one feature to one row, that pin. The pinned feature answers the row’s outcome without evaluating its conditions, and ticks no meter and records no exposure. matched is false when the preview document has no such row, and the feature was evaluated as usual.

object
feature
required
string
canvas
required
string
row
required

A rule’s id, (otherwise) or (onError).

string
matched
required
boolean
staleIdentity

Present and true when this request carried a session cookie but no usable signed access cookie, so the answer above was decided with no grants. Call POST /v1/id/get-session to refresh the access cookie, at most once per decide: the flag only checks that a session cookie is present and never verifies it, so refetching without a limit on a forged cookie never ends. Absent means nothing is wrong.

boolean
exposures
required

This batch’s deduped, edgekit-owned experiment exposures — one per experiment, not per feature, and never a vendor-assigned one (the vendor’s own SDK already recorded that). Decide records none of them. EdgeKit’s SDKs and the site proxy send each one as an iglu:cloud.edgekit/experiment_exposure/jsonschema/1-0-1 event, and send none when preview is true. A caller using none of them sends the events itself.

Array<object>
object
experiment
required
string
arm
required
string
unitId

The id the arm was bucketed on: the device id for a device experiment, the user id for a user experiment. Send it as the event’s unit_id. Absent when no unit was bucketed.

string

Example

{
"decisions": {
"additionalProperty": {
"type": "allow",
"experience": {
"url": "/edgekit/x/0000000000000000000000000000000000000000000000000000000000000000.js",
"display": {
"kind": "modal",
"edge": "top",
"corner": "bottom-right",
"width": "column",
"dismiss": "none"
},
"trigger": {
"kind": "immediate"
}
}
}
}
}

Invalid request.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details

Example

{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key."
}
}

Not allowed.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details

Example

{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key."
}
}

Resource not found.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details

Example

{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key."
}
}

Request body too large.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details

Example

{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key."
}
}

Request validation failed.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details

Example

{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key."
}
}

Too many requests. Retry-After says when to retry.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details

Example

{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key."
}
}

Unexpected error.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details

Example

{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key."
}
}

With Retry-After, briefly unavailable; without it, not configured.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details

Example

{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key."
}
}

edgekit.ai