Skip to contentSkip to page list

Docs

Create a new scenario event

Create a new scenario event

POST/api/v1/scenario-events
Request and response examples
request.py
import osimport requests​origin = "https://app.langwatch.ai"path = "/api/v1/scenario-events"api_key = os.environ["LANGWATCH_API_KEY"]headers = {    "X-Auth-Token": api_key,    "Content-Type": "application/json",}payload = {    "type": "SCENARIO_RUN_STARTED",    "timestamp": 0,    "rawEvent": None,    "batchRunId": "string",    "scenarioId": "string",    "scenarioRunId": "string",    "scenarioSetId": "default",    "metadata": {        "name": "string",        "description": "string",        "note": "string",        "agents": [            {                "name": "string",                "role": "agent",            },        ],        "langwatch": {            "targetReferenceId": "string",            "targetType": "prompt",            "targetKey": "string",            "targetParameters": {},            "simulationSuiteId": "string",            "scenarioVersion": -9007199254740991,            "simulatorModel": "string",            "judgeModel": "string",            "resolvedSimulatorModel": "string",            "resolvedJudgeModel": "string",            "actorId": "string",            "actorLabel": "user",            "agentInstance": {                "hostname": "string",                "label": "string",            },            "callerKind": "simulated",            "caller": {                "voice": "string",                "interruptProbability": 0,                "effects": "string",            },            "isCutAtLimit": False,        },    },}​response = requests.post(    origin + path,    headers=headers,    json=payload,)print(response.json())

Success

application/json · Generated from schema

{  "success": false,  "url": "string"}
api-reference/scenario-events/create-scenario-events

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

One of 9
Option 1type: "SCENARIO_RUN_STARTED"object
typestringrequired
Always"SCENARIO_RUN_STARTED"
timestampnumberrequired
rawEventany
batchRunIdstringrequired
scenarioIdstringrequired
scenarioRunIdstringrequired
scenarioSetIdstring
Default: "default"
metadataobjectrequired
Option 2type: "SCENARIO_RUN_FINISHED"object
typestringrequired
Always"SCENARIO_RUN_FINISHED"
timestampnumberrequired
rawEventany
batchRunIdstringrequired
scenarioIdstringrequired
scenarioRunIdstringrequired
scenarioSetIdstring
Default: "default"
statusstringrequired
One of"SUCCESS""ERROR""CANCELLED""IN_PROGRESS""PENDING""FAILED""STALLED""QUEUED""RUNNING""PENDING_EVALUATION"
resultsobject | null
Option 3type: "SCENARIO_MESSAGE_SNAPSHOT"object
typestringrequired
Always"SCENARIO_MESSAGE_SNAPSHOT"
timestampnumberrequired
rawEventany
batchRunIdstringrequired
scenarioIdstringrequired
scenarioRunIdstringrequired
scenarioSetIdstring
Default: "default"
messagesobject[]required
Option 4type: "SCENARIO_TEXT_MESSAGE_START"object
typestringrequired
Always"SCENARIO_TEXT_MESSAGE_START"
timestampnumberrequired
rawEventany
batchRunIdstringrequired
scenarioIdstringrequired
scenarioRunIdstringrequired
scenarioSetIdstring
Default: "default"
messageIdstringrequired
rolestringrequired
messageIndexnumber
Option 5type: "SCENARIO_TEXT_MESSAGE_END"object
typestringrequired
Always"SCENARIO_TEXT_MESSAGE_END"
timestampnumberrequired
rawEventany
batchRunIdstringrequired
scenarioIdstringrequired
scenarioRunIdstringrequired
scenarioSetIdstring
Default: "default"
messageIdstringrequired
rolestringrequired
contentstring
messageobject
traceIdstring
messageIndexnumber
Option 6type: "SCENARIO_TEXT_MESSAGE_CONTENT"object
typestringrequired
Always"SCENARIO_TEXT_MESSAGE_CONTENT"
timestampnumberrequired
rawEventany
batchRunIdstringrequired
scenarioIdstringrequired
scenarioRunIdstringrequired
scenarioSetIdstring
Default: "default"
messageIdstringrequired
deltastringrequired
Option 7type: "SCENARIO_TOOL_CALL_START"object
typestringrequired
Always"SCENARIO_TOOL_CALL_START"
timestampnumberrequired
rawEventany
batchRunIdstringrequired
scenarioIdstringrequired
scenarioRunIdstringrequired
scenarioSetIdstring
Default: "default"
toolCallIdstringrequired
toolCallNamestringrequired
parentMessageIdstring
Option 8type: "SCENARIO_TOOL_CALL_ARGS"object
typestringrequired
Always"SCENARIO_TOOL_CALL_ARGS"
timestampnumberrequired
rawEventany
batchRunIdstringrequired
scenarioIdstringrequired
scenarioRunIdstringrequired
scenarioSetIdstring
Default: "default"
toolCallIdstringrequired
deltastringrequired
Option 9type: "SCENARIO_TOOL_CALL_END"object
typestringrequired
Always"SCENARIO_TOOL_CALL_END"
timestampnumberrequired
rawEventany
batchRunIdstringrequired
scenarioIdstringrequired
scenarioRunIdstringrequired
scenarioSetIdstring
Default: "default"
toolCallIdstringrequired

Responses

201

Success

application/json

successbooleanrequired
urlstring | null
400

Invalid event data

application/json

errorstringrequired
401

Unauthorized

application/json

errorstringrequired
messagestring
422

Unprocessable Entity

application/json

errorstringrequired
messagestring
500

Internal Server Error

application/json

errorstringrequired
messagestring

Documentation