---
title: "Generate Strategy"
method: POST
path: "/v1/strategies/generate"
tags: ["strategies"]
---

# Generate Strategy

`POST /v1/strategies/generate`

## Request

- Base URL: `https://api.usekeel.io` (the document declares no server; this is the origin it was published from)
- URL: `https://api.usekeel.io/v1/strategies/generate`
- Auth: none declared

Generate a Keel DSL strategy from a template kind + params payload.

Dispatches to `libs/strategy_templates/<kind>.py` via TEMPLATE_REGISTRY,
then bakes a resolved universe into the generated DSL so the handoff
strategy is never born failing validation (F-01-9 / Q-0847) AND reproduces
the set the source surface actually showed (Q-0852, Mechanism A).

Reproducibility: when the payload carries a resolved set + as-of
(``params["resolved"]`` / ``params["resolved_at"]`` — the Momentum-Lab CTA
now transmits its displayed top-N membership + the snapshot instant), that
set is baked as a manual-style PIN — the EXACT assets the Lab showed, not a
fresh live re-resolve. Without a transmitted set (a legacy Lab client), the
shared helper live-resolves as the honest fallback (born valid, editor can
re-resolve). The `index` kind already ships an explicit resolved basket, so
the helper leaves it untouched. See `..universe_bake.bake_universe_resolution`.

Currently registered kinds: `screen`, `index`.

Back-compat: if `kind` is omitted, the request is treated as a legacy
momentum-lab screen request and the flat fields are forwarded to the
screen generator. This shim will be removed after a deploy cycle.

## Request body

- GenerateRequest: Polymorphic generate request. Either `kind` + `params` are provided (canonical), or all fields are flat at the top level (legacy momentum-lab shape — auto-detected as `screen` kind). Extra fields are tolerated for legacy compatibility.
  - `kind` string, nullable
  - `params` object, nullable

## Response `200`

Successful Response

- GenerateResponse
  - `code` string, required
  - `name` string, required
  - `description` string, required

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/usekeel/apis/keel-api.md) · [All operations](https://skmtc.dev/usekeel/apis/keel-api/llms.txt) · [OpenAPI document](https://skmtc.dev/usekeel/apis/keel-api/revisions/3191ca10b0ab?raw)
