> This page is for 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).
> Building a voice agent for customers in India? Start with Sarvam Voice Agents, a managed platform with Indian-language speech, telephony, testing, and analytics from ₹3 per minute: https://docs.sarvam.ai/voice-agents/why-voice-agents.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.sarvam.ai/_mcp/server.

# Stream cohort

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

Stream a cohort as JSON with two fields:

- `name` - Cohort name (1-50 characters)
- `users` - Array of user records (1-1000)

**When to use**

Stream cohort adds known callers to an inbound deployment programmatically. When a matched phone number calls in, the agent receives personalized variables for that contact.

- **CRM integration** - keep caller context in sync from Salesforce, HubSpot, Zoho, or your own database
- **Webhooks and automation** - update caller profiles when account data changes in your systems
- **Incremental batches** - add or refresh contacts over time without CSV uploads

For CSV files, use **Upload cohort** instead.

Processing is asynchronous - poll **Get cohort** until `status` is `completed` or `failed`.

Reference: https://docs.sarvam.ai/voice-agents/api/deployments/cohorts/stream

## Request

### Path parameters

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

### Headers

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

### Body (application/json)

This endpoint expects a StreamCohort.

- `name` (string, required) — Cohort name (1-50 characters). Letters, numbers, spaces, underscores, and hyphens only.
- `users` (list of CohortUserRecord, required) — List of user records (1-1000).

## Response

### 200

Successful Response

- `name` (string, required) — Name of the resource
- `cohort_id` (string, required) — Unique identifier for the cohort
- `status` (enum, required) — Current status
  - Allowed values: `processing`, `completed`, `failed`
- `source_type` (enum, required) — How the cohort was uploaded
  - Allowed values: `pre_signed_url`, `file_upload`
- `created_by` (string, required) — User who created this resource
- `created_at` (datetime, required) — Timestamp when the resource was created (ISO 8601)
- `updated_at` (datetime, required) — Timestamp when the resource was last updated (ISO 8601)
- `result` (CohortResult, optional, nullable) — Processing result with record counts
- `updated_by` (string, optional, nullable) — User who last updated this resource

## Errors

### 422 Unprocessable Entity Error

Validation Error

- `error` (ErrorBody, required) — Details of the error that occurred.

## Types

### CohortUserRecord

Represents one user and their data in a cohort.

- `user_phone_number` (string, required) — Phone number in E.164 format (for example `+919876543210`). 10-digit Indian numbers are also accepted and normalized automatically.
- `user_identifier` (string, optional, nullable) — Optional customer or user ID.
- `app_variables` (map from string to string, optional) — Key-value strings for agent variables. Keys must match variables configured on the agent.
- `app_overrides` (map from string to string, optional) — Per-user overrides. Supported keys: `initial_language_name`, `initial_state_name`, `initial_bot_message`.

### CohortResult

Processing result showing how many records were valid vs rejected.

- `total_records` (integer, required) — Total number of records in the uploaded file
- `valid_records` (integer, required) — Number of records that passed validation
- `rejected_records` (integer, required) — Number of records that failed validation

### ErrorBody

Details of the error that occurred.

- `code` (string, required) — A service-specific error code.
- `message` (string, required) — A human-readable description of the error.

## Examples

**Request**

```json
{
  "name": "known-callers-batch-1",
  "users": [
    {
      "user_phone_number": "+919876543210",
      "user_identifier": "CUST-001",
      "app_variables": {
        "customer_name": "Rahul"
      }
    }
  ]
}
```

**Response**

```json
{
  "name": "known-callers-batch-1",
  "cohort_id": "known-callers-batch-1-xxxxx",
  "status": "processing",
  "source_type": "file_upload",
  "created_by": "user@example.com",
  "created_at": "2026-08-05T10:00:00Z",
  "updated_at": "2026-08-05T10:00:00Z",
  "result": null,
  "updated_by": null,
  "cohort_category": "cohort"
}
```

**SDK Code**

```python User records (up to 1000)
import requests

url = "https://apps.sarvam.ai/api/scheduling/v1/orgs/org_id/workspaces/workspace_id/deployments/deployment_id/cohorts/stream"

payload = {
    "name": "known-callers-batch-1",
    "users": [
        {
            "user_phone_number": "+919876543210",
            "user_identifier": "CUST-001",
            "app_variables": { "customer_name": "Rahul" }
        }
    ]
}
headers = {
    "X-API-Key": "<your-api-key>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript User records (up to 1000)
const url = 'https://apps.sarvam.ai/api/scheduling/v1/orgs/org_id/workspaces/workspace_id/deployments/deployment_id/cohorts/stream';
const options = {
  method: 'POST',
  headers: {'X-API-Key': '<your-api-key>', 'Content-Type': 'application/json'},
  body: '{"name":"known-callers-batch-1","users":[{"user_phone_number":"+919876543210","user_identifier":"CUST-001","app_variables":{"customer_name":"Rahul"}}]}'
};

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

```go User records (up to 1000)
package main

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

func main() {

	url := "https://apps.sarvam.ai/api/scheduling/v1/orgs/org_id/workspaces/workspace_id/deployments/deployment_id/cohorts/stream"

	payload := strings.NewReader("{\n  \"name\": \"known-callers-batch-1\",\n  \"users\": [\n    {\n      \"user_phone_number\": \"+919876543210\",\n      \"user_identifier\": \"CUST-001\",\n      \"app_variables\": {\n        \"customer_name\": \"Rahul\"\n      }\n    }\n  ]\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 User records (up to 1000)
require 'uri'
require 'net/http'

url = URI("https://apps.sarvam.ai/api/scheduling/v1/orgs/org_id/workspaces/workspace_id/deployments/deployment_id/cohorts/stream")

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\": \"known-callers-batch-1\",\n  \"users\": [\n    {\n      \"user_phone_number\": \"+919876543210\",\n      \"user_identifier\": \"CUST-001\",\n      \"app_variables\": {\n        \"customer_name\": \"Rahul\"\n      }\n    }\n  ]\n}"

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

```java User records (up to 1000)
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/deployments/deployment_id/cohorts/stream")
  .header("X-API-Key", "<your-api-key>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"known-callers-batch-1\",\n  \"users\": [\n    {\n      \"user_phone_number\": \"+919876543210\",\n      \"user_identifier\": \"CUST-001\",\n      \"app_variables\": {\n        \"customer_name\": \"Rahul\"\n      }\n    }\n  ]\n}")
  .asString();
```

```php User records (up to 1000)
<?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/deployments/deployment_id/cohorts/stream', [
  'body' => '{
  "name": "known-callers-batch-1",
  "users": [
    {
      "user_phone_number": "+919876543210",
      "user_identifier": "CUST-001",
      "app_variables": {
        "customer_name": "Rahul"
      }
    }
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-API-Key' => '<your-api-key>',
  ],
]);

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

```csharp User records (up to 1000)
using RestSharp;

var client = new RestClient("https://apps.sarvam.ai/api/scheduling/v1/orgs/org_id/workspaces/workspace_id/deployments/deployment_id/cohorts/stream");
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\": \"known-callers-batch-1\",\n  \"users\": [\n    {\n      \"user_phone_number\": \"+919876543210\",\n      \"user_identifier\": \"CUST-001\",\n      \"app_variables\": {\n        \"customer_name\": \"Rahul\"\n      }\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift User records (up to 1000)
import Foundation

let headers = [
  "X-API-Key": "<your-api-key>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "known-callers-batch-1",
  "users": [
    [
      "user_phone_number": "+919876543210",
      "user_identifier": "CUST-001",
      "app_variables": ["customer_name": "Rahul"]
    ]
  ]
] 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/deployments/deployment_id/cohorts/stream")! 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()
```