---
title: "Patch Strategy"
method: PATCH
path: "/v1/strategies/{strategy_id}"
---

# Patch Strategy

`PATCH /v1/strategies/{strategy_id}`

## Request

- Base URL: `https://api.quantradin.com` (the document declares no server; this is the origin it was published from)
- URL: `https://api.quantradin.com/v1/strategies/{strategy_id}`
- Auth: none declared

Rename and/or replace the spec of ONE of the caller's saved strategies.

Body: ``{"name"?: str, "spec"?: object}`` — at least one (400, friendly, if
neither). Auth: session cookie wins, else X-Vega-Key, else an account key
pair (the same resolution as GET /v1/strategies/{id}); the shared guest key
with no session is refused, because on that one tenant an edit by id would
rewrite another visitor's work. 404 "Strategy not found" for a stranger —
byte-identical to a missing id. Bumps `updated_at`, returns the updated row.

A replaced spec is re-validated through the SAME path POST /v1/strategies
uses (_normalize_and_validate_spec), so a refusal carries the engine's own
teaching message plus `suggestions` / `suggested_spec`. A refused edit stores
NOTHING — the previous spec stands.

WHAT AN EDIT NEVER TOUCHES: a DEPLOYED bot keeps trading its own spec
snapshot (vega_paper_deployments.spec has no FK to this table), and a
finished backtest keeps its own `spec_snapshot`. Editing the library entry
is editing the DRAFT, never the running bot and never the graded receipt —
redeploy or re-run to put the new version to work.

## Path parameters

- `strategy_id` integer, required

## Headers

- `x-vega-key` string, nullable

## Request body

- StrategyPatchRequest: PATCH /v1/strategies/{id} — rename and/or replace the spec. Both fields optional, at least one required (400 otherwise). A replaced `spec` goes through the SAME validation POST /v1/strategies uses.
  - `name` string, nullable
  - `spec` object, nullable

## Response `200`

Successful Response

- unknown

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/quantradin/apis/vega-api.md) · [All operations](https://skmtc.dev/quantradin/apis/vega-api/llms.txt) · [OpenAPI document](https://skmtc.dev/quantradin/apis/vega-api/revisions/47add154ef38?raw)
