All protected endpoints in the Shipfastai API require a Bearer token passed in the Authorization request header. You obtain a token by logging in, and you keep access alive by refreshing it before it expires. This page walks you through the full token lifecycle.
Obtaining a token
Call POST /api/auth/login with your email and password. On success, the response includes an access_token and a refresh_token.
Response:
Passing the token
Include the access token in the Authorization header of every request to a protected endpoint:
Token expiry and refresh
Access tokens expire after 30 minutes. Before making a request after expiry, call POST /api/auth/refresh with your refresh token to receive a new token pair.
The response has the same shape as the login response: a new access_token and a new refresh_token. Replace both stored tokens with the new values.
Store your refresh token in a secure, persistent location such as an httpOnly cookie or an encrypted local store. Never expose it in JavaScript accessible to the page or in localStorage without additional protections, as a stolen refresh token grants long-lived access.
Error responses
401 Unauthorized
Returned when the token is missing, malformed, or expired.
403 Forbidden
Returned when the token is valid but the account is inactive.
When you receive a 401, attempt to refresh the access token. If the refresh also fails with a 401, the user’s session has expired and they must log in again.