API Ecommerce uses stateless JWT authentication powered byDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/JuanSCaicedo/Api-Ecommerce/llms.txt
Use this file to discover all available pages before exploring further.
tymon/jwt-auth. Every protected endpoint expects a signed bearer token; no session cookies or CSRF tokens are involved. The API enforces two distinct user roles via a type_user column on the users table: type_user=1 identifies admin accounts, while type_user=2 identifies customer accounts. Each role has a dedicated login endpoint — tokens are not interchangeable across roles, and attempting to use a customer token on an admin route (or vice versa) results in a 401 Unauthorized response.
Token format
All protected endpoints require the following HTTP header:JWT_SECRET value in your .env file and expire after the TTL configured in config/jwt.php (default 60 minutes, reported as expires_in seconds in login responses). Each issued token is also persisted to the user_tokens table alongside the issuing IP address and User-Agent, enabling per-device session management.
Register
POST /api/auth/register
Creates a new customer account (type_user=2). On success, a verification email is dispatched to the provided address. The account cannot be used to log in until email verification is completed. Returns HTTP 201 with the created user object.
Request fields
The customer’s first name.
The customer’s last name (surname).
Contact phone number.
A unique, valid email address. Duplicate emails are rejected with
HTTP 400.Minimum 8 characters. Stored as a bcrypt hash.
Example
Admin login
POST /api/auth/login
Authenticates an admin account (type_user=1). Rejects credentials belonging to customer accounts, even if the email and password are valid.
Request fields
The admin account’s email address.
The admin account’s password.
Example
Response
The signed JWT. Pass this in the
Authorization: Bearer header for all protected requests.Always
"bearer".Token lifetime in seconds (default
3600). After expiry, call /api/auth/refresh to obtain a new token without re-entering credentials.Concatenation of
name and surname fields.The authenticated user’s email address.
The authenticated user’s first name.
Customer login
POST /api/auth/login_ecommerce
Authenticates a customer account (type_user=2). In addition to validating credentials, this endpoint checks that email_verified_at is set on the account — unverified customers receive HTTP 401 even with correct credentials.
Request fields
The customer’s registered email address.
The customer’s password (minimum 8 characters at registration time).
Example
Response
The signed JWT. Pass this in the
Authorization: Bearer header for all protected storefront requests.Always
"bearer".Token lifetime in seconds (default
3600).Concatenation of the customer’s
name and surname fields.The authenticated customer’s email address.
The authenticated customer’s first name.
Token refresh
POST /api/auth/refresh
Issues a new JWT without requiring the user to re-enter their credentials. The current token must still be valid (not expired and not invalidated) at the time of the request.
Requires: Authorization: Bearer <current_token>
Example
access_token, token_type, expires_in, and user.
Logout
POST /api/auth/logout
Invalidates the currently authenticated token and removes its record from the user_tokens table, ending the session on the current device.
Requires: Authorization: Bearer <token>
Example
Response
Logout a specific device
POST /api/auth/logout_device
Invalidates a specific session token (identified by its string value) without affecting the caller’s own active session. This enables users or admins to remotely terminate sessions on other devices. The target token is looked up in the user_tokens table; if not found, the endpoint returns HTTP 404.
Requires: Authorization: Bearer <your_current_token>
Request fields
The full JWT string of the session you want to invalidate. This can be retrieved from the
user_tokens table or a device-management endpoint.Example
Response
Email verification
After a successful call toPOST /api/auth/register, the API sends a transactional email to the registered address. That email contains a code_user value (internally stored as the uniqd field on the user record). Submit that code to activate the account:
POST /api/auth/verified_auth
Request fields
The unique verification code sent to the user’s email address after registration.
Example
Response
email_verified_at to the current timestamp and clears uniqd. The account can now authenticate via /api/auth/login_ecommerce.
Until
verified_auth is called, any attempt to log in via /api/auth/login_ecommerce will return HTTP 401, even if the email and password are correct.Get authenticated user
POST /api/auth/me
Returns the profile of the currently authenticated user. This endpoint requires a valid Bearer token.
Requires: Authorization: Bearer <token>
Example
Response
The
avatar field returns a full URL. If the user has no uploaded avatar, a default placeholder URL is returned instead.Request password-reset email
POST /api/auth/verified_email
Sends a password-reset email containing a time-limited verification code to the specified address. The code is valid for 60 minutes. Use it with /api/auth/verified_code to confirm the code, then /api/auth/new_password to set a new password.
Request fields
The email address associated with the account that needs a password reset.
Example
Response
{ "message": 403 } if no account with the given email address is found.
Verify password-reset code
POST /api/auth/verified_code
Validates the reset code that was sent by /api/auth/verified_email. Returns success if the code exists and has not expired; returns an expiry error if the 60-minute window has passed.
Request fields
The reset code received in the password-reset email.
Example
Response
| Response value | Meaning |
|---|---|
{ "message": 200 } | Code is valid and within the 60-minute window. |
{ "message": 401 } | Code found but has expired. |
{ "message": 403 } | Code not found. |
Set new password
POST /api/auth/new_password
Sets a new password for the account identified by the reset code. The code is consumed and cleared after a successful update, so it cannot be reused.
Request fields
The reset code previously validated with
/api/auth/verified_code.The new password to set on the account. The value is stored as a bcrypt hash.
Example
Response
Rate limiting
All routes under the/api/auth/ prefix are grouped under a throttle:10,1 middleware, which allows a maximum of 10 requests per minute per IP address. Exceeding this limit returns:
Retry-After header is included in the response, indicating how many seconds to wait before retrying. This limit applies equally to registration, login, refresh, and logout endpoints.