Stack Overflow for Teams API
Joel Bradley avatar
Written by Joel Bradley
Updated over a week ago

Tags | Integrations | API |

Applies to: Basic, Business

Enterprise users can access their documentation here. Find your plan.


The Stack Overflow application programming interface (API) allows you to access your Basic and Business Teams data for automation, reporting, and more. Business Teams can use the API to read and write Teams data, while Basic Teams have read-only API access. Free Teams do not have API access.

NOTE: This article is for Stack Overflow Teams Basic and Business. Stack Overflow Enterprise users should read the API v2.3 and API v3 articles instead.

Accessing the API requires a personal access token (PAT) you create on your Teams Account Settings page. Introduced in December 2022, the PAT replaces the API authentication method that uses secret keys and access tokens. We will phase out the older API authentication method in early 2023.

If you're currently using the Stack Overflow API, follow the instructions below to:

  1. Generate a new PAT.

  2. Update your API URL.

  3. Put the PAT in your API call header.

The PAT interface

To create and manage your personal access tokens, go to your Account Settings page at Click on Personal access tokens in the "API" section of the left-hand menu. The personal access tokens page will appear.

The PAT page lists the description, team, scope, created date, and expiration date (if any) for each token. Click the Delete link next to any token to delete it.

Create a PAT

Click Create a new PAT to create a token.

A box appears with the following fields:

PAT Description
Enter a unique description to help you identify the token.

Team scope
Select the Teams data this token will be able to access.

Expiration date
Set a date this token will expire. You can choose 7, 30, 60, or 90 days, or no expiration.

Enable write access
Check this box if you need to write as well as read Teams data (write access is available for Business Teams only).

After you've entered your PAT information, click Create to create the token. The new token will appear in the PAT list with its unique code displayed in blue.

Click on the code to copy it to your computer's clipboard. Save the code to a document or password manager for safekeeping as it will not be displayed again. If you forget to copy the token code or lose it, you'll need to delete the token and create a new one.

Anatomy of a successful PAT API call

The process for making API calls with a PAT is simpler than the older key/token method. A successful API call now requires the following three components:

The base Teams API URL is, to which you'll append the specific API endpoint. To retrieve a list of questions, for example, the API URL would be

Team slug
The Team slug tells the API which team your PAT is accessing. You'll pass the team slug in the URL like this: team=your-team.

NOTE: The previous API auth method required each call to include the full Teams URL (for example: team= The new method requires just the team slug (for example: team=your-team).

PAT (in header)
Pass your PAT in the API call header as the X-API-Access-Token value, like this: X-API-Access-Token=abcdefgh12345678.

Try out PAT API access

The best way to learn how to use a PAT with the Stack Overflow API is through our API documentation sandbox. Start by accessing the Stack Overflow API documentation at The top of the page has general information about the API; further down the page you'll find the specific API endpoints (queries) you can access. Click one of the endpoint links (for example: questions) to see more information about that API query. You can also access the documentation for a specific endpoint directly like this:

Scroll to the bottom of the page to the "Try it" area. You can use this tool to test out Teams API calls with your PAT.

Enter your team slug into the Team slug field, and your PAT into the Access token field. Click Run. The API query should return question data, displayed beneath the API URL.

Use the additional "Try it" fields and pull-down menus to control the API query and the data it returns. You can also add other fields to the return data by clicking [edit] in the upper-right filter area. When you're done testing, use the generated URL as a starting point for creating your own automated API calls.

Here are two examples that show the API URL in use.

โ€‹ curl --header "X-API-Access-Token: [PAT]" '[team_slug]' | gunzip

โ€‹ powershell (Invoke-WebRequest '[team_slug]' -Headers @{"X-API-Access-Token"="[PAT]"}).Content | ConvertFrom-Json | ConvertTo-Json


To maintain security of data and stability of the site, Stack Overflow will reject certain API requests. Here are some of the most common reasons:

  • Invalid/missing PAT

  • Invalid/missing Team slug

  • Expired PAT

  • PAT not associated with specified team

  • Write operation specified for read-only PAT

  • Too many API calls in a given time period

NOTE: The Stack Overflow API compresses all responses by default, either with GZIP or DEFLATE. You'll need to unzip the data before use.

Need help? Submit an issue or question through our support portal.

Did this answer your question?