If a user is part of a team, the team object is returned in login (or req.login if using cio.AuthorizeMiddleware when authorizing.
const team = login.team;
Be careful sending Team objects!
Team instances have
headersandtokenproperties. If these are not removed from the object before sending it, say as a response, you'll expose your product key to your users!const login = req.login; delete login.team.headers; delete login.team.token; res.status(200).json({ ...login, });
Operations using the above team object will have the user data attached to it for tracking. If the team is returned using the command below, then operations will be tracked as "Anonymous".
const team = await cio.GetTeamById(id);
Custom team data that is set by the product is accessible under the team.data object.
The Team Object
Learn more about the Team object in the Full SDK Reference.
Update team data
await team.Update({/* diff */}, scopes, name);
The diff argument is a list of changes to team.data. To remove properties from team.data, set the key value to null.
For example, use the following to add the foo property with the value "bar".
await team.Update({ foo: "bar" });
Now, use the following to change the foo property to "foo".
await team.Update({ foo: "foo" });
Finally, delete the foo property by calling:
await team.Update({ foo: null });
Delete a team
await team.Delete();
List teams on product
Finally, also for the developer/customer service portal (if applicable), all teams can be listed:
const teams = await cio.ListTeams(0, 100);
The skip and count arguments are used for pagination.
