Teams

Stack Overflow recently released an updated Teams API, with a new URL and improved authentication method. We'll soon deprecate the existing Teams endpoints in the Stack Exchange API.

You can learn more about these changes, and how to migrate to the new Teams API, in our Stack Overflow for Teams API document.

Discussion

Starting with the release of Stack Overflow For Teams, the Stack Exchange API exposes read-only access to data stored in private Teams. In order to access Teams, you must do the following:

  • Obtain an access_token with the access_team|team-url scope (see Authentication for more details)
    • team-url is the root url of the Team (without protocol), and must be obtained from the user
    • For example, a Team for pickled cucumber enthusiasts might have a team-url of stackoverflow.com/c/pickles
    • The full query parameter for the example Pickles team might be ?scope=access_team|stackoverflow.com/c/pickles and url encoded as ?scope=access_team%7cstackoverflow.com%2fc%2fpickles
  • Send this access_token in the X-API-Access-Token header on all requests to the API
    • For security reasons passing access_token as a query parameter is not supported when accessing Team data
    • Any access_token passed as a query parameter while trying to access team data will be invalidated
  • Add the ?team=team-url query parameter to all requests to the API
    • Using the example Pickles team from above, the full query parameter might be ?team=stackoverflow.com/c/pickles and url encoded as ?team=stackoverflow.com%2fc%2fpickles
  • The ?site=site-name is still required for all methods that are site-specific, even when accessing Team data
    • The full query parameter will be ?site=stackoverflow when accessing Teams data

In addition to all write methods, the following methods (and their /me equivalents) are not supported when specifying a Team with ?team=:

An access_token obtained with an access_team|team-url scope cannot be used to access public Stack Overflow data. An access_token for public Stack Overflow can be obtained by using the /access-tokens/exchange method with exchange_type=team_for_public. The obtained access_token will have the same scopes and expiration as the original access_token except for the access_team scope.