# List teams

GET https://app.launchdarkly.com/api/v2/teams

Return a list of teams.

By default, this returns the first 20 teams. Page through this list with the `limit` parameter and by following the `first`, `prev`, `next`, and `last` links in the `_links` field that returns. If those links do not appear, the pages they refer to don't exist. For example, the `first` and `prev` links will be missing from the response on the first page, because there is no previous page and you cannot return to the first page when you are already on the first page.

### Filtering teams

LaunchDarkly supports the following fields for filters:

- `query` is a string that matches against the teams' names and keys. It is not case-sensitive.
  - A request with `query:abc` returns teams with the string `abc` in their name or key.
- `nomembers` is a boolean that filters the list of teams who have 0 members
  - A request with `nomembers:true` returns teams that have 0 members
  - A request with `nomembers:false` returns teams that have 1 or more members

### Expanding the teams response
LaunchDarkly supports expanding several fields in the "List teams" response. By default, these fields are **not** included in the response.

To expand the response, append the `expand` query parameter and add a comma-separated list with any of the following fields:

* `members` includes the total count of members that belong to the team.
* `roles` includes a paginated list of the custom roles that you have assigned to the team.
* `roleAttributes` includes a list of the role attributes that you have assigned to the team.
* `projects` includes a paginated list of the projects that the team has any write access to.
* `maintainers` includes a paginated list of the maintainers that you have assigned to the team.

For example, `expand=members,maintainers` includes the `members` and `maintainers` fields in the response.


Reference: https://launchdarkly.com/docs/api/teams/get-teams

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: LaunchDarkly REST API
  version: 1.0.0
paths:
  /api/v2/teams:
    get:
      operationId: get-teams
      summary: List teams
      description: >
        Return a list of teams.


        By default, this returns the first 20 teams. Page through this list with
        the `limit` parameter and by following the `first`, `prev`, `next`, and
        `last` links in the `_links` field that returns. If those links do not
        appear, the pages they refer to don't exist. For example, the `first`
        and `prev` links will be missing from the response on the first page,
        because there is no previous page and you cannot return to the first
        page when you are already on the first page.


        ### Filtering teams


        LaunchDarkly supports the following fields for filters:


        - `query` is a string that matches against the teams' names and keys. It
        is not case-sensitive.
          - A request with `query:abc` returns teams with the string `abc` in their name or key.
        - `nomembers` is a boolean that filters the list of teams who have 0
        members
          - A request with `nomembers:true` returns teams that have 0 members
          - A request with `nomembers:false` returns teams that have 1 or more members

        ### Expanding the teams response

        LaunchDarkly supports expanding several fields in the "List teams"
        response. By default, these fields are **not** included in the response.


        To expand the response, append the `expand` query parameter and add a
        comma-separated list with any of the following fields:


        * `members` includes the total count of members that belong to the team.

        * `roles` includes a paginated list of the custom roles that you have
        assigned to the team.

        * `roleAttributes` includes a list of the role attributes that you have
        assigned to the team.

        * `projects` includes a paginated list of the projects that the team has
        any write access to.

        * `maintainers` includes a paginated list of the maintainers that you
        have assigned to the team.


        For example, `expand=members,maintainers` includes the `members` and
        `maintainers` fields in the response.
      tags:
        - subpackage_teams
      parameters:
        - name: limit
          in: query
          description: The number of teams to return in the response. Defaults to 20.
          required: false
          schema:
            type: integer
            format: int64
        - name: offset
          in: query
          description: >-
            Where to start in the list. Use this with pagination. For example,
            an offset of 10 skips the first ten items and returns the next
            `limit` items.
          required: false
          schema:
            type: integer
            format: int64
        - name: filter
          in: query
          description: >-
            A comma-separated list of filters. Each filter is constructed as
            `field:value`.
          required: false
          schema:
            type: string
            format: string
        - name: expand
          in: query
          description: >-
            A comma-separated list of properties that can reveal additional
            information in the response.
          required: false
          schema:
            type: string
            format: string
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Teams collection response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Teams'
        '401':
          description: Invalid access token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedErrorRep'
        '405':
          description: Method not allowed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MethodNotAllowedErrorRep'
        '429':
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitedErrorRep'
servers:
  - url: https://app.launchdarkly.com
  - url: https://app.launchdarkly.us
components:
  schemas:
    ActionIdentifier:
      type: string
      title: ActionIdentifier
    ActionSpecifier:
      type: string
      title: ActionSpecifier
    AccessDeniedReasonEffect:
      type: string
      enum:
        - allow
        - deny
      description: Whether this statement should allow or deny actions on the resources.
      title: AccessDeniedReasonEffect
    AccessDeniedReason:
      type: object
      properties:
        resources:
          type: array
          items:
            type: string
          description: Resource specifier strings
        notResources:
          type: array
          items:
            type: string
          description: >-
            Targeted resources are the resources NOT in this list. The
            <code>resources</code> and <code>notActions</code> fields must be
            empty to use this field.
        actions:
          type: array
          items:
            $ref: '#/components/schemas/ActionSpecifier'
          description: Actions to perform on a resource
        notActions:
          type: array
          items:
            $ref: '#/components/schemas/ActionSpecifier'
          description: >-
            Targeted actions are the actions NOT in this list. The
            <code>actions</code> and <code>notResources</code> fields must be
            empty to use this field.
        effect:
          $ref: '#/components/schemas/AccessDeniedReasonEffect'
          description: >-
            Whether this statement should allow or deny actions on the
            resources.
        role_name:
          type: string
      required:
        - effect
      title: AccessDeniedReason
    AccessDenied:
      type: object
      properties:
        action:
          $ref: '#/components/schemas/ActionIdentifier'
        reason:
          $ref: '#/components/schemas/AccessDeniedReason'
      required:
        - action
        - reason
      title: AccessDenied
    AccessAllowedReasonEffect:
      type: string
      enum:
        - allow
        - deny
      description: Whether this statement should allow or deny actions on the resources.
      title: AccessAllowedReasonEffect
    AccessAllowedReason:
      type: object
      properties:
        resources:
          type: array
          items:
            type: string
          description: Resource specifier strings
        notResources:
          type: array
          items:
            type: string
          description: >-
            Targeted resources are the resources NOT in this list. The
            <code>resources</code> and <code>notActions</code> fields must be
            empty to use this field.
        actions:
          type: array
          items:
            $ref: '#/components/schemas/ActionSpecifier'
          description: Actions to perform on a resource
        notActions:
          type: array
          items:
            $ref: '#/components/schemas/ActionSpecifier'
          description: >-
            Targeted actions are the actions NOT in this list. The
            <code>actions</code> and <code>notResources</code> fields must be
            empty to use this field.
        effect:
          $ref: '#/components/schemas/AccessAllowedReasonEffect'
          description: >-
            Whether this statement should allow or deny actions on the
            resources.
        role_name:
          type: string
      required:
        - effect
      title: AccessAllowedReason
    AccessAllowedRep:
      type: object
      properties:
        action:
          $ref: '#/components/schemas/ActionIdentifier'
        reason:
          $ref: '#/components/schemas/AccessAllowedReason'
      required:
        - action
        - reason
      title: AccessAllowedRep
    Access:
      type: object
      properties:
        denied:
          type: array
          items:
            $ref: '#/components/schemas/AccessDenied'
        allowed:
          type: array
          items:
            $ref: '#/components/schemas/AccessAllowedRep'
      required:
        - denied
        - allowed
      title: Access
    UnixMillis:
      type: integer
      format: int64
      title: UnixMillis
    Link:
      type: object
      properties:
        href:
          type: string
          description: The URL of the link
        type:
          type: string
          description: The type of the link
      title: Link
    RoleAttributeValues:
      type: array
      items:
        type: string
      title: RoleAttributeValues
    RoleAttributeMap:
      type: object
      additionalProperties:
        $ref: '#/components/schemas/RoleAttributeValues'
      title: RoleAttributeMap
    ProjectSummary:
      type: object
      properties:
        _id:
          type: string
          description: The ID of this project
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
        key:
          type: string
          description: The project key
        name:
          type: string
          description: The project name
      required:
        - _id
        - _links
        - key
        - name
      title: ProjectSummary
    TeamProjects:
      type: object
      properties:
        totalCount:
          type: integer
        items:
          type: array
          items:
            $ref: '#/components/schemas/ProjectSummary'
          description: >-
            Details on each project where team members have write privileges on
            at least one resource type (e.g. flags)
      title: TeamProjects
    TeamCustomRole:
      type: object
      properties:
        key:
          type: string
          description: The key of the custom role
        name:
          type: string
          description: The name of the custom role
        projects:
          $ref: '#/components/schemas/TeamProjects'
          description: >-
            Details on the projects where team members have write privileges on
            at least one resource type (e.g. flags)
        appliedOn:
          $ref: '#/components/schemas/UnixMillis'
          description: Timestamp of when the custom role was assigned to this team
      title: TeamCustomRole
    TeamCustomRoles:
      type: object
      properties:
        totalCount:
          type: integer
          description: The number of custom roles assigned to this team
        items:
          type: array
          items:
            $ref: '#/components/schemas/TeamCustomRole'
          description: An array of the custom roles that have been assigned to this team
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
      title: TeamCustomRoles
    TeamMembers:
      type: object
      properties:
        totalCount:
          type: integer
          description: The total count of members that belong to the team
      title: TeamMembers
    MemberSummary:
      type: object
      properties:
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
        _id:
          type: string
          description: The member's ID
        firstName:
          type: string
          description: The member's first name
        lastName:
          type: string
          description: The member's last name
        role:
          type: string
          description: >-
            The member's base role. If the member has no additional roles, this
            role will be in effect.
        email:
          type: string
          description: The member's email address
      required:
        - _links
        - _id
        - role
        - email
      title: MemberSummary
    TeamMaintainers:
      type: object
      properties:
        totalCount:
          type: integer
          description: The number of maintainers of the team
        items:
          type: array
          items:
            $ref: '#/components/schemas/MemberSummary'
          description: >-
            Details on the members that have been assigned as maintainers of the
            team
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
      title: TeamMaintainers
    Team:
      type: object
      properties:
        description:
          type: string
          description: A description of the team
        key:
          type: string
          description: The team key
        name:
          type: string
          description: A human-friendly name for the team
        _access:
          $ref: '#/components/schemas/Access'
          description: Details on the allowed and denied actions for this team
        _creationDate:
          $ref: '#/components/schemas/UnixMillis'
          description: Timestamp of when the team was created
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
        _lastModified:
          $ref: '#/components/schemas/UnixMillis'
          description: Timestamp of when the team was most recently updated
        _version:
          type: integer
          description: The team version
        _idpSynced:
          type: boolean
          description: >-
            Whether the team has been synced with an external identity provider
            (IdP). Team sync is available to customers on an Enterprise plan.
        roleAttributes:
          $ref: '#/components/schemas/RoleAttributeMap'
          description: A map of role attributes for the team
        roles:
          $ref: '#/components/schemas/TeamCustomRoles'
          description: >-
            Paginated list of the custom roles assigned to this team. Only
            included if specified in the <code>expand</code> query parameter.
        members:
          $ref: '#/components/schemas/TeamMembers'
          description: >-
            Details on the total count of members that belong to the team. Only
            included if specified in the <code>expand</code> query parameter.
        projects:
          $ref: '#/components/schemas/TeamProjects'
          description: >-
            Paginated list of the projects that the team has any write access
            to. Only included if specified in the <code>expand</code> query
            parameter.
        maintainers:
          $ref: '#/components/schemas/TeamMaintainers'
          description: >-
            Paginated list of the maintainers assigned to this team. Only
            included if specified in the <code>expand</code> query parameter.
      title: Team
    Teams:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/Team'
          description: An array of teams
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
        totalCount:
          type: integer
          description: The number of teams
      required:
        - items
      title: Teams
    UnauthorizedErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: UnauthorizedErrorRep
    MethodNotAllowedErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: MethodNotAllowedErrorRep
    RateLimitedErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: RateLimitedErrorRep
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Authorization

```

## SDK Code Examples

```python
import requests

url = "https://app.launchdarkly.com/api/v2/teams"

headers = {"Authorization": "<apiKey>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript
const url = 'https://app.launchdarkly.com/api/v2/teams';
const options = {method: 'GET', headers: {Authorization: '<apiKey>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://app.launchdarkly.com/api/v2/teams"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "<apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://app.launchdarkly.com/api/v2/teams")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = '<apiKey>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://app.launchdarkly.com/api/v2/teams")
  .header("Authorization", "<apiKey>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://app.launchdarkly.com/api/v2/teams', [
  'headers' => [
    'Authorization' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://app.launchdarkly.com/api/v2/teams");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://app.launchdarkly.com/api/v2/teams")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```