View Source Appwrite.Services.Teams (appwrite v0.2.1)
The Teams service allows you to group users of your project and enable them to share read and write access to your project resources.
Each user who creates a team becomes the team owner and can delegate the ownership role by assigning it to another team member. Only the team owner can invite new members, add new owners, and delete or update the team.
A team member of any role can invite new members, but only the owner can delete the team. Invitations can be sent by email or via team invite URLs.
Summary
Functions
Create a new team.
Invite a new member to join a team.
Delete a team.
Delete a team membership.
Get a team by its ID.
Get a team member by their membership ID.
Get a team's shared preferences.
List all teams in which the current user is a member.
List a team's members.
Update a team's name.
Modify the roles of a team member.
Accept a team membership invitation.
Update a team's shared preferences.
Functions
@spec create(String.t(), String.t(), [String.t()] | nil) :: {:ok, Appwrite.Types.Team.t()} | {:error, Appwrite.Exceptions.AppwriteException.t()}
Create a new team.
The user who creates the team is automatically assigned the owner role. Only owners can invite new members, add owners, and delete or update the team.
Parameters
team_id(String.t()): Team ID. UseID.unique()or provide a custom ID. Valid chars: a-z, A-Z, 0-9,.,-,_. Max length: 36 chars.name(String.t()): Team name. Max length: 128 chars.roles([String.t()] | nil): Initial roles for the creator. Defaults to["owner"].
Returns
{:ok, Team.t()}on success.{:error, AppwriteException.t()}on failure.
@spec create_membership(String.t(), [String.t()], keyword()) :: {:ok, Appwrite.Types.Membership.t()} | {:error, Appwrite.Exceptions.AppwriteException.t()}
Invite a new member to join a team.
Provide an ID for existing users, or invite unregistered users via email or phone. From a client SDK, Appwrite will send an email or SMS with a link to join the team.
Parameters
team_id(String.t()): Team ID.roles([String.t()]): Roles to assign to the new member.opts(keyword()): Optional fields::email(String.t()) — email of the new member.:user_id(String.t()) — ID of an existing user to add.:phone(String.t()) — phone number of the new member.:url(String.t()) — redirect URL for the invitation email.:name(String.t()) — name of the new member.
Returns
{:ok, Membership.t()}on success.{:error, AppwriteException.t()}on failure.
@spec delete(String.t()) :: {:ok, map()} | {:error, Appwrite.Exceptions.AppwriteException.t()}
Delete a team.
Only team members with the owner role can delete the team.
Parameters
team_id(String.t()): Team ID.
Returns
{:ok, map()}on success.{:error, AppwriteException.t()}on failure.
@spec delete_membership(String.t(), String.t()) :: {:ok, map()} | {:error, Appwrite.Exceptions.AppwriteException.t()}
Delete a team membership.
Allows a user to leave a team, or a team owner to remove any member. Also works for unaccepted invitations.
Parameters
team_id(String.t()): Team ID.membership_id(String.t()): Membership ID.
Returns
{:ok, map()}on success.{:error, AppwriteException.t()}on failure.
@spec get(String.t()) :: {:ok, Appwrite.Types.Team.t()} | {:error, Appwrite.Exceptions.AppwriteException.t()}
Get a team by its ID.
All team members have read access to this endpoint.
Parameters
team_id(String.t()): Team ID.
Returns
{:ok, Team.t()}on success.{:error, AppwriteException.t()}on failure.
@spec get_membership(String.t(), String.t()) :: {:ok, Appwrite.Types.Membership.t()} | {:error, Appwrite.Exceptions.AppwriteException.t()}
Get a team member by their membership ID.
All team members have read access to this endpoint.
Parameters
team_id(String.t()): Team ID.membership_id(String.t()): Membership ID.
Returns
{:ok, Membership.t()}on success.{:error, AppwriteException.t()}on failure.
@spec get_prefs(String.t()) :: {:ok, Appwrite.Types.Preference.t()} | {:error, Appwrite.Exceptions.AppwriteException.t()}
Get a team's shared preferences.
Returns the team's preferences as a plain string-keyed map. If a preference does not need to be shared by all members, store it in user preferences instead.
Parameters
team_id(String.t()): Team ID.
Returns
{:ok, Preference.t()}on success.{:error, AppwriteException.t()}on failure.
@spec list([String.t()] | nil, String.t() | nil) :: {:ok, Appwrite.Types.TeamList.t()} | {:error, Appwrite.Exceptions.AppwriteException.t()}
List all teams in which the current user is a member.
Parameters
queries([String.t()] | nil): Optional query strings to filter results.search(String.t() | nil): Optional search term to filter teams by name.
Returns
{:ok, TeamList.t()}on success.{:error, AppwriteException.t()}on failure.
@spec list_memberships(String.t(), [String.t()] | nil, String.t() | nil) :: {:ok, Appwrite.Types.MembershipList.t()} | {:error, Appwrite.Exceptions.AppwriteException.t()}
List a team's members.
All team members have read access to this endpoint.
Parameters
team_id(String.t()): Team ID.queries([String.t()] | nil): Optional query strings to filter results.search(String.t() | nil): Optional search term to filter memberships.
Returns
{:ok, MembershipList.t()}on success.{:error, AppwriteException.t()}on failure.
@spec update(String.t(), String.t()) :: {:ok, Appwrite.Types.Team.t()} | {:error, Appwrite.Exceptions.AppwriteException.t()}
Update a team's name.
Only members with the owner role can update the team.
Parameters
team_id(String.t()): Team ID.name(String.t()): New team name. Max length: 128 chars.
Returns
{:ok, Team.t()}on success.{:error, AppwriteException.t()}on failure.
@spec update_membership(String.t(), String.t(), [String.t()]) :: {:ok, Appwrite.Types.Membership.t()} | {:error, Appwrite.Exceptions.AppwriteException.t()}
Modify the roles of a team member.
Only team members with the owner role can access this endpoint.
Parameters
team_id(String.t()): Team ID.membership_id(String.t()): Membership ID.roles([String.t()]): Updated array of roles.
Returns
{:ok, Membership.t()}on success.{:error, AppwriteException.t()}on failure.
@spec update_membership_status(String.t(), String.t(), String.t(), String.t()) :: {:ok, Appwrite.Types.Membership.t()} | {:error, Appwrite.Exceptions.AppwriteException.t()}
Accept a team membership invitation.
Allows a user to confirm their team membership after being redirected back to your app from the invitation email. On success, a session is created automatically.
Parameters
team_id(String.t()): Team ID.membership_id(String.t()): Membership ID.user_id(String.t()): User ID.secret(String.t()): Secret key from the invitation link.
Returns
{:ok, Membership.t()}on success.{:error, AppwriteException.t()}on failure.
@spec update_prefs(String.t(), Appwrite.Types.Preference.t()) :: {:ok, Appwrite.Types.Preference.t()} | {:error, Appwrite.Exceptions.AppwriteException.t()}
Update a team's shared preferences.
The object you pass replaces any previous preferences. Maximum allowed prefs size is 64 kB.
Parameters
team_id(String.t()): Team ID.prefs(Preference.t()): New preferences as a string-keyed map.
Returns
{:ok, Preference.t()}on success.{:error, AppwriteException.t()}on failure.