Skip to main content

Authentication

There are two authentication layers in the Dukanext API. They serve different purposes and are used together.

1. API Key (required on all requests)​

The API key authenticates your theme (the application) to the API. It identifies which shop you are accessing and which origins are allowed.

x-api-key: vst_your_key_here

Every single request must include this header. See API Keys for setup.

2. Customer JWT (required on protected routes)​

Some endpoints require the customer to be logged in. These are routes that access customer-specific data: their orders, notifications, profile, and reviews.

After a customer completes the login flow you receive a JWT. Pass it as a Bearer token:

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

Which endpoints require what​

EndpointsAPI KeyCustomer JWT
Products, Categories, SearchRequiredNot required
Settings, Config, ContentRequiredNot required
Newsletter, Contact FormRequiredNot required
AnalyticsRequiredNot required
POST /orders (place order)RequiredNot required
GET /orders, GET /orders/:idRequiredRequired
GET /auth, PATCH /authRequiredRequired
GET /notifications, DELETE /notifications/:idRequiredRequired
POST /reviews, GET /reviews/myRequiredRequired

Token lifecycle​

  • Store the JWT in localStorage or a secure cookie
  • Include it on every request to a protected endpoint
  • When a request returns SESSION_EXPIRED or AUTH_TOKEN_INVALID, the token has expired or been invalidated — clear it and redirect the customer to login

Customer login flow​

The login flow is a 3-step email OTP process. See Customer Auth Flow for the complete implementation guide.