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.
Create a new scenario event
Create a new scenario event
Try this endpoint
app.langwatch.ai
API key · X-Auth-Token
Kept in this tab. Cleared when you reload.
Body (application/json)
This sends a live request to app.langwatch.ai.
Request and response examples
request.py
import osimport requestsorigin = "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())const url = "https://app.langwatch.ai/api/v1/scenario-events";const response = await fetch(url, { method: "POST", headers: { "X-Auth-Token": process.env.LANGWATCH_API_KEY!, "Content-Type": "application/json", }, body: JSON.stringify({ "type": "SCENARIO_RUN_STARTED", "timestamp": 0, "rawEvent": null, "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 } } }),});const data = await response.json();curl --request POST \ --url 'https://app.langwatch.ai/api/v1/scenario-events' \ --header "X-Auth-Token: $LANGWATCH_API_KEY" \ --header 'Content-Type: application/json' \ --data '{"type":"SCENARIO_RUN_STARTED","timestamp":0,"rawEvent":null,"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}}}'Call the LangWatch API from this project.Request: POST https://app.langwatch.ai/api/v1/scenario-eventsReference: https://langwatch.ai/docs/api-reference/scenario-events/create-scenario-events.mdAuthentication: send the X-Auth-Token header, read from the LANGWATCH_API_KEY environment variable. Never hard-code the key.Body (application/json):```json{ "type": "SCENARIO_RUN_STARTED", "timestamp": 0, "rawEvent": null, "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 } }}```Use the HTTP client this project already uses, handle non-2xx responses, and show me the parsed result.Success
application/json · Generated from schema
{ "success": false, "url": "string"}Invalid event data
application/json · Generated from schema
{ "error": "string"}Unauthorized
application/json · Generated from schema
{ "error": "string", "message": "string"}Unprocessable Entity
application/json · Generated from schema
{ "error": "string", "message": "string"}Internal Server Error
application/json · Generated from schema
{ "error": "string", "message": "string"}Request body
application/json · Required
Responses
201Success
application/json
successbooleanrequiredurlstring | null400Invalid event data
application/json
errorstringrequired401Unauthorized
application/json
errorstringrequiredmessagestring422Unprocessable Entity
application/json
errorstringrequiredmessagestring500Internal Server Error
application/json
errorstringrequiredmessagestring