> This page is for API Reference.

> Sarvam Voice Agents (Samvaad) is a voice AI agent platform for Indian languages: build, test and deploy AI calling agents on your own phone numbers, from ₹3 a minute. Start here: https://docs.sarvam.ai/voice-agents/why-voice-agents.
> For clean Markdown of any page, append `.md` to the page URL.
> For a complete documentation index, see https://docs.sarvam.ai/llms.txt. For a section index, append `/llms.txt` to any section URL (for example https://docs.sarvam.ai/voice-agents/llms.txt).
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.sarvam.ai/_mcp/server.

# Create an experiment

POST https://apps.sarvam.ai/api/scheduling/v1/orgs/{org_id}/workspaces/{workspace_id}/experiments
Content-Type: application/json

Create an experiment across committed versions of one agent. Then create a campaign that runs it — see [Create Experiment Campaign](/voice-agents/api/experiments/create-experiment-campaign).

Reference: https://docs.sarvam.ai/api-reference/experiments/create

## Request

### Path parameters

- `org_id` (string, required)
- `workspace_id` (string, required)

### Headers

- `X-API-Key` (string, required) — Your workspace API key.

### Body (application/json)

This endpoint expects a CreateExperiment.

- `name` (string, required) — A/B test name. Letters, digits, spaces, hyphens, and underscores. Max 50 characters.
- `variants` (list of CreateExperimentVariant, required) — Two to five variants. traffic_percentage must sum to 100. Each variant uses a different committed version of the same agent.
- `description` (string, optional, nullable) — Optional description. Max 150 characters.
- `app_type` (enum, optional, default: agent) — Must be agent.
  - Allowed values: `agent`

## Response

### 200

Successful Response

- `experiment_id` (string, required) — Id to pass as app_config.experiment_id when creating a campaign.
- `name` (string, required)
- `app_type` (enum, required)
  - Allowed values: `agent`
- `variants` (list of ExperimentVariant, required)
- `created_by` (string, required)
- `created_at` (datetime, required)
- `updated_at` (datetime, required)
- `description` (string, optional, nullable)
- `updated_by` (string, optional, nullable)

## Errors

### 422 Unprocessable Entity Error

Validation Error

- `any`

## Types

### CreateExperimentVariant

One arm of an A/B test.

- `name` (string, required) — Variant name. Unique within the A/B test. Letters, digits, spaces, hyphens, and underscores.
- `traffic_percentage` (integer, required) — Share of attempts, from 1 to 100. All variants must sum to 100.
- `app_config` (VariantAppConfig, required) — Agent version this variant runs.

### ExperimentVariant

One arm of an A/B test, including the server-minted variant id.

- `variant_id` (string, required) — Server-minted id. Returned on create and sent on the call webhook.
- `name` (string, required) — Variant name. Unique within the A/B test. Letters, digits, spaces, hyphens, and underscores.
- `traffic_percentage` (integer, required) — Share of attempts, from 1 to 100. All variants must sum to 100.
- `app_config` (VariantAppConfig, required) — Agent version this variant runs.

### VariantAppConfig

The agent version a variant runs. Dial rate, numbers, and retries stay on the campaign.

- `app_id` (string, required) — Agent under test. Every variant in one A/B test must use the same app_id.
- `app_version` (integer, required) — Committed version of that agent. Versions must differ across variants.

## Examples

**Request**

```json
{
  "name": "greeting-test",
  "variants": [
    {
      "name": "control",
      "traffic_percentage": 50,
      "app_config": {
        "app_id": "payment-reminder-agent",
        "app_version": 3
      }
    },
    {
      "name": "casual",
      "traffic_percentage": 50,
      "app_config": {
        "app_id": "payment-reminder-agent",
        "app_version": 4
      }
    }
  ],
  "description": "Formal vs casual opener",
  "app_type": "agent"
}
```

**Response**

```json
{
  "experiment_id": "greeting-te-9f1c2a7b-4d3e",
  "name": "greeting-test",
  "app_type": "agent",
  "variants": [
    {
      "variant_id": "control-1a2b3c4d-5e6f",
      "name": "control",
      "traffic_percentage": 50,
      "app_config": {
        "app_id": "payment-reminder-agent",
        "app_version": 3
      }
    },
    {
      "variant_id": "casual-7a8b9c0d-1e2f",
      "name": "casual",
      "traffic_percentage": 50,
      "app_config": {
        "app_id": "payment-reminder-agent",
        "app_version": 4
      }
    }
  ],
  "created_by": "user@company.com",
  "created_at": "2026-10-28T08:00:00Z",
  "updated_at": "2026-10-28T08:00:00Z",
  "description": "Formal vs casual opener",
  "updated_by": null
}
```

**SDK Code**

```python
import requests

url = "https://apps.sarvam.ai/api/scheduling/v1/orgs/org_id/workspaces/workspace_id/experiments"

payload = {
    "name": "greeting-test",
    "variants": [
        {
            "name": "control",
            "traffic_percentage": 50,
            "app_config": {
                "app_id": "payment-reminder-agent",
                "app_version": 3
            }
        },
        {
            "name": "casual",
            "traffic_percentage": 50,
            "app_config": {
                "app_id": "payment-reminder-agent",
                "app_version": 4
            }
        }
    ],
    "description": "Formal vs casual opener",
    "app_type": "agent"
}
headers = {
    "X-API-Key": "<your-api-key>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://apps.sarvam.ai/api/scheduling/v1/orgs/org_id/workspaces/workspace_id/experiments';
const options = {
  method: 'POST',
  headers: {'X-API-Key': '<your-api-key>', 'Content-Type': 'application/json'},
  body: '{"name":"greeting-test","variants":[{"name":"control","traffic_percentage":50,"app_config":{"app_id":"payment-reminder-agent","app_version":3}},{"name":"casual","traffic_percentage":50,"app_config":{"app_id":"payment-reminder-agent","app_version":4}}],"description":"Formal vs casual opener","app_type":"agent"}'
};

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://apps.sarvam.ai/api/scheduling/v1/orgs/org_id/workspaces/workspace_id/experiments"

	payload := strings.NewReader("{\n  \"name\": \"greeting-test\",\n  \"variants\": [\n    {\n      \"name\": \"control\",\n      \"traffic_percentage\": 50,\n      \"app_config\": {\n        \"app_id\": \"payment-reminder-agent\",\n        \"app_version\": 3\n      }\n    },\n    {\n      \"name\": \"casual\",\n      \"traffic_percentage\": 50,\n      \"app_config\": {\n        \"app_id\": \"payment-reminder-agent\",\n        \"app_version\": 4\n      }\n    }\n  ],\n  \"description\": \"Formal vs casual opener\",\n  \"app_type\": \"agent\"\n}")

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

	req.Header.Add("X-API-Key", "<your-api-key>")
	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://apps.sarvam.ai/api/scheduling/v1/orgs/org_id/workspaces/workspace_id/experiments")

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

request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<your-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"greeting-test\",\n  \"variants\": [\n    {\n      \"name\": \"control\",\n      \"traffic_percentage\": 50,\n      \"app_config\": {\n        \"app_id\": \"payment-reminder-agent\",\n        \"app_version\": 3\n      }\n    },\n    {\n      \"name\": \"casual\",\n      \"traffic_percentage\": 50,\n      \"app_config\": {\n        \"app_id\": \"payment-reminder-agent\",\n        \"app_version\": 4\n      }\n    }\n  ],\n  \"description\": \"Formal vs casual opener\",\n  \"app_type\": \"agent\"\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://apps.sarvam.ai/api/scheduling/v1/orgs/org_id/workspaces/workspace_id/experiments")
  .header("X-API-Key", "<your-api-key>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"greeting-test\",\n  \"variants\": [\n    {\n      \"name\": \"control\",\n      \"traffic_percentage\": 50,\n      \"app_config\": {\n        \"app_id\": \"payment-reminder-agent\",\n        \"app_version\": 3\n      }\n    },\n    {\n      \"name\": \"casual\",\n      \"traffic_percentage\": 50,\n      \"app_config\": {\n        \"app_id\": \"payment-reminder-agent\",\n        \"app_version\": 4\n      }\n    }\n  ],\n  \"description\": \"Formal vs casual opener\",\n  \"app_type\": \"agent\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://apps.sarvam.ai/api/scheduling/v1/orgs/org_id/workspaces/workspace_id/experiments', [
  'body' => '{
  "name": "greeting-test",
  "variants": [
    {
      "name": "control",
      "traffic_percentage": 50,
      "app_config": {
        "app_id": "payment-reminder-agent",
        "app_version": 3
      }
    },
    {
      "name": "casual",
      "traffic_percentage": 50,
      "app_config": {
        "app_id": "payment-reminder-agent",
        "app_version": 4
      }
    }
  ],
  "description": "Formal vs casual opener",
  "app_type": "agent"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-API-Key' => '<your-api-key>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://apps.sarvam.ai/api/scheduling/v1/orgs/org_id/workspaces/workspace_id/experiments");
var request = new RestRequest(Method.POST);
request.AddHeader("X-API-Key", "<your-api-key>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"greeting-test\",\n  \"variants\": [\n    {\n      \"name\": \"control\",\n      \"traffic_percentage\": 50,\n      \"app_config\": {\n        \"app_id\": \"payment-reminder-agent\",\n        \"app_version\": 3\n      }\n    },\n    {\n      \"name\": \"casual\",\n      \"traffic_percentage\": 50,\n      \"app_config\": {\n        \"app_id\": \"payment-reminder-agent\",\n        \"app_version\": 4\n      }\n    }\n  ],\n  \"description\": \"Formal vs casual opener\",\n  \"app_type\": \"agent\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "X-API-Key": "<your-api-key>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "greeting-test",
  "variants": [
    [
      "name": "control",
      "traffic_percentage": 50,
      "app_config": [
        "app_id": "payment-reminder-agent",
        "app_version": 3
      ]
    ],
    [
      "name": "casual",
      "traffic_percentage": 50,
      "app_config": [
        "app_id": "payment-reminder-agent",
        "app_version": 4
      ]
    ]
  ],
  "description": "Formal vs casual opener",
  "app_type": "agent"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://apps.sarvam.ai/api/scheduling/v1/orgs/org_id/workspaces/workspace_id/experiments")! 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()
```