> This page is for Gateway.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.merge.dev/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.merge.dev/_mcp/server.

# Update Export Destination

PATCH https://api-gateway.merge.dev/v1/export-destinations/{destination_id}
Content-Type: application/json

Update the fields you send. Send `credential_secret` to rotate the
secret. `kind` and `otlp_preset` can't change.

Reference: https://docs.merge.dev/merge-gateway/management-api/export-destinations/update-export-destination

## Authentication

- `Authorization` header (bearer token, required) — A management key (`mgmt_...`), sent as `Authorization: Bearer <key>`. Reading /v1/routing-policies also accepts the organization's gateway API keys; writing there needs a management key.

## Request

### Path parameters

- `destination_id` (string, required) — The destination's `id`.

### Body (application/json)

This endpoint expects an ExportDestinationV1Update.

- `credential_secret` (string, optional) — Replaces the stored secret. The API key or token the destination authenticates with. Never returned; responses show credential_hint instead. Omit to keep the current value. null is rejected.
- `credential_username` (string, optional, nullable) — grafana only: the Grafana Cloud instance ID. Not a secret, so it is returned. null clears it, where the preset doesn't need it.
- `enabled` (boolean, optional) — Whether the gateway exports to the destination. Omit to keep the current value. null is rejected.
- `metrics_enabled` (boolean, optional) — Also export metrics. Datadog and Grafana Cloud bill these separately. Omit to keep the current value. null is rejected.
- `ml_app` (string, optional, nullable) — Datadog only: the ml_app tag on exported spans. null clears it.
- `name` (string, optional) — A name for the destination, unique in the organization. Omit to keep the current value. null is rejected.
- `otlp_endpoint` (string, optional) — generic only: the https URL of your OTLP collector. Omit to keep the current value. null is rejected.
- `privacy_mode` (boolean, optional) — When true, prompts and completions are left out of exported spans. Omit to keep the current value. null is rejected.
- `sample_rate` (double, optional) — Fraction of requests exported, from 0.0001 to 1. Omit to keep the current value. null is rejected.
- `site` (string, optional) — datadog: a Datadog site, like datadoghq.com. grafana: a Grafana Cloud zone, like prod-us-east-0. generic: not allowed; use otlp_endpoint. Omit to keep the current value. null is rejected.

## Response

### 200

The updated export destination

- `consecutive_failures` (integer, required) — Failed deliveries in a row.
- `created_at` (datetime, required) — When the destination was created.
- `credential_hint` (string, required, nullable) — The last 4 characters of the stored secret, to tell secrets apart. null when the secret is under 12 characters (4 would give away too much of it).
- `credential_username` (string, required, nullable) — grafana only: the Grafana Cloud instance ID. Not a secret, so it is returned.
- `delivery_suspended_until` (datetime, required, nullable) — Set while delivery is paused after repeated failures.
- `enabled` (boolean, required) — Whether the gateway exports to the destination.
- `id` (string, required) — The destination's id.
- `kind` ("otlp", required) — Can't be changed after creation.
- `last_error_at` (datetime, required, nullable) — When a delivery last failed.
- `last_error_message` (string, required, nullable) — Why the last failed delivery failed.
- `last_success_at` (datetime, required, nullable) — When a delivery last succeeded.
- `metrics_enabled` (boolean, required) — Also export metrics. Datadog and Grafana Cloud bill these separately.
- `ml_app` (string, required, nullable) — Datadog only: the ml_app tag on exported spans.
- `name` (string, required) — A name for the destination, unique in the organization.
- `organization_id` (string, required) — The organization the destination belongs to.
- `otlp_endpoint` (string, required, nullable) — generic only: the https URL of your OTLP collector.
- `otlp_preset` (enum, required) — Where spans go. Besides the presets create accepts, `datadog-apm`: those destinations are created in the dashboard only. Can't be changed after creation.
  - Allowed values: `datadog`, `datadog-apm`, `grafana`, `generic`
- `privacy_mode` (boolean, required) — When true, prompts and completions are left out of exported spans.
- `sample_rate` (double, required) — Fraction of requests exported, from 0.0001 to 1.
- `site` (string, required, nullable) — datadog: a Datadog site, like datadoghq.com. grafana: a Grafana Cloud zone, like prod-us-east-0. generic: not allowed; use otlp_endpoint.
- `updated_at` (datetime, required) — When the destination last changed.

## Errors

### 401 Unauthorized Error

The key is missing or invalid.

- `detail` (ErrorResponseDetail, required) — A message, or an object with a `code` to branch on and a `message`.

### 403 Forbidden Error

The key lacks the scope this route needs, or the change is not allowed.

- `detail` (ErrorResponseDetail, required) — A message, or an object with a `code` to branch on and a `message`.

### 404 Not Found Error

The resource does not exist in the key's organization.

- `detail` (ErrorResponseDetail, required) — A message, or an object with a `code` to branch on and a `message`.

### 409 Conflict Error

The request conflicts with the current state.

- `detail` (ErrorResponseDetail, required) — A message, or an object with a `code` to branch on and a `message`.

### 422 Unprocessable Entity Error

The request is invalid.

- `Update_export_destinationRequestUnprocessableEntityError`

### 503 Service Unavailable Error

A service the request needs, such as billing or the gateway itself, is temporarily unavailable. Retry later.

- `detail` (ErrorResponseDetail, required) — A message, or an object with a `code` to branch on and a `message`.

## Types

### ErrorResponseDetail

A message, or an object with a `code` to branch on and a `message`.

### HTTPValidationError

- `detail` (list of ValidationError, optional)

### ErrorResponse

The body of an error response.

- `detail` (ErrorResponseDetail, required) — A message, or an object with a `code` to branch on and a `message`.

### ErrorDetail

A structured error. Some carry extra fields, like `count`.

- `code` (string, required) — A stable code to branch on, like `payment_method_required`.
- `message` (string, required) — A human-readable explanation.

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)
- `ctx` (ValidationErrorCtx, optional)
- `input` (any, optional)

### ValidationErrorLocItems

### ValidationErrorCtx

## Examples

**Request**

```json
{
  "metrics_enabled": true,
  "sample_rate": 0.25
}
```

**Response**

```json
{
  "consecutive_failures": 0,
  "created_at": "2026-06-02T17:04:00Z",
  "credential_hint": "9f2c",
  "credential_username": null,
  "delivery_suspended_until": null,
  "enabled": true,
  "id": "1a7e3c5b-8d2f-4b6a-9c0e-3f5d7b9a1c24",
  "kind": "otlp",
  "last_error_at": null,
  "last_error_message": null,
  "last_success_at": "2026-10-15T08:12:44Z",
  "metrics_enabled": false,
  "ml_app": "support-bot",
  "name": "datadog-prod",
  "organization_id": "3f2b8c1e-6a4d-4e7f-9b21-5c8d0e7a4f13",
  "otlp_endpoint": null,
  "otlp_preset": "datadog",
  "privacy_mode": true,
  "sample_rate": 1,
  "site": "datadoghq.com",
  "updated_at": "2026-09-14T09:30:00Z"
}
```

**SDK Code**

```python
import requests

url = "https://api-gateway.merge.dev/v1/export-destinations/destination_id"

payload = {
    "metrics_enabled": True,
    "sample_rate": 0.25
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api-gateway.merge.dev/v1/export-destinations/destination_id';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"metrics_enabled":true,"sample_rate":0.25}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api-gateway.merge.dev/v1/export-destinations/destination_id"

	payload := strings.NewReader("{\n  \"metrics_enabled\": true,\n  \"sample_rate\": 0.25\n}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api-gateway.merge.dev/v1/export-destinations/destination_id")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"metrics_enabled\": true,\n  \"sample_rate\": 0.25\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api-gateway.merge.dev/v1/export-destinations/destination_id")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"metrics_enabled\": true,\n  \"sample_rate\": 0.25\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api-gateway.merge.dev/v1/export-destinations/destination_id', [
  'body' => '{
  "metrics_enabled": true,
  "sample_rate": 0.25
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api-gateway.merge.dev/v1/export-destinations/destination_id");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"metrics_enabled\": true,\n  \"sample_rate\": 0.25\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "metrics_enabled": true,
  "sample_rate": 0.25
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api-gateway.merge.dev/v1/export-destinations/destination_id")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```