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.
Save an experiment's setup
Replace the experiment's setup. Send expectedVersion with the version you read and the save is refused with a 409 when someone else wrote first, instead of overwriting their work.
Try this endpoint
app.langwatch.ai
API key · X-Auth-Token
Kept in this tab. Cleared when you reload.
The experiment's slug, or its id
The full setup to save
The version you read. Sending it refuses the save when someone else already wrote on top of it.
Names this version in the history list
This sends a live request to app.langwatch.ai.
Request and response examples
import osimport requestsorigin = "https://app.langwatch.ai"path = "/api/v1/experiments/<slug>/workbench-state"api_key = os.environ["LANGWATCH_API_KEY"]headers = { "X-Auth-Token": api_key, "Content-Type": "application/json",}payload = {}response = requests.put( origin + path, headers=headers, json=payload,)print(response.json())const url = "https://app.langwatch.ai/api/v1/experiments/<slug>/workbench-state";const response = await fetch(url, { method: "PUT", headers: { "X-Auth-Token": process.env.LANGWATCH_API_KEY!, "Content-Type": "application/json", }, body: JSON.stringify({}),});const data = await response.json();curl --request PUT \ --url 'https://app.langwatch.ai/api/v1/experiments/<slug>/workbench-state' \ --header "X-Auth-Token: $LANGWATCH_API_KEY" \ --header 'Content-Type: application/json' \ --data '{}'Call the LangWatch API from this project: Save an experiment's setup.Request: PUT https://app.langwatch.ai/api/v1/experiments/<slug>/workbench-stateReference: https://langwatch.ai/docs/api-reference/experiments/save-an-experiment-s-setup.mdAuthentication: send the X-Auth-Token header, read from the LANGWATCH_API_KEY environment variable. Never hard-code the key.Body (application/json):```json{}```Use the HTTP client this project already uses, handle non-2xx responses, and show me the parsed result.Success
application/json · Generated from schema
{ "version": -9007199254740991}The setup did not match the schema (experiment_invalid_workbench_state), points at something that no longer exists (experiment_workbench_missing_reference), or the experiment is not an evaluations workbench (experiment_type_mismatch)
Missing or invalid API key, or the key lacks the permission
No such experiment in this project
Someone else saved since you read this state (experiment_stale_workbench_state). currentVersion carries the version to read again.
Path parameters
slugstringrequiredThe experiment's slug, or its id
Request body
application/json · Required
stateobjectrequiredThe full setup to save
expectedVersionintegerThe version you read. Sending it refuses the save when someone else already wrote on top of it.
commitMessagestringNames this version in the history list
Responses
200Success
application/json
versionintegerrequiredThe version the save produced
400The setup did not match the schema (experiment_invalid_workbench_state), points at something that no longer exists (experiment_workbench_missing_reference), or the experiment is not an evaluations workbench (experiment_type_mismatch)
401Missing or invalid API key, or the key lacks the permission
404No such experiment in this project
409Someone else saved since you read this state (experiment_stale_workbench_state). currentVersion carries the version to read again.
currentVersion carries the version to read again.