---
title: Replace AI Gateway governance controls
description: Replace the organization-wide AI Gateway governance settings, which are the default data capture mode and whether requests must reach providers covered by…
breadcrumbs: Docs > API > Replace AI Gateway governance controls
---

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

# Replace AI Gateway governance controls

## v2 (latest)

{% alert level="warning" %}
**Note**: This endpoint is in Preview and is subject to change.
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help.md).
{% /alert %}

| Datadog site      | API endpoint                                        |
| ----------------- | --------------------------------------------------- |
| app.datadoghq.com | PUT https://api.datadoghq.com/api/v2/governance     |
| us3.datadoghq.com | PUT https://api.us3.datadoghq.com/api/v2/governance |
| us5.datadoghq.com | PUT https://api.us5.datadoghq.com/api/v2/governance |
| app.datadoghq.eu  | PUT https://api.datadoghq.eu/api/v2/governance      |
| ap1.datadoghq.com | PUT https://api.ap1.datadoghq.com/api/v2/governance |
| ap2.datadoghq.com | PUT https://api.ap2.datadoghq.com/api/v2/governance |
| uk1.datadoghq.com | PUT https://api.uk1.datadoghq.com/api/v2/governance |
| app.ddog-gov.com  | PUT https://api.ddog-gov.com/api/v2/governance      |
| us2.ddog-gov.com  | PUT https://api.us2.ddog-gov.com/api/v2/governance  |

### Overview

Replace the organization-wide AI Gateway governance settings, which are the default data capture mode and whether requests must reach providers covered by a zero data retention agreement.

This endpoint requires the `ai_gateway_config_write` permission.

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

### Request

#### Body Data (required)

{% tabs %}
{% tab label="Model" %}
| Parent field | Field                          | Type     | Description                                                                                                                                                                      |
| ------------ | ------------------------------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data [*required*]              | object   | Data used to replace the organization's AI Gateway governance controls.                                                                                                          |
| data         | attributes [*required*]        | object   | Organization-wide AI Gateway governance controls to replace.                                                                                                                     |
| attributes   | data_capture_mode [*required*] | enum     | Data capture mode used when no scoped override matches the request. Allowed enum values: `metadata_only`, `full_capture`.                                                        |
| attributes   | metadata_capture               | [string] | Optional items Metadata-only capture adds when no scoped override matches. Omit it to keep the stored items.                                                                     |
| attributes   | zdr_mode                       | enum     | Whether the organization requires every request to reach a provider covered by a zero data retention agreement. Omit to leave unchanged. Allowed enum values: `off`, `required`. |
| data         | id                             | string   | Optional singleton governance resource identifier. When provided, it must be `organization`.                                                                                     |
| data         | type [*required*]              | enum     | AI Gateway governance resource type. Allowed enum values: `governance`.                                                                                                          |
{% /tab %}

{% tab label="Example" %}
```json
{
  "data": {
    "attributes": {
      "data_capture_mode": "metadata_only",
      "metadata_capture": [
        "tool_usage",
        "tool_output_size",
        "tool_names"
      ],
      "zdr_mode": "off"
    },
    "id": "organization",
    "type": "governance"
  }
}
```
{% /tab %}
{% /tabs %}

### Response

{% tabs %}
{% tab label="200" %}
OK

{% tabs %}
{% tab label="Model" %}
Response containing the organization's AI Gateway governance controls.

| Parent field | Field                          | Type     | Description                                                                                                                                             |
| ------------ | ------------------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data [*required*]              | object   | Organization-wide AI Gateway governance resource.                                                                                                       |
| data         | attributes [*required*]        | object   | Organization-wide AI Gateway governance controls.                                                                                                       |
| attributes   | data_capture_mode [*required*] | enum     | Data capture mode used when no scoped override matches the request. Allowed enum values: `metadata_only`, `full_capture`.                               |
| attributes   | metadata_capture               | [string] | Items Metadata-only capture adds when no scoped override matches. Empty when none are selected.                                                         |
| attributes   | zdr_mode [*required*]          | enum     | Whether the organization requires every request to reach a provider covered by a zero data retention agreement. Allowed enum values: `off`, `required`. |
| data         | id [*required*]                | string   | Singleton governance resource identifier.                                                                                                               |
| data         | type [*required*]              | enum     | AI Gateway governance resource type. Allowed enum values: `governance`.                                                                                 |
{% /tab %}

{% tab label="Example" %}
```json
{
  "data": {
    "attributes": {
      "data_capture_mode": "metadata_only",
      "metadata_capture": [
        "tool_usage",
        "tool_output_size",
        "tool_names"
      ],
      "zdr_mode": "off"
    },
    "id": "organization",
    "type": "governance"
  }
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="400" %}
Bad Request

{% tabs %}
{% tab label="Model" %}
API error response.

| Field               | Type     | Description       |
| ------------------- | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="429" %}
Too many requests

{% tabs %}
{% tab label="Model" %}
API error response.

| Field               | Type     | Description       |
| ------------------- | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}
{% /tabs %}

### Code Example

{% tabs %}
{% tab label="Curl" %}
```bash
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com" # Or us3.datadoghq.com, us5.datadoghq.com, datadoghq.eu, ap1.datadoghq.com, ap2.datadoghq.com, uk1.datadoghq.com, ddog-gov.com, us2.ddog-gov.com
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X PUT "https://api.${DD_SITE}/api/v2/governance" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "data_capture_mode": "metadata_only",
      "metadata_capture": [
        "tool_usage",
        "tool_output_size",
        "tool_names"
      ],
      "zdr_mode": "off"
    },
    "id": "organization",
    "type": "governance"
  }
}
EOF
```
{% /tab %}
{% /tabs %}
