RealTimeX
Start For Free

RealTimeX

API Documentation

IntroductionAuthenticationBase URLHeadersError codes
Sample requestsSample responsesStatus codesAppendixChangelog

API Reference

Authentication

Authentication is required for most RealtimeX API endpoints. Every authenticated request must include a valid access token in the Authorization header.

The API usesBearer Token Authenticationto securely identify and authorize clients. Requests made without a valid token will be rejected with an authentication error.

Authentication flow

Follow these steps to authenticate your application and make protected API requests.

  1. 1

    Register or Login Client

    Authenticate your client by calling either Register Client or Login Client. A successful response returns an Access Token and a Refresh Token.

  2. 2

    Add Tenant Headers

    For tenant-scoped APIs, include the required tenant headers with every request.

    http
    is-tenant: true
    x-client-id: {client_id}
  3. 3

    Authenticate API Requests

    Send the Access Token in the Authorization header when calling protected endpoints.

    http
    Authorization: Bearer <access_token>
  4. 4

    Refresh Expired Tokens

    When the Access Token expires, call the New Access Token endpoint using the Refresh Token to receive a new token pair.

  5. 5

    Authenticate End Users

    For Conversations, Messages, and other user-level APIs, authenticate the end user using Login Client User. This returns a separate User Access Token.

Authentication Header

Include the following header with every authenticated request:

terminal
Authorization: Bearer <accessToken>
Example:
terminal
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0.KMUFsIDTnFmyG3nMiGM6H9FNFUROf3wh7SmqJp-QV30

Example Request

http
GET https://api.example.com/v1/user/profile HTTP/1.1
Host: api.example.com
Authorization: Bearer <access-token>
Content-Type: application/json

Public vs Protected Endpoints

Endpoint TypeAuthentication Required
LoginNo
Health Check (if available)No
Protected API EndpointsYes

Always refer to the endpoint documentation to determine whether authentication is required.

Authentication Errors

If authentication fails, the API returns an appropriate HTTP status code and error response.

Missing Authorization Header

HTTP Status

401 Unauthorized

Error Response

terminal
{
  "success": false,
  "message": "Authorization header is missing.",
  "data": null,
  "error": "Unauthorized"
}

HTTP Status

401 Unauthorized

Error Response

terminal
{
  "success": false,
  "message": "Invalid or expired access token.",
  "data": null,
  "error": "Unauthorized"
}

HTTP Status

403 Forbidden

Error Response

terminal
{
  "success": false,
  "message": "You do not have permission to access this resource.",
  "data": null,
  "error": "Forbidden"
}

Token types

TokenObtained FromUsed For
accessTokenAuth → Login Client / Register ClientClient-level (tenant owner) requests
refreshTokenAuth → Login Client / Register ClientAuth → New Access Token
userAccessTokenUser → Login Client UserConversation and Messages endpoints acting as an end user

Security Best Practices

  • Never expose access tokens in client-side source code.
  • Always transmit API requests over HTTPS.
  • Store tokens securely using your application's recommended storage mechanism.
  • Avoid logging sensitive authentication credentials.
  • Immediately revoke or replace compromised tokens.
  • Follow the principle of least privilege when assigning user roles and permissions.

What's Next

Once authentication is configured successfully, you can begin exploring the available API modules, including Users, Conversations, Messages, Roles, and other protected resources available in the RealtimeX API.

PreviousIntroductionNextBase URL

On this page

Authentication flowToken typesAuthorization Header FormatExample RequestPublic vs Protected EndpointsAuthentication ErrorsSecurity Best PracticesWhat's Next