import Roark from '@roarkanalytics/sdk';
const client = new Roark({
bearerToken: process.env['ROARK_API_BEARER_TOKEN'], // This is the default and can be omitted
});
const response = await client.simulation.run({
plan: {
agentEndpoints: [{ id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e' }],
direction: 'INBOUND',
maxSimulationDurationSeconds: 300,
metrics: [{}],
},
});
console.log(response.data);import os
from roark_analytics import Roark
client = Roark(
bearer_token=os.environ.get("ROARK_API_BEARER_TOKEN"), # This is the default and can be omitted
)
response = client.simulation.run(
plan={
"agent_endpoints": [{
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
}],
"direction": "INBOUND",
"max_simulation_duration_seconds": 300,
"metrics": [{}],
},
)
print(response.data)curl --request POST \
--url https://api.roark.ai/v1/simulation/run \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"saveAsPlan": true,
"plan": {
"name": "Billing regression",
"direction": "OUTBOUND",
"maxSimulationDurationSeconds": 300,
"agentEndpoints": [
{
"id": "7c9e6679-7425-40de-944b-e07fc1f90ae7"
}
],
"metrics": [
{
"slug": "customer_satisfaction"
}
],
"flows": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"happyPath": true,
"edgeCases": "ALL"
}
]
},
"variables": {
"orderNumber": "12345"
}
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.roark.ai/v1/simulation/run",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'saveAsPlan' => true,
'plan' => [
'name' => 'Billing regression',
'direction' => 'OUTBOUND',
'maxSimulationDurationSeconds' => 300,
'agentEndpoints' => [
[
'id' => '7c9e6679-7425-40de-944b-e07fc1f90ae7'
]
],
'metrics' => [
[
'slug' => 'customer_satisfaction'
]
],
'flows' => [
[
'id' => '550e8400-e29b-41d4-a716-446655440000',
'happyPath' => true,
'edgeCases' => 'ALL'
]
]
],
'variables' => [
'orderNumber' => '12345'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.roark.ai/v1/simulation/run"
payload := strings.NewReader("{\n \"saveAsPlan\": true,\n \"plan\": {\n \"name\": \"Billing regression\",\n \"direction\": \"OUTBOUND\",\n \"maxSimulationDurationSeconds\": 300,\n \"agentEndpoints\": [\n {\n \"id\": \"7c9e6679-7425-40de-944b-e07fc1f90ae7\"\n }\n ],\n \"metrics\": [\n {\n \"slug\": \"customer_satisfaction\"\n }\n ],\n \"flows\": [\n {\n \"id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"happyPath\": true,\n \"edgeCases\": \"ALL\"\n }\n ]\n },\n \"variables\": {\n \"orderNumber\": \"12345\"\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(string(body))
}HttpResponse<String> response = Unirest.post("https://api.roark.ai/v1/simulation/run")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"saveAsPlan\": true,\n \"plan\": {\n \"name\": \"Billing regression\",\n \"direction\": \"OUTBOUND\",\n \"maxSimulationDurationSeconds\": 300,\n \"agentEndpoints\": [\n {\n \"id\": \"7c9e6679-7425-40de-944b-e07fc1f90ae7\"\n }\n ],\n \"metrics\": [\n {\n \"slug\": \"customer_satisfaction\"\n }\n ],\n \"flows\": [\n {\n \"id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"happyPath\": true,\n \"edgeCases\": \"ALL\"\n }\n ]\n },\n \"variables\": {\n \"orderNumber\": \"12345\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.roark.ai/v1/simulation/run")
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 \"saveAsPlan\": true,\n \"plan\": {\n \"name\": \"Billing regression\",\n \"direction\": \"OUTBOUND\",\n \"maxSimulationDurationSeconds\": 300,\n \"agentEndpoints\": [\n {\n \"id\": \"7c9e6679-7425-40de-944b-e07fc1f90ae7\"\n }\n ],\n \"metrics\": [\n {\n \"slug\": \"customer_satisfaction\"\n }\n ],\n \"flows\": [\n {\n \"id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"happyPath\": true,\n \"edgeCases\": \"ALL\"\n }\n ]\n },\n \"variables\": {\n \"orderNumber\": \"12345\"\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"simulationRunPlanJobId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "PENDING",
"createdAt": "<string>",
"simulationRunPlanId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"savedAsPlan": true,
"simulationJobCount": 123
}
}{
"type": "validation",
"code": "invalid_parameter",
"message": "The request was invalid",
"param": "email"
}{
"type": "authentication",
"code": "unauthorized",
"message": "Authentication required"
}{
"type": "payment_required",
"code": "insufficient_credits",
"message": "Not enough credit to start this work. Add credit and try again."
}{
"type": "forbidden",
"code": "permission_denied",
"message": "You do not have permission to access this resource"
}{
"type": "not_found",
"code": "resource_not_found",
"message": "The requested resource could not be found"
}{
"type": "rate_limit",
"code": "too_many_requests",
"message": "Rate limit exceeded"
}{
"type": "internal",
"code": "internal_error",
"message": "Internal server error"
}Run a simulation
Starts a simulation and returns the run.
Send plan to describe a simulation and run it once. Add saveAsPlan to keep that
configuration as a reusable run plan. Send planId instead to run a plan you already have.
import Roark from '@roarkanalytics/sdk';
const client = new Roark({
bearerToken: process.env['ROARK_API_BEARER_TOKEN'], // This is the default and can be omitted
});
const response = await client.simulation.run({
plan: {
agentEndpoints: [{ id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e' }],
direction: 'INBOUND',
maxSimulationDurationSeconds: 300,
metrics: [{}],
},
});
console.log(response.data);import os
from roark_analytics import Roark
client = Roark(
bearer_token=os.environ.get("ROARK_API_BEARER_TOKEN"), # This is the default and can be omitted
)
response = client.simulation.run(
plan={
"agent_endpoints": [{
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
}],
"direction": "INBOUND",
"max_simulation_duration_seconds": 300,
"metrics": [{}],
},
)
print(response.data)curl --request POST \
--url https://api.roark.ai/v1/simulation/run \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"saveAsPlan": true,
"plan": {
"name": "Billing regression",
"direction": "OUTBOUND",
"maxSimulationDurationSeconds": 300,
"agentEndpoints": [
{
"id": "7c9e6679-7425-40de-944b-e07fc1f90ae7"
}
],
"metrics": [
{
"slug": "customer_satisfaction"
}
],
"flows": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"happyPath": true,
"edgeCases": "ALL"
}
]
},
"variables": {
"orderNumber": "12345"
}
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.roark.ai/v1/simulation/run",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'saveAsPlan' => true,
'plan' => [
'name' => 'Billing regression',
'direction' => 'OUTBOUND',
'maxSimulationDurationSeconds' => 300,
'agentEndpoints' => [
[
'id' => '7c9e6679-7425-40de-944b-e07fc1f90ae7'
]
],
'metrics' => [
[
'slug' => 'customer_satisfaction'
]
],
'flows' => [
[
'id' => '550e8400-e29b-41d4-a716-446655440000',
'happyPath' => true,
'edgeCases' => 'ALL'
]
]
],
'variables' => [
'orderNumber' => '12345'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.roark.ai/v1/simulation/run"
payload := strings.NewReader("{\n \"saveAsPlan\": true,\n \"plan\": {\n \"name\": \"Billing regression\",\n \"direction\": \"OUTBOUND\",\n \"maxSimulationDurationSeconds\": 300,\n \"agentEndpoints\": [\n {\n \"id\": \"7c9e6679-7425-40de-944b-e07fc1f90ae7\"\n }\n ],\n \"metrics\": [\n {\n \"slug\": \"customer_satisfaction\"\n }\n ],\n \"flows\": [\n {\n \"id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"happyPath\": true,\n \"edgeCases\": \"ALL\"\n }\n ]\n },\n \"variables\": {\n \"orderNumber\": \"12345\"\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(string(body))
}HttpResponse<String> response = Unirest.post("https://api.roark.ai/v1/simulation/run")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"saveAsPlan\": true,\n \"plan\": {\n \"name\": \"Billing regression\",\n \"direction\": \"OUTBOUND\",\n \"maxSimulationDurationSeconds\": 300,\n \"agentEndpoints\": [\n {\n \"id\": \"7c9e6679-7425-40de-944b-e07fc1f90ae7\"\n }\n ],\n \"metrics\": [\n {\n \"slug\": \"customer_satisfaction\"\n }\n ],\n \"flows\": [\n {\n \"id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"happyPath\": true,\n \"edgeCases\": \"ALL\"\n }\n ]\n },\n \"variables\": {\n \"orderNumber\": \"12345\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.roark.ai/v1/simulation/run")
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 \"saveAsPlan\": true,\n \"plan\": {\n \"name\": \"Billing regression\",\n \"direction\": \"OUTBOUND\",\n \"maxSimulationDurationSeconds\": 300,\n \"agentEndpoints\": [\n {\n \"id\": \"7c9e6679-7425-40de-944b-e07fc1f90ae7\"\n }\n ],\n \"metrics\": [\n {\n \"slug\": \"customer_satisfaction\"\n }\n ],\n \"flows\": [\n {\n \"id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"happyPath\": true,\n \"edgeCases\": \"ALL\"\n }\n ]\n },\n \"variables\": {\n \"orderNumber\": \"12345\"\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"simulationRunPlanJobId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "PENDING",
"createdAt": "<string>",
"simulationRunPlanId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"savedAsPlan": true,
"simulationJobCount": 123
}
}{
"type": "validation",
"code": "invalid_parameter",
"message": "The request was invalid",
"param": "email"
}{
"type": "authentication",
"code": "unauthorized",
"message": "Authentication required"
}{
"type": "payment_required",
"code": "insufficient_credits",
"message": "Not enough credit to start this work. Add credit and try again."
}{
"type": "forbidden",
"code": "permission_denied",
"message": "You do not have permission to access this resource"
}{
"type": "not_found",
"code": "resource_not_found",
"message": "The requested resource could not be found"
}{
"type": "rate_limit",
"code": "too_many_requests",
"message": "Rate limit exceeded"
}{
"type": "internal",
"code": "internal_error",
"message": "Internal server error"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
- New simulation
- Existing plan
Either a simulation to configure and run, or the id of a plan to run.
The simulation to run: what to call, who calls it, and what to measure.
Show child attributes
Show child attributes
Keeps this configuration as a run plan, listed by GET /v1/simulation/plan and re-runnable
with planId. Requires plan.name, since a plan you meant to keep should not be filed
under a generated one.
Omitted or false gives a one-off. The run still needs a plan to execute, so one is created either way, but it is hidden: it carries this run and nothing else.
Values for the {{variables}} the run resolves, overriding whatever the plan has pinned.
An object applies them to the whole run:
{ "orderNumber": "12345", "tier": "gold" }
An array applies them per flow, or to just its happy path or one of its edge cases, when a single set will not do. Each entry carries what it applies to:
[ { "flowId": "550e8400-...", "variables": { "orderNumber": "12345" } }, { "flowId": "550e8400-...", "happyPath": true, "variables": { "orderNumber": "55555" } }, { "flowId": "550e8400-...", "edgeCaseId": "7a3d2e1f-...", "variables": { "orderNumber": "67890" } } ]
An entry that narrows to neither covers everything that flow resolves. A flow this plan does not attach, or an edge case that does not belong to the flow, is rejected rather than ignored.
A plan built on scenarios rather than customer flows targets them the same way, with scenarioId in
place of flowId. That form is deprecated alongside scenarios themselves, and still accepted so runs
against those plans keep working.
- Option 1 · object
- Option 2 · object[]
- Option 3 · object[]
Show child attributes
Show child attributes
{ "orderNumber": "12345", "environment": "staging" }
Response
The run that was started
A started simulation run.
Show child attributes
Show child attributes