Overview
The Ambiotec API uses JSON Web Tokens (JWT) for authentication. After successfully logging in or registering, you’ll receive a JWT token that must be included in subsequent API requests.Authentication Flow
- Register or Login to obtain a JWT token
- Include the token in the
Authorizationheader for protected endpoints - Token expires after 8 hours (default)
JWT Token Details
Token Configuration:- Secret: Configured via
JWT_SECRETenvironment variable - Expiration: 8 hours (configurable via
JWT_EXPIRES) - Algorithm: HS256 (default)
Using the Token
Include the JWT token in theAuthorization header with the Bearer scheme:
Authentication Errors
The API returns standard HTTP status codes for authentication errors:| Status Code | Error Message | Description |
|---|---|---|
| 401 | Token no provisto | No Authorization header provided |
| 401 | Token inválido o caducado | Token is invalid or expired |
| 401 | Credenciales inválidas | Login credentials are incorrect |
Endpoints
Register
Create a new user account and receive a JWT token
Login
Authenticate with existing credentials
Security Best Practices
- Store tokens securely (e.g., httpOnly cookies, secure storage)
- Never expose tokens in URLs or logs
- Implement token refresh before expiration
- Use HTTPS for all API requests
- Handle token expiration gracefully in your application