Skip to content

Auth, roles & API keys

How EdgeCart authenticates admins, storefronts, and API clients.

EdgeCart uses Better Auth for people and two API-key styles for programmatic access. The three paths have different credentials and scopes.

Admin sessions

Admins sign in with email and password. The browser keeps a Better Auth session cookie, and every Admin API request sends:

  • the session cookie, and
  • the x-store-id header.

A request for a store the member does not belong to returns 404, not 403.

Roles:

Role Intended access
owner Full store control, including settings and membership.
admin Full store administration.
member Day-to-day store operations.
viewer Read-only access.

Storefront and customer access

  • The storefront first calls the key-free GET /api/storefront-config to get the publishable key and store profile.
  • Keyed storefront requests send x-publishable-api-key.
  • Customer account routes also require the customer’s session cookie.

The publishable key (pk_...) is public by design. Secret keys stay on the server; EdgeCart stores only their hash.

Creating API keys

API keys are managed through the Admin API (/api/api-keys). A key is either publishable or secret. Publishable keys are safe for browsers; secret keys must never be shipped to a client.

CSRF and idempotency

  • Cookie-authenticated mutations check the request Origin against TRUSTED_ORIGINS.
  • Mutation requests accept an Idempotency-Key header. Reuse the same key when retrying the same request.
  • Keys are scoped per store; a key reused with a different body is rejected.

Type to search…

↑↓ navigate↵ selectEsc close