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

# Create a team hierarchy link{% #create-a-team-hierarchy-link %}
Copy pageCopied
{% tab title="v2" %}

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

### Overview

Create a new team hierarchy link between a parent team and a sub team. This endpoint requires all of the following permissions:
`teams_read``teams_manage` 


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



### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field  | Field                           | Type   | Description                                                                                                    |
| ------------- | ------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------- |
|               | data [*required*]          | object | Data provided when creating a team hierarchy link                                                              |
| data          | relationships [*required*] | object | The related teams that will be connected by the team hierarchy link                                            |
| relationships | parent_team [*required*]   | object | Data about each team that will be connected by the team hierarchy link                                         |
| parent_team   | data [*required*]          | object | This schema defines the attributes about each team that has to be provided when creating a team hierarchy link |
| data          | id [*required*]            | string | The team's identifier                                                                                          |
| data          | type [*required*]          | enum   | Team type Allowed enum values: `team`                                                                          |
| relationships | sub_team [*required*]      | object | Data about each team that will be connected by the team hierarchy link                                         |
| sub_team      | data [*required*]          | object | This schema defines the attributes about each team that has to be provided when creating a team hierarchy link |
| 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`                                           |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "relationships": {
      "parent_team": {
        "data": {
          "id": "aeadc05e-98a8-11ec-ac2c-da7ad0900001",
          "type": "team"
        }
      },
      "sub_team": {
        "data": {
          "id": "7c47c39d-7740-6408-d686-7870a744701c",
          "type": "team"
        }
      }
    },
    "type": "team_hierarchy_links"
  }
}
```

{% /tab %}

### Response

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

| Parent field  | Field                            | Type      | Description                                                                                                                        |
| ------------- | -------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------- |
|               | data                             | object    | Team hierarchy link                                                                                                                |
| 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.                                                                                                        |

{% /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"
  }
}
```

{% /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="409" %}
Conflict
{% 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

##### 
                          \## default
# 
 \# Curl command curl -X POST "https://api.datadoghq.com/api/v2/team-hierarchy-links" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "data": {
    "relationships": {
      "parent_team": {
        "data": {
          "id": "692e8073-12c4-4c71-8408-5090bd44c9c8",
          "type": "team"
        }
      },
      "sub_team": {
        "data": {
          "id": "692e8073-12c4-4c71-8408-5090bd44c9c8",
          "type": "team"
        }
      }
    },
    "type": "team_hierarchy_links"
  }
}
EOF 
                        
##### 

```go
// Create a team hierarchy link 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 "dd_team" in the system
	DdTeamDataID := os.Getenv("DD_TEAM_DATA_ID")

	// there is a valid "dd_team_2" in the system
	DdTeam2DataID := os.Getenv("DD_TEAM_2_DATA_ID")

	body := datadogV2.TeamHierarchyLinkCreateRequest{
		Data: datadogV2.TeamHierarchyLinkCreate{
			Relationships: datadogV2.TeamHierarchyLinkCreateRelationships{
				ParentTeam: datadogV2.TeamHierarchyLinkCreateTeamRelationship{
					Data: datadogV2.TeamHierarchyLinkCreateTeam{
						Id:   DdTeamDataID,
						Type: datadogV2.TEAMTYPE_TEAM,
					},
				},
				SubTeam: datadogV2.TeamHierarchyLinkCreateTeamRelationship{
					Data: datadogV2.TeamHierarchyLinkCreateTeam{
						Id:   DdTeam2DataID,
						Type: datadogV2.TEAMTYPE_TEAM,
					},
				},
			},
			Type: datadogV2.TEAMHIERARCHYLINKTYPE_TEAM_HIERARCHY_LINKS,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewTeamsApi(apiClient)
	resp, r, err := api.AddTeamHierarchyLink(ctx, body)

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

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `TeamsApi.AddTeamHierarchyLink`:\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
// Create a team hierarchy link 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.model.TeamHierarchyLinkCreate;
import com.datadog.api.client.v2.model.TeamHierarchyLinkCreateRelationships;
import com.datadog.api.client.v2.model.TeamHierarchyLinkCreateRequest;
import com.datadog.api.client.v2.model.TeamHierarchyLinkCreateTeam;
import com.datadog.api.client.v2.model.TeamHierarchyLinkCreateTeamRelationship;
import com.datadog.api.client.v2.model.TeamHierarchyLinkResponse;
import com.datadog.api.client.v2.model.TeamHierarchyLinkType;
import com.datadog.api.client.v2.model.TeamType;

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

    // there is a valid "dd_team" in the system
    String DD_TEAM_DATA_ID = System.getenv("DD_TEAM_DATA_ID");

    // there is a valid "dd_team_2" in the system
    String DD_TEAM_2_DATA_ID = System.getenv("DD_TEAM_2_DATA_ID");

    TeamHierarchyLinkCreateRequest body =
        new TeamHierarchyLinkCreateRequest()
            .data(
                new TeamHierarchyLinkCreate()
                    .relationships(
                        new TeamHierarchyLinkCreateRelationships()
                            .parentTeam(
                                new TeamHierarchyLinkCreateTeamRelationship()
                                    .data(
                                        new TeamHierarchyLinkCreateTeam()
                                            .id(DD_TEAM_DATA_ID)
                                            .type(TeamType.TEAM)))
                            .subTeam(
                                new TeamHierarchyLinkCreateTeamRelationship()
                                    .data(
                                        new TeamHierarchyLinkCreateTeam()
                                            .id(DD_TEAM_2_DATA_ID)
                                            .type(TeamType.TEAM))))
                    .type(TeamHierarchyLinkType.TEAM_HIERARCHY_LINKS));

    try {
      TeamHierarchyLinkResponse result = apiInstance.addTeamHierarchyLink(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling TeamsApi#addTeamHierarchyLink");
      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"
##### 

```python
"""
Create a team hierarchy link returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.teams_api import TeamsApi
from datadog_api_client.v2.model.team_hierarchy_link_create import TeamHierarchyLinkCreate
from datadog_api_client.v2.model.team_hierarchy_link_create_relationships import TeamHierarchyLinkCreateRelationships
from datadog_api_client.v2.model.team_hierarchy_link_create_request import TeamHierarchyLinkCreateRequest
from datadog_api_client.v2.model.team_hierarchy_link_create_team import TeamHierarchyLinkCreateTeam
from datadog_api_client.v2.model.team_hierarchy_link_create_team_relationship import (
    TeamHierarchyLinkCreateTeamRelationship,
)
from datadog_api_client.v2.model.team_hierarchy_link_type import TeamHierarchyLinkType
from datadog_api_client.v2.model.team_type import TeamType

# there is a valid "dd_team" in the system
DD_TEAM_DATA_ID = environ["DD_TEAM_DATA_ID"]

# there is a valid "dd_team_2" in the system
DD_TEAM_2_DATA_ID = environ["DD_TEAM_2_DATA_ID"]

body = TeamHierarchyLinkCreateRequest(
    data=TeamHierarchyLinkCreate(
        relationships=TeamHierarchyLinkCreateRelationships(
            parent_team=TeamHierarchyLinkCreateTeamRelationship(
                data=TeamHierarchyLinkCreateTeam(
                    id=DD_TEAM_DATA_ID,
                    type=TeamType.TEAM,
                ),
            ),
            sub_team=TeamHierarchyLinkCreateTeamRelationship(
                data=TeamHierarchyLinkCreateTeam(
                    id=DD_TEAM_2_DATA_ID,
                    type=TeamType.TEAM,
                ),
            ),
        ),
        type=TeamHierarchyLinkType.TEAM_HIERARCHY_LINKS,
    ),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = TeamsApi(api_client)
    response = api_instance.add_team_hierarchy_link(body=body)

    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
# Create a team hierarchy link returns "OK" response

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

# there is a valid "dd_team" in the system
DD_TEAM_DATA_ID = ENV["DD_TEAM_DATA_ID"]

# there is a valid "dd_team_2" in the system
DD_TEAM_2_DATA_ID = ENV["DD_TEAM_2_DATA_ID"]

body = DatadogAPIClient::V2::TeamHierarchyLinkCreateRequest.new({
  data: DatadogAPIClient::V2::TeamHierarchyLinkCreate.new({
    relationships: DatadogAPIClient::V2::TeamHierarchyLinkCreateRelationships.new({
      parent_team: DatadogAPIClient::V2::TeamHierarchyLinkCreateTeamRelationship.new({
        data: DatadogAPIClient::V2::TeamHierarchyLinkCreateTeam.new({
          id: DD_TEAM_DATA_ID,
          type: DatadogAPIClient::V2::TeamType::TEAM,
        }),
      }),
      sub_team: DatadogAPIClient::V2::TeamHierarchyLinkCreateTeamRelationship.new({
        data: DatadogAPIClient::V2::TeamHierarchyLinkCreateTeam.new({
          id: DD_TEAM_2_DATA_ID,
          type: DatadogAPIClient::V2::TeamType::TEAM,
        }),
      }),
    }),
    type: DatadogAPIClient::V2::TeamHierarchyLinkType::TEAM_HIERARCHY_LINKS,
  }),
})
p api_instance.add_team_hierarchy_link(body)
```

#### 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"
##### 

```rust
// Create a team hierarchy link returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_teams::TeamsAPI;
use datadog_api_client::datadogV2::model::TeamHierarchyLinkCreate;
use datadog_api_client::datadogV2::model::TeamHierarchyLinkCreateRelationships;
use datadog_api_client::datadogV2::model::TeamHierarchyLinkCreateRequest;
use datadog_api_client::datadogV2::model::TeamHierarchyLinkCreateTeam;
use datadog_api_client::datadogV2::model::TeamHierarchyLinkCreateTeamRelationship;
use datadog_api_client::datadogV2::model::TeamHierarchyLinkType;
use datadog_api_client::datadogV2::model::TeamType;

#[tokio::main]
async fn main() {
    // there is a valid "dd_team" in the system
    let dd_team_data_id = std::env::var("DD_TEAM_DATA_ID").unwrap();

    // there is a valid "dd_team_2" in the system
    let dd_team_2_data_id = std::env::var("DD_TEAM_2_DATA_ID").unwrap();
    let body = TeamHierarchyLinkCreateRequest::new(TeamHierarchyLinkCreate::new(
        TeamHierarchyLinkCreateRelationships::new(
            TeamHierarchyLinkCreateTeamRelationship::new(TeamHierarchyLinkCreateTeam::new(
                dd_team_data_id.clone(),
                TeamType::TEAM,
            )),
            TeamHierarchyLinkCreateTeamRelationship::new(TeamHierarchyLinkCreateTeam::new(
                dd_team_2_data_id.clone(),
                TeamType::TEAM,
            )),
        ),
        TeamHierarchyLinkType::TEAM_HIERARCHY_LINKS,
    ));
    let configuration = datadog::Configuration::new();
    let api = TeamsAPI::with_config(configuration);
    let resp = api.add_team_hierarchy_link(body).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
/**
 * Create a team hierarchy link 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 "dd_team" in the system
const DD_TEAM_DATA_ID = process.env.DD_TEAM_DATA_ID as string;

// there is a valid "dd_team_2" in the system
const DD_TEAM_2_DATA_ID = process.env.DD_TEAM_2_DATA_ID as string;

const params: v2.TeamsApiAddTeamHierarchyLinkRequest = {
  body: {
    data: {
      relationships: {
        parentTeam: {
          data: {
            id: DD_TEAM_DATA_ID,
            type: "team",
          },
        },
        subTeam: {
          data: {
            id: DD_TEAM_2_DATA_ID,
            type: "team",
          },
        },
      },
      type: "team_hierarchy_links",
    },
  },
};

apiInstance
  .addTeamHierarchyLink(params)
  .then((data: v2.TeamHierarchyLinkResponse) => {
    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 %}
