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-idheader.
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-configto 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
OriginagainstTRUSTED_ORIGINS. - Mutation requests accept an
Idempotency-Keyheader. Reuse the same key when retrying the same request. - Keys are scoped per store; a key reused with a different body is rejected.