API Reference
Logout User
Overview
End the current authenticated client session and invalidate the active Access Token.
Call this endpoint when the client chooses to sign out. After a successful logout, clear all locally stored credentials and redirect the user to the login flow before making any further protected API requests.
When to use this endpoint?
Use Logout User when:
- The client explicitly signs out of your application.
- You need to end the current session for security or account-switch flows.
- You want to invalidate the active Access Token on the server side.
- The application is cleaning up credentials before returning to a public or login screen.
{baseUrl}/api/{apiVersion}/auth/jwt/client/logoutAuthentication
Required (Bearer token)
Tenant-scoped
No (root DB)
Request Headers
| Header | Value | Description |
|---|---|---|
| Authorization | Bearer <access_token> | The active Access Token for the session being ended. |
| Content-Type | application/json | Recommended for consistency with other Auth endpoints. |
| is-tenant | false | Targets the root DB for client authentication endpoints. |
Example Request
Authorization: Bearer <access_token>
is-tenant: false
Content-Type: application/jsonRequest Parameters
This endpoint does not require a request body.
Success Response (HTTP 200 OK)
When logout succeeds, the API confirms that the session has ended.
{
"success": true,
"message": "Logged out successfully",
"data": null,
"error": null
}After Logout
Clear credentials on the client
A successful logout response should always be followed by local session cleanup.
Access Token
ClearRemove it from storage. It should no longer be sent with API requests.
Refresh Token
ClearDelete the Refresh Token so the previous session cannot be renewed.
Next Step
LoginRedirect the client to Auth → Login Client to start a new session.
Workflow
Follow this flow to end a client session safely and return the user to an unauthenticated state.
- 1
Confirm the Active Session
Ensure the client still has a valid Access Token before calling Logout. Use Is Logged In if you need to verify the session first.
- 2
Call Logout
Send a POST request to the Logout endpoint with the Access Token in the Authorization header.
httpAuthorization: Bearer <access_token> - 3
Server Ends the Session
RealtimeX invalidates the current authenticated session so the Access Token can no longer be used for protected requests.
- 4
Clear Local Credentials
Remove the Access Token, Refresh Token, and any cached client session data from your application storage.
- 5
Redirect to Login
Send the client back to the login screen. A new Register Client or Login Client call is required before accessing protected APIs again.
Common Errors
Logout fails when the Access Token is missing, invalid, or already expired.
HTTP 401 Unauthorized
{
"success": false,
"message": "No token, authorization denied",
"data": null,
"error": "Unauthorized"
}| Code | Reason |
|---|---|
| 400 Bad Request | Required headers are missing or invalid. |
| 401 Unauthorized | Access Token is missing, invalid, or expired. |
| 500 Internal Server Error | An unexpected error occurred while ending the session. |
Session ended cleanly
After logout, keep the user on a public screen until they authenticate again with Auth → Login Client or Auth → Register Client.
Best Practices
- Always clear Access Token and Refresh Token from local storage after a successful logout response.
- Even if the API returns 401 because the token already expired, still clear local credentials and redirect to login.
- Do not keep calling protected APIs after logout until the client authenticates again.
- Use HTTPS for all authentication requests, including logout.
- Prefer a single logout path in your UI so session cleanup stays consistent across the app.