Skip to contentSkip to page list

Docs

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.

PUT/api/v1/experiments/{slug}/workbench-state
Request and response examples
request.py
import osimport requests​origin = "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())

Success

application/json · Generated from schema

{  "version": -9007199254740991}
api-reference/experiments/save-an-experiment-s-setup

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.

Path parameters

slugstringrequired

The experiment's slug, or its id

At least 1 character

Request body

application/json · Required

stateobjectrequired

The full setup to save

expectedVersioninteger

The version you read. Sending it refuses the save when someone else already wrote on top of it.

Minimum -9007199254740991Maximum 9007199254740991
commitMessagestring

Names this version in the history list

Responses

200

Success

application/json

versionintegerrequired

The version the save produced

Minimum -9007199254740991Maximum 9007199254740991
400

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)

401

Missing or invalid API key, or the key lacks the permission

404

No such experiment in this project

409

Someone else saved since you read this state (experiment_stale_workbench_state). currentVersion carries the version to read again.

Documentation