Login
Authenticate a user and receive a Sanctum API token for subsequent requests.Request Body
User’s email address. Must be a valid email format.
User’s password.
Response
Response status. Returns
success on successful authentication.Authenticated user information.
Laravel Sanctum API token. Include this in the
Authorization: Bearer {token} header for authenticated requests.Suggested redirect URL based on user role:
cliente:/(main store)empresa:/empresa/panel(business dashboard) or/empresa/create(if business profile not created)admin:/admin/dashboard(admin panel)
Success message.
Logout
Revoke the current user’s access token and end their session.This endpoint requires authentication. Include the
Authorization: Bearer {token} header.Headers
Bearer token obtained from login. Format:
Bearer {token}Response
Response status. Returns
success when token is successfully revoked.Confirmation message.
Get Current User
Retrieve the authenticated user’s information, including their associated business profile if applicable.This endpoint requires authentication. Include the
Authorization: Bearer {token} header.Headers
Bearer token obtained from login. Format:
Bearer {token}Response
User’s unique identifier.
User’s full name.
User’s email address.
User’s role. Possible values:
cliente, empresa, admin.Business profile information. Only present if user role is
empresa and profile exists.Token Management
Token Format
BeanQuick uses Laravel Sanctum for API authentication. Tokens are issued upon login and must be included in theAuthorization header for protected endpoints.
Header format:
Token Lifecycle
- Creation: Tokens are generated during login (
POST /api/login) and registration (POST /api/register) - Usage: Include in
Authorization: Bearer {token}header for authenticated requests - Revocation: Tokens are revoked when user logs out (
POST /api/logout) - Expiration: Tokens do not expire automatically but can be revoked at any time
Security Best Practices
- Store tokens securely (e.g., httpOnly cookies, secure storage)
- Implement token refresh mechanisms for long-lived sessions
- Revoke tokens immediately upon logout
- Use HTTPS for all API requests
- Validate user permissions on the server side
Multiple Sessions
EachcreateToken() call generates a new token. Users can have multiple active tokens across different devices or sessions. Calling logout revokes only the current token, not all user tokens.