{"openapi":"3.1.0","info":{"title":"FlagValent Public API","version":"0.1.0","description":"Runtime API for evaluating feature flags with FlagValent API keys: `fvpk_…` (publishable, browser-safe, `clientSide` flags only) or `fvsk_…` (secret, server-side). Tenant admin API (`/v1/admin/*`: flags, segments, releases, kill switches, audit) with a ValentConsole service account access token (`Authorization: Bearer <accessToken>` from `POST /api/projects/{project}/environments/{environment}/modules/features/admin-token`); evaluation keys are rejected there. Console and service-binding APIs are not part of this reference."},"servers":[{"url":"/","description":"Same origin as this documentation"}],"security":[{"apiKey":[]}],"paths":{"/healthz":{"get":{"tags":["Health"],"summary":"Worker liveness check","operationId":"getHealth","security":[],"responses":{"200":{"description":"The Worker is responding (not a D1, KV or Durable Object readiness probe).","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"ok":{"type":"boolean","const":true}},"required":["ok"]}},"required":["data"]}}}}}}},"/v1/evaluate":{"post":{"tags":["Evaluation"],"summary":"Evaluate flags for a context","description":"Evaluates every flag (or the requested `flags`, at most 500) against `context` using the current release and kill set. Publishable keys only see `clientSide` flags; other requested keys return `FLAG_NOT_FOUND`. CORS is open for browser use.","operationId":"evaluate","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"context":{"$ref":"#/components/schemas/EvaluationContext"},"flags":{"type":"array","items":{"type":"string"},"maxItems":500}},"required":["context"]}}}},"responses":{"200":{"description":"Evaluations keyed by flag key.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"stateVersion":{"type":"integer","description":"Monotonic version of the live state (release pointer + kills)."},"releaseVersion":{"type":"integer","description":"Current release; 0 before the first publish."},"stale":{"type":"boolean","description":"True when the live state was served stale (Durable Object unreachable)."},"flags":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/Evaluation"}}},"required":["stateVersion","releaseVersion","stale","flags"]}},"required":["data"]}}},"headers":{"x-flagvalent-state":{"description":"`fresh` when the live state came from the tenant Durable Object, `stale` when it was served stale.","schema":{"type":"string","enum":["fresh","stale"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"503":{"$ref":"#/components/responses/Unavailable"}}}},"/v1/snapshot":{"get":{"tags":["Evaluation"],"summary":"Current release snapshot and kill set","description":"For local evaluation by server SDKs. `ETag` is the quoted `stateVersion`; send it as `If-None-Match` to get `304 Not Modified` while nothing changed. Publishable keys receive a snapshot filtered to `clientSide` flags and the segments they reference.","operationId":"getSnapshot","parameters":[{"name":"If-None-Match","in":"header","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"The current release and kill set.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"stateVersion":{"type":"integer","description":"Monotonic version of the live state (release pointer + kills)."},"releaseVersion":{"type":"integer","description":"Current release; 0 before the first publish."},"stale":{"type":"boolean","description":"True when the live state was served stale (Durable Object unreachable)."},"snapshot":{"$ref":"#/components/schemas/ReleaseSnapshot"},"killed":{"type":"array","items":{"type":"string"}}},"required":["stateVersion","releaseVersion","stale","snapshot","killed"]}},"required":["data"]}}},"headers":{"x-flagvalent-state":{"description":"`fresh` when the live state came from the tenant Durable Object, `stale` when it was served stale.","schema":{"type":"string","enum":["fresh","stale"]}},"ETag":{"schema":{"type":"string"},"description":"`\"<stateVersion>\"`"}}},"304":{"description":"Unchanged since the `If-None-Match` ETag.","headers":{"x-flagvalent-state":{"description":"`fresh` when the live state came from the tenant Durable Object, `stale` when it was served stale.","schema":{"type":"string","enum":["fresh","stale"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"503":{"$ref":"#/components/responses/Unavailable"}}}},"/v1/stream":{"get":{"tags":["Evaluation"],"summary":"Live-state WebSocket (secret keys)","description":"WebSocket upgrade proxied to the tenant Durable Object. On connect and on every change it pushes `{ \"type\": \"state\", stateVersion, releaseVersion, killed }`; any client message is answered with the current state.","operationId":"streamState","parameters":[{"name":"Upgrade","in":"header","required":true,"schema":{"type":"string","const":"websocket"}}],"responses":{"101":{"description":"Switching protocols."},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"426":{"description":"The request is not a WebSocket upgrade."},"503":{"$ref":"#/components/responses/Unavailable"}}}},"/v1/admin/me":{"get":{"tags":["Tenant admin"],"operationId":"whoAmI","summary":"Describe the credential","description":"The tenant, credential and scopes of the service account access token. Public entrypoint only.","parameters":[{"name":"x-valent-tenant","in":"header","required":false,"description":"Optional tenant UUID; it must equal the token tenant (`403` otherwise).","schema":{"type":"string"}},{"name":"x-valent-actor","in":"header","required":false,"description":"End user acting through the service account; audited as `<actor> via sa:<id>` (default `sa:<id>`).","schema":{"type":"string"}},{"name":"x-valent-actor-email","in":"header","required":false,"description":"Actor e-mail, recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, echoed and recorded in the audit log.","schema":{"type":"string"}}],"responses":{"200":{"description":"The verified credential.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"tenantId":{"type":"string","format":"uuid"},"credential":{"type":"object"},"scopes":{"type":"array","items":{"type":"string","enum":["read","write","admin"]}}},"required":["tenantId","credential","scopes"]}},"required":["data"]}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"409":{"$ref":"#/components/responses/Conflict"}},"security":[{"serviceAccountToken":[]}]}},"/v1/admin/flags":{"get":{"tags":["Flags"],"operationId":"listFlags","summary":"List draft flags","parameters":[{"name":"x-valent-tenant","in":"header","required":false,"description":"Optional tenant UUID; it must equal the token tenant (`403` otherwise).","schema":{"type":"string"}},{"name":"x-valent-actor","in":"header","required":false,"description":"End user acting through the service account; audited as `<actor> via sa:<id>` (default `sa:<id>`).","schema":{"type":"string"}},{"name":"x-valent-actor-email","in":"header","required":false,"description":"Actor e-mail, recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, echoed and recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, recorded in the audit log.","schema":{"type":"string"}}],"responses":{"200":{"description":"Draft flags by key.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/FlagRecord"}}},"required":["data"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"}},"description":"Requires scope `read`.","security":[{"serviceAccountToken":[]}]},"post":{"tags":["Flags"],"operationId":"createFlag","summary":"Create a draft flag","parameters":[{"name":"x-valent-tenant","in":"header","required":false,"description":"Optional tenant UUID; it must equal the token tenant (`403` otherwise).","schema":{"type":"string"}},{"name":"x-valent-actor","in":"header","required":false,"description":"End user acting through the service account; audited as `<actor> via sa:<id>` (default `sa:<id>`).","schema":{"type":"string"}},{"name":"x-valent-actor-email","in":"header","required":false,"description":"Actor e-mail, recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, echoed and recorded in the audit log.","schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"Retry key (24 h, per tenant): the same key and request replay the stored response (`Idempotent-Replayed: true`); the same key with another request is `409 idempotency_key_reused`.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, recorded in the audit log.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Flag"}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/FlagRecord"}},"required":["data"]}}},"headers":{"ETag":{"description":"The flag `version` as a strong entity tag (`\"<version>\"`).","schema":{"type":"string"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"422":{"$ref":"#/components/responses/ValidationFailed"}},"description":"Requires scope `write`.","security":[{"serviceAccountToken":[]}]}},"/v1/admin/flags/{key}":{"get":{"tags":["Flags"],"operationId":"getFlag","summary":"Get a draft flag","parameters":[{"name":"x-valent-tenant","in":"header","required":false,"description":"Optional tenant UUID; it must equal the token tenant (`403` otherwise).","schema":{"type":"string"}},{"name":"x-valent-actor","in":"header","required":false,"description":"End user acting through the service account; audited as `<actor> via sa:<id>` (default `sa:<id>`).","schema":{"type":"string"}},{"name":"x-valent-actor-email","in":"header","required":false,"description":"Actor e-mail, recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, echoed and recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, recorded in the audit log.","schema":{"type":"string"}},{"name":"key","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The flag.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/FlagRecord"}},"required":["data"]}}},"headers":{"ETag":{"description":"The flag `version` as a strong entity tag (`\"<version>\"`).","schema":{"type":"string"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"}},"description":"Requires scope `read`.","security":[{"serviceAccountToken":[]}]},"put":{"tags":["Flags"],"operationId":"updateFlag","summary":"Replace a draft flag","parameters":[{"name":"x-valent-tenant","in":"header","required":false,"description":"Optional tenant UUID; it must equal the token tenant (`403` otherwise).","schema":{"type":"string"}},{"name":"x-valent-actor","in":"header","required":false,"description":"End user acting through the service account; audited as `<actor> via sa:<id>` (default `sa:<id>`).","schema":{"type":"string"}},{"name":"x-valent-actor-email","in":"header","required":false,"description":"Actor e-mail, recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, echoed and recorded in the audit log.","schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"Retry key (24 h, per tenant): the same key and request replay the stored response (`Idempotent-Replayed: true`); the same key with another request is `409 idempotency_key_reused`.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, recorded in the audit log.","schema":{"type":"string"}},{"name":"key","in":"path","required":true,"schema":{"type":"string"}},{"name":"If-Match","in":"header","required":false,"description":"Optimistic concurrency: the flag `ETag` (`\"<version>\"`, or a comma-separated list) or `*`. Without it the write is unconditional. A stale token is `412 precondition_failed`.","schema":{"type":"string","examples":["\"3\""]}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Flag"},{"type":"object","properties":{"expectedVersion":{"type":"integer","minimum":1,"description":"Same as `If-Match: \"<expectedVersion>\"`; when both are sent, both must match."},"expectedUpdatedAt":{"type":"string","format":"date-time","description":"Optimistic concurrency: the flag `updatedAt` as last read (not stored). When the flag changed since, the write is `409 conflict` with `details: { key, expectedUpdatedAt, currentUpdatedAt }`. Omit it for an unconditional write (last write wins)."}}}]}}}},"responses":{"200":{"description":"Updated (`version` incremented).","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/FlagRecord"}},"required":["data"]}}},"headers":{"ETag":{"description":"The flag `version` as a strong entity tag (`\"<version>\"`).","schema":{"type":"string"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/StaleWrite"},"412":{"$ref":"#/components/responses/PreconditionFailed"},"422":{"$ref":"#/components/responses/ValidationFailed"}},"description":"Requires scope `write`.","security":[{"serviceAccountToken":[]}]},"delete":{"tags":["Flags"],"operationId":"deleteFlag","summary":"Archive a flag (or hard-delete a never-published one)","parameters":[{"name":"x-valent-tenant","in":"header","required":false,"description":"Optional tenant UUID; it must equal the token tenant (`403` otherwise).","schema":{"type":"string"}},{"name":"x-valent-actor","in":"header","required":false,"description":"End user acting through the service account; audited as `<actor> via sa:<id>` (default `sa:<id>`).","schema":{"type":"string"}},{"name":"x-valent-actor-email","in":"header","required":false,"description":"Actor e-mail, recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, echoed and recorded in the audit log.","schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"Retry key (24 h, per tenant): the same key and request replay the stored response (`Idempotent-Replayed: true`); the same key with another request is `409 idempotency_key_reused`.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, recorded in the audit log.","schema":{"type":"string"}},{"name":"key","in":"path","required":true,"schema":{"type":"string"}},{"name":"If-Match","in":"header","required":false,"description":"Optimistic concurrency: the flag `ETag` (`\"<version>\"`, or a comma-separated list) or `*`. Without it the write is unconditional. A stale token is `412 precondition_failed`.","schema":{"type":"string","examples":["\"3\""]}},{"name":"hard","in":"query","required":false,"schema":{"type":"boolean"},"description":"Delete the row."}],"responses":{"200":{"description":"Archived flag (with `ETag`), or `{ key, deleted: true }`.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object"}},"required":["data"]}}},"headers":{"ETag":{"description":"The flag `version` as a strong entity tag (`\"<version>\"`).","schema":{"type":"string"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"412":{"$ref":"#/components/responses/PreconditionFailed"}},"description":"Requires scope `write`.","security":[{"serviceAccountToken":[]}]}},"/v1/admin/segments":{"get":{"tags":["Segments"],"operationId":"listSegments","summary":"List draft segments","parameters":[{"name":"x-valent-tenant","in":"header","required":false,"description":"Optional tenant UUID; it must equal the token tenant (`403` otherwise).","schema":{"type":"string"}},{"name":"x-valent-actor","in":"header","required":false,"description":"End user acting through the service account; audited as `<actor> via sa:<id>` (default `sa:<id>`).","schema":{"type":"string"}},{"name":"x-valent-actor-email","in":"header","required":false,"description":"Actor e-mail, recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, echoed and recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, recorded in the audit log.","schema":{"type":"string"}}],"responses":{"200":{"description":"Draft segments by key.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/SegmentRecord"}}},"required":["data"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"}},"description":"Requires scope `read`.","security":[{"serviceAccountToken":[]}]},"post":{"tags":["Segments"],"operationId":"createSegment","summary":"Create a draft segment","parameters":[{"name":"x-valent-tenant","in":"header","required":false,"description":"Optional tenant UUID; it must equal the token tenant (`403` otherwise).","schema":{"type":"string"}},{"name":"x-valent-actor","in":"header","required":false,"description":"End user acting through the service account; audited as `<actor> via sa:<id>` (default `sa:<id>`).","schema":{"type":"string"}},{"name":"x-valent-actor-email","in":"header","required":false,"description":"Actor e-mail, recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, echoed and recorded in the audit log.","schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"Retry key (24 h, per tenant): the same key and request replay the stored response (`Idempotent-Replayed: true`); the same key with another request is `409 idempotency_key_reused`.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, recorded in the audit log.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Segment"}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/SegmentRecord"}},"required":["data"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"422":{"$ref":"#/components/responses/ValidationFailed"}},"description":"Requires scope `write`.","security":[{"serviceAccountToken":[]}]}},"/v1/admin/segments/{key}":{"get":{"tags":["Segments"],"operationId":"getSegment","summary":"Get a draft segment","parameters":[{"name":"x-valent-tenant","in":"header","required":false,"description":"Optional tenant UUID; it must equal the token tenant (`403` otherwise).","schema":{"type":"string"}},{"name":"x-valent-actor","in":"header","required":false,"description":"End user acting through the service account; audited as `<actor> via sa:<id>` (default `sa:<id>`).","schema":{"type":"string"}},{"name":"x-valent-actor-email","in":"header","required":false,"description":"Actor e-mail, recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, echoed and recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, recorded in the audit log.","schema":{"type":"string"}},{"name":"key","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The segment.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/SegmentRecord"}},"required":["data"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"}},"description":"Requires scope `read`.","security":[{"serviceAccountToken":[]}]},"put":{"tags":["Segments"],"operationId":"updateSegment","summary":"Replace a draft segment","parameters":[{"name":"x-valent-tenant","in":"header","required":false,"description":"Optional tenant UUID; it must equal the token tenant (`403` otherwise).","schema":{"type":"string"}},{"name":"x-valent-actor","in":"header","required":false,"description":"End user acting through the service account; audited as `<actor> via sa:<id>` (default `sa:<id>`).","schema":{"type":"string"}},{"name":"x-valent-actor-email","in":"header","required":false,"description":"Actor e-mail, recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, echoed and recorded in the audit log.","schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"Retry key (24 h, per tenant): the same key and request replay the stored response (`Idempotent-Replayed: true`); the same key with another request is `409 idempotency_key_reused`.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, recorded in the audit log.","schema":{"type":"string"}},{"name":"key","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Segment"},{"type":"object","properties":{"expectedUpdatedAt":{"type":"string","format":"date-time","description":"Optimistic concurrency: the segment `updatedAt` as last read (not stored). When the segment changed since, the write is `409 conflict` with `details: { key, expectedUpdatedAt, currentUpdatedAt }`. Omit it for an unconditional write (last write wins)."}}}]}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/SegmentRecord"}},"required":["data"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/StaleWrite"},"422":{"$ref":"#/components/responses/ValidationFailed"}},"description":"Requires scope `write`.","security":[{"serviceAccountToken":[]}]},"delete":{"tags":["Segments"],"operationId":"deleteSegment","summary":"Delete a segment no flag references","parameters":[{"name":"x-valent-tenant","in":"header","required":false,"description":"Optional tenant UUID; it must equal the token tenant (`403` otherwise).","schema":{"type":"string"}},{"name":"x-valent-actor","in":"header","required":false,"description":"End user acting through the service account; audited as `<actor> via sa:<id>` (default `sa:<id>`).","schema":{"type":"string"}},{"name":"x-valent-actor-email","in":"header","required":false,"description":"Actor e-mail, recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, echoed and recorded in the audit log.","schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"Retry key (24 h, per tenant): the same key and request replay the stored response (`Idempotent-Replayed: true`); the same key with another request is `409 idempotency_key_reused`.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, recorded in the audit log.","schema":{"type":"string"}},{"name":"key","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object"}},"required":["data"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"}},"description":"Requires scope `write`.","security":[{"serviceAccountToken":[]}]}},"/v1/admin/draft/status":{"get":{"tags":["Releases"],"operationId":"getDraftStatus","summary":"Compare the draft with the current release","parameters":[{"name":"x-valent-tenant","in":"header","required":false,"description":"Optional tenant UUID; it must equal the token tenant (`403` otherwise).","schema":{"type":"string"}},{"name":"x-valent-actor","in":"header","required":false,"description":"End user acting through the service account; audited as `<actor> via sa:<id>` (default `sa:<id>`).","schema":{"type":"string"}},{"name":"x-valent-actor-email","in":"header","required":false,"description":"Actor e-mail, recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, echoed and recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, recorded in the audit log.","schema":{"type":"string"}}],"responses":{"200":{"description":"Changes, validation issues and fingerprints.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"releaseVersion":{"type":"integer"},"stateVersion":{"type":"integer"},"fingerprint":{"type":"string","description":"SHA-256 of the draft content."},"releaseFingerprint":{"type":["string","null"]},"changes":{"type":"array","items":{"type":"object","properties":{"entity":{"type":"string","enum":["flag","segment"]},"key":{"type":"string"},"action":{"type":"string","enum":["create","update","delete"]}}}},"issues":{"type":"array","items":{"type":"object"}},"publishable":{"type":"boolean"}}}},"required":["data"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"503":{"$ref":"#/components/responses/Unavailable"}},"description":"Requires scope `read`.","security":[{"serviceAccountToken":[]}]}},"/v1/admin/releases":{"get":{"tags":["Releases"],"operationId":"listReleases","summary":"Release history, newest first","parameters":[{"name":"x-valent-tenant","in":"header","required":false,"description":"Optional tenant UUID; it must equal the token tenant (`403` otherwise).","schema":{"type":"string"}},{"name":"x-valent-actor","in":"header","required":false,"description":"End user acting through the service account; audited as `<actor> via sa:<id>` (default `sa:<id>`).","schema":{"type":"string"}},{"name":"x-valent-actor-email","in":"header","required":false,"description":"Actor e-mail, recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, echoed and recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, recorded in the audit log.","schema":{"type":"string"}},{"name":"cursor","in":"query","required":false,"schema":{"type":"string"},"description":"Opaque `nextCursor`."},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":200,"default":50}}],"responses":{"200":{"description":"Releases.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Release"}},"nextCursor":{"type":["string","null"]}},"required":["data"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"}},"description":"Requires scope `read`.","security":[{"serviceAccountToken":[]}]},"post":{"tags":["Releases"],"operationId":"publishRelease","summary":"Publish the draft as a new immutable release","parameters":[{"name":"x-valent-tenant","in":"header","required":false,"description":"Optional tenant UUID; it must equal the token tenant (`403` otherwise).","schema":{"type":"string"}},{"name":"x-valent-actor","in":"header","required":false,"description":"End user acting through the service account; audited as `<actor> via sa:<id>` (default `sa:<id>`).","schema":{"type":"string"}},{"name":"x-valent-actor-email","in":"header","required":false,"description":"Actor e-mail, recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, echoed and recorded in the audit log.","schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"Retry key (24 h, per tenant): the same key and request replay the stored response (`Idempotent-Replayed: true`); the same key with another request is `409 idempotency_key_reused`.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, recorded in the audit log.","schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"notes":{"type":"string","maxLength":2000}}}}}},"responses":{"200":{"description":"The draft equals the current release; nothing was published (`created: false`).","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object"}},"required":["data"]}}}},"201":{"description":"Published and activated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"release":{"$ref":"#/components/schemas/Release"},"created":{"type":"boolean"},"stateVersion":{"type":"integer"}}}},"required":["data"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"422":{"$ref":"#/components/responses/ValidationFailed"},"503":{"$ref":"#/components/responses/Unavailable"}},"description":"Requires scope `write`.","security":[{"serviceAccountToken":[]}]}},"/v1/admin/releases/{version}":{"get":{"tags":["Releases"],"operationId":"getRelease","summary":"A release and its snapshot","parameters":[{"name":"x-valent-tenant","in":"header","required":false,"description":"Optional tenant UUID; it must equal the token tenant (`403` otherwise).","schema":{"type":"string"}},{"name":"x-valent-actor","in":"header","required":false,"description":"End user acting through the service account; audited as `<actor> via sa:<id>` (default `sa:<id>`).","schema":{"type":"string"}},{"name":"x-valent-actor-email","in":"header","required":false,"description":"Actor e-mail, recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, echoed and recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, recorded in the audit log.","schema":{"type":"string"}},{"name":"version","in":"path","required":true,"schema":{"type":"integer","minimum":1}}],"responses":{"200":{"description":"The release.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"release":{"$ref":"#/components/schemas/Release"},"snapshot":{"$ref":"#/components/schemas/ReleaseSnapshot"}}}},"required":["data"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"}},"description":"Requires scope `read`.","security":[{"serviceAccountToken":[]}]}},"/v1/admin/releases/{version}/rollback":{"post":{"tags":["Releases"],"operationId":"rollbackRelease","summary":"Point the tenant at an existing release","parameters":[{"name":"x-valent-tenant","in":"header","required":false,"description":"Optional tenant UUID; it must equal the token tenant (`403` otherwise).","schema":{"type":"string"}},{"name":"x-valent-actor","in":"header","required":false,"description":"End user acting through the service account; audited as `<actor> via sa:<id>` (default `sa:<id>`).","schema":{"type":"string"}},{"name":"x-valent-actor-email","in":"header","required":false,"description":"Actor e-mail, recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, echoed and recorded in the audit log.","schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"Retry key (24 h, per tenant): the same key and request replay the stored response (`Idempotent-Replayed: true`); the same key with another request is `409 idempotency_key_reused`.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, recorded in the audit log.","schema":{"type":"string"}},{"name":"version","in":"path","required":true,"schema":{"type":"integer","minimum":1}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string","minLength":1,"maxLength":500}}}}}},"responses":{"200":{"description":"The pointer moved (`changed: true`) or already pointed there.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"release":{"$ref":"#/components/schemas/Release"},"previousReleaseVersion":{"type":"integer"},"changed":{"type":"boolean"},"stateVersion":{"type":"integer"}}}},"required":["data"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"503":{"$ref":"#/components/responses/Unavailable"}},"description":"Requires scope `write`.","security":[{"serviceAccountToken":[]}]}},"/v1/admin/kill-switches":{"get":{"tags":["Kill switches"],"operationId":"listKillSwitches","summary":"Current kill set and history","parameters":[{"name":"x-valent-tenant","in":"header","required":false,"description":"Optional tenant UUID; it must equal the token tenant (`403` otherwise).","schema":{"type":"string"}},{"name":"x-valent-actor","in":"header","required":false,"description":"End user acting through the service account; audited as `<actor> via sa:<id>` (default `sa:<id>`).","schema":{"type":"string"}},{"name":"x-valent-actor-email","in":"header","required":false,"description":"Actor e-mail, recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, echoed and recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, recorded in the audit log.","schema":{"type":"string"}},{"name":"cursor","in":"query","required":false,"schema":{"type":"string"},"description":"Opaque `nextCursor`."},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":200,"default":50}}],"responses":{"200":{"description":"Active kill switches and their history (newest first).","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"stateVersion":{"type":"integer"},"killSwitches":{"type":"array","items":{"type":"object"}},"history":{"type":"array","items":{"type":"object"}}}},"nextCursor":{"type":["string","null"]}},"required":["data"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"503":{"$ref":"#/components/responses/Unavailable"}},"description":"Requires scope `read`.","security":[{"serviceAccountToken":[]}]}},"/v1/admin/flags/{key}/kill":{"post":{"tags":["Kill switches"],"operationId":"killFlag","summary":"Kill a flag (takes effect on the next evaluation)","parameters":[{"name":"x-valent-tenant","in":"header","required":false,"description":"Optional tenant UUID; it must equal the token tenant (`403` otherwise).","schema":{"type":"string"}},{"name":"x-valent-actor","in":"header","required":false,"description":"End user acting through the service account; audited as `<actor> via sa:<id>` (default `sa:<id>`).","schema":{"type":"string"}},{"name":"x-valent-actor-email","in":"header","required":false,"description":"Actor e-mail, recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, echoed and recorded in the audit log.","schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"Retry key (24 h, per tenant): the same key and request replay the stored response (`Idempotent-Replayed: true`); the same key with another request is `409 idempotency_key_reused`.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, recorded in the audit log.","schema":{"type":"string"}},{"name":"key","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string","minLength":1,"maxLength":500}},"required":["reason"]}}}},"responses":{"200":{"description":"The kill set changed (`changed: true`) or the flag was already killed.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"stateVersion":{"type":"integer"}}}},"required":["data"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"422":{"$ref":"#/components/responses/ValidationFailed"},"503":{"$ref":"#/components/responses/Unavailable"}},"description":"Requires scope `write`.","security":[{"serviceAccountToken":[]}]}},"/v1/admin/flags/{key}/unkill":{"post":{"tags":["Kill switches"],"operationId":"unkillFlag","summary":"Clear a kill switch","parameters":[{"name":"x-valent-tenant","in":"header","required":false,"description":"Optional tenant UUID; it must equal the token tenant (`403` otherwise).","schema":{"type":"string"}},{"name":"x-valent-actor","in":"header","required":false,"description":"End user acting through the service account; audited as `<actor> via sa:<id>` (default `sa:<id>`).","schema":{"type":"string"}},{"name":"x-valent-actor-email","in":"header","required":false,"description":"Actor e-mail, recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, echoed and recorded in the audit log.","schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"Retry key (24 h, per tenant): the same key and request replay the stored response (`Idempotent-Replayed: true`); the same key with another request is `409 idempotency_key_reused`.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, recorded in the audit log.","schema":{"type":"string"}},{"name":"key","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string","minLength":1,"maxLength":500}}}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"stateVersion":{"type":"integer"}}}},"required":["data"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"503":{"$ref":"#/components/responses/Unavailable"}},"description":"Requires scope `write`.","security":[{"serviceAccountToken":[]}]}},"/v1/admin/evaluate":{"post":{"tags":["Simulator"],"operationId":"simulateEvaluation","summary":"Evaluate a context against the draft or a release","parameters":[{"name":"x-valent-tenant","in":"header","required":false,"description":"Optional tenant UUID; it must equal the token tenant (`403` otherwise).","schema":{"type":"string"}},{"name":"x-valent-actor","in":"header","required":false,"description":"End user acting through the service account; audited as `<actor> via sa:<id>` (default `sa:<id>`).","schema":{"type":"string"}},{"name":"x-valent-actor-email","in":"header","required":false,"description":"Actor e-mail, recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, echoed and recorded in the audit log.","schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"Retry key (24 h, per tenant): the same key and request replay the stored response (`Idempotent-Replayed: true`); the same key with another request is `409 idempotency_key_reused`.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, recorded in the audit log.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"context":{"$ref":"#/components/schemas/EvaluationContext"},"flags":{"type":"array","items":{"type":"string"},"maxItems":500},"source":{"description":"`draft` (default), `current` or a release version.","anyOf":[{"type":"string","enum":["draft","current"]},{"type":"integer","minimum":1}]},"applyKillSwitches":{"type":"boolean","default":true}},"required":["context"]}}}},"responses":{"200":{"description":"Evaluation and gate per flag, with context issues.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"source":{},"releaseVersion":{"type":"integer"},"stateVersion":{"type":"integer"},"killed":{"type":"array","items":{"type":"string"}},"contextIssues":{"type":"array","items":{"type":"object"}},"issues":{"type":"array","items":{"type":"object"}},"results":{"type":"object","additionalProperties":{"type":"object"}}}}},"required":["data"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"503":{"$ref":"#/components/responses/Unavailable"}},"description":"Requires scope `read`.","security":[{"serviceAccountToken":[]}]}},"/v1/admin/audit":{"get":{"tags":["Audit"],"operationId":"listAudit","summary":"Audit log, newest first","parameters":[{"name":"x-valent-tenant","in":"header","required":false,"description":"Optional tenant UUID; it must equal the token tenant (`403` otherwise).","schema":{"type":"string"}},{"name":"x-valent-actor","in":"header","required":false,"description":"End user acting through the service account; audited as `<actor> via sa:<id>` (default `sa:<id>`).","schema":{"type":"string"}},{"name":"x-valent-actor-email","in":"header","required":false,"description":"Actor e-mail, recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, echoed and recorded in the audit log.","schema":{"type":"string"}},{"name":"x-request-id","in":"header","required":false,"description":"Correlation id, recorded in the audit log.","schema":{"type":"string"}},{"name":"cursor","in":"query","required":false,"schema":{"type":"string"},"description":"Opaque `nextCursor`."},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":200,"default":50}}],"responses":{"200":{"description":"Audit entries.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AuditEntry"}},"nextCursor":{"type":["string","null"]}},"required":["data"]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"}},"description":"Requires scope `read`.","security":[{"serviceAccountToken":[]}]}}},"components":{"schemas":{"ErrorEnvelope":{"type":"object","description":"Contract error envelope used by every non-2xx response.","properties":{"error":{"type":"object","properties":{"code":{"type":"string","examples":["not_found"]},"message":{"type":"string"},"issues":{"type":"array","items":{"type":"object","properties":{"path":{"type":"array","items":{"anyOf":[{"type":"string"},{"type":"integer"}]}},"message":{"type":"string"},"code":{"type":"string"}},"required":["path","message"]}},"requestId":{"type":"string"},"details":{"type":"object","additionalProperties":true,"description":"Extra machine-readable context, e.g. `stateApplied` after a partial live-state change."}},"required":["code","message"]}},"required":["error"]},"EvaluationContext":{"type":"object","properties":{"key":{"type":"string","description":"Subject id (opaque; never an e-mail)."},"tenantKey":{"type":"string","description":"Host customer id used by per-customer overrides."},"attributes":{"type":"object","additionalProperties":true}},"required":["key"]},"Evaluation":{"type":"object","properties":{"flagKey":{"type":"string"},"value":{},"variation":{"type":["string","null"]},"reason":{"type":"string","enum":["OFF","KILLED","TENANT_OVERRIDE","RULE_MATCH","FALLTHROUGH","FLAG_NOT_FOUND","ERROR"]},"ruleId":{"type":"string"},"errorCode":{"type":"string","enum":["INVALID_CONTEXT","MISSING_BUCKET_ATTRIBUTE","MALFORMED_FLAG","INVALID_SNAPSHOT"]},"releaseVersion":{"type":"integer"}},"required":["flagKey","value","variation","reason","releaseVersion"]},"Flag":{"type":"object","description":"A flag definition (docs/architecture.md §3.1).","properties":{"key":{"type":"string","pattern":"^[a-z][a-z0-9_.-]{0,127}$"},"name":{"type":"string"},"description":{"type":"string"},"type":{"type":"string","enum":["boolean","string","number","json"]},"variations":{"type":"array","items":{"type":"object"}},"enabled":{"type":"boolean"},"offVariation":{"type":"string"},"tenantOverrides":{"type":"array","items":{"type":"object"}},"rules":{"type":"array","items":{"type":"object"}},"fallthrough":{"type":"object"},"clientSide":{"type":"boolean"},"tags":{"type":"array","items":{"type":"string"}},"archived":{"type":"boolean"}},"required":["key","name","type","variations","offVariation","fallthrough"]},"Segment":{"type":"object","properties":{"key":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"included":{"type":"array","items":{"type":"string"}},"excluded":{"type":"array","items":{"type":"string"}},"rules":{"type":"array","items":{"type":"object"}}},"required":["key","name"]},"ReleaseSnapshot":{"type":"object","description":"An immutable release: every non-archived flag and every segment at publish time.","properties":{"version":{"type":"integer"},"flags":{"type":"array","items":{"$ref":"#/components/schemas/Flag"}},"segments":{"type":"array","items":{"$ref":"#/components/schemas/Segment"}}},"required":["version","flags","segments"]},"FlagRecord":{"type":"object","properties":{"flag":{"$ref":"#/components/schemas/Flag"},"version":{"type":"integer","minimum":1,"description":"Concurrency token: incremented by every write to the flag (update, archive, import); a recreated key never reuses a version. Send it back as `If-Match: \"<version>\"` or `expectedVersion`."},"firstPublishedVersion":{"type":["integer","null"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"SegmentRecord":{"type":"object","properties":{"segment":{"$ref":"#/components/schemas/Segment"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"Release":{"type":"object","properties":{"version":{"type":"integer"},"contentHash":{"type":"string"},"flagCount":{"type":"integer"},"segmentCount":{"type":"integer"},"notes":{"type":["string","null"]},"publishedBy":{"type":"string"},"publishedByEmail":{"type":["string","null"]},"publishedAt":{"type":"string","format":"date-time"},"status":{"type":"string","enum":["pending","live","abandoned"],"description":"Only `live` releases can be rolled back to (docs/architecture.md §4)."},"current":{"type":"boolean"}}},"AuditEntry":{"type":"object","properties":{"id":{"type":"integer"},"actor":{"type":"string"},"actorEmail":{"type":["string","null"]},"action":{"type":"string","examples":["flag.created","release.published","flag.killed"]},"entity":{"type":"string","enum":["flag","segment","release","kill_switch"]},"entityKey":{"type":["string","null"]},"before":{},"after":{},"reason":{"type":["string","null"]},"requestId":{"type":["string","null"]},"createdAt":{"type":"string","format":"date-time"}}}},"responses":{"BadRequest":{"description":"Malformed request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"Unauthorized":{"description":"Missing or invalid credentials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"Forbidden":{"description":"The credentials may not perform this operation.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"NotFound":{"description":"The resource does not exist.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"Conflict":{"description":"The request conflicts with the current state (`conflict`, `tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"PreconditionFailed":{"description":"The `If-Match` / `expectedVersion` token is not the current version (`precondition_failed`, with `details: { key, expectedVersion, currentVersion }`; `currentVersion` is `null` if the entity was deleted).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"StaleWrite":{"description":"The request conflicts with the current state (`conflict`). With `expectedUpdatedAt`, a record that changed since it was read (`details: { key, expectedUpdatedAt, currentUpdatedAt }`; `currentUpdatedAt` is `null` if the entity was deleted): reload it and retry.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"ValidationFailed":{"description":"The body failed validation (`validation_failed`, with `issues`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"Unavailable":{"description":"A dependency (live state or release snapshot) is temporarily unavailable.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"NotImplemented":{"description":"The operation is not supported (`not_implemented`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"InternalError":{"description":"Unexpected server error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}},"securitySchemes":{"apiKey":{"type":"http","scheme":"bearer","description":"`Authorization: Bearer fvpk_…` or `Bearer fvsk_…`."},"serviceAccountToken":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"ValentConsole service account access token for module `features` (≤ 15 minutes, scopes `read`/`write`). The tenant comes from the token."}}}}