RealTimeX
Start For Free

RealTimeX

API Documentation

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

API Reference

New Access Token

Overview

Use this endpoint to obtain a new Access Token when the current one has expired, without requiring the client to sign in again.

Send a valid Refresh Token from Register Client or Login Client. RealtimeX validates it and returns a fresh Access Token so your application can continue calling protected APIs seamlessly.

When to use this endpoint?

Call New Access Token when:

  • A protected API returns 401 Unauthorized because the Access Token expired.
  • Is Logged In fails and you still have a stored Refresh Token.
  • Your application wants to renew the session silently in the background.
  • You want to avoid forcing the client through a full login flow.

If the Refresh Token is also invalid or expired, redirect the client to Auth → Login Client.

POST{baseUrl}/api/{apiVersion}/auth/jwt/client/refresh-token

Authentication

Not required

Tenant-scoped

No (root DB)

Request Headers

HeaderValueDescription
Content-Typeapplication/jsonSpecifies the content type of the request body.
is-tenantfalseTargets the root DB for client authentication endpoints.

Request Payload

json
{
  "refreshToken": "<refresh_token>"
}
FieldTypeRequiredDescription
refreshTokenstringThe Refresh Token returned from Register Client or Login Client.

Success Response (HTTP 200 OK)

When the Refresh Token is valid, the API returns a new Access Token that you should use for subsequent authenticated requests.

json
{
  "success": true,
  "message": "New access token",
  "data": {
    "accessToken": "<new_access_token>"
  },
  "error": null
}

After a Successful Refresh

Update your session immediately

Discard the expired Access Token and continue with the new one.

New Access Token

Required

Replace the previous token and send it in the Authorization header.

Refresh Token

Keep secure

Continue storing the existing Refresh Token unless your app issues a new one.

Example authenticated request

http
GET /api/v1/user/list HTTP/1.1
Authorization: Bearer <new_access_token>
is-tenant: true
x-client-id: <client_id>

Workflow

Use this flow to recover from an expired Access Token without sending the client back to the login screen.

  1. 1

    Detect an Expired Access Token

    When a protected API returns 401 Unauthorized, or Is Logged In fails, treat the Access Token as expired or invalid.

  2. 2

    Send the Refresh Token

    Call New Access Token with the stored Refresh Token in the request body. Do not send the expired Access Token.

    json
    {
      "refreshToken": "<refresh_token>"
    }
  3. 3

    Receive a New Access Token

    On success, the API returns a fresh Access Token. Replace the previous Access Token in your secure storage.

  4. 4

    Retry the Original Request

    Continue with protected endpoints using the new Access Token in the Authorization header.

    http
    Authorization: Bearer <new_access_token>
  5. 5

    Fall Back to Login if Needed

    If the Refresh Token is invalid or expired, redirect the client to Login Client to start a new session.

Common Errors

If the Refresh Token is missing, invalid, or expired, token renewal fails.

HTTP 401 Unauthorized

json
{
  "success": false,
  "message": "Invalid or expired refresh token",
  "data": null,
  "error": "Unauthorized"
}
CodeReason
400 Bad RequestThe request body is missing refreshToken or contains invalid data.
401 UnauthorizedRefresh Token is missing, invalid, or expired.
500 Internal Server ErrorAn unexpected error occurred while issuing a new Access Token.

You’re ready to continue

After refreshing successfully, retry the original request or continue calling protected APIs with the new Access Token. If refresh fails, send the client to Auth → Login Client.

Best Practices

  • Refresh automatically when you receive 401 Unauthorized from a protected endpoint.
  • Store the Refresh Token securely and never expose it in client-side source code or logs.
  • Replace the Access Token immediately after a successful refresh — do not keep using the expired token.
  • Avoid refreshing on every request. Refresh only when the Access Token is expired or rejected.
  • Always send refresh requests over HTTPS to protect credentials in transit.
  • If refresh fails, clear the local session and redirect to login.
PreviousIs logged inNextLogout client

On this page

OverviewWhen to use this endpoint?Request HeadersRequest PayloadSuccess ResponseAfter a Successful RefreshWorkflowCommon ErrorsBest Practices