Class

SynapseAdminApis

SynapseAdminApis()

Access to various administrative APIs specifically available in Synapse.
Constructor

# new SynapseAdminApis()

View Source SynapseAdminApis.ts, line 27

Classes

SynapseAdminApis

Methods

# async createRegistrationToken(options)

Create a new registration token.
Parameters:
Name Type Description
options Options to pass to the request.

View Source SynapseAdminApis.ts, line 527

The newly created token.

# async deleteRegistrationToken(token)

Delete a registration token
Parameters:
Name Type Description
token The token to update.

View Source SynapseAdminApis.ts, line 546

A promise that resolves upon success.

# async deleteRoom(roomId) → {Promise}

Deletes a room from the server, purging all record of it.
Parameters:
Name Type Description
roomId string The room to delete.

View Source SynapseAdminApis.ts, line 488

Resolves when complete.
Promise

# async getDeleteRoomState(roomId) → {Promise.<Array.<any>>}

Gets the status of all active deletion tasks, and all those completed in the last 24h, for the given room_id.
Parameters:
Name Type Description
roomId string The room ID to get deletion state for.

View Source SynapseAdminApis.ts, line 497

Resolves to the room's deletion status results.
Promise.<Array.<any>>

# async getRegistrationToken(token)

Get details about a single token.
Parameters:
Name Type Description
token The token to fetch.

View Source SynapseAdminApis.ts, line 518

A registration tokens, or null if not found.

# async getRoomState(roomId) → {Promise.<Array.<any>>}

Gets a list of state events in a room.
Parameters:
Name Type Description
roomId string The room ID to get state for.

View Source SynapseAdminApis.ts, line 479

Resolves to the room's state events.
Promise.<Array.<any>>

# async getUser(userId) → {Promise.<SynapseUser>}

Get information about a user. The client making the request must be an admin user.
Parameters:
Name Type Description
userId string The user ID to check.

View Source SynapseAdminApis.ts, line 394

The resulting Synapse user record
Promise.<SynapseUser>

# async isAdmin(userId) → {Promise.<boolean>}

Determines if the given user is a Synapse server administrator for this homeserver. The client making the request must be an admin user themselves (check with `isSelfAdmin`)
Parameters:
Name Type Description
userId string The user ID to check.

View Source SynapseAdminApis.ts, line 448

Resolves to true if the user is an admin, false otherwise. Throws if there's an error.
Promise.<boolean>

# async isSelfAdmin() → {Promise.<boolean>}

Determines if the current user is an admin for the Synapse homeserver.

View Source SynapseAdminApis.ts, line 457

Resolve to true if the user is an admin, false otherwise. Throws if there's an error.
Promise.<boolean>

# async listAllUsers(options) → {AsyncGenerator.<SynapseUserListing>}

Get a list of all users registered with Synapse, optionally filtered by some criteria. The client making the request must be an admin user. This method returns an async generator that can be used to filter results.
Parameters:
Name Type Description
options Options to pass to the user listing function

View Source SynapseAdminApis.ts, line 437

AsyncGenerator.<SynapseUserListing>
Example
for await (const user of synapseAdminApis.listAllUsers()) {
   if (user.name === '@alice:example.com') {
      return user;
   }
}

# async listRegistrationTokens(valid)

List all registration tokens on the homeserver.
Parameters:
Name Type Description
valid If true, only valid tokens are returned. If false, only tokens that have expired or have had all uses exhausted are returned. If omitted, all tokens are returned regardless of validity.

View Source SynapseAdminApis.ts, line 509

An array of registration tokens.

# async listRooms(searchTerm, from, limit, orderBy, reverseOrder) → {Promise.<SynapseRoomList>}

Lists the rooms on the server.
Parameters:
Name Type Description
searchTerm string A term to search for in the room names
from string A previous batch token to search from
limit number The maximum number of rooms to return
orderBy SynapseRoomProperty A property of rooms to order by
reverseOrder boolean True to reverse the orderBy direction.

View Source SynapseAdminApis.ts, line 470

Resolves to the server's rooms, ordered and filtered.
Promise.<SynapseRoomList>

# async listUsers(from, limit, name, guests, deactivated) → {Promise.<SynapseUserList>}

Get a list of users registered with Synapse, optionally filtered by some criteria. The client making the request must be an admin user.
Parameters:
Name Type Description
from string The token to continue listing users from.
limit number The maximum number of users to request.
name string Optional localpart or display name filter for results.
guests boolean Whether or not to include guest accounts. Default true.
deactivated boolean Whether or not to include deactivated accounts. Default false.

View Source SynapseAdminApis.ts, line 419

A batch of user results.
Promise.<SynapseUserList>

# async makeRoomAdmin(roomId, userId)

Grants another user the highest power available to a local user who is in the room. If the user is not in the room, and it is not publicly joinable, then invite the user.
Parameters:
Name Type Description
roomId The room to make the user admin in.
userId The user to make admin in the room. If undefined, it uses the authenticated user.

View Source SynapseAdminApis.ts, line 557

Resolves when complete.

# async updateRegistrationToken(token, options)

Update an existing registration token.
Parameters:
Name Type Description
token The token to update.
options Options to pass to the request.

View Source SynapseAdminApis.ts, line 537

The newly created token.

# async upsertUser(userId, opts) → {Promise.<SynapseUser>}

Create or update a given user on a Synapse server. The client making the request must be an admin user.
Parameters:
Name Type Description
userId string The user ID to check.
opts SynapseUserProperties Options to set when creating or updating the user.

View Source SynapseAdminApis.ts, line 405

The resulting Synapse user record
Promise.<SynapseUser>