---
title: Get team hierarchy links
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > Teams
---

# Get team hierarchy links{% #get-team-hierarchy-links %}
Copy pageCopied
{% tab title="v2" %}

| Datadog site      | API endpoint                                                  |
| ----------------- | ------------------------------------------------------------- |
| ap1.datadoghq.com | GET https://api.ap1.datadoghq.com/api/v2/team-hierarchy-links |
| ap2.datadoghq.com | GET https://api.ap2.datadoghq.com/api/v2/team-hierarchy-links |
| app.datadoghq.eu  | GET https://api.datadoghq.eu/api/v2/team-hierarchy-links      |
| app.ddog-gov.com  | GET https://api.ddog-gov.com/api/v2/team-hierarchy-links      |
| us2.ddog-gov.com  | GET https://api.us2.ddog-gov.com/api/v2/team-hierarchy-links  |
| app.datadoghq.com | GET https://api.datadoghq.com/api/v2/team-hierarchy-links     |
| us3.datadoghq.com | GET https://api.us3.datadoghq.com/api/v2/team-hierarchy-links |
| us5.datadoghq.com | GET https://api.us5.datadoghq.com/api/v2/team-hierarchy-links |

### Overview

List all team hierarchy links that match the provided filters. This endpoint requires the `teams_read` permission.

OAuth apps require the `teams_read` authorization [scope](https://docs.datadoghq.com/api/latest/scopes.md#teams) to access this endpoint.



### Arguments

#### Query Strings

| Name                | Type    | Description                                              |
| ------------------- | ------- | -------------------------------------------------------- |
| page[number]        | integer | Specific page number to return.                          |
| page[size]          | integer | Size for a given page. The maximum allowed value is 100. |
| filter[parent_team] | string  | Filter by parent team ID                                 |
| filter[sub_team]    | string  | Filter by sub team ID                                    |

### Response

{% tab title="200" %}
OK
{% tab title="Model" %}
Team hierarchy links response

| Parent field  | Field                            | Type      | Description                                                                                                                        |
| ------------- | -------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------- |
|               | data                             | [object]  | Team hierarchy links response data                                                                                                 |
| data          | attributes [*required*]     | object    | Team hierarchy link attributes                                                                                                     |
| attributes    | created_at [*required*]     | date-time | Timestamp when the team hierarchy link was created                                                                                 |
| attributes    | provisioned_by [*required*] | string    | The provisioner of the team hierarchy link                                                                                         |
| data          | id [*required*]             | string    | The team hierarchy link's identifier                                                                                               |
| data          | relationships                    | object    | Team hierarchy link relationships                                                                                                  |
| relationships | parent_team [*required*]    | object    | Team hierarchy link team relationship                                                                                              |
| parent_team   | data [*required*]           | object    | Team hierarchy links connect different teams. This represents team objects that are connected by the team hierarchy link.          |
| data          | attributes                       | object    | Team hierarchy links connect different teams. This represents attributes from teams that are connected by the team hierarchy link. |
| attributes    | avatar                           | string    | The team's avatar                                                                                                                  |
| attributes    | banner                           | int64     | The team's banner                                                                                                                  |
| attributes    | handle [*required*]         | string    | The team's handle                                                                                                                  |
| attributes    | is_managed                       | boolean   | Whether the team is managed                                                                                                        |
| attributes    | is_open_membership               | boolean   | Whether the team has open membership                                                                                               |
| attributes    | link_count                       | int64     | The number of links for the team                                                                                                   |
| attributes    | name [*required*]           | string    | The team's name                                                                                                                    |
| attributes    | summary                          | string    | The team's summary                                                                                                                 |
| attributes    | user_count                       | int64     | The number of users in the team                                                                                                    |
| data          | id [*required*]             | string    | The team's identifier                                                                                                              |
| data          | type [*required*]           | enum      | Team type Allowed enum values: `team`                                                                                              |
| relationships | sub_team [*required*]       | object    | Team hierarchy link team relationship                                                                                              |
| sub_team      | data [*required*]           | object    | Team hierarchy links connect different teams. This represents team objects that are connected by the team hierarchy link.          |
| data          | attributes                       | object    | Team hierarchy links connect different teams. This represents attributes from teams that are connected by the team hierarchy link. |
| attributes    | avatar                           | string    | The team's avatar                                                                                                                  |
| attributes    | banner                           | int64     | The team's banner                                                                                                                  |
| attributes    | handle [*required*]         | string    | The team's handle                                                                                                                  |
| attributes    | is_managed                       | boolean   | Whether the team is managed                                                                                                        |
| attributes    | is_open_membership               | boolean   | Whether the team has open membership                                                                                               |
| attributes    | link_count                       | int64     | The number of links for the team                                                                                                   |
| attributes    | name [*required*]           | string    | The team's name                                                                                                                    |
| attributes    | summary                          | string    | The team's summary                                                                                                                 |
| attributes    | user_count                       | int64     | The number of users in the team                                                                                                    |
| data          | id [*required*]             | string    | The team's identifier                                                                                                              |
| data          | type [*required*]           | enum      | Team type Allowed enum values: `team`                                                                                              |
| data          | type [*required*]           | enum      | Team hierarchy link type Allowed enum values: `team_hierarchy_links`                                                               |
|               | included                         | [object]  | Included teams                                                                                                                     |
| included      | attributes                       | object    | Team hierarchy links connect different teams. This represents attributes from teams that are connected by the team hierarchy link. |
| attributes    | avatar                           | string    | The team's avatar                                                                                                                  |
| attributes    | banner                           | int64     | The team's banner                                                                                                                  |
| attributes    | handle [*required*]         | string    | The team's handle                                                                                                                  |
| attributes    | is_managed                       | boolean   | Whether the team is managed                                                                                                        |
| attributes    | is_open_membership               | boolean   | Whether the team has open membership                                                                                               |
| attributes    | link_count                       | int64     | The number of links for the team                                                                                                   |
| attributes    | name [*required*]           | string    | The team's name                                                                                                                    |
| attributes    | summary                          | string    | The team's summary                                                                                                                 |
| attributes    | user_count                       | int64     | The number of users in the team                                                                                                    |
| included      | id [*required*]             | string    | The team's identifier                                                                                                              |
| included      | type [*required*]           | enum      | Team type Allowed enum values: `team`                                                                                              |
|               | links                            | object    | When querying team hierarchy links, a set of links for navigation between different pages is included                              |
| links         | first                            | string    | Link to the first page.                                                                                                            |
| links         | last                             | string    | Link to the last page.                                                                                                             |
| links         | next                             | string    | Link to the next page.                                                                                                             |
| links         | prev                             | string    | Link to the previous page.                                                                                                         |
| links         | self                             | string    | Link to the current object.                                                                                                        |
|               | meta                             | object    | Metadata that is included in the response when querying the team hierarchy links                                                   |
| meta          | page                             | object    | Metadata related to paging information that is included in the response when querying the team hierarchy links                     |
| page          | first_number                     | int64     | First page number.                                                                                                                 |
| page          | last_number                      | int64     | Last page number.                                                                                                                  |
| page          | next_number                      | int64     | Next page number.                                                                                                                  |
| page          | number                           | int64     | Page number.                                                                                                                       |
| page          | prev_number                      | int64     | Previous page number.                                                                                                              |
| page          | size                             | int64     | Page size.                                                                                                                         |
| page          | total                            | int64     | Total number of results.                                                                                                           |
| page          | type                             | string    | Pagination type.                                                                                                                   |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": [
    {
      "attributes": {
        "created_at": "",
        "provisioned_by": "system"
      },
      "id": "b8626d7e-cedd-11eb-abf5-da7ad0900001",
      "relationships": {
        "parent_team": {
          "data": {
            "attributes": {
              "avatar": "string",
              "banner": "integer",
              "handle": "team-handle",
              "is_managed": false,
              "is_open_membership": false,
              "link_count": "integer",
              "name": "Team Name",
              "summary": "string",
              "user_count": "integer"
            },
            "id": "692e8073-12c4-4c71-8408-5090bd44c9c8",
            "type": "team"
          }
        },
        "sub_team": {
          "data": {
            "attributes": {
              "avatar": "string",
              "banner": "integer",
              "handle": "team-handle",
              "is_managed": false,
              "is_open_membership": false,
              "link_count": "integer",
              "name": "Team Name",
              "summary": "string",
              "user_count": "integer"
            },
            "id": "692e8073-12c4-4c71-8408-5090bd44c9c8",
            "type": "team"
          }
        }
      },
      "type": "team_hierarchy_links"
    }
  ],
  "included": [
    {
      "attributes": {
        "avatar": "string",
        "banner": "integer",
        "handle": "team-handle",
        "is_managed": false,
        "is_open_membership": false,
        "link_count": "integer",
        "name": "Team Name",
        "summary": "string",
        "user_count": "integer"
      },
      "id": "692e8073-12c4-4c71-8408-5090bd44c9c8",
      "type": "team"
    }
  ],
  "links": {
    "first": "string",
    "last": "string",
    "next": "string",
    "prev": "string",
    "self": "string"
  },
  "meta": {
    "page": {
      "first_number": "integer",
      "last_number": "integer",
      "next_number": "integer",
      "number": "integer",
      "prev_number": "integer",
      "size": "integer",
      "total": "integer",
      "type": "number_size"
    }
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \# Curl command curl -X GET "https://api.datadoghq.com/api/v2/team-hierarchy-links" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" 
                
##### 

```python
"""
Get team hierarchy links returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.teams_api import TeamsApi

# there is a valid "team_hierarchy_link" in the system
TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_PARENT_TEAM_DATA_ID = environ[
    "TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_PARENT_TEAM_DATA_ID"
]
TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_SUB_TEAM_DATA_ID = environ[
    "TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_SUB_TEAM_DATA_ID"
]

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = TeamsApi(api_client)
    response = api_instance.list_team_hierarchy_links(
        page_number=0,
        page_size=100,
        filter_parent_team=TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_PARENT_TEAM_DATA_ID,
        filter_sub_team=TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_SUB_TEAM_DATA_ID,
    )

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) and then save the example to `example.py` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
##### 

```ruby
# Get team hierarchy links returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::TeamsAPI.new

# there is a valid "team_hierarchy_link" in the system
TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_PARENT_TEAM_DATA_ID = ENV["TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_PARENT_TEAM_DATA_ID"]
TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_SUB_TEAM_DATA_ID = ENV["TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_SUB_TEAM_DATA_ID"]
opts = {
  filter_parent_team: TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_PARENT_TEAM_DATA_ID,
  filter_sub_team: TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_SUB_TEAM_DATA_ID,
  page_number: 0,
  page_size: 100,
}
p api_instance.list_team_hierarchy_links(opts)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) and then save the example to `example.rb` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
##### 

```go
// Get team hierarchy links returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)

func main() {
	// there is a valid "team_hierarchy_link" in the system
	TeamHierarchyLinkDataRelationshipsParentTeamDataID := os.Getenv("TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_PARENT_TEAM_DATA_ID")
	TeamHierarchyLinkDataRelationshipsSubTeamDataID := os.Getenv("TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_SUB_TEAM_DATA_ID")

	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewTeamsApi(apiClient)
	resp, r, err := api.ListTeamHierarchyLinks(ctx, *datadogV2.NewListTeamHierarchyLinksOptionalParameters().WithFilterParentTeam(TeamHierarchyLinkDataRelationshipsParentTeamDataID).WithFilterSubTeam(TeamHierarchyLinkDataRelationshipsSubTeamDataID).WithPageNumber(0).WithPageSize(100))

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `TeamsApi.ListTeamHierarchyLinks`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `TeamsApi.ListTeamHierarchyLinks`:\n%s\n", responseContent)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) and then save the example to `main.go` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
##### 

```java
// Get team hierarchy links returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.TeamsApi;
import com.datadog.api.client.v2.api.TeamsApi.ListTeamHierarchyLinksOptionalParameters;
import com.datadog.api.client.v2.model.TeamHierarchyLinksResponse;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    TeamsApi apiInstance = new TeamsApi(defaultClient);

    // there is a valid "team_hierarchy_link" in the system
    String TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_PARENT_TEAM_DATA_ID =
        System.getenv("TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_PARENT_TEAM_DATA_ID");
    String TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_SUB_TEAM_DATA_ID =
        System.getenv("TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_SUB_TEAM_DATA_ID");

    try {
      TeamHierarchyLinksResponse result =
          apiInstance.listTeamHierarchyLinks(
              new ListTeamHierarchyLinksOptionalParameters()
                  .filterParentTeam(TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_PARENT_TEAM_DATA_ID)
                  .filterSubTeam(TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_SUB_TEAM_DATA_ID)
                  .pageNumber(0L)
                  .pageSize(100L));
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling TeamsApi#listTeamHierarchyLinks");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=java) and then save the example to `Example.java` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
##### 

```rust
// Get team hierarchy links returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_teams::ListTeamHierarchyLinksOptionalParams;
use datadog_api_client::datadogV2::api_teams::TeamsAPI;

#[tokio::main]
async fn main() {
    // there is a valid "team_hierarchy_link" in the system
    let team_hierarchy_link_data_relationships_parent_team_data_id =
        std::env::var("TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_PARENT_TEAM_DATA_ID").unwrap();
    let team_hierarchy_link_data_relationships_sub_team_data_id =
        std::env::var("TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_SUB_TEAM_DATA_ID").unwrap();
    let configuration = datadog::Configuration::new();
    let api = TeamsAPI::with_config(configuration);
    let resp = api
        .list_team_hierarchy_links(
            ListTeamHierarchyLinksOptionalParams::default()
                .filter_parent_team(
                    team_hierarchy_link_data_relationships_parent_team_data_id.clone(),
                )
                .filter_sub_team(team_hierarchy_link_data_relationships_sub_team_data_id.clone())
                .page_number(0)
                .page_size(100),
        )
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) and then save the example to `src/main.rs` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
##### 

```typescript
/**
 * Get team hierarchy links returns "OK" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v2.TeamsApi(configuration);

// there is a valid "team_hierarchy_link" in the system
const TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_PARENT_TEAM_DATA_ID = process.env
  .TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_PARENT_TEAM_DATA_ID as string;
const TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_SUB_TEAM_DATA_ID = process.env
  .TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_SUB_TEAM_DATA_ID as string;

const params: v2.TeamsApiListTeamHierarchyLinksRequest = {
  pageNumber: 0,
  pageSize: 100,
  filterParentTeam: TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_PARENT_TEAM_DATA_ID,
  filterSubTeam: TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_SUB_TEAM_DATA_ID,
};

apiInstance
  .listTeamHierarchyLinks(params)
  .then((data: v2.TeamHierarchyLinksResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) and then save the example to `example.ts` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
{% /tab %}
