Skip to main content

Version: v1

Logout User

Terminates a user's session by clearing the HTTP-only refresh token cookie. Upon successful logout, the user will need to re-authenticate to access the protected routes.


HTTP Method & Endpoint​

GET | /auth/logout


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)
AuthorizationBearer {token}Authentication token (replace {token} with your actual token)

Response Format​

Success Response (200 OK)​

FieldTypeDescription
messageStringStatus message indicating successful login
dataObjectContains user details and authentication token
sourceStringSource of the data (e.g., "db")

Data Object Properties​

FieldTypeDescription
emailStringemail id of the user

Sample Success Response​

{
"message": "Logout Success",
"data": {
"email": "abc@gmail.com"
},
"source": ""
}

Examples​

cURL​

curl --location 'https://dev-sfapi.unisouk.com/auth/logout' \
--header 'x-store-id: <STORE_ID>' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <TOKEN>' \
--data ''

JavaScript (React)​

import axios from "axios";

const loginUser = async () => {
try {
const response = await axios.get(
"https://dev-sfapi.unisouk.com/auth/logout",

{
headers: {
"Content-Type": "application/json",
"x-store-id": "<STORE_ID>",
Authorization: "Bearer <TOKEN>",
},
}
);

console.log("Logout successful:", response.data);
} catch (error) {
console.error("Logout failed:", error.response?.data || error.message);
}
};

Error Responses​

Status CodeDescription
400Bad Request - Invalid parameters or validation failed
401Unauthorized - Invalid email or password
403Forbidden - Account inactive or suspended
404Not Found - Email address not registered
500Internal Server Error - Something went wrong on the server

Sample Error Responses​

Invalid Credentials:

{
"requestId": "8d472d95-140e-414d-bbd7-26f0b82bd059",
"error": "UnauthorizedException",
"statusCode": 401,
"message": "Unauthorized",
"path": "/auth/logout",
"timestamp": 1748353090215
}