> 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.

# Send Routing Feedback

POST https://api-gateway.merge.dev/v1/classifiers/feedback
Content-Type: application/json

Say whether a request was routed well. When a custom classifier scored it and the
feedback carries a prompt, the prompt is added to that classifier's examples with the
corrected complexity and the classifier rebuilds in the background. Only one feedback
on a request trains. A skipped feedback keeps no prompt; resending it with the same
idempotency_key and a new body corrects that row, and trains if the correction
qualifies.

Reference: https://docs.merge.dev/merge-gateway/management-api/routing-policies/send-routing-feedback

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

### Body (application/json)

This endpoint expects a RoutingFeedbackV1Request.

- `request_id` (string, required) — The request's id.
- `verdict` (enum, required) — Whether the routed model fit the request.
  - Allowed values: `good`, `bad`
- `correct_complexity` (double, optional, nullable) — The complexity it should have scored, 0 to 1.
- `direction` (enum, optional, nullable) — For `bad`: which way routing should have gone. Inferred when the request went to the cheapest or the strongest tier.
  - Allowed values: `stronger`, `cheaper`
- `idempotency_key` (string, optional, nullable) — Retries with the same key are no-ops.
- `note` (string, optional, nullable) — Free text, stored with the feedback.
- `prompt` (string, optional, nullable) — The request's prompt (its last user message). Without it the feedback is stored but doesn't train.

## Response

### 200

A replay of stored feedback

- `classifier_id` (string, required, nullable) — The classifier that scored the request.
- `id` (string, required)
- `label` (double, required, nullable) — The complexity label, when one could be set.
- `request_id` (string, required)
- `skip_reason` (enum, required, nullable) — Why it didn't train, when it didn't.
  - Allowed values: `no_custom_classifier`, `no_prompt`, `direction_required`, `no_score`, `already_trained`, `feedback_cap`
- `trained` (boolean, required) — Whether an example was added to the classifier.
- `verdict` (enum, required)
  - Allowed values: `good`, `bad`

### 201

The stored feedback

- `classifier_id` (string, required, nullable) — The classifier that scored the request.
- `id` (string, required)
- `label` (double, required, nullable) — The complexity label, when one could be set.
- `request_id` (string, required)
- `skip_reason` (enum, required, nullable) — Why it didn't train, when it didn't.
  - Allowed values: `no_custom_classifier`, `no_prompt`, `direction_required`, `no_score`, `already_trained`, `feedback_cap`
- `trained` (boolean, required) — Whether an example was added to the classifier.
- `verdict` (enum, required)
  - Allowed values: `good`, `bad`

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

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### ErrorResponseDetail

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

- string
- ErrorDetail: ErrorDetail

### ValidationError

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

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

### ValidationErrorLocItems

- string
- integer

### ValidationErrorCtx

## Examples

### Example 1

**Request**

```json
{
  "request_id": "req_01JD3X7Q4M8N2P5R6S7T8V9W0X",
  "verdict": "bad",
  "direction": "stronger",
  "idempotency_key": "ticket-4812",
  "note": "Missed the GAAP adjustments.",
  "prompt": "Build the Q3 ARR bridge and tie it back to the GAAP revenue waterfall."
}
```

**Response**

```json
{
  "classifier_id": null,
  "id": "6a1f0c3e-8b2d-4f7a-9c5e-1d2b3a4c5e6f",
  "label": null,
  "request_id": "req_01JD3X7Q4M8N2P5R6S7T8V9W0X",
  "skip_reason": null,
  "trained": true,
  "verdict": "bad"
}
```

**SDK Code**

```python
import requests

url = "https://api-gateway.merge.dev/v1/classifiers/feedback"

payload = {
    "request_id": "req_01JD3X7Q4M8N2P5R6S7T8V9W0X",
    "verdict": "bad",
    "direction": "stronger",
    "idempotency_key": "ticket-4812",
    "note": "Missed the GAAP adjustments.",
    "prompt": "Build the Q3 ARR bridge and tie it back to the GAAP revenue waterfall."
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api-gateway.merge.dev/v1/classifiers/feedback';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"request_id":"req_01JD3X7Q4M8N2P5R6S7T8V9W0X","verdict":"bad","direction":"stronger","idempotency_key":"ticket-4812","note":"Missed the GAAP adjustments.","prompt":"Build the Q3 ARR bridge and tie it back to the GAAP revenue waterfall."}'
};

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/classifiers/feedback"

	payload := strings.NewReader("{\n  \"request_id\": \"req_01JD3X7Q4M8N2P5R6S7T8V9W0X\",\n  \"verdict\": \"bad\",\n  \"direction\": \"stronger\",\n  \"idempotency_key\": \"ticket-4812\",\n  \"note\": \"Missed the GAAP adjustments.\",\n  \"prompt\": \"Build the Q3 ARR bridge and tie it back to the GAAP revenue waterfall.\"\n}")

	req, _ := http.NewRequest("POST", 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/classifiers/feedback")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"request_id\": \"req_01JD3X7Q4M8N2P5R6S7T8V9W0X\",\n  \"verdict\": \"bad\",\n  \"direction\": \"stronger\",\n  \"idempotency_key\": \"ticket-4812\",\n  \"note\": \"Missed the GAAP adjustments.\",\n  \"prompt\": \"Build the Q3 ARR bridge and tie it back to the GAAP revenue waterfall.\"\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.post("https://api-gateway.merge.dev/v1/classifiers/feedback")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"request_id\": \"req_01JD3X7Q4M8N2P5R6S7T8V9W0X\",\n  \"verdict\": \"bad\",\n  \"direction\": \"stronger\",\n  \"idempotency_key\": \"ticket-4812\",\n  \"note\": \"Missed the GAAP adjustments.\",\n  \"prompt\": \"Build the Q3 ARR bridge and tie it back to the GAAP revenue waterfall.\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api-gateway.merge.dev/v1/classifiers/feedback', [
  'body' => '{
  "request_id": "req_01JD3X7Q4M8N2P5R6S7T8V9W0X",
  "verdict": "bad",
  "direction": "stronger",
  "idempotency_key": "ticket-4812",
  "note": "Missed the GAAP adjustments.",
  "prompt": "Build the Q3 ARR bridge and tie it back to the GAAP revenue waterfall."
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api-gateway.merge.dev/v1/classifiers/feedback");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"request_id\": \"req_01JD3X7Q4M8N2P5R6S7T8V9W0X\",\n  \"verdict\": \"bad\",\n  \"direction\": \"stronger\",\n  \"idempotency_key\": \"ticket-4812\",\n  \"note\": \"Missed the GAAP adjustments.\",\n  \"prompt\": \"Build the Q3 ARR bridge and tie it back to the GAAP revenue waterfall.\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "request_id": "req_01JD3X7Q4M8N2P5R6S7T8V9W0X",
  "verdict": "bad",
  "direction": "stronger",
  "idempotency_key": "ticket-4812",
  "note": "Missed the GAAP adjustments.",
  "prompt": "Build the Q3 ARR bridge and tie it back to the GAAP revenue waterfall."
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api-gateway.merge.dev/v1/classifiers/feedback")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
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()
```

### Example 2

**Request**

```json
{
  "request_id": "req_01JD3X7Q4M8N2P5R6S7T8V9W0X",
  "verdict": "bad",
  "direction": "stronger",
  "idempotency_key": "ticket-4812",
  "note": "Missed the GAAP adjustments.",
  "prompt": "Build the Q3 ARR bridge and tie it back to the GAAP revenue waterfall."
}
```

**Response**

```json
{
  "classifier_id": null,
  "id": "6a1f0c3e-8b2d-4f7a-9c5e-1d2b3a4c5e6f",
  "label": null,
  "request_id": "req_01JD3X7Q4M8N2P5R6S7T8V9W0X",
  "skip_reason": null,
  "trained": true,
  "verdict": "bad"
}
```

**SDK Code**

```python
import requests

url = "https://api-gateway.merge.dev/v1/classifiers/feedback"

payload = {
    "request_id": "req_01JD3X7Q4M8N2P5R6S7T8V9W0X",
    "verdict": "bad",
    "direction": "stronger",
    "idempotency_key": "ticket-4812",
    "note": "Missed the GAAP adjustments.",
    "prompt": "Build the Q3 ARR bridge and tie it back to the GAAP revenue waterfall."
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api-gateway.merge.dev/v1/classifiers/feedback';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"request_id":"req_01JD3X7Q4M8N2P5R6S7T8V9W0X","verdict":"bad","direction":"stronger","idempotency_key":"ticket-4812","note":"Missed the GAAP adjustments.","prompt":"Build the Q3 ARR bridge and tie it back to the GAAP revenue waterfall."}'
};

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/classifiers/feedback"

	payload := strings.NewReader("{\n  \"request_id\": \"req_01JD3X7Q4M8N2P5R6S7T8V9W0X\",\n  \"verdict\": \"bad\",\n  \"direction\": \"stronger\",\n  \"idempotency_key\": \"ticket-4812\",\n  \"note\": \"Missed the GAAP adjustments.\",\n  \"prompt\": \"Build the Q3 ARR bridge and tie it back to the GAAP revenue waterfall.\"\n}")

	req, _ := http.NewRequest("POST", 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/classifiers/feedback")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"request_id\": \"req_01JD3X7Q4M8N2P5R6S7T8V9W0X\",\n  \"verdict\": \"bad\",\n  \"direction\": \"stronger\",\n  \"idempotency_key\": \"ticket-4812\",\n  \"note\": \"Missed the GAAP adjustments.\",\n  \"prompt\": \"Build the Q3 ARR bridge and tie it back to the GAAP revenue waterfall.\"\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.post("https://api-gateway.merge.dev/v1/classifiers/feedback")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"request_id\": \"req_01JD3X7Q4M8N2P5R6S7T8V9W0X\",\n  \"verdict\": \"bad\",\n  \"direction\": \"stronger\",\n  \"idempotency_key\": \"ticket-4812\",\n  \"note\": \"Missed the GAAP adjustments.\",\n  \"prompt\": \"Build the Q3 ARR bridge and tie it back to the GAAP revenue waterfall.\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api-gateway.merge.dev/v1/classifiers/feedback', [
  'body' => '{
  "request_id": "req_01JD3X7Q4M8N2P5R6S7T8V9W0X",
  "verdict": "bad",
  "direction": "stronger",
  "idempotency_key": "ticket-4812",
  "note": "Missed the GAAP adjustments.",
  "prompt": "Build the Q3 ARR bridge and tie it back to the GAAP revenue waterfall."
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api-gateway.merge.dev/v1/classifiers/feedback");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"request_id\": \"req_01JD3X7Q4M8N2P5R6S7T8V9W0X\",\n  \"verdict\": \"bad\",\n  \"direction\": \"stronger\",\n  \"idempotency_key\": \"ticket-4812\",\n  \"note\": \"Missed the GAAP adjustments.\",\n  \"prompt\": \"Build the Q3 ARR bridge and tie it back to the GAAP revenue waterfall.\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "request_id": "req_01JD3X7Q4M8N2P5R6S7T8V9W0X",
  "verdict": "bad",
  "direction": "stronger",
  "idempotency_key": "ticket-4812",
  "note": "Missed the GAAP adjustments.",
  "prompt": "Build the Q3 ARR bridge and tie it back to the GAAP revenue waterfall."
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api-gateway.merge.dev/v1/classifiers/feedback")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
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()
```