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
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
Add Tenant Headers
For tenant-scoped APIs, include the required tenant headers with every request.
httpis-tenant: true x-client-id: {client_id} - 3
Authenticate API Requests
Send the Access Token in the Authorization header when calling protected endpoints.
httpAuthorization: Bearer <access_token> - 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
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.
Example Request
GET https://api.example.com/v1/user/profile HTTP/1.1
Host: api.example.com
Authorization: Bearer <access-token>
Content-Type: application/jsonPublic vs Protected Endpoints
| Endpoint Type | Authentication Required |
|---|---|
| Login | No |
| Health Check (if available) | No |
| Protected API Endpoints | Yes |
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 UnauthorizedError Response
{
"success": false,
"message": "Authorization header is missing.",
"data": null,
"error": "Unauthorized"
}HTTP Status
401 UnauthorizedError Response
{
"success": false,
"message": "Invalid or expired access token.",
"data": null,
"error": "Unauthorized"
}HTTP Status
403 ForbiddenError Response
{
"success": false,
"message": "You do not have permission to access this resource.",
"data": null,
"error": "Forbidden"
}Token types
| Token | Obtained From | Used For |
|---|---|---|
| accessToken | Auth → Login Client / Register Client | Client-level (tenant owner) requests |
| refreshToken | Auth → Login Client / Register Client | Auth → New Access Token |
| userAccessToken | User → Login Client User | Conversation 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.