Authentication

Updated on April 10, 2022

Before you can authenticate and receive events, you need to connect to the RTM API. Please read our RTM API Quickstart guide first.

Authentication Payload

Once the connection is opened, you need to authenticate and tell the server which events you are interested in.

Send an authentication payload, with eg. the following data:

{
  // Set authentication tier to 'plugin', as we are using a plugin token
  "tier": "plugin",

  // Replace '<token_identifier>' + '<token_key>' with relevant values
  // The same credentials are used for REST API authentication
  "username": "<token_identifier>",
  "password": "<token_key>",

  "events": [
    // List of events to subscribe to (replace this with your values), eg:
    "message:send",
    "message:received",
    "message:updated",
    "message:removed"
  ],

  "rooms": [
    // List of rooms (website IDs of yours) to subscribe to (replace this with your values), eg:
    "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"
  ]
}

Handing Success or Failure

Once the authentication payload event has been received by the server and processed, the server will either acknowledge authentication success, or disconnect you if it failed.

You will start receiving real-time events as soon as your authentication tokens are confirmed to be valid.

Authentication success

The server will reply with an empty authenticated event.

Authentication failure

The server will reply with an unauthorized event. It will then immediately close the connection.