Skip to content

Authentication ​

The API uses JWT (JSON Web Tokens) for authentication. There are two separate auth contexts:

ContextLogin endpointToken typeUse case
AdminPOST /rest/auth/admin/loginBackendAdmin panel, product management, order management
CustomerPOST /rest/auth/customer/loginFrontendStorefront, customer account, wishlist, cart

Login ​

Send credentials as JSON:

http
POST /rest/auth/admin/login
Content-Type: application/json

{
  "username": "admin@example.com",
  "password": "your-password"
}

Successful response (200):

json
{
  "access_token": "eyJhbGciOiJIUzI1NiIs...",
  "refresh_token": "a1b2c3d4e5f6..."
}

The customer login endpoint works identically: POST /rest/auth/customer/login.

Using the Access Token ​

Include the access token in the Authorization header on every request:

http
GET /rest/product/product
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...

Refreshing Tokens ​

When the access token expires, use the refresh token to get a new one without re-authenticating:

http
POST /rest/auth/admin/refresh
Content-Type: application/json

{
  "refresh_token": "a1b2c3d4e5f6..."
}

Response (200):

json
{
  "access_token": "eyJhbGciOiJIUzI1NiIs..."
}

The refresh token itself does not rotate on refresh. Use POST /rest/auth/customer/refresh for customer tokens.

Customer Registration ​

http
POST /rest/auth/customer/register
Content-Type: application/json

{
  "email": "new@example.com",
  "password": "min6chars",
  "firstName": "John",
  "lastName": "Doe",
  "phone": "+30210...",
  "newsletter": true
}

Successful response (201) returns access_token and refresh_token directly, so the customer is logged in immediately.

Access Scopes ​

The token type determines the scope of each request, which affects what data is returned:

ScopeToken requiredDescription
PublicNoneAnonymous access. Only public fields and relations are returned.
CustomerCustomer JWTLogged-in customer. Additional customer-specific fields and relations.
BackendAdmin JWTAdmin user. All fields and relations, including admin-only data.

Many endpoints are accessible publicly (product catalog, CMS pages, etc.) but return richer data when authenticated. See Response Scoping for details.

Roles (Backend Only) ​

Admin tokens carry role information. The API enforces role-based access on backend-protected endpoints:

RoleIDAccess
Advisable1Superuser — bypasses all role checks
Developer2Technical settings
Admin3General administration
CMS4Content management
Products5Product catalog
Orders6Order management
Reporting7Analytics
Marketing8Promotions and campaigns
Media9Media and sliders

If a backend endpoint requires a role you don't have, you'll receive a 403 Forbidden response.

Live Testing Notes ​

Response Structure ​

Auth endpoints return tokens at the root level of the JSON response, not nested under a data key:

json
{
  "access_token": "eyJhbGciOiJIUzI1NiIs...",
  "refresh_token": "a1b2c3d4e5f6..."
}

This differs from resource endpoints, which use a standard envelope:

json
{
  "success": true,
  "data": [...],
  "pagination": { "page": 1, "per_page": 20, "total": 150, "total_pages": 8, "has_next": true, "has_prev": false }
}

Keep this distinction in mind when building API clients: auth responses are unwrapped, everything else is enveloped.

Admin Login ​

http
POST /rest/auth/admin/login
Content-Type: application/json

{
  "username": "admin@example.com",
  "password": "your-password"
}

The username field accepts the admin's email address. Config-based static users (defined in application configuration) are checked before database users, so a static user with the same username will always take precedence.

Customer Registration ​

http
POST /rest/auth/customer/register
Content-Type: application/json

{
  "email": "new@example.com",
  "password": "min6chars",
  "firstName": "John",
  "lastName": "Doe"
}

The required fields are email, password, firstName, and lastName. Additional fields (phone, newsletter, etc.) are optional. A successful registration returns access_token and refresh_token at the root level, logging the customer in immediately.