Skip to content

Add documentation for /api/v2/team/sync #2746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .generated-info
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"spec_repo_commit": "d02c8a3",
"generated": "2025-08-08 12:07:20.979"
"spec_repo_commit": "07f8772",
"generated": "2025-08-11 21:19:54.357"
}
127 changes: 127 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42273,6 +42273,68 @@ components:
urgency:
$ref: '#/components/schemas/Urgency'
type: object
TeamSyncAttributes:
description: Team sync attributes.
properties:
source:
$ref: '#/components/schemas/TeamSyncAttributesSource'
type:
$ref: '#/components/schemas/TeamSyncAttributesType'
required:
- source
- type
type: object
TeamSyncAttributesSource:
description: The external source platform for team synchronization. Only "github"
is supported.
enum:
- github
example: github
type: string
x-enum-varnames:
- GITHUB
TeamSyncAttributesType:
description: The type of synchronization operation. Only "link" is supported,
which links existing teams by matching names.
enum:
- link
example: link
type: string
x-enum-varnames:
- LINK
TeamSyncBulkType:
description: Team sync bulk type.
enum:
- team_sync_bulk
example: team_sync_bulk
type: string
x-enum-varnames:
- TEAM_SYNC_BULK
TeamSyncData:
description: Team sync data.
properties:
attributes:
$ref: '#/components/schemas/TeamSyncAttributes'
type:
$ref: '#/components/schemas/TeamSyncBulkType'
required:
- attributes
- type
type: object
TeamSyncRequest:
description: Team sync request.
example:
data:
attributes:
source: github
type: link
type: team_sync_bulk
properties:
data:
$ref: '#/components/schemas/TeamSyncData'
required:
- data
type: object
TeamTarget:
description: Represents a team target for an escalation policy step, including
the team's ID and resource type.
Expand Down Expand Up @@ -65313,6 +65375,71 @@ paths:
permissions:
- teams_read
- teams_manage
/api/v2/team/sync:
post:
description: 'This endpoint attempts to link your existing Datadog teams with
GitHub teams by matching their names.

It evaluates all current Datadog teams and compares them against teams in
the GitHub organization

connected to your Datadog account, based on Datadog Team handle and GitHub
Team slug

(lowercased and kebab-cased).


This operation is read-only on the GitHub side, no teams will be modified
or created.


[A GitHub organization must be connected to your Datadog account](https://docs.datadoghq.com/integrations/github/),

and the GitHub App integrated with Datadog must have the `Members Read` permission.
Matching is performed by comparing the Datadog team handle to the GitHub team
slug

using a normalized exact match; case is ignored and spaces are removed. No
modifications are made

to teams in GitHub. This will not create new Teams in Datadog.'
operationId: SyncTeams
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/TeamSyncRequest'
required: true
responses:
'200':
description: OK
'403':
$ref: '#/components/responses/ForbiddenResponse'
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
'500':
content:
application/json:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: Internal Server Error - Unexpected error during linking.
security:
- apiKeyAuth: []
appKeyAuth: []
- AuthZ:
- teams_manage
summary: Link Teams with GitHub Teams
tags:
- Teams
x-codegen-request-body-name: body
x-permission:
operator: AND
permissions:
- teams_manage
x-unstable: '**Note**: This endpoint is in Preview. To request access, fill
out this [form](https://www.datadoghq.com/product-preview/github-integration-for-teams/).

If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
/api/v2/team/{super_team_id}/member_teams:
get:
description: Get all member teams.
Expand Down
42 changes: 42 additions & 0 deletions docs/datadog_api_client.v2.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18785,6 +18785,48 @@ datadog\_api\_client.v2.model.team\_routing\_rules\_request\_rule module
:members:
:show-inheritance:

datadog\_api\_client.v2.model.team\_sync\_attributes module
-----------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.team_sync_attributes
:members:
:show-inheritance:

datadog\_api\_client.v2.model.team\_sync\_attributes\_source module
-------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.team_sync_attributes_source
:members:
:show-inheritance:

datadog\_api\_client.v2.model.team\_sync\_attributes\_type module
-----------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.team_sync_attributes_type
:members:
:show-inheritance:

datadog\_api\_client.v2.model.team\_sync\_bulk\_type module
-----------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.team_sync_bulk_type
:members:
:show-inheritance:

datadog\_api\_client.v2.model.team\_sync\_data module
-----------------------------------------------------

.. automodule:: datadog_api_client.v2.model.team_sync_data
:members:
:show-inheritance:

datadog\_api\_client.v2.model.team\_sync\_request module
--------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.team_sync_request
:members:
:show-inheritance:

datadog\_api\_client.v2.model.team\_target module
-------------------------------------------------

Expand Down
28 changes: 28 additions & 0 deletions examples/v2/teams/SyncTeams.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
Link Teams with GitHub Teams returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.teams_api import TeamsApi
from datadog_api_client.v2.model.team_sync_attributes import TeamSyncAttributes
from datadog_api_client.v2.model.team_sync_attributes_source import TeamSyncAttributesSource
from datadog_api_client.v2.model.team_sync_attributes_type import TeamSyncAttributesType
from datadog_api_client.v2.model.team_sync_bulk_type import TeamSyncBulkType
from datadog_api_client.v2.model.team_sync_data import TeamSyncData
from datadog_api_client.v2.model.team_sync_request import TeamSyncRequest

body = TeamSyncRequest(
data=TeamSyncData(
attributes=TeamSyncAttributes(
source=TeamSyncAttributesSource.GITHUB,
type=TeamSyncAttributesType.LINK,
),
type=TeamSyncBulkType.TEAM_SYNC_BULK,
),
)

configuration = Configuration()
configuration.unstable_operations["sync_teams"] = True
with ApiClient(configuration) as api_client:
api_instance = TeamsApi(api_client)
api_instance.sync_teams(body=body)
27 changes: 27 additions & 0 deletions examples/v2/teams/SyncTeams_3215592344.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""
Sync teams returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.teams_api import TeamsApi
from datadog_api_client.v2.model.team_sync_attributes import TeamSyncAttributes
from datadog_api_client.v2.model.team_sync_attributes_source import TeamSyncAttributesSource
from datadog_api_client.v2.model.team_sync_attributes_type import TeamSyncAttributesType
from datadog_api_client.v2.model.team_sync_bulk_type import TeamSyncBulkType
from datadog_api_client.v2.model.team_sync_data import TeamSyncData
from datadog_api_client.v2.model.team_sync_request import TeamSyncRequest

body = TeamSyncRequest(
data=TeamSyncData(
attributes=TeamSyncAttributes(
source=TeamSyncAttributesSource.GITHUB,
type=TeamSyncAttributesType.LINK,
),
type=TeamSyncBulkType.TEAM_SYNC_BULK,
),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = TeamsApi(api_client)
api_instance.sync_teams(body=body)
1 change: 1 addition & 0 deletions src/datadog_api_client/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ def __init__(
"v2.add_member_team": False,
"v2.list_member_teams": False,
"v2.remove_member_team": False,
"v2.sync_teams": False,
"v2.create_incident_team": False,
"v2.delete_incident_team": False,
"v2.get_incident_team": False,
Expand Down
47 changes: 47 additions & 0 deletions src/datadog_api_client/v2/api/teams_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from datadog_api_client.v2.model.team import Team
from datadog_api_client.v2.model.team_response import TeamResponse
from datadog_api_client.v2.model.team_create_request import TeamCreateRequest
from datadog_api_client.v2.model.team_sync_request import TeamSyncRequest
from datadog_api_client.v2.model.add_member_team_request import AddMemberTeamRequest
from datadog_api_client.v2.model.team_update_request import TeamUpdateRequest
from datadog_api_client.v2.model.team_links_response import TeamLinksResponse
Expand Down Expand Up @@ -512,6 +513,26 @@ def __init__(self, api_client=None):
api_client=api_client,
)

self._sync_teams_endpoint = _Endpoint(
settings={
"response_type": None,
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/team/sync",
"operation_id": "sync_teams",
"http_method": "POST",
"version": "v2",
},
params_map={
"body": {
"required": True,
"openapi_types": (TeamSyncRequest,),
"location": "body",
},
},
headers_map={"accept": ["*/*"], "content_type": ["application/json"]},
api_client=api_client,
)

self._update_team_endpoint = _Endpoint(
settings={
"response_type": (TeamResponse,),
Expand Down Expand Up @@ -1191,6 +1212,32 @@ def remove_member_team(

return self._remove_member_team_endpoint.call_with_http_info(**kwargs)

def sync_teams(
self,
body: TeamSyncRequest,
) -> None:
"""Link Teams with GitHub Teams.

This endpoint attempts to link your existing Datadog teams with GitHub teams by matching their names.
It evaluates all current Datadog teams and compares them against teams in the GitHub organization
connected to your Datadog account, based on Datadog Team handle and GitHub Team slug
(lowercased and kebab-cased).

This operation is read-only on the GitHub side, no teams will be modified or created.

`A GitHub organization must be connected to your Datadog account <https://docs.datadoghq.com/integrations/github/>`_ ,
and the GitHub App integrated with Datadog must have the ``Members Read`` permission. Matching is performed by comparing the Datadog team handle to the GitHub team slug
using a normalized exact match; case is ignored and spaces are removed. No modifications are made
to teams in GitHub. This will not create new Teams in Datadog.

:type body: TeamSyncRequest
:rtype: None
"""
kwargs: Dict[str, Any] = {}
kwargs["body"] = body

return self._sync_teams_endpoint.call_with_http_info(**kwargs)

def update_team(
self,
team_id: str,
Expand Down
48 changes: 48 additions & 0 deletions src/datadog_api_client/v2/model/team_sync_attributes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
)


if TYPE_CHECKING:
from datadog_api_client.v2.model.team_sync_attributes_source import TeamSyncAttributesSource
from datadog_api_client.v2.model.team_sync_attributes_type import TeamSyncAttributesType


class TeamSyncAttributes(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.team_sync_attributes_source import TeamSyncAttributesSource
from datadog_api_client.v2.model.team_sync_attributes_type import TeamSyncAttributesType

return {
"source": (TeamSyncAttributesSource,),
"type": (TeamSyncAttributesType,),
}

attribute_map = {
"source": "source",
"type": "type",
}

def __init__(self_, source: TeamSyncAttributesSource, type: TeamSyncAttributesType, **kwargs):
"""
Team sync attributes.

:param source: The external source platform for team synchronization. Only "github" is supported.
:type source: TeamSyncAttributesSource

:param type: The type of synchronization operation. Only "link" is supported, which links existing teams by matching names.
:type type: TeamSyncAttributesType
"""
super().__init__(kwargs)

self_.source = source
self_.type = type
Loading
Loading