Create rooms and add members from your backend
Your backend can set up rooms before users open the chat: a group room per team, project or order, a 1:1 room between two users, or default rooms that every user joins. All calls on this page use a server JWT (see Connect your users), and the users must already exist in your app.
Names and IDs
| Thing | Format | Example (Ethora Cloud) |
|---|---|---|
Room uuid | Your stable id for the room | project-42 |
Chat name (chatName) | <appId>_<uuid> | <appId>_project-42 |
| Room JID | <appId>_<uuid>@conference.<xmppHost> | <appId>_project-42@conference.xmpp.chat.ethora.com |
Member (xmppUsername) | <appId>_<userId> | <appId>_user-1 |
userId is the uuid you used when you created the user with POST /v1/users/batch. On Ethora Cloud xmppHost is xmpp.chat.ethora.com. On a self-hosted server read it from GET /v1/apps/get-config?domainName=app (result.xmppHost).
Create a group room
POST /v1/chats, header x-custom-token: <server JWT>:
{ "title": "Project Apollo", "uuid": "project-42", "type": "group" }The OpenAPI spec also lists description, picture (an image URL) and members (an array of xmppUsername), and type can be public or group. If you omit uuid, the server generates one. The response is { "result": { "_id", "name", "title", "type", "appId", … } }, where name is the chat name.
Add and remove members
POST /v2/chats/users-access, same header. members are your own user IDs (the uuid each user was created with):
{ "chatName": "<appId>_project-42", "members": ["user-1", "user-2"] }Adding an existing member does nothing, so the call is safe to repeat. The response has ok, summary (requested, byStatus), results (only the newly added users) and details (xmppUsername, status, optional code for each member). To remove members, send the same body with DELETE /v2/chats/users-access.
Per the spec, a server JWT can manage any room of its app. A user token that names an app chat gets 403 APP_CHAT_ADMIN_ROUTE.
Node.js helper
Uses serverToken() from the authentication helper.
// ethora-rooms.js — Node.js >= 18
const { serverToken } = require('./ethora-token');
const APP_ID = process.env.ETHORA_APP_ID;
const API_URL = (process.env.ETHORA_API_URL || 'https://api.chat.ethora.com').replace(/\/v[12]\/?$/, '');
/** Create a group room (idempotent) and add members. Returns the chat name. */
async function ensureRoom({ roomId, title, memberIds = [] }) {
const headers = { 'Content-Type': 'application/json', 'x-custom-token': serverToken() };
const r = await fetch(`${API_URL}/v1/chats`, {
method: 'POST', headers, body: JSON.stringify({ title, uuid: String(roomId), type: 'group' }),
});
if (!r.ok && !/exist|already/i.test(await r.text())) throw new Error(`Ethora room creation failed: ${r.status}`);
const chatName = `${APP_ID}_${roomId}`;
if (memberIds.length) {
const m = await fetch(`${API_URL}/v2/chats/users-access`, {
method: 'POST', headers, body: JSON.stringify({ chatName, members: memberIds }),
});
if (!m.ok) throw new Error(`Ethora add members failed: ${m.status} ${await m.text()}`);
}
return chatName; // room JID: `${chatName}@conference.<xmppHost>`
}
module.exports = { ensureRoom };1:1 private chats
POST /v2/apps/{appId}/chats/private opens a private chat between two users of the app without either of them being the caller:
{ "members": ["user-1", "user-2"] }members: exactly two different users, asxmppUsernameor bare user id (the<appId>_prefix is added when missing).e2ee(optional, defaultfalse): use the pair's end-to-end encrypted room instead. The app needse2eeEnabled, otherwise403 E2EE_DISABLED. Encrypted rooms stay encrypted for life.- Idempotent: a new room answers
201withcreated: true; an existing one200withcreated: false. - The room name is
<xmppUsernameA>-<xmppUsernameB>(sorted), plus-e2eefor the encrypted room. The app's system chat account owns the room and sends both invites.
When a signed-in user starts the chat themselves, the client uses POST /v1/chats/private with { "username": "<xmppUsername>" } and their user token.
Default rooms
Default rooms belong to the app, not to a user.
- An app created with
createDefaultChat: truestarts with a "Main chat". POST /v1/apps/create-app-chat/{appId}(multipart form):titleandpinnedare required.autoJoindefaults totrue, which adds the app's people and every new member to the chat.membersOnly: truemakes a private group room that nobody joins automatically; add people withPOST /v2/apps/{appId}/chats/users-access.GET /v1/apps/get-default-rooms/app-id/{appId}lists them as[{ chatId, title, jid, pinned, autoJoin, creator }].PATCH /v1/apps/{appId}/chats/{jid}/defaultswith{ "autoJoin": false }stops adding new members; nobody is removed.POST /v2/apps/{appId}/provisionwith{ "rooms": [{ "title": "General", "pinned": true }] }creates up to 20 default rooms in one call.
The spec lists a User JWT (app admin) for create-app-chat and get-default-rooms, and accepts a server JWT for the PATCH and provision calls.
App-scoped v2 endpoints
The spec recommends /v2 for new integrations and marks POST /v1/chats as deprecated. These app-scoped endpoints accept a server JWT and keep the target app explicit in the path:
| Endpoint | Purpose |
|---|---|
POST /v2/apps/{appId}/chats | Create a public or group room (same body as above); the app system account owns it |
POST / DELETE /v2/apps/{appId}/chats/users-access | Add or remove members (chatName and members required) |
GET /v2/apps/{appId}/users/{userId}/chats | List the rooms a user belongs to |
PATCH /v2/apps/{appId}/chats/{chatId} | Update title or description |
Open a specific room in the UI
Pass the room JID as roomJID on Chat. On the web, add disableRooms: true to the config to hide the room list (single-room mode).
// ProjectChat.tsx — web, @ethora/chat-component
const roomJID = `${appId}_project-42@conference.xmpp.chat.ethora.com`;
<XmppProvider config={config}>
<Chat config={config} roomJID={roomJID} />
</XmppProvider>React Native (@ethora/chat-component-rn) takes the same prop: <Chat config={config} roomJID={roomJID} />, without an outer XmppProvider.
Next steps
- REST API overview: messages, webhooks and AI agents for your rooms
- If the chat opens with no rooms, create a default room or add the user to a room (see above)
- Interactive API reference: https://api.chat.ethora.com/api-docs/
Stuck or planning something bigger?
Book 15 minutes with the team, or open an issue on GitHub. Self-hosting and enterprise questions are welcome.