Skip to contentSkip to page list

Docs

Create a new scenario

Create a new scenario

POST/api/v1/scenarios
Request and response examples
request.py
import osimport requests​origin = "https://app.langwatch.ai"path = "/api/v1/scenarios"api_key = os.environ["LANGWATCH_API_KEY"]headers = {    "X-Auth-Token": api_key,    "Content-Type": "application/json",}payload = {    "redTeam": {        "owaspIds": [],    },}​response = requests.post(    origin + path,    headers=headers,    json=payload,)print(response.json())

Success

application/json · Generated from schema

{  "id": "string",  "name": "string",  "situation": "string",  "criteria": [    "string"  ],  "labels": [    "string"  ],  "parameters": [    {      "name": "string",      "description": "string",      "defaultValue": "string",      "secret": false,      "type": "string",      "options": [        "string"      ],      "required": false    }  ],  "simulatorModel": "string",  "judgeModel": "string",  "traceQuietPeriodMs": -9007199254740991,  "traceWaitTimeoutMs": -9007199254740991,  "maxTurns": -9007199254740991,  "minTurns": -9007199254740991,  "testSuiteId": "string",  "fields": {},  "platformUrl": "string"}
api-reference/scenarios/create-scenarios

Authorization

X-Auth-Tokenstringheaderrequired

Project API key for sending traces and accessing project-scoped resources. Format: sk-lw-... (no underscore). Obtain one by creating a project via the Admin API or the LangWatch UI.

Request body

application/json · Required

namestringrequired
At least 1 character
situationstringrequired
criteriastring[]
Default: []
labelsstring[]
Default: []
parametersobject[]

The parameters this scenario declares by name, each with an optional description and default. A run supplies values for these names, readable from the scenario's own text as params.NAME. A parameter marked secret carries no default: its value is supplied per run, encrypted, delivered to the target as secrets.NAME, and never readable from the scenario's own text.

namestringrequired
At least 1 characterUp to 64 charactersPattern ^[A-Za-z_][A-Za-z0-9_]*$
descriptionstring
Up to 500 characters
defaultValuestring | number | boolean
secretboolean
typestring
One of"string""number""boolean"
optionsstring | number | boolean[]
requiredboolean
simulatorModelstring | null

Model for the simulated user, e.g. openai/gpt-6-luna. Null uses the project default.

Option 1string
Option 2null
judgeModelstring | null

Model for the judge, e.g. openai/gpt-6-luna. Null uses the project default.

Option 1string
Option 2null
traceQuietPeriodMsinteger | null

Milliseconds (0 to 60000) the agent's trace must stay unchanged before the judge reads it. Null uses the project's recommendation.

Option 1integer
Option 2null
traceWaitTimeoutMsinteger | null

Milliseconds (1000 to 300000) the judge waits for the agent's trace before a verdict. Null uses the project's recommendation.

Option 1integer
Option 2null
maxTurnsinteger | null

Maximum conversation turns for a run of this scenario. Null uses the default.

Option 1integer
Option 2null
minTurnsinteger | null

Minimum conversation turns before the judge may end the run. Null uses the default.

Option 1integer
Option 2null
testSuiteIdstring | null

The test suite to file this scenario in. It must name a non-archived test suite of the same project. null files the scenario into the project's Default test suite.

fieldsobject

The value for each field the test suite declares, keyed by field identifier: text, a number or a boolean, in the field's own type. A field the suite does not declare answers 422 scenario_field_unknown; a value of the wrong type answers 422 scenario_field_type_invalid. An empty value clears the field.

kindstring

Absent or "standard" plays a user simulator. "red_team" plays an attacker and requires redTeam; a standard scenario with redTeam answers 422 scenario_red_team_config_mismatch.

One of"standard""red_team"
redTeamobject

The attack a red_team scenario plays: goal, OWASP ids, strategy and turn budget.

attackGoalstringrequired
At least 1 characterUp to 4000 characters
owaspIdsstring[]required
strategystring
One of"crescendo""goat"
Default: "crescendo"
maxTurnsinteger
Minimum 1Maximum 50
Default: 30
sourceTemplateIdany

Refused: only applying a suite template marks a scenario with its template.

Responses

201

Success

application/json

idstringrequired
namestringrequired
situationstringrequired
criteriastring[]required
labelsstring[]required
parametersobject[]required
namestringrequired
At least 1 characterUp to 64 charactersPattern ^[A-Za-z_][A-Za-z0-9_]*$
descriptionstring
Up to 500 characters
defaultValuestring | number | boolean
secretboolean
typestring
One of"string""number""boolean"
optionsstring | number | boolean[]
requiredboolean
simulatorModelstring | null

The model that plays the user, or null for the project default. Absent on servers that predate model overrides on this family.

judgeModelstring | null

The model that judges the run, or null for the project default. Absent on servers that predate model overrides on this family.

traceQuietPeriodMsinteger | null

Milliseconds the agent's trace must stay unchanged before the judge reads it, or null for the project's recommendation. Absent on servers that predate judge trace settings.

Option 1integer
Option 2null
traceWaitTimeoutMsinteger | null

Milliseconds the judge waits for the agent's trace before a verdict, or null for the project's recommendation. Absent on servers that predate judge trace settings.

Option 1integer
Option 2null
maxTurnsinteger | null

The most conversation turns a run of this scenario takes, or null for the default. Absent on servers that predate turn limits on this family.

Option 1integer
Option 2null
minTurnsinteger | null

The fewest conversation turns before the judge may end a run, or null for the default. Absent on servers that predate turn limits on this family.

Option 1integer
Option 2null
testSuiteIdstring | null

The test suite this scenario is filed in, or null when unfiled. Absent on servers that predate test suites.

fieldsobject

The value this scenario carries for each field its test suite declares, keyed by field identifier. A field with no value has no key. Absent on servers that predate suite fields.

platformUrlstring (uri)required

Documentation