Skip to main content
POST
/
v1
/
simulation
/
plan
/
{planId}
/
job
JavaScript
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.simulationRunPlanJob.start('7f3e4d2c-8a91-4b5c-9e6f-1a2b3c4d5e6f');

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_job.start(
    plan_id="7f3e4d2c-8a91-4b5c-9e6f-1a2b3c4d5e6f",
)
print(response.data)
curl --request POST \
  --url https://api.roark.ai/v1/simulation/plan/{planId}/job \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "variables": {
    "orderNumber": "12345",
    "environment": "staging"
  }
}
'
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.roark.ai/v1/simulation/plan/{planId}/job",
  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([
    'variables' => [
        'orderNumber' => '12345',
        'environment' => 'staging'
    ]
  ]),
  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/plan/{planId}/job"

	payload := strings.NewReader("{\n  \"variables\": {\n    \"orderNumber\": \"12345\",\n    \"environment\": \"staging\"\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/plan/{planId}/job")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"variables\": {\n    \"orderNumber\": \"12345\",\n    \"environment\": \"staging\"\n  }\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.roark.ai/v1/simulation/plan/{planId}/job")

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  \"variables\": {\n    \"orderNumber\": \"12345\",\n    \"environment\": \"staging\"\n  }\n}"

response = http.request(request)
puts response.read_body
{
  "data": {
    "simulationRunPlanId": "9a8b7c6d-5e4f-3210-abcd-ef9876543210",
    "simulationRunPlanJobId": "7f3e4d2c-8a91-4b5c-9e6f-1a2b3c4d5e6f",
    "status": "PENDING",
    "createdAt": "2024-01-15T10:30:00Z"
  }
}
{
  "type": "authentication",
  "code": "unauthorized",
  "message": "Authentication required"
}
{
  "type": "forbidden",
  "code": "permission_denied",
  "message": "You do not have permission to access this resource"
}
{
  "type": "rate_limit",
  "code": "too_many_requests",
  "message": "Rate limit exceeded"
}
{
  "type": "internal",
  "code": "internal_error",
  "message": "Internal server error"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

Body

application/json

Optional request body for running a simulation plan with runtime variables

variables
object

Runtime variables that override plan-defined scenario variables. Accepts one of two formats:

Option 1 — Global (flat key-value object, applies to ALL scenarios): { "orderNumber": "12345", "environment": "staging" }

Option 2 — Per-scenario (array of objects with scenarioId + variables): [ { "scenarioId": "550e8400-...", "variables": { "orderNumber": "12345" } }, { "scenarioId": "7a3d2e1f-...", "variables": { "orderNumber": "67890" } } ]

Example:
{
  "orderNumber": "12345",
  "environment": "staging"
}

Response

Successfully triggered simulation run plan

data
object
required

Response when triggering a simulation run plan

Example:
{
  "simulationRunPlanId": "9a8b7c6d-5e4f-3210-abcd-ef9876543210",
  "simulationRunPlanJobId": "7f3e4d2c-8a91-4b5c-9e6f-1a2b3c4d5e6f",
  "status": "PENDING",
  "createdAt": "2024-01-15T10:30:00Z"
}