Appearance
Authentication
The API uses JWT (JSON Web Tokens) for authentication. There are two separate auth contexts:
| Context | Login endpoint | Token type | Use case |
|---|---|---|---|
| Admin | POST /rest/auth/admin/login | Backend | Admin panel, product management, order management |
| Customer | POST /rest/auth/customer/login | Frontend | Storefront, 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.
Signing Out
Revoke the refresh token when the user signs out, so it can no longer mint access tokens. This ends the session of that device only: a user who is signed in on several devices (each sign-in starts its own session) stays signed in on the others.
http
POST /rest/auth/customer/logout
Content-Type: application/json
{
"refresh_token": "a1b2c3d4e5f6..."
}Response (200), whatever the token's state:
json
{
"message": "Logged out."
}POST /rest/auth/admin/logout is the admin twin. No access token is needed: holding the refresh token is the authority, so a client whose access token has already expired can still sign out. The call is idempotent and answers the same 200 for an unknown, already-revoked, malformed or missing token, so it is safe to retry and reveals nothing about the token. An access token already issued stays valid until it expires; discard it on the client.
A customer's refresh tokens are also revoked when their password is reset (REST reset-password or the storefront form) or changed on the storefront account page. The revocation runs before the new password is written, so if it fails nothing changes: reset-password answers 500 and the same reset token can be retried. A change through POST /rest/customer/me/password ends every other session of the customer and keeps the caller's, which it recognises by the sid claim in the access token (the id of the session, added at login, registration and refresh). The revocation and the password write commit together: if either fails the call answers 500 and nothing changes, so the old password and every session stay and the call can be retried. An access token issued before the sid claim existed ends every session, the caller's included.
A user may hold up to REST_AUTH_MAX_SESSIONS_PER_USER live sessions (default 10); signing in past that limit ends the least recently used session, whose next refresh answers 401.
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:
| Scope | Token required | Description |
|---|---|---|
| Public | None | Anonymous access. Only public fields and relations are returned. |
| Customer | Customer JWT | Logged-in customer. Additional customer-specific fields and relations. |
| Backend | Admin JWT | Admin 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:
| Role | ID | Access |
|---|---|---|
| Advisable | 1 | Superuser — bypasses all role checks |
| Developer | 2 | Technical settings |
| Admin | 3 | General administration |
| CMS | 4 | Content management |
| Products | 5 | Product catalog |
| Orders | 6 | Order management |
| Reporting | 7 | Analytics |
| Marketing | 8 | Promotions and campaigns |
| Media | 9 | Media 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.