Refresh

View as Markdown
# BizMail API 1.0 — Refresh Token --- ## 🇬🇧 English > **Note:** Username and password are generated in the **BizMail Portal**. Please log in to your account at the portal to obtain your credentials before calling these APIs. --- ### Refresh Token **`POST /api/1.0/auth/refresh`** Use the `refresh_token` to get a new pair of access token and refresh token without re-entering credentials. #### Headers | Key | Value | Required | |-----|-------|----------| | Content-Type | application/json | ✅ | #### Body (JSON) | Field | Type | Required | Description | |-------|------|----------|-------------| | refresh_token | string | ✅ | The refresh token received from `POST /api/1.0/auth/token` | #### Example Request ```json { "refresh_token": "<jwt_refresh_token>" } ``` #### Responses **200 OK — Success** ```json { "success": true, "access_token": "<new_jwt_access_token>", "refresh_token": "<new_jwt_refresh_token>", "token_type": "Bearer", "expires_in": 86400 } ``` | Field | Type | Description | |-------|------|-------------| | access_token | string | New JWT token for API authentication. Expires in **1 day** | | refresh_token | string | New refresh token. Expires in **90 days** | | token_type | string | Always `Bearer` | | expires_in | integer | Access token lifetime in seconds (86400 = 1 day) | **400 Bad Request — Missing field** ```json { "success": false, "message": "refresh_token is required" } ``` **401 Unauthorized — Token expired** ```json { "success": false, "message": "Refresh token expired" } ``` **401 Unauthorized — Invalid token** ```json { "success": false, "message": "Invalid refresh token" } ``` **401 Unauthorized — User not found** ```json { "success": false, "message": "User not found" } ``` **500 Internal Server Error** ```json { "success": false, "message": "Internal server error" } ``` --- ### Usage Use the new `access_token` in subsequent requests via the `Authorization` header: ``` Authorization: Bearer <access_token> ``` When the `refresh_token` also expires (after 90 days), call `POST /api/1.0/auth/token` again to get a new pair. --- --- ## 🇻🇳 Tiếng Việt > **Lưu ý:** Username và password được tạo trên **BizMail Portal**. Vui lòng đăng nhập vào tài khoản của bạn trên portal để lấy thông tin đăng nhập trước khi gọi các API này. --- ### Refresh Token **`POST /api/1.0/auth/refresh`** Dùng `refresh_token` để lấy cặp token mới mà không cần nhập lại username/password. #### Headers | Key | Value | Bắt buộc | |-----|-------|----------| | Content-Type | application/json | ✅ | #### Body (JSON) | Tham số | Kiểu | Bắt buộc | Mô tả | |---------|------|----------|-------| | refresh_token | string | ✅ | Refresh token nhận được từ `POST /api/1.0/auth/token` | #### Ví dụ Request ```json { "refresh_token": "<jwt_refresh_token>" } ``` #### Responses **200 OK — Thành công** ```json { "success": true, "access_token": "<new_jwt_access_token>", "refresh_token": "<new_jwt_refresh_token>", "token_type": "Bearer", "expires_in": 86400 } ``` | Trường | Kiểu | Mô tả | |--------|------|-------| | access_token | string | JWT token mới dùng để xác thực API. Hết hạn sau **1 ngày** | | refresh_token | string | Refresh token mới. Hết hạn sau **90 ngày** | | token_type | string | Luôn là `Bearer` | | expires_in | integer | Thời hạn access token tính bằng giây (86400 = 1 ngày) | **400 Bad Request — Thiếu tham số** ```json { "success": false, "message": "refresh_token is required" } ``` **401 Unauthorized — Token hết hạn** ```json { "success": false, "message": "Refresh token expired" } ``` **401 Unauthorized — Token không hợp lệ** ```json { "success": false, "message": "Invalid refresh token" } ``` **401 Unauthorized — Không tìm thấy user** ```json { "success": false, "message": "User not found" } ``` **500 Internal Server Error** ```json { "success": false, "message": "Internal server error" } ``` --- ### Cách sử dụng Dùng `access_token` mới trong header `Authorization` của các request tiếp theo: ``` Authorization: Bearer <access_token> ``` Khi `refresh_token` cũng hết hạn (sau 90 ngày), gọi lại `POST /api/1.0/auth/token` để lấy cặp token mới.

Request

This endpoint expects a multipart form.
refresh_tokenstringRequired

Response headers

x-powered-bystring
etagstring
front-end-httpsstring
strict-transport-securitystring

Response

OK
successboolean
access_tokenstring
refresh_tokenstring
token_typestring
expires_ininteger

Errors

401
Unauthorized Error