Add Users to Channel

Prev Next
Post
/api/v1/channels.invite

Add a user or bulk users to a channel.

For a user to invite other users, they must match at least one of the following premises:

  • The user is a member of the channel and has the add-user-to-joined-room (Add user to any joined channel) permission.
  • The user has the add-user-to-any-c-room (Add user to any public channel) permission.

You can identify the channel by roomId or roomName, and the users either by ID (userId, userIds) or by username (username, user, usernames). You cannot mix IDs and usernames in the same request.

Users that do not exist are skipped and the valid users are invited. If none of the users you provide exist, the request fails with invalid-user-invite-list. Users who are already members of the channel are ignored, and the request still succeeds.

Changelog

Version Description
9.0.0 Added the userIds and usernames parameters to invite multiple users in one request.
0.48.0 Added
Header parameters
X-Auth-Token
stringRequired

The authToken of the authenticated user.

ExampleRScctEHSmLGZGywfIhWyRpyofhKOiMoUIpimhvheU3f
X-User-Id
stringRequired

The userId of the authenticated user.

ExamplerbAXPnMktTFbNpwtJ
Body parameters
Invite by ID
{
  "roomId": "nSYqWzZ4GsKTX4dyK",
  "userId": "ByehQjC44FwMeiLbX"
}
Invite multiple users by ID
{
  "roomId": "nSYqWzZ4GsKTX4dyK",
  "userIds": [
    "ByehQjC44FwMeiLbX",
    "Wq3kLm8TzR2vNpX5d"
  ]
}
Invite multiple users by username
{
  "roomName": "general",
  "usernames": [
    "john.doe",
    "jane.doe"
  ]
}
object
roomId
string

The channel's ID. This parameter is required if no roomName is provided.

ExamplenSYqWzZ4GsKTX4dyK
roomName
string

The channel's name. This parameter is required if no roomId is provided.

Examplegeneral
userId
string

The ID of the user to invite. Cannot be combined with username, user, or usernames.

ExampleByehQjC44FwMeiLbX
userIds
Array of string

An array of IDs of the users to invite. Cannot be combined with username, user, or usernames.

Example[ "ByehQjC44FwMeiLbX", "Wq3kLm8TzR2vNpX5d" ]
string
username
string

The username of the user to invite. Cannot be combined with userId or userIds.

Examplejohn.doe
user
string

The username of the user to invite. Alternative to username. Cannot be combined with userId or userIds.

Examplejohn.doe
usernames
Array of string

An array of usernames of the users to invite. Cannot be combined with userId or userIds.

Example[ "john.doe", "jane.doe" ]
string

You can enter the user ID of one user or add multiple users. Use any one of the objects above as the body parameters.

Responses
200

OK

Add bulk users
{
  "channel": {
    "_id": "nSYqWzZ4GsKTX4dyK",
    "fname": "testing",
    "_updatedAt": "2026-11-02T20:32:22.790Z",
    "name": "testing",
    "t": "c",
    "msgs": 2,
    "usersCount": 3,
    "u": {
      "_id": "uXquEbv7EkGHfBLa3",
      "username": "admin",
      "name": "Admin"
    },
    "ts": "2026-11-02T20:32:22.614Z",
    "ro": false,
    "default": false,
    "sysMes": true
  },
  "success": true
}
Add a user
{
  "channel": {
    "_id": "nSYqWzZ4GsKTX4dyK",
    "fname": "testing",
    "_updatedAt": "2026-11-02T20:32:22.790Z",
    "name": "testing",
    "t": "c",
    "msgs": 1,
    "usersCount": 2,
    "u": {
      "_id": "uXquEbv7EkGHfBLa3",
      "username": "admin",
      "name": "Admin"
    },
    "ts": "2026-11-02T20:32:22.614Z",
    "ro": false,
    "default": false,
    "sysMes": true
  },
  "success": true
}
Expand All
object
channel
object
_id
string
fname
string
customFields
object
description
string
broadcast
boolean
encrypted
boolean
federated
boolean
name
string
t
string
msgs
integer
usersCount
integer
u
object
_id
string
username
string
ts
string
ro
boolean
default
boolean
sysMes
boolean
_updatedAt
string
lm
string
lastMessage
object
_id
string
t
string
msg
string
groupable
boolean
blocks
Array of object
object
type
string
blockId
string
callId
string
appId
string
ts
string
u
object
_id
string
username
string
name
string
rid
string
_updatedAt
string
urls
Array of object
object
mentions
Array of object
object
channels
Array of object
object
success
boolean
400

Bad Request

IDs and Usernames Combined
{
  "success": false,
  "errorType": "error-invalid-params",
  "error": "must NOT be valid"
}
User parameter required
{
  "success": false,
  "error": "Please provide \"userId\" or \"username\" or \"userIds\" or \"usernames\" as param [error-users-params-not-provided]",
  "errorType": "error-users-params-not-provided"
}
Not allowed
{
  "success": false,
  "error": "Not allowed [error-not-allowed]",
  "errorType": "error-not-allowed",
  "details": {
    "method": "addUsersToRoom"
  }
}
No users to invite
{
  "success": false,
  "error": "invalid-user-invite-list",
  "errorType": "Cannot invite if no users are provided"
}
Expand All
object
success
boolean
error
string
errorType
string
details
object
method
string
401

Unauthorized

Authorization Error
{
  "success": false,
  "error": "You must be logged in to do this."
}
object
success
boolean
error
string