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

# Start a simulation

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

Start a new simulation using a simulation case.

Reference: https://docs.synthflow.ai/api-reference/platform-api/simulations/start-simulation

## 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)

- `simulation_case_id` (string, required)
- `target_agent_id` (string, required)
- `simulation_session_id` (string, optional, nullable)
- `custom_variables` (map from string to any, optional)

## Response

### 200

200

- `status` (string, optional) — Whether the request was successful.
- `response` (object, optional) — Simulation details.
  - `simulation_id` (string, optional)
  - `simulation_session_id` (string, optional)
  - `simulation_case_id` (string, optional)
  - `simulation_case_name` (string, optional, nullable)
  - `simulation_case_prompt` (string, optional, nullable)
  - `success_criteria` (list of string, optional, nullable)
  - `call_success_type` (enum, optional, nullable)
    - Allowed values: `all`, `any`
  - `persona_agent_id` (string, optional, nullable)
  - `persona_phone_number` (string, optional, nullable)
  - `target_agent_id` (string, optional)
  - `agent_name` (string, optional, nullable)
  - `agent_avatar_url` (string, optional, nullable)
  - `target_phone_number` (string, optional, nullable)
  - `target_call_id` (string, optional, nullable)
  - `custom_variables` (map from string to any, optional, nullable)
  - `status` (enum, optional)
    - Allowed values: `in-progress`, `completed`, `failed`
  - `workspace_id` (string, optional)
  - `created_at` (datetime, optional)
  - `updated_at` (datetime, optional)
  - `error_info` (object, optional, nullable) — Error information for failed simulations.
    - `message` (string, required)
    - `code` (integer, required)
    - `type` (string, required)
  - `recording_url` (string, optional, nullable)
  - `timeline` (list of object, optional, nullable)
    - `sender_type` (string, optional, nullable)
    - `value` (string, optional, nullable)
    - `type` (string, optional, nullable)
    - `timestamp_datetime` (datetime, optional, nullable)
    - `timestamp` (float, optional, nullable)
  - `success_criteria_analysis` (object, optional, nullable) — Summary of the success criteria evaluation results.
    - `success` (boolean, required)
    - `evaluations` (list of object, required)
      - `success` (boolean, required)
      - `reasoning` (string, required)

## Examples

**Request**

```json
{
  "simulation_case_id": "9ad09ad3-9c22-441e-ae35-c05016a09786",
  "target_agent_id": "1726005822670-239735712159542050",
  "custom_variables": {
    "customer_name": "John Doe"
  }
}
```

**Response**

```json
{
  "status": "ok",
  "response": {
    "simulation_id": "b29da8ff-c89e-4628-94b6-d81193f883c7"
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.synthflow.ai/v2/simulations"

payload = {
    "simulation_case_id": "9ad09ad3-9c22-441e-ae35-c05016a09786",
    "target_agent_id": "1726005822670-239735712159542050",
    "custom_variables": { "customer_name": "John Doe" }
}
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/simulations"

	payload := strings.NewReader("{\n  \"simulation_case_id\": \"9ad09ad3-9c22-441e-ae35-c05016a09786\",\n  \"target_agent_id\": \"1726005822670-239735712159542050\",\n  \"custom_variables\": {\n    \"customer_name\": \"John Doe\"\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/simulations")

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  \"simulation_case_id\": \"9ad09ad3-9c22-441e-ae35-c05016a09786\",\n  \"target_agent_id\": \"1726005822670-239735712159542050\",\n  \"custom_variables\": {\n    \"customer_name\": \"John Doe\"\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/simulations")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"simulation_case_id\": \"9ad09ad3-9c22-441e-ae35-c05016a09786\",\n  \"target_agent_id\": \"1726005822670-239735712159542050\",\n  \"custom_variables\": {\n    \"customer_name\": \"John Doe\"\n  }\n}")
  .asString();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.synthflow.ai/v2/simulations");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"simulation_case_id\": \"9ad09ad3-9c22-441e-ae35-c05016a09786\",\n  \"target_agent_id\": \"1726005822670-239735712159542050\",\n  \"custom_variables\": {\n    \"customer_name\": \"John Doe\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "simulation_case_id": "9ad09ad3-9c22-441e-ae35-c05016a09786",
  "target_agent_id": "1726005822670-239735712159542050",
  "custom_variables": ["customer_name": "John Doe"]
] as [String : Any]

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

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