logout
Method: POST
Path: /auth/logout
Tags: Auth
Summary
Logout user
Description
The Logout User API initiate the logout process for a user. Upon a successful request, the API responds with a confirmation message. If the user is not found or there's an issue with the request, an error response is returned with an appropriate message.
Storefront SDK Usage
SDK Method: sdk.auth.logout()
Example:
typescript
// Logout current user
const { data, error } = await sdk.auth.logout();
if (error) {
console.error("Logout failed:", error.message);
} else {
console.log("Logout successful");
console.log("Session ended for user:", data.user.email);
}TypeScript Definition
typescript
logout: {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody?: never;
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": {
/** @description A descriptive message confirming the success or failure of the operation. */
message: string;
/** @description Indicates whether the request was successful or failure (true for success, false for failure). */
success: boolean;
/** @description An object containing the response content. */
content: {
/** @description It is a string-based token utilized for authentication and authorization. */
access_token: string;
/** @description It is a string-based token designed for refreshing the user's access token. */
refresh_token: string;
/** @description An object representing user details. */
user: components["schemas"]["User"];
};
};
};
};
400: components["responses"]["BadRequest"];
401: components["responses"]["Unauthorized"];
404: components["responses"]["NotFound"];
};Component References
| Reference | Resolves To |
|---|---|
components["schemas"]["User"] | User |
components["responses"]["BadRequest"] | BadRequest |
components["responses"]["Unauthorized"] | Unauthorized |
components["responses"]["NotFound"] | NotFound |
Responses
200
OK
400
Bad request
401
Not authorized for given operation on the Resource
404
Requested resource not found
OpenAPI Definition
json
{
"tags": [
"Auth"
],
"operationId": "logout",
"summary": "Logout user",
"description": "The Logout User API initiate the logout process for a user. Upon a successful request, the API responds with a confirmation message. If the user is not found or there's an issue with the request, an error response is returned with an appropriate message.",
"externalDocs": {
"url": "https://llm-docs.commercengine.io/storefront/operations/logout",
"description": "API reference for the logout operation"
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"message",
"success",
"content"
],
"properties": {
"message": {
"description": "A descriptive message confirming the success or failure of the operation.",
"type": "string"
},
"success": {
"description": "Indicates whether the request was successful or failure (true for success, false for failure).",
"type": "boolean"
},
"content": {
"description": "An object containing the response content.",
"properties": {
"access_token": {
"description": "It is a string-based token utilized for authentication and authorization.",
"type": "string"
},
"refresh_token": {
"description": "It is a string-based token designed for refreshing the user's access token.",
"type": "string"
},
"user": {
"description": "An object representing user details.",
"$ref": "#/components/schemas/User"
}
},
"required": [
"access_token",
"refresh_token",
"user"
],
"type": "object"
}
}
}
}
}
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"404": {
"$ref": "#/components/responses/NotFound"
}
},
"security": [
{
"Authorization": []
}
],
"x-speakeasy-group": "auth",
"x-speakeasy-ignore": false,
"x-speakeasy-name-override": "logout"
}Auto-generated from OpenAPI spec and TypeScript definitions