X-API-Key and acts on that key’s application.
The Policy
The policy decides what Baselayer recommends for each request. baselayer.js applies it to your pages. It is a list of steps, such asbrowse, cart and checkout, and an optional list of scopes. Each step names the requests it covers and holds rules tried in order; the first rule that matches decides. Steps are also tried in order, so put the most specific first. A request no rule of its step matches is decided by the step’s fallback.
A person is never decided by a step. A request that detection finds no automated visitor in is allowed before any rule runs.
A rule’s when matches on these members. Each takes a list, and a member left out matches anything. An empty list matches nothing.
A claim is
spoofed when a request names a platform’s agent but comes from outside that platform’s published ranges. rdns and cloud_browser are only known after Baselayer has processed a request, never when baselayer.js decides, so a rule on them takes effect only when Baselayer reads stored records back.
A rule’s outcome is one of three:
A step’s
enforcement_mode is monitor, where decisions are recorded and never applied, or enforce.
The Fallback
Every step has afallback: what it decides, by visitor type, when no rule matches. It names all three of agent, crawler and unknown, and each is an outcome and, for a step_up only, a requirement.
fallback. The step’s enforcement_mode applies to it as to a rule’s.
What Step Up Asks For
Astep_up carries a requirement: the keys the agent’s KYA credential must prove, and the credential the person gets when they approve.
required_keys is one of four sets, all required:
Any other set is refused. Baselayer stores the keys sorted. The requirement’s
identity_level, L2 or L3, is worked out from the keys on every read. It is never stored, and a value you send is ignored.
credential is required and says what the person gets on approval:
scope names one of the policy’s scopes, or is null to ask for the keys alone. purpose and fields are read-only: every read fills them in from the scope, and a replace overwrites what it is sent. With no scope they are null and empty.
step_up to the agent and checks the credential it presents. See What Your Visitors See.
Scopes
scopes name the sets of fields a step-up asks the person to share. A scope has a name (1 to 64 lowercase letters, digits and _, unique in the policy), the purpose shown to the person on the consent screen (up to 500 characters) and its fields, each once. Baselayer stores them sorted.
ETag, If-Match and monitor mode as any other change.
The keys a rule requires decide which fields its scope may hold. The Level 3 keys back every field. Otherwise only a Level 2 field whose key is among them:
GET /acceptance/policy lists every field a scope may name in available_fields, with the key that proves it. For what each field is, see Fields a Scope Can List. A scope no rule or fallback names is kept, with an unused_scope warning.
Steps and Matching
A step’sname is your own key for it: 1 to 32 lowercase letters, digits and _, used once in the policy. Decisions and visits carry it.
A step’s match says which requests it covers:
An empty list matches nothing, so a plain web site leaves
mcp_tools and ucp_operations as []. A step that matches nothing, or one that has methods and no paths, is refused. A request path is matched without its query string and fragment. A request no step claims is allowed.
A step an earlier step fully shadows is refused. One it partly shadows is kept, with a partly_shadowed_step warning.
Crawlers and Search Engines
An enforcedstep_up is shown to every visitor it covers, search engine crawlers included, and a crawler can’t answer it. To keep your pages indexed, put a rule ahead of the step-up that lets proven crawlers through: visitor_type ["crawler"], trust_level ["signed", "declared"], outcome allow. Setting the fallback’s crawler to allow instead lets every crawler through that no rule matched, proven or not.
The Default Policy
A new application starts on policy version 1, Baselayer’s default: one step,default, that matches every request, in monitor mode. Its one rule, suspect, steps a spoofed agent or crawler up to Level 2 with ["email_possession"] held on an account. Its fallback allows every agent, crawler and unknown visitor. A new version applies with no deploy.
Warnings
A policy that is valid but probably not what you meant is stored withwarnings. Each has a code, a message for a person, and the step, rule or scope it concerns:
Limits
A replace past any of these is refused with a422 naming the field:
Read the Current Policy
Needs theacceptance_policy:read permission.
ETag header. Keep it: you send it back to replace the policy. To poll for a change, send it as If-None-Match: the answer is 304 with no body until the policy or your audiences change.
Response
Response
available_fields is trimmed here: a read lists all 22 fields.policy_hash is the hash of the policy body. Each decision names the policy version it ran, so you can always tell which policy made it. audiences are your registered audiences, as /acceptance/domains returns them. available_fields and audiences are read-only: they are not part of policy.
Replace the Policy
Needs theacceptance_policy:update permission. Send the whole policy, exactly as a read returns it under policy, with the ETag you read as If-Match:
policy.json:
412 policy_version_stale and nothing changes: read it again and reapply your change. A request with no If-Match is refused with 428 if_match_required. A policy that breaks a rule above is refused with 422 validation_failed; each error names the field that is wrong and has its own type:
Earlier Versions
Versions are never changed or deleted.GET /acceptance/policy/versions lists them, newest first, and GET /acceptance/policy/versions/{policy_version_id} returns one exactly as it ran, which is the version a decision’s policy.version_id names.
Audiences and Allowed Origins
Two lists sit beside the policy, and changing them mints no policy version:audiences: where a KYA credential can be presented. A credential’s audience must be one of them. Each is a bare lowercase domain, such asshop.example, orhttps://<host>.allowed_origins: where baselayer.js may run. Each ishttps://and a host, with a port only when it isn’t the default, such ashttps://shop.example, orhttp://onlocalhost,127.0.0.1or[::1]for local testing, such ashttp://localhost:8080. A page on any other origin has its records and checks refused, and an application with no allowed origins accepts none.
https://<host>. Each response lists origin_without_audience in warnings for an origin that has none.
Reading needs acceptance_audiences:read:
acceptance_audiences:update, and changing allowed_origins also needs acceptance_origins:update, which a default API key does not have: an organization admin has it. Send both lists whole, with the response’s ETag as If-Match. Each value must already be in the form above and is refused rather than rewritten. Both lists are stored sorted.
A change applies to the next presentations and browser checks.
Treat browser records as reports, not proof: anyone can copy your browser key and claim an allowed origin.
Browser Keys
A browser key lets baselayer.js send records and checks for your application. It is public, like a publishable key: it ships in your page, and your allowed origins stop its use elsewhere. An application has at most 2 keys, so you can deploy a replacement before you delete the old one.Create a Key
Needs theorganizations_apikeys:create permission. name says what the key is for, such as the site it ships on, in 1 to 100 characters:
201, with the key’s URL in Location. Baselayer accepts a new key usually within about 20 seconds. With 2 keys already, the create is refused with 409 browser_key_limit_reached: delete one first.
List and Read Keys
Needsorganizations_apikeys:read. GET /acceptance/browser_keys lists your keys, newest first, and GET /acceptance/browser_keys/{browser_key_id} returns one. Both include browser_key, so you can read a key again at any time.
Replace a Key
Create a new key, deploy it to your pages, then delete the old one.Delete a Key
DELETE /acceptance/browser_keys/{browser_key_id} needs organizations_apikeys:delete and answers 204. The key leaves the list, and Baselayer stops accepting it usually within about 20 seconds, and within about 5 minutes once publishing is healthy. Deleting it again answers 404.