---
title: Register an OAuth2 client
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > OAuth2 Client Public
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Register an OAuth2 client{% #register-an-oauth2-client %}
Copy pageCopied
{% tab title="v2" %}
**Note**: This endpoint is in preview and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).
| Datadog site      | API endpoint                                              |
| ----------------- | --------------------------------------------------------- |
| ap1.datadoghq.com | POST https://api.ap1.datadoghq.com/api/v2/oauth2/register |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v2/oauth2/register |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v2/oauth2/register      |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v2/oauth2/register      |
| us2.ddog-gov.com  | POST https://api.us2.ddog-gov.com/api/v2/oauth2/register  |
| uk1.datadoghq.com | POST https://api.uk1.datadoghq.com/api/v2/oauth2/register |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v2/oauth2/register     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v2/oauth2/register |
| us5.datadoghq.com | POST https://api.us5.datadoghq.com/api/v2/oauth2/register |

### Overview

Register an OAuth2 client using the Dynamic Client Registration protocol defined in RFC 7591.

### Request

#### Body Data (required)



{% tab title="Model" %}

| Field                           | Type     | Description                                                                                                  |
| ------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------ |
| client_name [*required*]   | string   | Human-readable name of the client. Control characters are rejected.                                          |
| client_uri                      | string   | URL of the home page of the client.                                                                          |
| grant_types                     | [string] | OAuth 2.0 grant types the client may use. Defaults to `authorization_code` and `refresh_token` when omitted. |
| jwks_uri                        | string   | URL referencing the client's JSON Web Key Set.                                                               |
| logo_uri                        | string   | URL referencing a logo for the client.                                                                       |
| policy_uri                      | string   | URL pointing to the client's privacy policy.                                                                 |
| redirect_uris [*required*] | [string] | Array of redirection URI strings used by the client in redirect-based flows.                                 |
| response_types                  | [string] | OAuth 2.0 response types the client may use. Only `code` is supported.                                       |
| scope                           | string   | Space-separated list of scope values the client may request.                                                 |
| token_endpoint_auth_method      | string   | Requested authentication method for the token endpoint. Only `none` is supported.                            |
| tos_uri                         | string   | URL pointing to the client's terms of service.                                                               |

{% /tab %}

{% tab title="Example" %}

```json
{
  "client_name": "Example MCP Client",
  "client_uri": "https://example.com",
  "grant_types": [
    "authorization_code",
    "refresh_token"
  ],
  "jwks_uri": "https://example.com/.well-known/jwks.json",
  "logo_uri": "https://example.com/logo.png",
  "policy_uri": "https://example.com/privacy",
  "redirect_uris": [
    "https://example.com/oauth/callback"
  ],
  "response_types": [
    "code"
  ],
  "scope": "openid profile",
  "token_endpoint_auth_method": "none",
  "tos_uri": "https://example.com/tos"
}
```

{% /tab %}

### Response

{% tab title="201" %}
Created
{% tab title="Model" %}
Response payload for a successful OAuth2 dynamic client registration as defined by RFC 7591.

| Field                                        | Type     | Description                                                             |
| -------------------------------------------- | -------- | ----------------------------------------------------------------------- |
| client_id [*required*]                  | uuid     | Unique identifier assigned to the registered client.                    |
| client_name [*required*]                | string   | Human-readable name of the client.                                      |
| grant_types [*required*]                | [string] | OAuth 2.0 grant types registered for the client.                        |
| redirect_uris [*required*]              | [string] | Redirection URIs registered for the client.                             |
| response_types [*required*]             | [string] | OAuth 2.0 response types registered for the client.                     |
| token_endpoint_auth_method [*required*] | string   | Authentication method registered for the token endpoint. Always `none`. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "client_id": "72b68208-36a6-11f0-b21b-da7ad0900002",
  "client_name": "Example MCP Client",
  "grant_types": [
    "authorization_code",
    "refresh_token"
  ],
  "redirect_uris": [
    "https://example.com/oauth/callback"
  ],
  "response_types": [
    "code"
  ],
  "token_endpoint_auth_method": "none"
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
Error payload returned by OAuth2 dynamic client registration as defined by RFC 7591.

| Field                               | Type   | Description                                                                                   |
| ----------------------------------- | ------ | --------------------------------------------------------------------------------------------- |
| error [*required*]             | string | Single ASCII error code per RFC 7591, such as `invalid_request` or `invalid_client_metadata`. |
| error_description [*required*] | string | Human-readable description of the error.                                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "error": "invalid_client_metadata",
  "error_description": "redirect URI is not well-formed"
}
```

{% /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/oauth2/register" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d @- << EOF
{
  "client_name": "Example MCP Client",
  "grant_types": [
    "authorization_code",
    "refresh_token"
  ],
  "redirect_uris": [
    "https://example.com/oauth/callback"
  ],
  "response_types": [
    "code"
  ],
  "token_endpoint_auth_method": "none"
}
EOF 
                
##### 

```python
"""
Register an OAuth2 client returns "Created" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.o_auth2_client_public_api import OAuth2ClientPublicApi
from datadog_api_client.v2.model.o_auth_client_registration_grant_type import OAuthClientRegistrationGrantType
from datadog_api_client.v2.model.o_auth_client_registration_request import OAuthClientRegistrationRequest
from datadog_api_client.v2.model.o_auth_client_registration_response_type import OAuthClientRegistrationResponseType

body = OAuthClientRegistrationRequest(
    client_name="Example MCP Client",
    client_uri="https://example.com",
    grant_types=[
        OAuthClientRegistrationGrantType.AUTHORIZATION_CODE,
        OAuthClientRegistrationGrantType.REFRESH_TOKEN,
    ],
    jwks_uri="https://example.com/.well-known/jwks.json",
    logo_uri="https://example.com/logo.png",
    policy_uri="https://example.com/privacy",
    redirect_uris=[
        "https://example.com/oauth/callback",
    ],
    response_types=[
        OAuthClientRegistrationResponseType.CODE,
    ],
    scope="openid profile",
    token_endpoint_auth_method="none",
    tos_uri="https://example.com/tos",
)

configuration = Configuration()
configuration.unstable_operations["register_o_auth_client"] = True
with ApiClient(configuration) as api_client:
    api_instance = OAuth2ClientPublicApi(api_client)
    response = api_instance.register_o_auth_client(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" python3 "example.py"
##### 

```ruby
# Register an OAuth2 client returns "Created" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.unstable_operations["v2.register_o_auth_client".to_sym] = true
end
api_instance = DatadogAPIClient::V2::OAuth2ClientPublicAPI.new

body = DatadogAPIClient::V2::OAuthClientRegistrationRequest.new({
  client_name: "Example MCP Client",
  client_uri: "https://example.com",
  grant_types: [
    DatadogAPIClient::V2::OAuthClientRegistrationGrantType::AUTHORIZATION_CODE,
    DatadogAPIClient::V2::OAuthClientRegistrationGrantType::REFRESH_TOKEN,
  ],
  jwks_uri: "https://example.com/.well-known/jwks.json",
  logo_uri: "https://example.com/logo.png",
  policy_uri: "https://example.com/privacy",
  redirect_uris: [
    "https://example.com/oauth/callback",
  ],
  response_types: [
    DatadogAPIClient::V2::OAuthClientRegistrationResponseType::CODE,
  ],
  scope: "openid profile",
  token_endpoint_auth_method: "none",
  tos_uri: "https://example.com/tos",
})
p api_instance.register_o_auth_client(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" rb "example.rb"
##### 

```go
// Register an OAuth2 client returns "Created" 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() {
	body := datadogV2.OAuthClientRegistrationRequest{
		ClientName: "Example MCP Client",
		ClientUri:  datadog.PtrString("https://example.com"),
		GrantTypes: []datadogV2.OAuthClientRegistrationGrantType{
			datadogV2.OAUTHCLIENTREGISTRATIONGRANTTYPE_AUTHORIZATION_CODE,
			datadogV2.OAUTHCLIENTREGISTRATIONGRANTTYPE_REFRESH_TOKEN,
		},
		JwksUri:   datadog.PtrString("https://example.com/.well-known/jwks.json"),
		LogoUri:   datadog.PtrString("https://example.com/logo.png"),
		PolicyUri: datadog.PtrString("https://example.com/privacy"),
		RedirectUris: []string{
			"https://example.com/oauth/callback",
		},
		ResponseTypes: []datadogV2.OAuthClientRegistrationResponseType{
			datadogV2.OAUTHCLIENTREGISTRATIONRESPONSETYPE_CODE,
		},
		Scope:                   datadog.PtrString("openid profile"),
		TokenEndpointAuthMethod: datadog.PtrString("none"),
		TosUri:                  datadog.PtrString("https://example.com/tos"),
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("v2.RegisterOAuthClient", true)
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewOAuth2ClientPublicApi(apiClient)
	resp, r, err := api.RegisterOAuthClient(ctx, body)

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

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `OAuth2ClientPublicApi.RegisterOAuthClient`:\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" go run "main.go"
##### 

```java
// Register an OAuth2 client returns "Created" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.OAuth2ClientPublicApi;
import com.datadog.api.client.v2.model.OAuthClientRegistrationGrantType;
import com.datadog.api.client.v2.model.OAuthClientRegistrationRequest;
import com.datadog.api.client.v2.model.OAuthClientRegistrationResponse;
import com.datadog.api.client.v2.model.OAuthClientRegistrationResponseType;
import java.util.Arrays;
import java.util.Collections;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    defaultClient.setUnstableOperationEnabled("v2.registerOAuthClient", true);
    OAuth2ClientPublicApi apiInstance = new OAuth2ClientPublicApi(defaultClient);

    OAuthClientRegistrationRequest body =
        new OAuthClientRegistrationRequest()
            .clientName("Example MCP Client")
            .clientUri("https://example.com")
            .grantTypes(
                Arrays.asList(
                    OAuthClientRegistrationGrantType.AUTHORIZATION_CODE,
                    OAuthClientRegistrationGrantType.REFRESH_TOKEN))
            .jwksUri("https://example.com/.well-known/jwks.json")
            .logoUri("https://example.com/logo.png")
            .policyUri("https://example.com/privacy")
            .redirectUris(Collections.singletonList("https://example.com/oauth/callback"))
            .responseTypes(Collections.singletonList(OAuthClientRegistrationResponseType.CODE))
            .scope("openid profile")
            .tokenEndpointAuthMethod("none")
            .tosUri("https://example.com/tos");

    try {
      OAuthClientRegistrationResponse result = apiInstance.registerOAuthClient(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling OAuth2ClientPublicApi#registerOAuthClient");
      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" java "Example.java"
##### 

```rust
// Register an OAuth2 client returns "Created" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_o_auth2_client_public::OAuth2ClientPublicAPI;
use datadog_api_client::datadogV2::model::OAuthClientRegistrationGrantType;
use datadog_api_client::datadogV2::model::OAuthClientRegistrationRequest;
use datadog_api_client::datadogV2::model::OAuthClientRegistrationResponseType;

#[tokio::main]
async fn main() {
    let body = OAuthClientRegistrationRequest::new(
        "Example MCP Client".to_string(),
        vec!["https://example.com/oauth/callback".to_string()],
    )
    .client_uri("https://example.com".to_string())
    .grant_types(vec![
        OAuthClientRegistrationGrantType::AUTHORIZATION_CODE,
        OAuthClientRegistrationGrantType::REFRESH_TOKEN,
    ])
    .jwks_uri("https://example.com/.well-known/jwks.json".to_string())
    .logo_uri("https://example.com/logo.png".to_string())
    .policy_uri("https://example.com/privacy".to_string())
    .response_types(vec![OAuthClientRegistrationResponseType::CODE])
    .scope("openid profile".to_string())
    .token_endpoint_auth_method("none".to_string())
    .tos_uri("https://example.com/tos".to_string());
    let mut configuration = datadog::Configuration::new();
    configuration.set_unstable_operation_enabled("v2.RegisterOAuthClient", true);
    let api = OAuth2ClientPublicAPI::with_config(configuration);
    let resp = api.register_o_auth_client(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" cargo run
##### 

```typescript
/**
 * Register an OAuth2 client returns "Created" response
 */

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

const configuration = client.createConfiguration();
configuration.unstableOperations["v2.registerOAuthClient"] = true;
const apiInstance = new v2.OAuth2ClientPublicApi(configuration);

const params: v2.OAuth2ClientPublicApiRegisterOAuthClientRequest = {
  body: {
    clientName: "Example MCP Client",
    clientUri: "https://example.com",
    grantTypes: ["authorization_code", "refresh_token"],
    jwksUri: "https://example.com/.well-known/jwks.json",
    logoUri: "https://example.com/logo.png",
    policyUri: "https://example.com/privacy",
    redirectUris: ["https://example.com/oauth/callback"],
    responseTypes: ["code"],
    scope: "openid profile",
    tokenEndpointAuthMethod: "none",
    tosUri: "https://example.com/tos",
  },
};

apiInstance
  .registerOAuthClient(params)
  .then((data: v2.OAuthClientRegistrationResponse) => {
    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" tsc "example.ts"
{% /tab %}
