Skip to main content
The Vacaciones API uses JSON Web Tokens (JWT) for authentication. Every protected endpoint requires a valid token in the Authorization header. The only endpoint that does not require a token is POST /api/auth/login.

Obtaining a token

Exchange a username and password for a JWT by calling the login endpoint.

POST /api/auth/login

string
required
The account username.
string
required
The account password.
Response
string
required
A signed JWT. Include this value in the Authorization header of subsequent requests.

Token payload

The JWT payload contains the following claims: You can decode the payload client-side with standard base64 decoding. The front end reads the payload to populate the authenticated user context:

Using the token

Include the token as a Bearer credential in the Authorization header on every protected request:
The front end stores the token in localStorage under the key token and attaches it automatically to every apiFetch call.

Token expiry and logout

When the user logs out, the front end removes the token from localStorage. The server does not provide a token revocation endpoint; tokens remain valid until they expire according to their embedded exp claim.

401 Unauthorized

If a request is made with a missing or invalid token, the server responds with 401 Unauthorized.
All endpoints except POST /api/auth/login return 401 when the Authorization header is absent or the token is expired or malformed. Obtain a fresh token via the login endpoint and retry.