Docs

Teams

The teams' service allows you to group together users of your project and allow 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 inviting a new team member. Only team owners can invite new users to the team.

List Teams

GET/teams

Get a list of all the current user teams. You can use the query params to filter your results. On managed mode, this endpoint will return a list of all of the project teams. Learn more about different API modes.

Arguments

Name Type Description
search optional string

Search term to filter your list results.

limit optional integer

Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.

offset optional integer

Results offset. The default value is 0. Use this param to manage pagination.

orderType optional string

Order result by ASC or DESC order.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        setProject('')
        setKey('')
    ;
    
    let promise = sdk.teams.listTeams();
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Teams;
    
    $client = new Client();
    
    $client
        setProject('')
        setKey('')
    ;
    
    $teams = new Teams($client);
    
    $result = $teams->listTeams();

Get Team

GET/teams/{teamId}

Get team by its unique ID. All team members have read access for this resource.

Arguments

Name Type Description
teamId required string

Team unique ID.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        setProject('')
        setKey('')
    ;
    
    let promise = sdk.teams.getTeam('[TEAM_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Teams;
    
    $client = new Client();
    
    $client
        setProject('')
        setKey('')
    ;
    
    $teams = new Teams($client);
    
    $result = $teams->getTeam('[TEAM_ID]');

Get Team Members

GET/teams/{teamId}/members

Get team members by the team unique ID. All team members have read access for this list of resources.

Arguments

Name Type Description
teamId required string

Team unique ID.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        setProject('')
        setKey('')
    ;
    
    let promise = sdk.teams.getTeamMembers('[TEAM_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Teams;
    
    $client = new Client();
    
    $client
        setProject('')
        setKey('')
    ;
    
    $teams = new Teams($client);
    
    $result = $teams->getTeamMembers('[TEAM_ID]');

Create Team

POST/teams

Create a new team. The user who creates the team will automatically be assigned as the owner of the team. The team owner can invite new members, who will be able add new owners and update or delete the team from your project.

Arguments

Name Type Description
name required string

Team name.

roles optional array

User roles array. Use this param to set the roles in the team for the user who created the team. The default role is owner, a role can be any string.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        setProject('')
        setKey('')
    ;
    
    let promise = sdk.teams.createTeam('[NAME]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Teams;
    
    $client = new Client();
    
    $client
        setProject('')
        setKey('')
    ;
    
    $teams = new Teams($client);
    
    $result = $teams->createTeam('[NAME]');

Update Team

PUT/teams/{teamId}

Update team by its unique ID. Only team owners have write access for this resource.

Arguments

Name Type Description
teamId required string

Team unique ID.

name required string

Team name.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        setProject('')
        setKey('')
    ;
    
    let promise = sdk.teams.updateTeam('[TEAM_ID]', '[NAME]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Teams;
    
    $client = new Client();
    
    $client
        setProject('')
        setKey('')
    ;
    
    $teams = new Teams($client);
    
    $result = $teams->updateTeam('[TEAM_ID]', '[NAME]');

Delete Team

DELETE/teams/{teamId}

Delete team by its unique ID. Only team owners have write access for this resource.

Arguments

Name Type Description
teamId required string

Team unique ID.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        setProject('')
        setKey('')
    ;
    
    let promise = sdk.teams.deleteTeam('[TEAM_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Teams;
    
    $client = new Client();
    
    $client
        setProject('')
        setKey('')
    ;
    
    $teams = new Teams($client);
    
    $result = $teams->deleteTeam('[TEAM_ID]');

Create Team Membership

POST/teams/{teamId}/memberships

Use this endpoint to invite a new member to your team. An email with a link to join the team will be sent to the new member email address. If member doesn't exists in the project it will be automatically created.

Use the redirect parameter to redirect the user from the invitation email back to your app. When the user is redirected, use the /teams/{teamId}/memberships/{inviteId}/status endpoint to finally join the user to the team.

Please notice that in order to avoid a Redirect Attacks the only valid redirect URL's are the once from domains you have set when added your platforms in the console interface.

Arguments

Name Type Description
teamId required string

Team unique ID.

email required string

New team member email address.

roles required array

Invite roles array. Learn more about roles and permissions.

redirect required string

Reset page to redirect user back to your app from the invitation email.

name optional string

New team member name.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        setProject('')
        setKey('')
    ;
    
    let promise = sdk.teams.createTeamMembership('[TEAM_ID]', 'email@example.com', [], 'https://example.com');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Teams;
    
    $client = new Client();
    
    $client
        setProject('')
        setKey('')
    ;
    
    $teams = new Teams($client);
    
    $result = $teams->createTeamMembership('[TEAM_ID]', 'email@example.com', [], 'https://example.com');

Create Team Membership (Resend Invitation Email)

POST/teams/{teamId}/memberships/{inviteId}/resend

Use this endpoint to resend your invitation email for a user to join a team.

Arguments

Name Type Description
teamId required string

Team unique ID.

inviteId required string

Invite unique ID.

redirect required string

Reset page to redirect user back to your app from the invitation email.

Example Request
  • let sdk = new Appwrite();
    
    sdk
        setProject('')
        setKey('')
    ;
    
    let promise = sdk.teams.createTeamMembershipResend('[TEAM_ID]', '[INVITE_ID]', 'https://example.com');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Teams;
    
    $client = new Client();
    
    $client
        setProject('')
        setKey('')
    ;
    
    $teams = new Teams($client);
    
    $result = $teams->createTeamMembershipResend('[TEAM_ID]', '[INVITE_ID]', 'https://example.com');

Update Team Membership Status

PATCH/teams/{teamId}/memberships/{inviteId}/status

Use this endpoint to let user accept an invitation to join a team after he is being redirect back to your app from the invitation email. Use the success and failure URL's to redirect users back to your application after the request completes.

Please notice that in order to avoid a Redirect Attacks the only valid redirect URL's are the once from domains you have set when added your platforms in the console interface.

When not using the success or failure redirect arguments this endpoint will result with a 200 status code on success and with 401 status error on failure. This behavior was applied to help the web clients deal with browsers who don't allow to set 3rd party HTTP cookies needed for saving the account session token.

Arguments

Name Type Description
teamId required string

Team unique ID.

inviteId required string

Invite unique ID

userId required string

User unique ID

secret required string

Secret Key

success optional string

Redirect when registration succeed

failure optional string

Redirect when registration failed

Example Request
  • let sdk = new Appwrite();
    
    sdk
        setProject('')
        setKey('')
    ;
    
    let promise = sdk.teams.updateTeamMembershipStatus('[TEAM_ID]', '[INVITE_ID]', '[USER_ID]', '[SECRET]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Teams;
    
    $client = new Client();
    
    $client
        setProject('')
        setKey('')
    ;
    
    $teams = new Teams($client);
    
    $result = $teams->updateTeamMembershipStatus('[TEAM_ID]', '[INVITE_ID]', '[USER_ID]', '[SECRET]');

Delete Team Membership

DELETE/teams/{teamId}/memberships/{inviteId}

This endpoint allows a user to leave a team or for a team owner to delete the membership of any other team member.

Arguments

Name Type Description
teamId required string

Team unique ID.

inviteId required string

Invite unique ID

Example Request
  • let sdk = new Appwrite();
    
    sdk
        setProject('')
        setKey('')
    ;
    
    let promise = sdk.teams.deleteTeamMembership('[TEAM_ID]', '[INVITE_ID]');
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Teams;
    
    $client = new Client();
    
    $client
        setProject('')
        setKey('')
    ;
    
    $teams = new Teams($client);
    
    $result = $teams->deleteTeamMembership('[TEAM_ID]', '[INVITE_ID]');