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

# Sync cases

PUT https://api-gateway.merge.dev/v1/evals/suites/{suite_id}/cases
Content-Type: application/json

Declaratively sync the suite's cases from a repo dataset.

Cases are matched by ``external_id``: matched ones are updated in place,
new ones created, and (with ``prune``, the default) synced cases missing
from the payload deleted. Dashboard-authored cases are never touched.
In-flight runs are unaffected — runs snapshot their cases at trigger time.

Reference: https://docs.merge.dev/merge-gateway/evals-api/cases/sync-cases

## Authentication

- `Authorization` header (bearer token, required) — Your gateway API key (mg_ prefix), the same key used for /v1/responses

## Request

### Path parameters

- `suite_id` (string, required)

### Body (application/json)

This endpoint expects a CaseSyncRequestV1In.

- `cases` (list of CaseSyncIn, required)
- `prune` (boolean, optional, default: true)

## Response

### 200

Successful Response

- `created` (integer, required)
- `updated` (integer, required)
- `deleted` (integer, required)
- `unchanged` (integer, required)

## Errors

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### CaseSyncIn

One case in a declarative sync payload: a dashboard case shape plus the required sync key. ``position`` is ignored — sync appends new cases.

- `name` (string, required)
- `input_messages` (list of CaseMessage, required)
- `graders` (list of CaseSyncInGradersItems, required)
- `external_id` (string, required)
- `request_params` (map from string to any, optional, nullable)
- `grader_policy` (enum, optional, default: all)
  - Allowed values: `all`, `any`
- `enabled` (boolean, optional, default: true)
- `required` (boolean, optional, default: true)
- `position` (integer, optional, nullable)

### ValidationError

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

### CaseMessage

One turn of a case's input, /v1/responses shape (text-only in v1).

- `role` (enum, required)
  - Allowed values: `system`, `user`, `assistant`
- `content` (string, required)

### CaseSyncInGradersItems

- `type`: `contains` (ContainsGrader)
  - `value` (string, required)
  - `case_sensitive` (boolean, optional, default: false)
- `type`: `exact_match` (ExactMatchGrader)
  - `expected` (string, required)
  - `case_sensitive` (boolean, optional, default: false)
  - `strip` (boolean, optional, default: true)
- `type`: `json_field` (JsonFieldGrader)
  - `op` (enum, required)
    - Allowed values: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `contains`, `exists`
  - `path` (string, required)
  - `value` (any, optional)
- `type`: `json_schema` (JsonSchemaGrader)
  - `schema` (map from string to any, required)
- `type`: `llm_judge` (LlmJudgeGrader)
  - `expected` (string, optional, nullable)
  - `judge_model` (string, optional, nullable)
  - `rubric` (string, optional, nullable)
  - `threshold` (double, optional, nullable)
- `type`: `not_contains` (NotContainsGrader)
  - `value` (string, required)
  - `case_sensitive` (boolean, optional, default: false)
- `type`: `regex` (RegexGrader)
  - `pattern` (string, required)
  - `flags` (list of enum, optional)
    - Allowed values: `i`, `m`, `s`
- `type`: `tool_call` (ToolCallGrader)
  - `tool_name` (string, required)
  - `arg_assertions` (list of ToolCallArgAssertion, optional)
  - `must_be_called` (boolean, optional, default: true)

### ValidationErrorLocItems

- string
- integer

### ValidationErrorCtx

### ToolCallArgAssertion

Assertion against one path in a tool call's arguments.

- `path` (string, required)
- `op` (enum, required)
  - Allowed values: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `contains`, `exists`
- `value` (any, optional)

## Examples

**Request**

```json
{
  "cases": [
    {
      "name": "string",
      "input_messages": [
        {
          "role": "system",
          "content": "string"
        }
      ],
      "graders": [
        {
          "expected": "string",
          "type": "string"
        }
      ],
      "external_id": "string"
    }
  ]
}
```

**Response**

```json
{
  "created": 1,
  "updated": 1,
  "deleted": 1,
  "unchanged": 1
}
```

**SDK Code**

```python
import requests

url = "https://api-gateway.merge.dev/v1/evals/suites/suite_id/cases"

payload = { "cases": [
        {
            "name": "string",
            "input_messages": [
                {
                    "role": "system",
                    "content": "string"
                }
            ],
            "graders": [
                {
                    "expected": "string",
                    "type": "string"
                }
            ],
            "external_id": "string"
        }
    ] }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api-gateway.merge.dev/v1/evals/suites/suite_id/cases';
const options = {
  method: 'PUT',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"cases":[{"name":"string","input_messages":[{"role":"system","content":"string"}],"graders":[{"expected":"string","type":"string"}],"external_id":"string"}]}'
};

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/evals/suites/suite_id/cases"

	payload := strings.NewReader("{\n  \"cases\": [\n    {\n      \"name\": \"string\",\n      \"input_messages\": [\n        {\n          \"role\": \"system\",\n          \"content\": \"string\"\n        }\n      ],\n      \"graders\": [\n        {\n          \"expected\": \"string\",\n          \"type\": \"string\"\n        }\n      ],\n      \"external_id\": \"string\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("PUT", 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/evals/suites/suite_id/cases")

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

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"cases\": [\n    {\n      \"name\": \"string\",\n      \"input_messages\": [\n        {\n          \"role\": \"system\",\n          \"content\": \"string\"\n        }\n      ],\n      \"graders\": [\n        {\n          \"expected\": \"string\",\n          \"type\": \"string\"\n        }\n      ],\n      \"external_id\": \"string\"\n    }\n  ]\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.put("https://api-gateway.merge.dev/v1/evals/suites/suite_id/cases")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"cases\": [\n    {\n      \"name\": \"string\",\n      \"input_messages\": [\n        {\n          \"role\": \"system\",\n          \"content\": \"string\"\n        }\n      ],\n      \"graders\": [\n        {\n          \"expected\": \"string\",\n          \"type\": \"string\"\n        }\n      ],\n      \"external_id\": \"string\"\n    }\n  ]\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api-gateway.merge.dev/v1/evals/suites/suite_id/cases', [
  'body' => '{
  "cases": [
    {
      "name": "string",
      "input_messages": [
        {
          "role": "system",
          "content": "string"
        }
      ],
      "graders": [
        {
          "expected": "string",
          "type": "string"
        }
      ],
      "external_id": "string"
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api-gateway.merge.dev/v1/evals/suites/suite_id/cases");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"cases\": [\n    {\n      \"name\": \"string\",\n      \"input_messages\": [\n        {\n          \"role\": \"system\",\n          \"content\": \"string\"\n        }\n      ],\n      \"graders\": [\n        {\n          \"expected\": \"string\",\n          \"type\": \"string\"\n        }\n      ],\n      \"external_id\": \"string\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["cases": [
    [
      "name": "string",
      "input_messages": [
        [
          "role": "system",
          "content": "string"
        ]
      ],
      "graders": [
        [
          "expected": "string",
          "type": "string"
        ]
      ],
      "external_id": "string"
    ]
  ]] as [String : Any]

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

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