--- title: ServerTeam subtitle: Reference for the ServerTeam object enableTableOfContents: true tag: beta --- ## `ServerTeam` The `ServerTeam` object is used on the server side to represent a team. It includes all the functionality of a `Team` object, plus additional server-side functionality. ### Table of Contents ```typescript type ServerTeam = // Inherits all functionality from Team & Team & { serverMetadata: Json; serverReadOnlyMetadata: Json; listUsers(): Promise; getTeamProfile(user): Promise; hasPermission(scope, permissionId): Promise; getPermission(scope, permissionId[, options]): Promise; listPermissions(scope[, options]): Promise; listContactChannels(): Promise; createApiKey(options): Promise; listApiKeys(): Promise; }; ``` ### `serverTeam.serverMetadata` The server metadata of the team as a `Json` object. This can be modified by the server. ```typescript declare const serverMetadata: Json; ``` ### `serverTeam.serverReadOnlyMetadata` The server read-only metadata of the team as a `Json` object. This cannot be modified by the server. ```typescript declare const serverReadOnlyMetadata: Json; ``` ### `serverTeam.listUsers()` Lists all users in the team. #### Returns `Promise`: The list of users ```typescript declare function listUsers(): Promise; ``` ### `serverTeam.getTeamProfile(user)` Gets the team profile for a user. #### Parameters - `user`: The user #### Returns `Promise`: The team profile ```typescript declare function getTeamProfile(user: ServerUser): Promise; ``` ### `serverTeam.hasPermission(scope, permissionId)` Checks if the team has a permission. #### Parameters - `scope`: The scope of the permission - `permissionId`: The ID of the permission #### Returns `Promise`: Whether the team has the permission ```typescript declare function hasPermission(scope: string, permissionId: string): Promise; ``` ### `serverTeam.getPermission(scope, permissionId[, options])` Gets a permission. #### Parameters - `scope`: The scope of the permission - `permissionId`: The ID of the permission - `options`: An object containing options: - `or`: What to do if the permission is not found: - `"return-null"`: Return null (default) - `"throw"`: Throw an error #### Returns `Promise`: The permission, or `null` if not found ```typescript declare function getPermission( scope: string, permissionId: string, options?: { or?: 'return-null' | 'throw'; } ): Promise; ``` ### `serverTeam.listPermissions(scope[, options])` Lists all permissions in a scope. #### Parameters - `scope`: The scope of the permissions - `options`: An object containing options: - `or`: What to do if no permissions are found: - `"return-empty"`: Return an empty array (default) - `"throw"`: Throw an error #### Returns `Promise`: The list of permissions ```typescript declare function listPermissions( scope: string, options?: { or?: 'return-empty' | 'throw'; } ): Promise; ``` ### `serverTeam.listContactChannels()` Lists all contact channels for the team. #### Returns `Promise`: The list of contact channels ```typescript declare function listContactChannels(): Promise; ``` ### `serverTeam.createApiKey(options)` Creates a new API key for the team. #### Parameters - `options`: An object containing options: - `name`: The name of the API key - `expiresAt`: The expiration date of the API key #### Returns `Promise`: The created API key ```typescript declare function createApiKey(options: { name: string; expiresAt?: Date; }): Promise; ``` ### `serverTeam.listApiKeys()` Lists all API keys for the team. #### Returns `Promise`: The list of API keys ```typescript declare function listApiKeys(): Promise; ```