Getting Started

Authentication

Tenant API keys, the bearer header, scopes, the /v1/api/me endpoint, and tenant suspension.

View as Markdown

Every request to a /v1/api route is authenticated with a tenant API key. The key is a bearer token that belongs to a single store (tenant): it both authenticates the request and selects the store, so no separate tenant identifier or header is ever needed. This page covers how keys work, which scopes exist, the identity endpoint, and what happens when a store is suspended.

API keys

An API key is a long-lived secret token issued for one store. By default a key does not expire and stays valid until the merchant revokes it; the merchant can also give a key an expiry date (30, 90 or 365 days) at creation, after which it stops working. The plaintext key is shown exactly once, at creation. Store it in a secret manager immediately; it cannot be retrieved again.

Merchants create, edit and revoke keys in the client dashboard (app.borkol.com) under Settings > API keys. At creation the merchant picks a name, a set of scopes and an optional expiry for the key. The dashboard lists each key's name, scopes, creation time, last-used time and expiry, and can rename a key, change its scopes or revoke it at any point. A scope change applies to the next request made with the same token, so a storefront never needs a new key for it. A revoked or expired key immediately stops working: requests with it return 401 {"message": "Unauthenticated."}.

Send the key on every request in the Authorization header:

text
Authorization: Bearer {api_key}

There is no X-Tenant-Id header on /v1/api routes and none is read. The store context derives entirely from the key.

Scopes

Each key carries a set of scopes granted at creation. Scopes gate endpoints: a route that requires a scope the key does not carry returns 403 {"message": "Invalid ability provided."}.

Scope names follow the pattern {module}:{read|write}. The full set:

ScopeGrants
tenant:readBasic store identity access (GET /v1/api/business, the redirect and sitemap endpoints). Always available to grant.
catalog:readProducts, categories and the configurator endpoints. commerce:read is accepted on the same routes.
catalog:writeGrantable; no /v1/api route uses it yet.
commerce:readCarts (read), orders, and everywhere catalog:read or sales:read is accepted.
commerce:writeCarts (write), checkout, quote requests, and everywhere sales:write is accepted.
configurator:read / configurator:writeGrantable; the configurator endpoints check catalog:read or commerce:read, not these.
contacts:readCustomer account GET endpoints (/v1/api/contacts/*).
contacts:writeCustomer registration, login, logout, password reset, profile and address changes.
customers:read / customers:writeThe former names of contacts:read / contacts:write. Still grantable and accepted on the same routes, so keys minted before the rename keep working.
sales:readRead a quote by token (GET /v1/api/sales/quotes/by-token/{token}).
sales:writeAccept or decline a quote by token.
stock:readStock levels (GET /v1/api/stock/*).
stock:writeGrantable; no /v1/api route uses it yet.
objects:readObject types and records (GET /v1/api/objects/*), and the sitemap.
objects:writeGrantable; no /v1/api route uses it yet.
objects:schemaPush a site's schema and upload section thumbnails (PUT /v1/api/objects/schema, POST /v1/api/objects/media). Only on a connected site's push key; never grantable on an API key. See Build a site.
forms:readLoad published forms (GET /v1/api/forms/{key}) and the address lookup.
forms:writeUpload files for form file fields (POST /v1/api/forms/{key}/uploads) and send form submissions (POST /v1/api/forms/{key}/submissions). Server-side only; see below.

A module without a public surface (payroll) offers its permission names as scopes too; no /v1/api route uses them. Where a route lists two scopes, a key carrying either one passes: the older commerce:* family predates the split of the commerce module into catalog, commerce and sales, and is accepted on all three.

A merchant can only grant scopes for modules currently enabled on their store: the grantable set is always tenant:read plus the {module}:read and {module}:write pair of each enabled module. Requesting an unavailable scope at key creation fails with a 422 in the dashboard flow.

Keep forms:write keys on your server. A key with forms:write sends submissions, and every submission sends mail in the merchant's name. Never ship it to a browser or a mobile app: load and submit forms from your own server, and give the key that loads forms (forms:read) and the key that submits them (forms:write) separately. See Forms.

Scopes and module enablement are enforced independently. Even when a key carries commerce:read, calling a commerce route while the commerce module is disabled for the store returns 403 {"error": "Module not enabled: commerce"}. Read endpoints require the module's read scope; create, update, and delete endpoints require the module's write scope. Each endpoint's reference page states the scope it requires.

Request processing order

Middleware runs in a fixed order on every /v1/api request. Knowing the order helps interpret error responses:

  1. Authentication: the bearer token is resolved to a store. Missing, malformed, revoked, or expired token: 401 {"message": "Unauthenticated."}.
  2. Tenancy and suspension: the store context is initialized from the key. Suspended store: 403 {"message": "Tenant suspended.", "code": "tenant_suspended"}.
  3. Rate limiting: 120 requests per minute per store. Exceeded: 429 {"message": "Too Many Attempts."}.
  4. Module gate and scope check (module routes only): both run after the steps above, but their relative order varies by route. Disabled module: 403 {"error": "Module not enabled: {key}"}. Missing ability: 403 {"message": "Invalid ability provided."}. The checks are independent; when both would fail, either error may surface first.

Tenant suspension

Borkol can suspend a store. While suspended, every /v1/api request with that store's keys, regardless of scope or endpoint, returns:

Response (403, suspended)
{
  "message": "Tenant suspended.",
  "code": "tenant_suspended"
}

with HTTP status 403. The code field is stable and machine-readable; check for tenant_suspended to distinguish this 403 from scope and module errors. Suspension does not invalidate keys: when the suspension is lifted, existing keys work again unchanged.

GET /v1/api/me

Returns the identity of the store the presented API key belongs to, plus the scopes granted to that key. This is the canonical first call to verify a key works and to inspect its abilities. It requires no scope; any valid key can call it.

Parameters

None. Only the Authorization: Bearer {api_key} header is required.

Response fields

NameTypeRequiredDescription
tenantobjectalwaysThe store the key belongs to.
tenant.idstring (UUID)alwaysStore ID.
tenant.namestringalwaysStore display name.
tenant.slugstringalwaysURL-safe store identifier.
scopesarray of stringsalwaysThe scopes granted to this key, for example ["tenant:read", "commerce:read"].
Request
curl https://api.borkol.com/v1/api/me \
  -H "Authorization: Bearer {api_key}"
Request (JS)
const res = await fetch("https://api.borkol.com/v1/api/me", {
  headers: { Authorization: `Bearer ${apiKey}` },
});
const me = await res.json();
Response
{
  "tenant": {
    "id": "9c4e7f0a-2b31-4d6e-8f0a-1d2c3b4a5e6f",
    "name": "Example Store",
    "slug": "example-store"
  },
  "scopes": ["tenant:read", "commerce:read", "commerce:write", "stock:read"]
}

Errors

StatusBodyWhen
401{"message": "Unauthenticated."}Bearer token missing, malformed, revoked, or expired.
403{"message": "Tenant suspended.", "code": "tenant_suspended"}The store is suspended.
429{"message": "Too Many Attempts."}More than 120 requests in the current minute.

GET /v1/ping

Unauthenticated health check for API v1. No credentials, no store context, no scopes, and no tenant rate limit apply. Use it for uptime monitoring and to verify connectivity and the base URL before wiring credentials.

Parameters

None.

Response fields

NameTypeRequiredDescription
statusstringalwaysAlways "ok".
versionstringalwaysAlways "v1".
Request
curl https://api.borkol.com/v1/ping
Response
{
  "status": "ok",
  "version": "v1"
}

Errors

None specific to this route.