Teams

SERVER

The Teams service allows you to group users of your project and to enable them to share read and write access to your project resources, such as database documents or storage files.

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 their team.

Base URL
https://cloud.appwrite.io/v1

List teams

Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results.

  • Request
    • queries array

      Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total, billingPlan

    • search string

      Search term to filter your list results. Max length: 256 chars.

  • Response
Endpoint
GET /teams
Dart
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
    .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('<YOUR_PROJECT_ID>') // Your project ID
    .setSession(''); // The user session to authenticate with

Teams teams = Teams(client);

TeamList result = await teams.list(
    queries: [], // (optional)
    search: '<SEARCH>', // (optional)
);

Create team

Create a new team. The user who creates the team will automatically be assigned as the owner of the team. Only the users with the owner role can invite new members, add new owners and delete or update the team.

  • Request
    • teamId string
      required

      Team ID. Choose a custom ID or generate a random ID with ID.unique(). Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.

    • name string
      required

      Team name. Max length: 128 chars.

    • roles array

      Array of strings. Use this param to set the roles in the team for the user who created it. The default role is owner. A role can be any string. Learn more about roles and permissions. Maximum of 100 roles are allowed, each 32 characters long.

  • Response
    • 201 application/json
Endpoint
POST /teams
Dart
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
    .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('<YOUR_PROJECT_ID>') // Your project ID
    .setSession(''); // The user session to authenticate with

Teams teams = Teams(client);

Team result = await teams.create(
    teamId: '<TEAM_ID>',
    name: '<NAME>',
    roles: [], // (optional)
);

Get team

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

  • Request
    • teamId string
      required

      Team ID.

  • Response
    • 200 application/json
Endpoint
GET /teams/{teamId}
Dart
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
    .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('<YOUR_PROJECT_ID>') // Your project ID
    .setSession(''); // The user session to authenticate with

Teams teams = Teams(client);

Team result = await teams.get(
    teamId: '<TEAM_ID>',
);

Update name

Update the team's name by its unique ID.

  • Request
    • teamId string
      required

      Team ID.

    • name string
      required

      New team name. Max length: 128 chars.

  • Response
    • 200 application/json
Endpoint
PUT /teams/{teamId}
Dart
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
    .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('<YOUR_PROJECT_ID>') // Your project ID
    .setSession(''); // The user session to authenticate with

Teams teams = Teams(client);

Team result = await teams.updateName(
    teamId: '<TEAM_ID>',
    name: '<NAME>',
);

Delete team

Delete a team using its ID. Only team members with the owner role can delete the team.

  • Request
    • teamId string
      required

      Team ID.

  • Response
    • 204 application/json
Endpoint
DELETE /teams/{teamId}
Dart
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
    .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('<YOUR_PROJECT_ID>') // Your project ID
    .setSession(''); // The user session to authenticate with

Teams teams = Teams(client);

await teams.delete(
    teamId: '<TEAM_ID>',
);

List team memberships

Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint.

  • Request
    • teamId string
      required

      Team ID.

    • queries array

      Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm

    • search string

      Search term to filter your list results. Max length: 256 chars.

  • Response
Endpoint
GET /teams/{teamId}/memberships
Dart
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
    .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('<YOUR_PROJECT_ID>') // Your project ID
    .setSession(''); // The user session to authenticate with

Teams teams = Teams(client);

MembershipList result = await teams.listMemberships(
    teamId: '<TEAM_ID>',
    queries: [], // (optional)
    search: '<SEARCH>', // (optional)
);

Create team membership

Invite a new member to join your team. Provide an ID for existing users, or invite unregistered users using an email or phone number. If initiated from a Client SDK, Appwrite will send an email or sms with a link to join the team to the invited user, and an account will be created for them if one doesn't exist. If initiated from a Server SDK, the new member will be added automatically to the team.

You only need to provide one of a user ID, email, or phone number. Appwrite will prioritize accepting the user ID > email > phone number if you provide more than one of these parameters.

Use the url parameter to redirect the user from the invitation email to your app. After the user is redirected, use the Update Team Membership Status endpoint to allow the user to accept the invitation to the team.

Please note that to avoid a Redirect Attack Appwrite will accept the only redirect URLs under the domains you have added as a platform on the Appwrite Console.

  • Request
    • teamId string
      required

      Team ID.

    • roles array
      required

      Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about roles and permissions. Maximum of 100 roles are allowed, each 32 characters long.

    • email string

      Email of the new team member.

    • userId string

      ID of the user to be added to a team.

    • phone string

      Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.

    • url string

      URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an open redirect attack against your project API.

    • name string

      Name of the new team member. Max length: 128 chars.

  • Response
  • Rate limits

    This endpoint is not limited when using Server SDKs with API keys. If you are using SSR with setSession, these rate limits will still apply. Learn more about SSR rate limits.

    The limit is applied for each unique limit key.

    Time frame
    Attempts
    Key
    60 minutes 10 requests URL + IP
Endpoint
POST /teams/{teamId}/memberships
Dart
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
    .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('<YOUR_PROJECT_ID>') // Your project ID
    .setSession(''); // The user session to authenticate with

Teams teams = Teams(client);

Membership result = await teams.createMembership(
    teamId: '<TEAM_ID>',
    roles: [],
    email: 'email@example.com', // (optional)
    userId: '<USER_ID>', // (optional)
    phone: '+12065550100', // (optional)
    url: 'https://example.com', // (optional)
    name: '<NAME>', // (optional)
);

Get team membership

Get a team member by the membership unique id. All team members have read access for this resource.

  • Request
    • teamId string
      required

      Team ID.

    • membershipId string
      required

      Membership ID.

  • Response
Endpoint
GET /teams/{teamId}/memberships/{membershipId}
Dart
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
    .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('<YOUR_PROJECT_ID>') // Your project ID
    .setSession(''); // The user session to authenticate with

Teams teams = Teams(client);

Membership result = await teams.getMembership(
    teamId: '<TEAM_ID>',
    membershipId: '<MEMBERSHIP_ID>',
);

Update membership

Modify the roles of a team member. Only team members with the owner role have access to this endpoint. Learn more about roles and permissions.

  • Request
    • teamId string
      required

      Team ID.

    • membershipId string
      required

      Membership ID.

    • roles array
      required

      An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about roles and permissions. Maximum of 100 roles are allowed, each 32 characters long.

  • Response
Endpoint
PATCH /teams/{teamId}/memberships/{membershipId}
Dart
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
    .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('<YOUR_PROJECT_ID>') // Your project ID
    .setSession(''); // The user session to authenticate with

Teams teams = Teams(client);

Membership result = await teams.updateMembership(
    teamId: '<TEAM_ID>',
    membershipId: '<MEMBERSHIP_ID>',
    roles: [],
);

Delete team membership

This endpoint allows a user to leave a team or for a team owner to delete the membership of any other team member. You can also use this endpoint to delete a user membership even if it is not accepted.

  • Request
    • teamId string
      required

      Team ID.

    • membershipId string
      required

      Membership ID.

  • Response
    • 204 application/json
Endpoint
DELETE /teams/{teamId}/memberships/{membershipId}
Dart
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
    .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('<YOUR_PROJECT_ID>') // Your project ID
    .setSession(''); // The user session to authenticate with

Teams teams = Teams(client);

await teams.deleteMembership(
    teamId: '<TEAM_ID>',
    membershipId: '<MEMBERSHIP_ID>',
);

Update team membership status

Use this endpoint to allow a user to accept an invitation to join a team after being redirected back to your app from the invitation email received by the user.

If the request is successful, a session for the user is automatically created.

  • Request
    • teamId string
      required

      Team ID.

    • membershipId string
      required

      Membership ID.

    • userId string
      required

      User ID.

    • secret string
      required

      Secret key.

  • Response
Endpoint
PATCH /teams/{teamId}/memberships/{membershipId}/status
Dart
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
    .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('<YOUR_PROJECT_ID>') // Your project ID
    .setSession(''); // The user session to authenticate with

Teams teams = Teams(client);

Membership result = await teams.updateMembershipStatus(
    teamId: '<TEAM_ID>',
    membershipId: '<MEMBERSHIP_ID>',
    userId: '<USER_ID>',
    secret: '<SECRET>',
);

Get team preferences

Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in user preferences.

  • Request
    • teamId string
      required

      Team ID.

  • Response
Endpoint
GET /teams/{teamId}/prefs
Dart
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
    .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('<YOUR_PROJECT_ID>') // Your project ID
    .setSession(''); // The user session to authenticate with

Teams teams = Teams(client);

Preferences result = await teams.getPrefs(
    teamId: '<TEAM_ID>',
);

Update preferences

Update the team's preferences by its unique ID. The object you pass is stored as is and replaces any previous value. The maximum allowed prefs size is 64kB and throws an error if exceeded.

  • Request
    • teamId string
      required

      Team ID.

    • prefs object
      required

      Prefs key-value JSON object.

  • Response
Endpoint
PUT /teams/{teamId}/prefs
Dart
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
    .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('<YOUR_PROJECT_ID>') // Your project ID
    .setSession(''); // The user session to authenticate with

Teams teams = Teams(client);

Preferences result = await teams.updatePrefs(
    teamId: '<TEAM_ID>',
    prefs: {},
);