> For a complete page index, fetch https://docs.synthflow.ai/llms.txt. For full documentation content, fetch https://docs.synthflow.ai/llms-full.txt.

# Create a batch call

POST https://api.synthflow.ai/v2/calls/batch
Content-Type: application/json

Creates a batch of outbound calls that are dialed over time as your account's concurrency allows. Provide `batch_call_id` to append more recipients to an existing batch instead of creating a new one.

Reference: https://docs.synthflow.ai/api-reference/platform-api/batch-calls/create-a-batch-call

## Authentication

- `Authorization` header (bearer token, required)

## Servers

- `https://api.synthflow.ai/v2` (Global, default)
- `https://api.us.synthflow.ai/v2` (United States)
- `https://api.eu.synthflow.ai/v2` (European Union)

## Request

### Body (application/json)

- `tasks` (list of object, required) — The recipients to call. Between 1 and 10000 per request. Append to the batch to go beyond that.
  - `to_phone_number` (string, required) — The recipient's phone number.
  - `id` (string, optional) — Optional caller-supplied recipient id, unique within the batch. Recipients re-sent with an id that already exists in the batch are skipped, which makes retries safe.
  - `lead_name` (string, optional) — The recipient's name.
  - `lead_email` (string, optional) — The recipient's email address.
  - `custom_variables` (map from string to any, optional) — Prompt variables forwarded to the call, as key-value pairs.
  - `override_model_id` (string, optional) — Agent to use for this recipient instead of the batch's `model_id`.
- `name` (string, optional) — A display name for the batch.
- `model_id` (string, optional) — The agent that places the calls. Required when creating a new batch, ignored when appending to an existing one.
- `from_phone_number` (string, optional) — The caller ID used for every call in the batch. Required when creating a new batch, ignored when appending.
- `batch_call_id` (string, optional) — An existing batch to append the recipients to. When set, `model_id`, `from_phone_number`, `trigger_timestamp`, `reserved_concurrency` and `call_time_window` are ignored.
- `trigger_timestamp` (integer, optional) — Unix timestamp in milliseconds at which dialing starts. Omit to start dialing immediately.
- `reserved_concurrency` (integer, optional, default: 0) — Number of concurrent call slots held back for calls outside this batch. Must be lower than the account's maximum concurrent calls.
- `call_time_window` (object, optional) — Calling window evaluated in the agent's timezone. When set it overrides the agent's working hours for this batch. When neither is configured, recipients are dialed at any time.
  - `enable` (boolean, optional) — Whether the window is enforced. Defaults to true when `weekly_hours` is provided.
  - `weekly_hours` (map from string to list of object, optional) — Keys are lowercase weekday names (`monday` to `sunday`). Each day holds a list of windows in `HH:MM` 24-hour format with `start` earlier than `end`. A missing or empty day means no calls on that day.
    - `start` (string, optional)
    - `end` (string, optional)

## Response

### 200

200

- `status` (string, optional)
- `response` (object, optional)
  - `batch_call_id` (string, optional)
  - `name` (string, optional)
  - `from_phone_number` (string, optional)
  - `scheduled_timestamp` (integer, optional) — Unix timestamp in milliseconds at which dialing starts. Null when dialing starts immediately.
  - `total_task_count` (integer, optional) — Recipients stored in the batch after this request, excluding duplicates that were skipped.
  - `call_time_window` (object, optional)
  - `status` (string, optional)

## Examples

**Request**

```json
{
  "tasks": [
    {
      "to_phone_number": "+12025551234",
      "id": "lead-0001",
      "lead_name": "John Doe",
      "custom_variables": {
        "plan": "pro"
      }
    }
  ],
  "name": "August re-engagement",
  "model_id": "1631a495-e29b-4933-a0b7-3ea0f4a45e64",
  "from_phone_number": "+16286666348",
  "call_time_window": {
    "weekly_hours": {
      "monday": [
        {
          "start": "09:00",
          "end": "17:00"
        }
      ],
      "tuesday": [
        {
          "start": "09:00",
          "end": "17:00"
        }
      ]
    }
  }
}
```

**Response**

```json
{
  "status": "ok",
  "response": {
    "batch_call_id": "3f6f2f5e-4f4b-4f0e-9a4e-2b6d1a5c7e90",
    "name": "August re-engagement",
    "from_phone_number": "+16286666348",
    "scheduled_timestamp": null,
    "total_task_count": 1,
    "call_time_window": {
      "enable": true,
      "weekly_hours": {
        "monday": [
          {
            "end": "17:00",
            "start": "09:00"
          }
        ],
        "tuesday": [
          {
            "end": "17:00",
            "start": "09:00"
          }
        ]
      }
    },
    "status": "scheduled"
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.synthflow.ai/v2/calls/batch"

payload = {
    "tasks": [
        {
            "to_phone_number": "+12025551234",
            "id": "lead-0001",
            "lead_name": "John Doe",
            "custom_variables": { "plan": "pro" }
        }
    ],
    "name": "August re-engagement",
    "model_id": "1631a495-e29b-4933-a0b7-3ea0f4a45e64",
    "from_phone_number": "+16286666348",
    "call_time_window": { "weekly_hours": {
            "monday": [
                {
                    "start": "09:00",
                    "end": "17:00"
                }
            ],
            "tuesday": [
                {
                    "start": "09:00",
                    "end": "17:00"
                }
            ]
        } }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```go
package main

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

func main() {

	url := "https://api.synthflow.ai/v2/calls/batch"

	payload := strings.NewReader("{\n  \"tasks\": [\n    {\n      \"to_phone_number\": \"+12025551234\",\n      \"id\": \"lead-0001\",\n      \"lead_name\": \"John Doe\",\n      \"custom_variables\": {\n        \"plan\": \"pro\"\n      }\n    }\n  ],\n  \"name\": \"August re-engagement\",\n  \"model_id\": \"1631a495-e29b-4933-a0b7-3ea0f4a45e64\",\n  \"from_phone_number\": \"+16286666348\",\n  \"call_time_window\": {\n    \"weekly_hours\": {\n      \"monday\": [\n        {\n          \"start\": \"09:00\",\n          \"end\": \"17:00\"\n        }\n      ],\n      \"tuesday\": [\n        {\n          \"start\": \"09:00\",\n          \"end\": \"17:00\"\n        }\n      ]\n    }\n  }\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.synthflow.ai/v2/calls/batch")

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  \"tasks\": [\n    {\n      \"to_phone_number\": \"+12025551234\",\n      \"id\": \"lead-0001\",\n      \"lead_name\": \"John Doe\",\n      \"custom_variables\": {\n        \"plan\": \"pro\"\n      }\n    }\n  ],\n  \"name\": \"August re-engagement\",\n  \"model_id\": \"1631a495-e29b-4933-a0b7-3ea0f4a45e64\",\n  \"from_phone_number\": \"+16286666348\",\n  \"call_time_window\": {\n    \"weekly_hours\": {\n      \"monday\": [\n        {\n          \"start\": \"09:00\",\n          \"end\": \"17:00\"\n        }\n      ],\n      \"tuesday\": [\n        {\n          \"start\": \"09:00\",\n          \"end\": \"17:00\"\n        }\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://api.synthflow.ai/v2/calls/batch")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"tasks\": [\n    {\n      \"to_phone_number\": \"+12025551234\",\n      \"id\": \"lead-0001\",\n      \"lead_name\": \"John Doe\",\n      \"custom_variables\": {\n        \"plan\": \"pro\"\n      }\n    }\n  ],\n  \"name\": \"August re-engagement\",\n  \"model_id\": \"1631a495-e29b-4933-a0b7-3ea0f4a45e64\",\n  \"from_phone_number\": \"+16286666348\",\n  \"call_time_window\": {\n    \"weekly_hours\": {\n      \"monday\": [\n        {\n          \"start\": \"09:00\",\n          \"end\": \"17:00\"\n        }\n      ],\n      \"tuesday\": [\n        {\n          \"start\": \"09:00\",\n          \"end\": \"17:00\"\n        }\n      ]\n    }\n  }\n}")
  .asString();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.synthflow.ai/v2/calls/batch");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"tasks\": [\n    {\n      \"to_phone_number\": \"+12025551234\",\n      \"id\": \"lead-0001\",\n      \"lead_name\": \"John Doe\",\n      \"custom_variables\": {\n        \"plan\": \"pro\"\n      }\n    }\n  ],\n  \"name\": \"August re-engagement\",\n  \"model_id\": \"1631a495-e29b-4933-a0b7-3ea0f4a45e64\",\n  \"from_phone_number\": \"+16286666348\",\n  \"call_time_window\": {\n    \"weekly_hours\": {\n      \"monday\": [\n        {\n          \"start\": \"09:00\",\n          \"end\": \"17:00\"\n        }\n      ],\n      \"tuesday\": [\n        {\n          \"start\": \"09:00\",\n          \"end\": \"17:00\"\n        }\n      ]\n    }\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "tasks": [
    [
      "to_phone_number": "+12025551234",
      "id": "lead-0001",
      "lead_name": "John Doe",
      "custom_variables": ["plan": "pro"]
    ]
  ],
  "name": "August re-engagement",
  "model_id": "1631a495-e29b-4933-a0b7-3ea0f4a45e64",
  "from_phone_number": "+16286666348",
  "call_time_window": ["weekly_hours": [
      "monday": [
        [
          "start": "09:00",
          "end": "17:00"
        ]
      ],
      "tuesday": [
        [
          "start": "09:00",
          "end": "17:00"
        ]
      ]
    ]]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.synthflow.ai/v2/calls/batch")! 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()
```