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
| Header | Value | Description |
|---|---|---|
Content-Type | application/json | Specifies that the request body is in JSON format |
x-store-id | {storeId} | StoreId (replace {storeId} with your actual storeId) |
Authorization | Bearer {token} | Authentication token (replace {token} with your actual token) |
Response Format
Success Response (200 OK)
| Field | Type | Description |
|---|---|---|
message | String | Status message indicating successful login |
data | Object | Contains user details and authentication token |
source | String | Source of the data (e.g., "db") |
Data Object Properties
| Field | Type | Description |
|---|---|---|
email | String | email 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 Code | Description |
|---|---|
| 400 | Bad Request - Invalid parameters or validation failed |
| 401 | Unauthorized - Invalid email or password |
| 403 | Forbidden - Account inactive or suspended |
| 404 | Not Found - Email address not registered |
| 500 | Internal 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
}