curl --request POST \
--url https://api.getbluejay.ai/v1/scenario \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <x-api-key>' \
--data '
{
"agent_ids": [],
"definition": {
"edges": [
{
"id": "e-wf-start-n-greet",
"source": "wf-start",
"target": "n-greet"
}
],
"nodes": [
{
"data": {
"id": "wf-start"
},
"deletable": false,
"draggable": true,
"id": "wf-start",
"position": {
"x": 100,
"y": 50
},
"type": "start"
},
{
"data": {
"criteria": "Greet the caller and offer help",
"id": "n-greet",
"speaker": "agent",
"turn": 0,
"type": "message"
},
"id": "n-greet",
"position": {
"x": 200,
"y": 180
},
"type": "single"
}
]
},
"description": "Password reset IVR",
"name": "Support reset flow"
}
'import requests
url = "https://api.getbluejay.ai/v1/scenario"
payload = {
"agent_ids": [],
"definition": {
"edges": [
{
"id": "e-wf-start-n-greet",
"source": "wf-start",
"target": "n-greet"
}
],
"nodes": [
{
"data": { "id": "wf-start" },
"deletable": False,
"draggable": True,
"id": "wf-start",
"position": {
"x": 100,
"y": 50
},
"type": "start"
},
{
"data": {
"criteria": "Greet the caller and offer help",
"id": "n-greet",
"speaker": "agent",
"turn": 0,
"type": "message"
},
"id": "n-greet",
"position": {
"x": 200,
"y": 180
},
"type": "single"
}
]
},
"description": "Password reset IVR",
"name": "Support reset flow"
}
headers = {
"X-API-Key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
agent_ids: [],
definition: {
edges: [{id: 'e-wf-start-n-greet', source: 'wf-start', target: 'n-greet'}],
nodes: [
{
data: {id: 'wf-start'},
deletable: false,
draggable: true,
id: 'wf-start',
position: {x: 100, y: 50},
type: 'start'
},
{
data: {
criteria: 'Greet the caller and offer help',
id: 'n-greet',
speaker: 'agent',
turn: 0,
type: 'message'
},
id: 'n-greet',
position: {x: 200, y: 180},
type: 'single'
}
]
},
description: 'Password reset IVR',
name: 'Support reset flow'
})
};
fetch('https://api.getbluejay.ai/v1/scenario', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.getbluejay.ai/v1/scenario",
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([
'agent_ids' => [
],
'definition' => [
'edges' => [
[
'id' => 'e-wf-start-n-greet',
'source' => 'wf-start',
'target' => 'n-greet'
]
],
'nodes' => [
[
'data' => [
'id' => 'wf-start'
],
'deletable' => false,
'draggable' => true,
'id' => 'wf-start',
'position' => [
'x' => 100,
'y' => 50
],
'type' => 'start'
],
[
'data' => [
'criteria' => 'Greet the caller and offer help',
'id' => 'n-greet',
'speaker' => 'agent',
'turn' => 0,
'type' => 'message'
],
'id' => 'n-greet',
'position' => [
'x' => 200,
'y' => 180
],
'type' => 'single'
]
]
],
'description' => 'Password reset IVR',
'name' => 'Support reset flow'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <x-api-key>"
],
]);
$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.getbluejay.ai/v1/scenario"
payload := strings.NewReader("{\n \"agent_ids\": [],\n \"definition\": {\n \"edges\": [\n {\n \"id\": \"e-wf-start-n-greet\",\n \"source\": \"wf-start\",\n \"target\": \"n-greet\"\n }\n ],\n \"nodes\": [\n {\n \"data\": {\n \"id\": \"wf-start\"\n },\n \"deletable\": false,\n \"draggable\": true,\n \"id\": \"wf-start\",\n \"position\": {\n \"x\": 100,\n \"y\": 50\n },\n \"type\": \"start\"\n },\n {\n \"data\": {\n \"criteria\": \"Greet the caller and offer help\",\n \"id\": \"n-greet\",\n \"speaker\": \"agent\",\n \"turn\": 0,\n \"type\": \"message\"\n },\n \"id\": \"n-greet\",\n \"position\": {\n \"x\": 200,\n \"y\": 180\n },\n \"type\": \"single\"\n }\n ]\n },\n \"description\": \"Password reset IVR\",\n \"name\": \"Support reset flow\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<x-api-key>")
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.getbluejay.ai/v1/scenario")
.header("X-API-Key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"agent_ids\": [],\n \"definition\": {\n \"edges\": [\n {\n \"id\": \"e-wf-start-n-greet\",\n \"source\": \"wf-start\",\n \"target\": \"n-greet\"\n }\n ],\n \"nodes\": [\n {\n \"data\": {\n \"id\": \"wf-start\"\n },\n \"deletable\": false,\n \"draggable\": true,\n \"id\": \"wf-start\",\n \"position\": {\n \"x\": 100,\n \"y\": 50\n },\n \"type\": \"start\"\n },\n {\n \"data\": {\n \"criteria\": \"Greet the caller and offer help\",\n \"id\": \"n-greet\",\n \"speaker\": \"agent\",\n \"turn\": 0,\n \"type\": \"message\"\n },\n \"id\": \"n-greet\",\n \"position\": {\n \"x\": 200,\n \"y\": 180\n },\n \"type\": \"single\"\n }\n ]\n },\n \"description\": \"Password reset IVR\",\n \"name\": \"Support reset flow\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.getbluejay.ai/v1/scenario")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"agent_ids\": [],\n \"definition\": {\n \"edges\": [\n {\n \"id\": \"e-wf-start-n-greet\",\n \"source\": \"wf-start\",\n \"target\": \"n-greet\"\n }\n ],\n \"nodes\": [\n {\n \"data\": {\n \"id\": \"wf-start\"\n },\n \"deletable\": false,\n \"draggable\": true,\n \"id\": \"wf-start\",\n \"position\": {\n \"x\": 100,\n \"y\": 50\n },\n \"type\": \"start\"\n },\n {\n \"data\": {\n \"criteria\": \"Greet the caller and offer help\",\n \"id\": \"n-greet\",\n \"speaker\": \"agent\",\n \"turn\": 0,\n \"type\": \"message\"\n },\n \"id\": \"n-greet\",\n \"position\": {\n \"x\": 200,\n \"y\": 180\n },\n \"type\": \"single\"\n }\n ]\n },\n \"description\": \"Password reset IVR\",\n \"name\": \"Support reset flow\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"name": "<string>",
"definition": {},
"created_at": "2023-11-07T05:31:56Z",
"organization_id": "<string>",
"agent_ids": [],
"description": "<string>",
"dh_sync_summary": {},
"warnings": [
"<string>"
]
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Create scenario
Create a scenario definition as a React Flow graph.
curl --request POST \
--url https://api.getbluejay.ai/v1/scenario \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <x-api-key>' \
--data '
{
"agent_ids": [],
"definition": {
"edges": [
{
"id": "e-wf-start-n-greet",
"source": "wf-start",
"target": "n-greet"
}
],
"nodes": [
{
"data": {
"id": "wf-start"
},
"deletable": false,
"draggable": true,
"id": "wf-start",
"position": {
"x": 100,
"y": 50
},
"type": "start"
},
{
"data": {
"criteria": "Greet the caller and offer help",
"id": "n-greet",
"speaker": "agent",
"turn": 0,
"type": "message"
},
"id": "n-greet",
"position": {
"x": 200,
"y": 180
},
"type": "single"
}
]
},
"description": "Password reset IVR",
"name": "Support reset flow"
}
'import requests
url = "https://api.getbluejay.ai/v1/scenario"
payload = {
"agent_ids": [],
"definition": {
"edges": [
{
"id": "e-wf-start-n-greet",
"source": "wf-start",
"target": "n-greet"
}
],
"nodes": [
{
"data": { "id": "wf-start" },
"deletable": False,
"draggable": True,
"id": "wf-start",
"position": {
"x": 100,
"y": 50
},
"type": "start"
},
{
"data": {
"criteria": "Greet the caller and offer help",
"id": "n-greet",
"speaker": "agent",
"turn": 0,
"type": "message"
},
"id": "n-greet",
"position": {
"x": 200,
"y": 180
},
"type": "single"
}
]
},
"description": "Password reset IVR",
"name": "Support reset flow"
}
headers = {
"X-API-Key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
agent_ids: [],
definition: {
edges: [{id: 'e-wf-start-n-greet', source: 'wf-start', target: 'n-greet'}],
nodes: [
{
data: {id: 'wf-start'},
deletable: false,
draggable: true,
id: 'wf-start',
position: {x: 100, y: 50},
type: 'start'
},
{
data: {
criteria: 'Greet the caller and offer help',
id: 'n-greet',
speaker: 'agent',
turn: 0,
type: 'message'
},
id: 'n-greet',
position: {x: 200, y: 180},
type: 'single'
}
]
},
description: 'Password reset IVR',
name: 'Support reset flow'
})
};
fetch('https://api.getbluejay.ai/v1/scenario', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.getbluejay.ai/v1/scenario",
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([
'agent_ids' => [
],
'definition' => [
'edges' => [
[
'id' => 'e-wf-start-n-greet',
'source' => 'wf-start',
'target' => 'n-greet'
]
],
'nodes' => [
[
'data' => [
'id' => 'wf-start'
],
'deletable' => false,
'draggable' => true,
'id' => 'wf-start',
'position' => [
'x' => 100,
'y' => 50
],
'type' => 'start'
],
[
'data' => [
'criteria' => 'Greet the caller and offer help',
'id' => 'n-greet',
'speaker' => 'agent',
'turn' => 0,
'type' => 'message'
],
'id' => 'n-greet',
'position' => [
'x' => 200,
'y' => 180
],
'type' => 'single'
]
]
],
'description' => 'Password reset IVR',
'name' => 'Support reset flow'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <x-api-key>"
],
]);
$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.getbluejay.ai/v1/scenario"
payload := strings.NewReader("{\n \"agent_ids\": [],\n \"definition\": {\n \"edges\": [\n {\n \"id\": \"e-wf-start-n-greet\",\n \"source\": \"wf-start\",\n \"target\": \"n-greet\"\n }\n ],\n \"nodes\": [\n {\n \"data\": {\n \"id\": \"wf-start\"\n },\n \"deletable\": false,\n \"draggable\": true,\n \"id\": \"wf-start\",\n \"position\": {\n \"x\": 100,\n \"y\": 50\n },\n \"type\": \"start\"\n },\n {\n \"data\": {\n \"criteria\": \"Greet the caller and offer help\",\n \"id\": \"n-greet\",\n \"speaker\": \"agent\",\n \"turn\": 0,\n \"type\": \"message\"\n },\n \"id\": \"n-greet\",\n \"position\": {\n \"x\": 200,\n \"y\": 180\n },\n \"type\": \"single\"\n }\n ]\n },\n \"description\": \"Password reset IVR\",\n \"name\": \"Support reset flow\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<x-api-key>")
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.getbluejay.ai/v1/scenario")
.header("X-API-Key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"agent_ids\": [],\n \"definition\": {\n \"edges\": [\n {\n \"id\": \"e-wf-start-n-greet\",\n \"source\": \"wf-start\",\n \"target\": \"n-greet\"\n }\n ],\n \"nodes\": [\n {\n \"data\": {\n \"id\": \"wf-start\"\n },\n \"deletable\": false,\n \"draggable\": true,\n \"id\": \"wf-start\",\n \"position\": {\n \"x\": 100,\n \"y\": 50\n },\n \"type\": \"start\"\n },\n {\n \"data\": {\n \"criteria\": \"Greet the caller and offer help\",\n \"id\": \"n-greet\",\n \"speaker\": \"agent\",\n \"turn\": 0,\n \"type\": \"message\"\n },\n \"id\": \"n-greet\",\n \"position\": {\n \"x\": 200,\n \"y\": 180\n },\n \"type\": \"single\"\n }\n ]\n },\n \"description\": \"Password reset IVR\",\n \"name\": \"Support reset flow\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.getbluejay.ai/v1/scenario")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"agent_ids\": [],\n \"definition\": {\n \"edges\": [\n {\n \"id\": \"e-wf-start-n-greet\",\n \"source\": \"wf-start\",\n \"target\": \"n-greet\"\n }\n ],\n \"nodes\": [\n {\n \"data\": {\n \"id\": \"wf-start\"\n },\n \"deletable\": false,\n \"draggable\": true,\n \"id\": \"wf-start\",\n \"position\": {\n \"x\": 100,\n \"y\": 50\n },\n \"type\": \"start\"\n },\n {\n \"data\": {\n \"criteria\": \"Greet the caller and offer help\",\n \"id\": \"n-greet\",\n \"speaker\": \"agent\",\n \"turn\": 0,\n \"type\": \"message\"\n },\n \"id\": \"n-greet\",\n \"position\": {\n \"x\": 200,\n \"y\": 180\n },\n \"type\": \"single\"\n }\n ]\n },\n \"description\": \"Password reset IVR\",\n \"name\": \"Support reset flow\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"name": "<string>",
"definition": {},
"created_at": "2023-11-07T05:31:56Z",
"organization_id": "<string>",
"agent_ids": [],
"description": "<string>",
"dh_sync_summary": {},
"warnings": [
"<string>"
]
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}# Bluejay — Testing & Monitoring Platform for Conversational AI Agents
You are a senior backend engineer integrating the Bluejay API. Think step-by-step: first understand the endpoint, then plan the integration, then implement with minimal changes.
## Create scenario — POST /v1/scenario
> **What this endpoint does:** Creates a scenario row. agent_ids must reference agents in your organization when provided. Definition is validated before persist; failures return **400** with a plain-text detail message. **Typed shapes:** discriminated graph nodes and `data` variants are defined in **components** (the `WorkflowGraph*` component schemas describe scenario graphs; legacy automation models live on **Deprecated** routes). **Draft vs. validated graph:** If the definition contains no content nodes (no `single` or `options` nodes), the graph is stored as a draft with minimal validation — only duplicate start nodes are rejected. Once at least one content node is present, full export validation runs. **Validation (when content nodes are present):** - At most one node with type `start` is allowed (duplicate start nodes are always rejected, even in draft mode). Having zero start nodes with content nodes results in a "No paths from Start" error. - At least one content node (`single` or `options`) must be reachable from the start node via edges. Orphaned content nodes not on any path from Start are rejected. - The graph must not contain directed cycles. - **Single** nodes: data.type is required — one of exact, contextual, silence, dtmf. exact/contextual: non-empty data.message. contextual: only when data.speaker is agent (default); not allowed for user. silence: data.duration_ms — finite number, non-negative, at most 86400000 (24h). dtmf: data.digits — non-empty string containing only 0-9, *, #, and A-D (case-insensitive) after trim. - **Options** nodes: data.branch_options has at least two entries; node speaker must be omitted or "user". Each branch: non-empty id; type one of exact, silence, dtmf (not contextual); exact requires message. - From an options node, edges continuing the flow should set sourceHandle to the chosen branch id (must match branch_options[].id). **Rate limiting:** 100 requests per minute per route (middleware). **Authentication:** JWT (Authorization: Bearer) or X-API-Key header.
**Endpoint:** POST `https://api.getbluejay.ai/v1/scenario`
**Auth:** `X-API-Key` header
**Content-Type:** application/json
### Required Parameters
| Name | Type | Description |
|------|------|-------------|
| X-API-Key | string | API key required to authenticate requests. |
| name | string | |
| definition | object | React Flow graph. Both nodes and edges are optional — omitting either defaults to []. Optional keys such as viewport are allowed. Stored graphs may include extra React Flow / UI fields on nodes and edges (additionalProperties). |
Review the full parameter list at https://docs.getbluejay.ai/api-reference/endpoint/create-scenario and include any optional parameters (e.g., `agent_ids`, `description`) that serve your integration's use case and align with Bluejay's testing and monitoring capabilities.
### Request Body (required fields)
```json
{
"name": "example_name",
"definition": {
"nodes": [
{
"id": "string",
"type": "start",
"position": {
"x": 1.0,
"y": 1.0
},
"data": {
"key": "value"
}
}
],
"edges": [
{
"id": "string",
"source": "string",
"target": "string",
"sourceHandle": "string"
}
],
"viewport": {
"key": "value"
}
}
}
```
Refer to the full schema at https://docs.getbluejay.ai/api-reference/endpoint/create-scenario. Include optional fields that serve the goal of setting up for testing and monitoring on Bluejay.
### Example
**POST with body:**
```python
import requests
def create_scenario(payload: dict, api_key: str) -> dict:
url = "https://api.getbluejay.ai/v1/scenario"
headers = {"X-API-Key": api_key}
response = requests.post(url, headers=headers, json=payload)
response.raise_for_status()
return response.json()
```
### Constraints
- Minimal changes — only add/change files needed for this integration.
- Match existing codebase patterns (naming, file structure, error handling).
- Include error handling for 400: Invalid definition or graph validation error; 401: Unauthorized; 422: Request body schema validation failed (Pydantic).
### Integration Checklist
Before writing code, verify:
1. Which module/service owns this API domain in the codebase?
2. What HTTP client and error-handling patterns does the project use?
3. Are there existing types/interfaces to extend?
Then implement the integration, export it, and confirm it compiles/passes lint.
nodes, edges, and optional viewport.Body
Create a workflow; definition is a React Flow graph (nodes, edges, optional viewport).
Name of the workflow
1 - 255React Flow graph. Omitted nodes / edges default to []. Each node must have a non-empty string id on the node object (not only inside data). Each edge must have a non-empty string id, unique across all edges. With no single or options nodes, the graph is stored as a draft (only multiple-start is rejected). Once there is content, export rules apply (paths, branch_options, etc.).
Owning agents (must belong to your organization). Omit or null for org-only workflow.
Human-readable description of the workflow
Response
Successful Response
Single workflows_v2 row.
Workflow ID
Name of the workflow
Stored React Flow graph (start / single / options nodes). Nodes and edges use top-level string id fields; edge id values are unique within the graph.
Creation timestamp
Owning organization ID (set by middleware on create)
Linked agent ids when the workflow is agent-scoped
Description
Present on PUT responses when the definition was updated. Keys: updated, created, marked_stale, skipped, errors.
Non-blocking lint warnings emitted at save time (e.g. node text referencing an unknown {{trait_name}}). Empty when the definition is clean or no agents are linked.