# Get team custom roles

GET https://app.launchdarkly.com/api/v2/teams/{teamKey}/roles

Fetch the custom roles that have been assigned to the team. To learn more, read [Managing team permissions](https://launchdarkly.com/docs/home/account/team-permissions).

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

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: LaunchDarkly REST API
  version: 1.0.0
paths:
  /api/v2/teams/{teamKey}/roles:
    get:
      operationId: get-team-roles
      summary: Get team custom roles
      description: >-
        Fetch the custom roles that have been assigned to the team. To learn
        more, read [Managing team
        permissions](https://launchdarkly.com/docs/home/account/team-permissions).
      tags:
        - subpackage_teams
      parameters:
        - name: teamKey
          in: path
          description: The team key
          required: true
          schema:
            type: string
            format: string
        - name: limit
          in: query
          description: The number of roles 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. This is for use with pagination. For
            example, an offset of 10 skips the first ten items and then returns
            the next items in the list, up to the query `limit`.
          required: false
          schema:
            type: integer
            format: int64
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Team roles response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TeamCustomRoles'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvalidRequestErrorRep'
        '401':
          description: Invalid access token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedErrorRep'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ForbiddenErrorRep'
        '404':
          description: Invalid resource identifier
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundErrorRep'
        '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:
    Link:
      type: object
      properties:
        href:
          type: string
          description: The URL of the link
        type:
          type: string
          description: The type of the link
      title: Link
    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
    UnixMillis:
      type: integer
      format: int64
      title: UnixMillis
    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
    InvalidRequestErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: InvalidRequestErrorRep
    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
    ForbiddenErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: ForbiddenErrorRep
    NotFoundErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: NotFoundErrorRep
    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/teamKey/roles"

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

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

print(response.json())
```

```javascript
const url = 'https://app.launchdarkly.com/api/v2/teams/teamKey/roles';
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/teamKey/roles"

	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/teamKey/roles")

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/teamKey/roles")
  .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/teamKey/roles', [
  'headers' => [
    'Authorization' => '<apiKey>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://app.launchdarkly.com/api/v2/teams/teamKey/roles");
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/teamKey/roles")! 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()
```