> 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 full documentation content in one file, see https://docs.sarvam.ai/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.sarvam.ai/_mcp/server.

# Create cohort

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

Create a cohort from a pre-signed URL source with a transformation configuration. Use this when your CSV is already hosted and accessible via a URL.

Reference: https://docs.sarvam.ai/conversations/api/deployments/cohorts/create

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: agents
  version: 1.0.0
paths:
  /v1/orgs/{org_id}/workspaces/{workspace_id}/deployments/{deployment_id}/cohorts:
    post:
      operationId: create-deployment-cohort
      summary: Create Cohort
      description: >-
        Create a cohort from a pre-signed URL source with a transformation
        configuration. Use this when your CSV is already hosted and accessible
        via a URL.
      tags:
        - v1-cohorts
      parameters:
        - name: org_id
          in: path
          required: true
          schema:
            type: string
        - name: workspace_id
          in: path
          required: true
          schema:
            type: string
        - name: deployment_id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CohortMetadata'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCohort'
servers:
  - url: https://apps.sarvam.ai/api/scheduling
    description: Production
components:
  schemas:
    CreateCohortSource:
      oneOf:
        - type: object
          properties:
            type:
              type: string
              enum:
                - pre_signed_url
              default: pre_signed_url
              description: Source type. Always 'pre_signed_url'.
            url:
              type: string
              description: Pre-signed URL pointing to the cohort CSV file
          required:
            - type
            - url
          description: Cohort data source from a pre-signed URL pointing to a CSV file.
      discriminator:
        propertyName: type
      description: Source of the cohort data
      title: CreateCohortSource
    CohortFormattingFunctionName:
      type: string
      enum:
        - indian_currency
        - date
        - string_replace
        - string_strip
        - string_capitalize
        - indian_state_language_map
        - format_language_name
      description: |-
        Available formatting functions for cohort column transformations:
        - `indian_currency` — Formats numbers as Indian currency
        - `date` — Converts dd/mm/yyyy or dd-mm-yyyy to dd/month name/yyyy
        - `string_replace` — Replace values based on a dictionary
        - `string_strip` — Strip whitespace
        - `string_capitalize` — Capitalize the string
        - `indian_state_language_map` — Map Indian state to language
        - `format_language_name` — Normalize language name
      title: CohortFormattingFunctionName
    FormattingFunction:
      type: object
      properties:
        name:
          $ref: '#/components/schemas/CohortFormattingFunctionName'
          description: Name of the formatting function to apply
        params:
          type: object
          additionalProperties:
            description: Any type
          description: Parameters for the formatting function
      required:
        - name
      description: >-
        A transformation function applied to a column value (e.g. currency
        formatting, date conversion).
      title: FormattingFunction
    PhoneNumberColumnMapping:
      type: object
      properties:
        column_name:
          type: string
          description: Name of the phone number column in the CSV file
        required:
          type: boolean
          default: true
          description: Whether the phone number column is required
        formatting_functions:
          type: array
          items:
            $ref: '#/components/schemas/FormattingFunction'
          description: Transformations to apply to the phone number
        country_code:
          type: string
          default: IN
          description: ISO 3166-1 alpha-2 country code (e.g. IN, US, GB).
      required:
        - column_name
      description: >-
        Maps a CSV column to the phone number field, with country code for
        validation.
      title: PhoneNumberColumnMapping
    ColumnMapping:
      type: object
      properties:
        column_name:
          type: string
          description: Name of the column in the CSV file
        required:
          type: boolean
          default: false
          description: Whether this column is required
        formatting_functions:
          type: array
          items:
            $ref: '#/components/schemas/FormattingFunction'
          description: Transformations to apply to the column value
      required:
        - column_name
      description: >-
        Maps a single CSV column to an agent variable, with optional formatting
        functions.
      title: ColumnMapping
    CohortTransformationConfig:
      type: object
      properties:
        phone_number:
          $ref: '#/components/schemas/PhoneNumberColumnMapping'
          description: Mapping for the phone number column
        user_identifier:
          oneOf:
            - $ref: '#/components/schemas/ColumnMapping'
            - type: 'null'
          description: Optional mapping for a user identifier column
        app_variables:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/ColumnMapping'
          description: Mappings from CSV columns to agent variables
        app_overrides:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/ColumnMapping'
          description: Mappings from CSV columns to agent override settings
      required:
        - phone_number
      description: Maps CSV columns to phone number, user identifier, and agent variables.
      title: CohortTransformationConfig
    CreateCohort:
      type: object
      properties:
        name:
          type: string
        source:
          $ref: '#/components/schemas/CreateCohortSource'
          description: Source of the cohort data
        cohort_transformation:
          $ref: '#/components/schemas/CohortTransformationConfig'
          description: >-
            Configuration for how CSV columns map to phone numbers and agent
            variables
      required:
        - name
        - source
        - cohort_transformation
      description: Request model for creating a cohort.
      title: CreateCohort
    CohortStatus:
      type: string
      enum:
        - processing
        - completed
        - failed
      title: CohortStatus
    CohortSourceType:
      type: string
      enum:
        - pre_signed_url
        - file_upload
      title: CohortSourceType
    CohortResult:
      type: object
      properties:
        total_records:
          type: integer
          description: Total number of records in the uploaded file
        valid_records:
          type: integer
          description: Number of records that passed validation
        rejected_records:
          type: integer
          description: Number of records that failed validation
      required:
        - total_records
        - valid_records
        - rejected_records
      description: Processing result showing how many records were valid vs rejected.
      title: CohortResult
    CohortMetadata:
      type: object
      properties:
        name:
          type: string
          description: Name of the resource
        cohort_id:
          type: string
          description: Unique identifier for the cohort
        status:
          $ref: '#/components/schemas/CohortStatus'
          description: Current status
        source_type:
          $ref: '#/components/schemas/CohortSourceType'
          description: How the cohort was uploaded
        result:
          oneOf:
            - $ref: '#/components/schemas/CohortResult'
            - type: 'null'
          description: Processing result with record counts
        created_by:
          type: string
          description: User who created this resource
        created_at:
          type: string
          format: date-time
          description: Timestamp when the resource was created (ISO 8601)
        updated_by:
          type:
            - string
            - 'null'
          description: User who last updated this resource
        updated_at:
          type: string
          format: date-time
          description: Timestamp when the resource was last updated (ISO 8601)
      required:
        - name
        - cohort_id
        - status
        - source_type
        - created_by
        - created_at
        - updated_at
      description: Cohort metadata including processing status and result counts.
      title: CohortMetadata
    ErrorBody:
      type: object
      properties:
        code:
          type: string
          description: A service-specific error code.
        message:
          type: string
          description: A human-readable description of the error.
      required:
        - code
        - message
      description: Details of the error that occurred.
      title: ErrorBody
    ErrorResponse:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/ErrorBody'
      required:
        - error
      description: A standard wrapper for all error responses.
      title: ErrorResponse

```

## Examples



**Request**

```json
{
  "name": "April Users Batch 2",
  "source": {
    "type": "pre_signed_url",
    "url": "https://storage.example.com/cohorts/april-batch-2.csv?signature=..."
  },
  "cohort_transformation": {
    "phone_number": {
      "column_name": "mobile",
      "country_code": "IN"
    },
    "app_variables": {
      "account_balance": {
        "column_name": "balance"
      },
      "customer_name": {
        "column_name": "name"
      }
    }
  }
}
```

**Response**

```json
{
  "name": "April Users Batch 1",
  "cohort_id": "coh-x1y2z3",
  "status": "completed",
  "source_type": "file_upload",
  "created_by": "user@company.com",
  "created_at": "2026-04-01T09:00:00Z",
  "updated_at": "2026-04-01T09:02:30Z",
  "result": {
    "total_records": 5000,
    "valid_records": 4850,
    "rejected_records": 150
  },
  "updated_by": null
}
```

**SDK Code**

```python
import requests

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

payload = {
    "name": "April Users Batch 2",
    "source": {
        "type": "pre_signed_url",
        "url": "https://storage.example.com/cohorts/april-batch-2.csv?signature=..."
    },
    "cohort_transformation": {
        "phone_number": {
            "column_name": "mobile",
            "country_code": "IN"
        },
        "app_variables": {
            "account_balance": { "column_name": "balance" },
            "customer_name": { "column_name": "name" }
        }
    }
}
headers = {"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/deployments/deployment_id/cohorts';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"name":"April Users Batch 2","source":{"type":"pre_signed_url","url":"https://storage.example.com/cohorts/april-batch-2.csv?signature=..."},"cohort_transformation":{"phone_number":{"column_name":"mobile","country_code":"IN"},"app_variables":{"account_balance":{"column_name":"balance"},"customer_name":{"column_name":"name"}}}}'
};

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/deployments/deployment_id/cohorts"

	payload := strings.NewReader("{\n  \"name\": \"April Users Batch 2\",\n  \"source\": {\n    \"type\": \"pre_signed_url\",\n    \"url\": \"https://storage.example.com/cohorts/april-batch-2.csv?signature=...\"\n  },\n  \"cohort_transformation\": {\n    \"phone_number\": {\n      \"column_name\": \"mobile\",\n      \"country_code\": \"IN\"\n    },\n    \"app_variables\": {\n      \"account_balance\": {\n        \"column_name\": \"balance\"\n      },\n      \"customer_name\": {\n        \"column_name\": \"name\"\n      }\n    }\n  }\n}")

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

	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/deployments/deployment_id/cohorts")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"April Users Batch 2\",\n  \"source\": {\n    \"type\": \"pre_signed_url\",\n    \"url\": \"https://storage.example.com/cohorts/april-batch-2.csv?signature=...\"\n  },\n  \"cohort_transformation\": {\n    \"phone_number\": {\n      \"column_name\": \"mobile\",\n      \"country_code\": \"IN\"\n    },\n    \"app_variables\": {\n      \"account_balance\": {\n        \"column_name\": \"balance\"\n      },\n      \"customer_name\": {\n        \"column_name\": \"name\"\n      }\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.post("https://apps.sarvam.ai/api/scheduling/v1/orgs/org_id/workspaces/workspace_id/deployments/deployment_id/cohorts")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"April Users Batch 2\",\n  \"source\": {\n    \"type\": \"pre_signed_url\",\n    \"url\": \"https://storage.example.com/cohorts/april-batch-2.csv?signature=...\"\n  },\n  \"cohort_transformation\": {\n    \"phone_number\": {\n      \"column_name\": \"mobile\",\n      \"country_code\": \"IN\"\n    },\n    \"app_variables\": {\n      \"account_balance\": {\n        \"column_name\": \"balance\"\n      },\n      \"customer_name\": {\n        \"column_name\": \"name\"\n      }\n    }\n  }\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/deployments/deployment_id/cohorts', [
  'body' => '{
  "name": "April Users Batch 2",
  "source": {
    "type": "pre_signed_url",
    "url": "https://storage.example.com/cohorts/april-batch-2.csv?signature=..."
  },
  "cohort_transformation": {
    "phone_number": {
      "column_name": "mobile",
      "country_code": "IN"
    },
    "app_variables": {
      "account_balance": {
        "column_name": "balance"
      },
      "customer_name": {
        "column_name": "name"
      }
    }
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://apps.sarvam.ai/api/scheduling/v1/orgs/org_id/workspaces/workspace_id/deployments/deployment_id/cohorts");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"April Users Batch 2\",\n  \"source\": {\n    \"type\": \"pre_signed_url\",\n    \"url\": \"https://storage.example.com/cohorts/april-batch-2.csv?signature=...\"\n  },\n  \"cohort_transformation\": {\n    \"phone_number\": {\n      \"column_name\": \"mobile\",\n      \"country_code\": \"IN\"\n    },\n    \"app_variables\": {\n      \"account_balance\": {\n        \"column_name\": \"balance\"\n      },\n      \"customer_name\": {\n        \"column_name\": \"name\"\n      }\n    }\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "name": "April Users Batch 2",
  "source": [
    "type": "pre_signed_url",
    "url": "https://storage.example.com/cohorts/april-batch-2.csv?signature=..."
  ],
  "cohort_transformation": [
    "phone_number": [
      "column_name": "mobile",
      "country_code": "IN"
    ],
    "app_variables": [
      "account_balance": ["column_name": "balance"],
      "customer_name": ["column_name": "name"]
    ]
  ]
] 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")! 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()
```