Authentication
There is one credential: a JSON Web Token in an Authorization header. No API keys, no
tokens in query strings, no cookies — an API call carries its own credential, and nothing
about it depends on a browser session.
Code
The token is a user's, and it reaches the accounts that user is a member of. A website id
in an account you do not belong to answers NOT_FOUND, not PERMISSION_DENIED, because
refusing by name would confirm that the site exists; inside your own account, a section
your role does not cover answers PERMISSION_DENIED. The rules — membership, role,
section, and the account's owner — are below.
Straight after a signup there is a second way in. The registration response carries a
one-time signup_token; trading it at users:exchange_handoff returns a session token,
which is how the platform's own dashboard opens already signed in without asking for the
password that was just chosen. It works exactly once.
Sign-up is the one surface that needs no token at all, and that is why every call on it is rate-limited and bot-checked at the edge — a CAPTCHA proof travels with it. Nothing behind that surface can read another tenant's data.
Two operational notes for a long-lived integration. A token expires: treat a 401
(UNAUTHENTICATED) as "re-authenticate and retry once", not as a failure to report. And
in a browser, the preflight matters — PATCH, Authorization and If-Match are none of
them "simple", so a client that sees no response at all is usually looking at a refused
preflight rather than a refused request.
19. Authentication
Authorization: Bearer <jwt>on every authenticated surface. No API keys, no tokens in query strings, no session cookies for API calls.- Missing or unparsable credentials →
UNAUTHENTICATED(401). Valid credentials without the right →PERMISSION_DENIED(403), except where 403 would reveal existence, which isNOT_FOUND(§7). - Every tenant-scoped route MUST verify the caller against the account that
owns the scope in the path —
accounts/{account},projects/{project}orwebsites/{website}. Scoping by path alone is not authorization. /site-apiis unauthenticated by design and MUST be rate-limited and bot-checked at the edge; nothing behind it may read another tenant's data.
Authorization on the tenant API
A token names a user, and a user reaches an account by being a member of it. What a member may do there is decided in three steps, in this order, on every request:
- Membership. The route's scope — an account, a project or a website —
is resolved to the account that owns it, and the caller must be a member
of that account. A caller who is not gets
NOT_FOUNDon the scope's name: the same answer a scope that does not exist gets, so an id belonging to someone else's account confirms nothing (§7). Routes without a scope — the caller's ownprofile, the list of theiraccounts, the catalogues — need only a valid token. - Role. Each membership holds exactly one role:
roles/admin(every section, to change),roles/editor(every section except managing who has access),roles/sections(only the grants written on the membership itself), or one of the account's own roles,accounts/{account}/roles/{role}— a named set of grants. A grant is{permission, level}: a section of the permission catalogue (GET permissions) andREADorWRITE, whereWRITEincludesREADand a grant on a section covers every section below it. A section may declareimplies— grants that come with it, so that holding blog posts onWRITEalso lets the editor upload the post's image. - Section. Every scoped route belongs to one section, or is declared
open to any member (the scope's long-running operations) or to the owner
alone. Reading (
GET) takesREADon the section, any other methodWRITE; a custom method that only reads is declared as a read. A section markedreadable_by_all_members— everything under a website, the account's settings, its projects — is readable by every member whatever the role, so pickers of media, pages or categories work for everyone; a grant on it decides what the member may change. Access management, the account's AI and its billing are read only with a grant.
A member whose role does not reach the route gets PERMISSION_DENIED (403,
§13): they belong to the account and already know it exists, so refusing by
name gives nothing away. NOT_FOUND is kept for the caller who is not a
member at all. What a member actually holds — the role's grants with implies
followed — is effective_grants on their own membership,
accounts/{account}/members/{their user id}, which every member may read.
Rights are read afresh on every request and are not carried in the token: a changed role or a removed member takes effect on the very next call, and no token has to be revoked.
A website's modules. Most functions of a website — its pages and blocks,
its menus, its media library, its email templates, its blog, its content plan,
its customer accounts — are modules the tenant turns on and off one
website at a time: websites/{website}/modules lists every module with its
enabled, and an Update of enabled (WRITE on website.modules) is the
switch. A new website starts with the pages, the menus, the media library and
the email templates on, and every other module off. While a module is off,
every route that belongs to it, reading included, answers
FAILED_PRECONDITION with a PRECONDITION_FAILURE of type
MODULE_DISABLED whose subject is the module's name,
websites/{website}/modules/{module} — the resource to turn on, not a reason
to retry. The routes and their modules:
Routes under websites/{website}/ | Module |
|---|---|
cms_pages (with a page's views and group_versions), cms_blocks (with a block's views) | cms |
menus (with their items and the items' views) | navigation |
media, media_folders | media |
email_templates (with their views) | email_templates |
blog_posts, blog_categories, blog_tags, blog_authors (with their views) | blog |
editorial_plan, editorial_topics, editorial_slots, editorial_ai_policy, editorial_generations | editorial |
customers, customer_groups, customer_attributes, customer_attribute_groups | customers |
catalog_attributes, catalog_attribute_sets, catalog_categories, catalog_products (categories and products with their views) | catalog |
A theme that names a new picture while media is off is refused the same way.
The modules, the settings, the themes and the views of a website stay open
whatever is off, and so do analytics_metrics and :reindex_search. The
contact form, site search, site analytics, SEO, tracking and the Content
Security Policy own no route of this table: an off switch takes them out of
the published site instead.
That is weighed after the three steps above, so a member whose role does not
reach the route is still told PERMISSION_DENIED. What the module holds is
kept while it is off, and turning it back on opens its routes on the next
call. A module that works on top of another is refused the same way in both
directions: MODULE_REQUIRED turning it on while the other is off,
MODULE_REQUIRED_BY turning the other off under it, each naming the module to
act on first — turning off, one MODULE_REQUIRED_BY for every module that
requires it and is on, nearest dependants last. A website whose provisioning_status is still PENDING lists
every module off and without data — its provisioning has not reached them yet;
once READY, the four it starts with read on — and refuses a write to any of
them with WEBSITE_PROVISIONING, whose subject is the website,
websites/{website}: wait for READY, then repeat the call.
A website whose provisioning failed. provisioning_status: FAILED is not
the end of a website. websites/{website}:retry_provisioning — WRITE on
account.projects, as creating and deleting a website take — deletes what the
failed attempt left and provisions the website again under the same name,
answering it PENDING. websites/{website}:report_provisioning_failure — any
member — mails the platform's administrators about it, at most once an hour per
website, and answers {"sent": true} or, within that hour, {"sent": false}.
Asked of a website that is not FAILED, either is FAILED_PRECONDITION with
WEBSITE_PROVISIONING, the website as its subject.
The owner. An account that has members has exactly one owner, named by the
account's owner field (users/{user}); the first member of an account
nobody belongs to becomes its owner. Accepting an invitation never makes
anybody the owner: the new membership holds the role the invitation names,
no more. The owner holds every section whatever the
membership's role says, and two things are the owner's alone: deleting the
account and handing it to another member (accounts/{account}:transfer_ownership).
The owner's membership can be neither removed nor changed —
FAILED_PRECONDITION — until the account has been handed over; the previous
owner then stays a member with roles/admin.
Nobody gives more than they hold. Assigning a role or grants — to a member,
an invitation or an account role — that reach further than the caller's own
rights is PERMISSION_DENIED, naming the first grant too many. The owner and
roles/admin are never refused.
The account's AI assistant. The assistant calls this API on its user's
behalf, with that user's rights and never more, and every operation also has a
class that says what the assistant may do with it: READ — it reads on its
own; WRITE — it changes at once, and the change is shown to the user with a
way to undo it; CONFIRM — it changes only after the user confirms (every
delete, anything that moves money or stock, sends a letter, publishes or
generates, or changes the live site); FORBIDDEN — never (signing in, the
profile, who has access, the AI connections and billing, the assistant's own
settings, deleting a website or a project). A call the class does not admit is
PERMISSION_DENIED with an ASSISTANT_ACCESS detail (§13); the user's own call
of the same operation is not affected. A route that answers with text the
website's visitors typed — customers, orders, carts, invoices, wishlists — is
marked as such: having read it, the assistant applies no change without its
user's confirmation. A website's setting has a class of its own, the
assistant_class of its setting_descriptors entry: writing settings is WRITE
as a route, and the class of the path written decides; the assistant reads
"[secret]" in place of a secret setting's value.
Customers of a website
A website's customers — the visitors who register and sign in on the
tenant's site, websites/{website}/customers — are not callers of this API.
Their session lives between their browser and the site: HttpOnly cookies the
site sets on its own domain when they sign in (Secure, SameSite=Lax),
renews while they browse and clears when they sign out. The API itself stays
stateless and bearer-only. The tenant API manages customers and their groups
under the tenant's token like any other resource, and never accepts a
customer's session in place of that token: a customer's credential presented
to it is UNAUTHENTICATED.
A session belongs to one website. It opens nothing on another website — not
even one of the same account — and the same address on two websites is two
customers, each with a password and connected accounts of its own. Anything a
site renders for a signed-in customer is answered Cache-Control: private, no-store, so no shared cache keeps it; a visitor without a session is served
exactly what every other anonymous visitor is.
A customer may also sign in without a password, through the shop's own app at
Google, Apple or Facebook, which the tenant connects to the website
(customer_sign_in_providers). The browser goes to the provider and comes back
to the site's own address, https://<host>/api/auth/provider/<provider>/callback
— which is why each such address is registered in the shop's app at the
provider — and the site opens the same session a password does. Who signs in is
decided once, the same way for every provider: the customer the person's
account at the provider is linked to; otherwise the customer with the address
the provider vouches for, linked from then on; otherwise a new customer under
that address, without a password. A provider that vouches for no address finds
only a customer already linked to it. An account whose address was registered
with a password and never proved loses that password at the first sign-in that
proves the address, and every session of it ends: whoever set the password may
not own the address. The customer sets a password again by the reset link
mailed to the address, and from then on the password and the providers work side
by side.
A customer may also sign in with a six-digit code the site mails to the address
they type. Asking for a code gets the same answer, and the same email, whether or
not the address has an account: the right code signs its owner in, or up when
nobody has the address yet. A code works once, for ten minutes; five wrong tries
give it up, and asking again replaces it. The right code proves the address the
way a provider vouching for it does, so it leads by the same rule — and takes a
password nobody proved the same way. The website's setting
customers.sign_in.email_code switches the code off, as each provider's setting
switches its button off.
Where the website's registration form asks for a field it cannot be sent without, neither a provider nor a code creates a customer of an address nobody has. The site shows the person the registration form instead — the address the sign-in proved, fixed; no password; the name the provider gave filled in — and the customer is created, and signed in, once the form is sent.
A signed-in customer connects their account at another provider in their profile — whatever address it names, since they are signed in already — and disconnects any of them, the last one too: the address stays a way in, by a code or by the password's reset link. Every way to sign in is the website's own, like its sessions: a code one website mails, its registration form's sign-up and the shop's app at a provider open nothing on another website, and the same person at the same provider signs in to two websites as two customers.