RealTimeX
Start For Free

RealTimeX

API Documentation

IntroductionAuthenticationBase URLHeadersError codes
RegisterLoginIs logged inRefresh tokenLogout client
Sample requestsSample responsesStatus codesAppendixChangelog

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.
POST{baseUrl}/api/{apiVersion}/auth/jwt/client/logout

Authentication

Required (Bearer token)

Tenant-scoped

No (root DB)

Request Headers

HeaderValueDescription
AuthorizationBearer <access_token>The active Access Token for the session being ended.
Content-Typeapplication/jsonRecommended for consistency with other Auth endpoints.
is-tenantfalseTargets the root DB for client authentication endpoints.

Example Request

http
Authorization: Bearer <access_token>
is-tenant: false
Content-Type: application/json

Request 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.

json
{
  "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

Clear

Remove it from storage. It should no longer be sent with API requests.

Refresh Token

Clear

Delete the Refresh Token so the previous session cannot be renewed.

Next Step

Login

Redirect 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. 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. 2

    Call Logout

    Send a POST request to the Logout endpoint with the Access Token in the Authorization header.

    http
    Authorization: Bearer <access_token>
  3. 3

    Server Ends the Session

    RealtimeX invalidates the current authenticated session so the Access Token can no longer be used for protected requests.

  4. 4

    Clear Local Credentials

    Remove the Access Token, Refresh Token, and any cached client session data from your application storage.

  5. 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

json
{
  "success": false,
  "message": "No token, authorization denied",
  "data": null,
  "error": "Unauthorized"
}
CodeReason
400 Bad RequestRequired headers are missing or invalid.
401 UnauthorizedAccess Token is missing, invalid, or expired.
500 Internal Server ErrorAn 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.
PreviousRefresh tokenNextGet profile

On this page

OverviewWhen to use this endpoint?Request HeadersRequest ParametersSuccess ResponseAfter LogoutWorkflowCommon ErrorsBest Practices