Get started
JWT authentication
How to sign in, call APIs with JWT, and refresh tokens.
Follow these steps to authenticate and call the API.
1. Sign in to get tokens
Nhất Tín provides credentials for each environment.
curl --request POST \
--url https://apisandbox.ntlogistics.vn/v1/auth/sign-in \
--header "Content-Type: application/json" \
--data '{"username":"your_account","password":"your_password"}'Successful sign-in response:
{
"success": true,
"data": {
"jwt_token": "<access_token>",
"token_type": "Bearer",
"token_expires_in": "1m",
"refresh_token": "<refresh_token>",
"refresh_expires_in": "2m"
}
}
Keep refresh_token private. Use it to extend access when the access token expires.
2. Call APIs with the access token
Send the Authorization header with the access token on every request:
GET /v3/your-endpoint
Authorization: Bearer <access_token>
If you receive 401 because the token has expired, refresh the token and retry the request.
3. Refresh the access token
curl --request POST \
--url https://apisandbox.ntlogistics.vn/v1/auth/refresh-token \
--header "Content-Type: application/json" \
--data '{"refresh_token":"<refresh_token>"}'Successful refresh response:
{
"success": true,
"data": {
"jwt_token": "<new_access_token>",
"token_type": "Bearer",
"token_expires_in": "1m",
"refresh_token": "<new_refresh_token>",
"refresh_expires_in": "2m"
}
}
Common errors
| Lỗi | Trạng thái | Khi nào xảy ra | Cách khắc phục |
|---|---|---|---|
| Authentication required | 401 | Missing Authorization header | Add Authorization: Bearer <access_token> |
| Invalid header format | 401 | Header is not in Bearer <token> format | Use the correct Bearer format |
| Token expired | 401 | The access token has expired | Refresh the token and retry |
| Authentication failed | 401 | The token is invalid | Sign in again to get a new token |
| Missing refresh token | 400 | refresh_token is missing in the refresh request | Add refresh_token to the request body |
Updated from the legacy docs on 16/09/2025 by Nhất Tín Logistics.