Skip to main content

Version: v1

Refresh Access Token

Generate a new access token using the refresh token that was set as an HTTP-only cookie during login. This endpoint helps maintain user sessions without requiring re-authentication.


HTTP Method & Endpoint

GET | /auth/refresh/{storeId}

Path Parameter

ParameterTypeRequiredDescription
storeIdStringYesStoreId (replace {storeId} with your actual storeId)

Request

Headers

HeaderValueDescription
Content-Typeapplication/jsonSpecifies that the request body is in JSON format
x-store-id{storeId}StoreId (replace {storeId} with your actual storeId)
Cookie__Secure-unisouk.{storeId}.refresh-token={token}HTTP-only refresh token cookie (set by the server; inaccessible to JavaScript )

HTTP Method & Endpoint

GET | /auth/refresh/{storeId}

Path Parameter

ParameterTypeRequiredDescription
storeIdStringYesStoreId (replace {storeId} with your actual storeId)

Request

Headers

HeaderValueDescription
Content-Typeapplication/jsonSpecifies that the request body is in JSON format
x-store-id{storeId}StoreId (replace {storeId} with your actual storeId)
Cookie__Secure-unisouk.{storeId}.refresh-token={token}HTTP-only refresh token cookie (set by the server; inaccessible to JavaScript )
warning

The refresh token cookie is automatically sent by the browser when this API is called. You do not need to include it manually in your request.

Important Notes:

  1. The refresh token cookie is automatically set by the Login API upon successful authentication
  2. The cookie is HTTP-only and Secure, making it inaccessible to client-side JavaScript
  3. The cookie name follows the pattern: __Secure-unisouk.{storeId}.refresh-token
  4. The access tokens have short expiration times (ie 15 minutes)

Response Format

Success Response (200 OK)

{
"message": "Refresh Success.",
"data": {
"customer": {
"id": "2342341293912113",
"storeId": "2342341293912313",
"email": "abc@gmail.com",
"mobileNumber": null,
"emailVerified": "2025-05-16T06:26:16.513Z",
"mobileVerified": null,
"status": "ACTIVE",
"createdAt": "2025-05-16T06:25:36.043Z",
"updatedAt": "2025-05-16T06:26:16.514Z"
},
"accessToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImtleV9Udm1iWVUyWEdiSDk0TnpaIn0...."
},
"source": "db"
}

Data properties

FieldTypeDescription
accessTokenStringNew JWT access token
customerCustomerContains all details about the authenticated user

Customer Properties

FieldTypeDescriptionFormat/Values
idStringUnique identifier for the customerBigInt( eg. 2342341293912313)
storeIdStringUnique identifier of the associated storeBigInt( eg. 2342341293912313)
emailStringCustomer's email addressValid email format
emailVerifiedStringTimestamp when the email was last verifiedISO 8601 format (e.g., "2025-05-16T06:26:16.514Z")
statusEnumCurrent status of the customer accountACTIVE or INACTIVE
createdAtStringTimestamp when the customer account was createdISO 8601 format (e.g., "2025-05-16T06:26:16.514Z")
updatedAtStringTimestamp when the customer account was last updatedISO 8601 format (e.g., "2025-05-16T06:26:16.514Z")

Notes:

  1. All timestamp fields use ISO 8601 format with millisecond precision and UTC timezone (Z suffix)
  2. The status field is restricted to two possible values: ACTIVE or INACTIVE
  3. The emailVerified field will be null if the email hasn't been verified

Examples

JavaScript (React)

Since the refresh token is HTTP-only, browser JavaScript cannot directly access it. This logic — including automatic token refreshing and cookie handling — is already implemented as part of the token management setup in the Axios Interceptor Setup section.

No additional changes are required here; your requests will automatically include the cookie, and expired tokens will be refreshed as needed.


Error Responses

Status CodeError TypeDescription
400BadRequestExceptionInvalid customer ID or missing store ID header
401UnauthorizedExceptionInvalid or expired refresh token
403ForbiddenExceptionAccount inactive or suspended
404NotFoundExceptionCustomer record not found
500InternalServerErrorServer error during token generation

Sample Error Response

{
"requestId": "c7d4e5f6-g8h9-i1j2-k3l4-m5n6o7p8q9r0",
"error": "UnauthorizedException",
"statusCode": 401,
"message": "Refresh token expired",
"path": "/auth/refresh/2342341293912313",
"timestamp": 1747838047845
}