{"openapi":"3.1.0","info":{"title":"AccessValent API","version":"0.1.0","description":"Feature/action authorization as a service. Every error uses the envelope `{ error: { code, message, issues?, requestId? } }`. Authentication: server calls send a secret key (`av_sk_…`) as a bearer token (or in `x-api-key`); browsers send a publishable key (`av_pk_…`) in `x-api-key` plus a short-lived subject token (`avst_…`) as a bearer token. ValentConsole reaches `/v1/admin/*` only through its service binding, with its service token and `x-valent-tenant`. `/v1/authorize` is the read-safe AccessValent-only dimension and must be composed with FlagValent, BillValent and product lifecycle decisions. Legacy `/v1/check*` evaluates its configured live adapters; `/v1/me/permissions` serves cached permission maps with an `ETag`. Everything fails closed."},"servers":[{"url":"/"}],"components":{"securitySchemes":{"secretKey":{"type":"http","scheme":"bearer","description":"Secret API key, server-side only: a legacy `av_sk_…` key (also accepted in `x-api-key`) or a scoped tenant admin key `acv_sk_…` (`read` ⊂ `write` ⊂ `admin`, bearer only)."},"serviceAccountToken":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"ValentConsole service account access token (`aud` `access`, verified with `CONSOLE_GRANT_PUBLIC_KEYS`), `/v1/admin/*` only; never grants `admin`."},"publishableKey":{"type":"apiKey","in":"header","name":"x-api-key","description":"Publishable API key (`av_pk_…`), safe for browsers."},"subjectToken":{"type":"http","scheme":"bearer","description":"Short-lived subject token (`avst_…`) minted by `POST /v1/subject-tokens`."}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string","example":"not_found"},"message":{"type":"string"},"issues":{"type":"array","items":{"type":"object","properties":{"path":{"type":"array","items":{"anyOf":[{"type":"string"},{"type":"number"}]}},"message":{"type":"string"},"code":{"type":"string"}},"required":["path","message"]}},"requestId":{"type":"string"}},"required":["code","message"]}},"required":["error"],"description":"Contract v1 error envelope."},"Health":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"version":{"type":"string","example":"0.1.0"}},"required":["ok","version"]},"Decision":{"type":"object","properties":{"allowed":{"type":"boolean"},"code":{"type":"string","enum":["allowed","bypass_role","unknown_feature","feature_inactive","unknown_action","kill_switch","feature_disabled","no_role","no_plan","subscription_inactive","not_in_plan","role_denied"]},"reason":{"type":"string"},"roles":{"type":"array","items":{"type":"string"}},"plan":{"$ref":"#/components/schemas/PlanSummary"},"matchedRule":{"type":"object","properties":{"source":{"type":"string","enum":["override","default","custom_role","bypass"]},"role":{"type":"string"},"plan":{"type":["string","null"]},"action":{"type":["string","null"]},"effect":{"type":"string","enum":["allow","deny"]}},"required":["source","role","effect"]},"trace":{"type":"array","items":{"type":"object","properties":{"step":{"type":"string","enum":["catalog","flag","roles","plan","matrix"]},"outcome":{"type":"string","enum":["pass","fail","skip"]},"detail":{"type":"string"}},"required":["step","outcome","detail"]}}},"required":["allowed","code","reason","roles"]},"PlanSummary":{"type":"object","properties":{"key":{"type":"string"},"state":{"type":"string","enum":["active","trialing","past_due","free","suspended","canceled"]},"upgradeTo":{"type":["string","null"]}},"required":["key","state"]},"AuthValentIdentity":{"type":"object","properties":{"issuer":{"type":"string","minLength":1,"maxLength":512},"sub":{"type":"string","pattern":"^\\S{1,256}$"}},"required":["issuer","sub"],"additionalProperties":false,"description":"AuthValent user (`iss`, `sub` of the access token). The issuer must be the tenant's `authvalentIssuer`."},"CheckBatchResult":{"type":"object","properties":{"results":{"type":"array","items":{"$ref":"#/components/schemas/Decision"}}},"required":["results"]},"FeatureAuthorizationDecision":{"type":"object","properties":{"outcome":{"type":"string","enum":["ALLOWED","DENIED","DENIED_BY_ROLE","UNKNOWN"]},"reasonCode":{"type":"string","enum":["allowed","bypass_role","unknown_feature","unknown_action","context_mismatch","no_role","role_denied"]},"reason":{"type":"string"},"allowed":{"type":"boolean"},"context":{"$ref":"#/components/schemas/FeatureAuthorizationContext"},"feature":{"$ref":"#/components/schemas/FeatureIdentity"},"actionKey":{"type":"string","pattern":"^[A-Z][A-Z0-9_]{0,63}$","example":"READ"},"roles":{"type":"array","items":{"type":"string"}},"policy":{"type":"object","properties":{"schemaVersion":{"type":"number","enum":[1]},"version":{"type":"string"},"matchedRule":{"type":"object","properties":{"source":{"type":"string","enum":["override","default","custom_role","bypass"]},"role":{"type":"string"},"plan":{"type":["string","null"]},"action":{"type":["string","null"]},"effect":{"type":"string","enum":["allow","deny"]}},"required":["source","role","effect"]}},"required":["schemaVersion","version"]},"entitlementReference":{"type":"string"}},"required":["outcome","reasonCode","reason","allowed","context","feature","actionKey","roles","policy"],"description":"AccessValent authorization only. A product must separately allow runtime rollout, entitlement and lifecycle gates before operating."},"FeatureAuthorizationContext":{"type":"object","properties":{"subjectId":{"type":"string","pattern":"^\\S{1,256}$","example":"user_123"},"projectId":{"type":"string","pattern":"^[A-Za-z0-9][A-Za-z0-9_.@-]{0,127}$","description":"Stable product identifier."},"organizationId":{"type":"string","pattern":"^[A-Za-z0-9][A-Za-z0-9_.@-]{0,127}$","description":"Stable product identifier."}},"required":["subjectId","projectId"],"additionalProperties":false},"FeatureIdentity":{"type":"object","properties":{"namespace":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,31}$","example":"nestx"},"key":{"type":"string","pattern":"^[A-Z][A-Z0-9_]{0,63}$","example":"RESERVATIONS"}},"required":["namespace","key"],"additionalProperties":false},"FeatureAuthorizationRequest":{"type":"object","properties":{"context":{"$ref":"#/components/schemas/FeatureAuthorizationContext"},"feature":{"$ref":"#/components/schemas/FeatureIdentity"},"actionKey":{"type":"string","pattern":"^[A-Z][A-Z0-9_]{0,63}$","example":"READ"},"verifiedClaims":{"$ref":"#/components/schemas/VerifiedAuthorizationClaims"},"entitlement":{"$ref":"#/components/schemas/EntitlementEvidence"}},"required":["context","feature","actionKey","verifiedClaims"],"additionalProperties":false},"VerifiedAuthorizationClaims":{"type":"object","properties":{"roles":{"type":"array","items":{"type":"string","pattern":"^[A-Z][A-Z0-9_]{0,63}$","example":"OWNER"},"maxItems":20,"description":"Roles asserted by the trusted caller (secret key only)."},"reference":{"type":"string","maxLength":512,"description":"Opaque verification reference or claims digest; not an authorization input."}},"required":["roles"],"additionalProperties":false,"description":"Claims verified by the secret-key caller. Only role keys participate in AccessValent policy."},"EntitlementEvidence":{"type":"object","properties":{"reference":{"type":"string","minLength":1,"maxLength":512}},"required":["reference"],"additionalProperties":false,"description":"BillValent evidence reference only. AccessValent correlates but never verifies or grants the entitlement."},"PermissionMap":{"type":"object","properties":{"subject":{"type":"string"},"scope":{"type":"string"},"roles":{"type":"array","items":{"type":"string"}},"plan":{"$ref":"#/components/schemas/PlanSummary"},"version":{"type":"string","example":"p17.s4.efake-9.ffake-2"},"permissions":{"type":"object","additionalProperties":{"type":"object","additionalProperties":{"type":"object","properties":{"allowed":{"type":"boolean"},"code":{"type":"string","enum":["allowed","bypass_role","unknown_feature","feature_inactive","unknown_action","kill_switch","feature_disabled","no_role","no_plan","subscription_inactive","not_in_plan","role_denied"]}},"required":["allowed"]}}},"navOrder":{"type":"object","additionalProperties":{"type":"number"}}},"required":["subject","scope","roles","permissions","navOrder"]},"SubjectToken":{"type":"object","properties":{"token":{"type":"string"},"subject":{"type":"string"},"expiresAt":{"type":"string"}},"required":["token","subject","expiresAt"]},"Registry":{"type":"object","properties":{"namespaces":{"type":"array","items":{"type":"object","properties":{"namespace":{"type":"string"},"version":{"type":"string"},"groups":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"label":{"type":"string"},"order":{"type":"number"}},"required":["key","label"]}},"actions":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"label":{"type":"string"},"description":{"type":"string"}},"required":["key","label"]}}},"required":["namespace","groups","actions"]}},"roles":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"label":{"type":"string"},"description":{"type":"string"},"kind":{"type":"string"}},"required":["key","label","kind"]}},"features":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"namespace":{"type":"string"},"key":{"type":"string"},"label":{"type":"string"},"description":{"type":"string"},"group":{"type":"string"},"active":{"type":"boolean"},"actions":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"label":{"type":"string"},"description":{"type":"string"}},"required":["key","label"]}}},"required":["id","namespace","key","label","active","actions"]}}},"required":["namespaces","roles","features"]},"AccessRequestList":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/AccessRequest"}},"nextCursor":{"type":["string","null"]}},"required":["items","nextCursor"]},"AccessRequest":{"type":"object","properties":{"id":{"type":"string"},"subject":{"type":"string"},"subjectEmail":{"type":["string","null"]},"subjectName":{"type":["string","null"]},"scope":{"type":"string"},"want":{"$ref":"#/components/schemas/AccessRequestWant"},"message":{"type":["string","null"]},"status":{"type":"string","enum":["pending","approved","denied","canceled","expired"]},"handledBy":{"type":["string","null"]},"responseMessage":{"type":["string","null"]},"grant":{"$ref":"#/components/schemas/RoleGrant"},"createdAt":{"type":"string"},"handledAt":{"type":["string","null"]},"expiresAt":{"type":["string","null"]}},"required":["id","subject","scope","want","message","status","handledBy","responseMessage","grant","createdAt","handledAt","expiresAt"]},"AccessRequestWant":{"anyOf":[{"type":"object","properties":{"roleKey":{"type":"string","pattern":"^[A-Z][A-Z0-9_]{0,63}$","example":"OWNER"}},"required":["roleKey"],"additionalProperties":false},{"type":"object","properties":{"customRoleId":{"type":"string","minLength":1,"maxLength":64}},"required":["customRoleId"],"additionalProperties":false},{"type":"object","properties":{"feature":{"type":"string","minLength":1,"maxLength":128,"example":"nestx.COMMON_AREAS","description":"Qualified feature id, or a bare key with `namespace`."},"action":{"type":"string","pattern":"^[A-Z][A-Z0-9_]{0,63}$","example":"READ"}},"required":["feature","action"],"additionalProperties":false}]},"RoleGrant":{"anyOf":[{"type":"object","properties":{"roleKey":{"type":"string","pattern":"^[A-Z][A-Z0-9_]{0,63}$","example":"OWNER"}},"required":["roleKey"],"additionalProperties":false},{"type":"object","properties":{"customRoleId":{"type":"string","minLength":1,"maxLength":64}},"required":["customRoleId"],"additionalProperties":false},{"type":"null"}]},"StoredCatalog":{"type":"object","properties":{"namespace":{"type":"string"},"hash":{"type":"string"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"catalog":{"type":"object","additionalProperties":{},"description":"module-contract `PermissionsCatalog`."}},"required":["namespace","hash","createdAt","updatedAt","catalog"]},"CatalogWriteResult":{"type":"object","properties":{"catalog":{"$ref":"#/components/schemas/StoredCatalog"},"changed":{"type":"boolean"},"orphans":{"type":"array","items":{"$ref":"#/components/schemas/Orphan"}}},"required":["catalog","changed","orphans"]},"Orphan":{"type":"object","properties":{"kind":{"type":"string","enum":["override","custom_role_grant","custom_role_base","custom_role_scope"]},"ref":{"type":"string"},"message":{"type":"string"}},"required":["kind","ref","message"]},"RoleTemplate":{"type":"object","properties":{"key":{"type":"string"},"label":{"type":"string"},"description":{"type":"string"},"namespace":{"type":"string"},"catalog":{"type":"object","additionalProperties":{},"description":"module-contract `PermissionsCatalog`."}},"required":["key","label","description","namespace","catalog"]},"MatrixOverride":{"type":"object","properties":{"id":{"type":"string"},"planKey":{"type":["string","null"]},"roleKey":{"type":"string"},"featureId":{"type":"string"},"action":{"type":["string","null"]},"effect":{"type":"string","enum":["allow","deny"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","planKey","roleKey","featureId","action","effect","createdAt","updatedAt"]},"EffectiveMatrix":{"type":"object","properties":{"plan":{"type":["string","null"]},"roles":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"label":{"type":"string"},"kind":{"type":"string"},"bypass":{"type":"boolean"}},"required":["key","label","kind","bypass"]}},"features":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"label":{"type":"string"},"active":{"type":"boolean"},"actions":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"label":{"type":"string"},"cells":{"type":"object","additionalProperties":{"type":"object","properties":{"effect":{"type":"string","enum":["allow","deny"]},"source":{"type":"string","enum":["override","default","bypass"]},"plan":{"type":["string","null"]},"action":{"type":["string","null"]}},"required":["effect","source"]}}},"required":["key","label","cells"]}}},"required":["id","label","active","actions"]}},"orphans":{"type":"array","items":{"$ref":"#/components/schemas/Orphan"}}},"required":["plan","roles","features","orphans"]},"TenantSettings":{"type":"object","properties":{"onMissingPlan":{"type":"string","enum":["deny","allow"]},"billvalentTenantId":{"type":["string","null"]},"flagvalentTenantId":{"type":["string","null"]},"accessRequestTtlDays":{"type":"integer"},"authvalentIssuer":{"type":["string","null"]}},"required":["onMissingPlan","billvalentTenantId","flagvalentTenantId","accessRequestTtlDays","authvalentIssuer"]},"CustomRole":{"type":"object","properties":{"id":{"type":"string"},"key":{"type":"string"},"name":{"type":"string"},"kind":{"type":"string","enum":["template","custom"]},"ownerScope":{"type":"string"},"baseRole":{"type":["string","null"]},"grants":{"type":"array","items":{"type":"string"}},"denies":{"type":"array","items":{"type":"string"}},"sourceTemplateId":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","key","name","kind","ownerScope","grants","denies","sourceTemplateId","createdAt","updatedAt"]},"SimulationResult":{"type":"object","properties":{"decision":{"$ref":"#/components/schemas/Decision"},"account":{"type":"string"},"scope":{"type":"string"},"roles":{"type":"array","items":{"type":"string"}}},"required":["decision","account","scope","roles"]},"ReconcileStoreAdminResult":{"type":"object","properties":{"identity":{"$ref":"#/components/schemas/AuthValentIdentity"},"scope":{"type":"string"},"role":{"type":["string","null"],"enum":["STORE_OWNER","STORE_EDITOR","STORE_SUPPORT",null]},"active":{"type":"boolean"},"assignment":{"$ref":"#/components/schemas/Assignment"},"changed":{"type":"boolean"}},"required":["identity","scope","role","active","assignment","changed"]},"Assignment":{"type":["object","null"],"properties":{"id":{"type":"string"},"subject":{"type":"string"},"roleKey":{"type":["string","null"]},"customRoleId":{"type":["string","null"]},"scope":{"type":"string"},"expiresAt":{"type":["string","null"]},"active":{"type":"boolean"},"assignedBy":{"type":"string"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","subject","roleKey","customRoleId","scope","expiresAt","active","assignedBy","createdAt","updatedAt"]},"ReconcileStoreAdminRequest":{"type":"object","properties":{"identity":{"$ref":"#/components/schemas/AuthValentIdentity"},"authorization":{"type":"object","properties":{"projectId":{"type":"string","minLength":1,"maxLength":256},"environmentId":{"type":"string","minLength":1,"maxLength":256}},"required":["projectId","environmentId"],"additionalProperties":false},"scope":{"type":"string","maxLength":1100,"example":"org:42/property:9","description":"Scope path (`*` or empty = tenant-wide)."},"role":{"type":["string","null"],"enum":["STORE_OWNER","STORE_EDITOR","STORE_SUPPORT",null]},"active":{"type":"boolean","description":"Defaults to true. `false` retains the grant rows but denies access until re-enabled."}},"required":["identity","authorization","scope","role"],"additionalProperties":false,"description":"Reconciles the exclusive Store staff role set for a canonical AuthValent identity. Console must call this only after independently verifying the project/environment membership authorization; email or membership never grants access by themselves."},"StoreAdminSeatPage":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/StoreAdminSeat"}},"seatCount":{"type":"integer","description":"Distinct principal identities with at least one active, unexpired Store role in this exact scope."},"nextCursor":{"type":["string","null"]}},"required":["items","seatCount","nextCursor"]},"StoreAdminSeat":{"type":"object","properties":{"identity":{"$ref":"#/components/schemas/AuthValentIdentity"},"scope":{"type":"string"},"roles":{"type":"array","items":{"type":"string","enum":["STORE_OWNER","STORE_EDITOR","STORE_SUPPORT"]}},"updatedAt":{"type":"string"}},"required":["identity","scope","roles","updatedAt"]},"AssignmentList":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Assignment"}},"nextCursor":{"type":["string","null"]}},"required":["items","nextCursor"]},"AccessRequestApproval":{"type":"object","properties":{"request":{"$ref":"#/components/schemas/AccessRequest"},"assignment":{"$ref":"#/components/schemas/Assignment"}},"required":["request","assignment"]},"AuditPage":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/AuditEvent"}},"nextCursor":{"type":["string","null"]}},"required":["items","nextCursor"]},"AuditEvent":{"type":"object","properties":{"id":{"type":"string"},"tenantId":{"type":"string"},"source":{"type":"string","enum":["access","app"],"description":"`access`: AccessValent config change. `app`: event written by the host (`POST /v1/admin/audit`)."},"actor":{"type":"string"},"actorEmail":{"type":["string","null"]},"requestId":{"type":["string","null"]},"action":{"type":"string","description":"A built-in action (`assignment.created`, …) for `access` events; a host-defined one for `app` events."},"entity":{"type":"string"},"entityId":{"type":"string"},"outcome":{"type":["string","null"],"enum":["success","failure","pending",null]},"before":{},"after":{},"recordedBy":{"type":["string","null"],"description":"Credential that wrote an `app` event, or that acted on behalf of a `user:<id>` actor (`x-valent-actor`)."},"subject":{"type":["string","null"],"description":"Subject the event is about (`assignment`, `access_request` and `subject` events; `null` otherwise). Filter with `?subject=`."},"createdAt":{"type":"string"}},"required":["id","tenantId","source","actor","actorEmail","requestId","action","entity","entityId","outcome","recordedBy","subject","createdAt"]},"AuditWriteRequest":{"type":"object","properties":{"action":{"type":"string","maxLength":130,"example":"product.update"},"entity":{"type":"string","maxLength":64,"example":"product","description":"Defaults to `app`."},"entityId":{"type":"string","maxLength":256},"actor":{"type":"string","maxLength":300,"example":"subject:6f1c2a8e-8a35-4c55-9a1e-2f0f0b1e8c3d"},"actorEmail":{"type":"string","maxLength":320,"format":"email"},"outcome":{"type":"string","enum":["success","failure","pending"]},"before":{},"after":{}},"required":["action"],"additionalProperties":false},"SubjectErasure":{"type":"object","properties":{"subject":{"type":"string"},"assignments":{"type":"number"},"accessRequests":{"type":"number"}},"required":["subject","assignments","accessRequests"]},"ReplaceSubjectRolesResult":{"type":"object","properties":{"subject":{"type":"string"},"scope":{"type":"string"},"assigned":{"allOf":[{"$ref":"#/components/schemas/Assignment"},{"description":"The `role` assignment after the call."}]},"removed":{"type":"array","items":{"$ref":"#/components/schemas/Assignment"},"description":"Deleted assignments (as they were)."},"deactivated":{"type":"array","items":{"$ref":"#/components/schemas/Assignment"},"description":"Assignments deactivated by this call."},"changed":{"type":"boolean","description":"`false` when the subject already had this state (nothing written)."}},"required":["subject","scope","assigned","removed","deactivated","changed"]},"ReplaceSubjectRolesRequest":{"type":"object","properties":{"roleSet":{"type":"array","items":{"type":"string","minLength":1,"maxLength":71,"example":"STORE_ADMIN","description":"A catalog role key (`STORE_ADMIN`) or a custom role id (bare or as `custom:<id>`)."},"minItems":1,"maxItems":50,"description":"Roles managed as one exclusive set: the subject's other assignments of these roles in `scope` are removed (or deactivated). Assignments of roles outside the set are never touched."},"role":{"type":["string","null"],"minLength":1,"maxLength":71,"example":"STORE_ADMIN","description":"The role the subject keeps (must be in `roleSet`); `null` removes every role of the set."},"active":{"type":"boolean","description":"`true` (default): `role` is assigned active and the other roles of the set are deleted. `false`: nothing is deleted; `role` (created if missing) and every other assignment of the set are deactivated (disable a user; enable again with `active: true`)."},"scope":{"type":"string","maxLength":1100,"example":"org:42/property:9","description":"Scope path (`*` or empty = tenant-wide)."},"identity":{"allOf":[{"$ref":"#/components/schemas/AuthValentIdentity"},{"description":"AuthValent identity; when sent it must belong to the tenant issuer and map to `{subject}`."}]}},"required":["roleSet","role"],"additionalProperties":false},"ApiKey":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string","enum":["publishable","secret"]},"name":{"type":"string"},"prefix":{"type":"string","example":"av_sk_Ab12Cd34"},"createdAt":{"type":"string"},"lastUsedAt":{"type":["string","null"]},"revokedAt":{"type":["string","null"]},"scopes":{"type":["array","null"],"items":{"type":"string","enum":["read","write","admin"]},"description":"Tenant admin scopes of an `acv_sk_` key; `null` for legacy `av_*` keys."},"expiresAt":{"type":["string","null"],"description":"Set on a key created with an expiry or rotated out."}},"required":["id","kind","name","prefix","createdAt","lastUsedAt","revokedAt","scopes","expiresAt"]},"CreatedApiKey":{"type":"object","properties":{"key":{"$ref":"#/components/schemas/ApiKey"},"plaintext":{"type":"string"}},"required":["key","plaintext"]},"TenantAdminWhoAmI":{"type":"object","properties":{"tenantId":{"type":"string"},"credential":{"$ref":"#/components/schemas/TenantAdminCredential"},"scopes":{"type":"array","items":{"type":"string","enum":["read","write","admin"]}}},"required":["tenantId","credential","scopes"]},"TenantAdminCredential":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["secret_key"]},"keyId":{"type":"string"}},"required":["type","keyId"]},{"type":"object","properties":{"type":{"type":"string","enum":["service_account"]},"serviceAccountId":{"type":"string"},"credentialId":{"type":"string"},"projectId":{"type":"string"},"tokenId":{"type":"string"}},"required":["type","serviceAccountId","credentialId","projectId","tokenId"]},{"type":"object","properties":{"type":{"type":"string","enum":["console"]}},"required":["type"]}]},"CreatedScopedApiKey":{"allOf":[{"$ref":"#/components/schemas/ApiKey"},{"type":"object","properties":{"secret":{"type":"string","description":"The `acv_sk_…` token, returned once."}},"required":["secret"]}]},"RotatedApiKey":{"type":"object","properties":{"key":{"$ref":"#/components/schemas/CreatedScopedApiKey"},"previous":{"$ref":"#/components/schemas/ApiKey"}},"required":["key","previous"]},"FakePlan":{"type":"object","properties":{"account":{"type":"string"},"planKey":{"type":"string"},"state":{"type":"string","enum":["active","trialing","past_due","free","suspended","canceled"]},"features":{"type":"array","items":{"type":"string"}},"upgradeTo":{"type":["string","null"]},"updatedAt":{"type":"string"}},"required":["account","planKey","state","features","upgradeTo","updatedAt"]},"FakeFlag":{"type":"object","properties":{"flag":{"type":"string"},"enabled":{"type":"boolean"},"killed":{"type":"boolean"},"updatedAt":{"type":"string"}},"required":["flag","enabled","killed","updatedAt"]}},"parameters":{}},"paths":{"/health":{"get":{"tags":["Health"],"summary":"Worker health check","description":"The Worker is responding. Not a D1 or KV readiness probe.","operationId":"getHealth","responses":{"200":{"description":"Worker is responding.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Health"}}}}}}},"/v1/check":{"post":{"tags":["Checks"],"summary":"Check one feature/action","description":"Evaluates live (never from the permission-map cache). `roles` and `account` are trusted inputs of the secret-key caller.","operationId":"check","security":[{"secretKey":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"subject":{"type":"string","pattern":"^\\S{1,256}$","example":"user_123","description":"Required unless `identity` is given."},"identity":{"$ref":"#/components/schemas/AuthValentIdentity"},"scope":{"type":"string","maxLength":1100,"example":"org:42/property:9","description":"Scope path (`*` or empty = tenant-wide)."},"account":{"type":"string","minLength":1,"maxLength":256,"example":"org:42","description":"Billing account; defaults to the first scope segment, then the subject."},"roles":{"type":"array","items":{"type":"string","pattern":"^[A-Z][A-Z0-9_]{0,63}$","example":"OWNER"},"maxItems":20,"description":"Roles asserted by the trusted caller (secret key only)."},"namespace":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,31}$","example":"nestx","description":"Namespace for bare feature keys."},"feature":{"type":"string","minLength":1,"maxLength":128,"example":"nestx.COMMON_AREAS","description":"Qualified feature id, or a bare key with `namespace`."},"action":{"type":"string","pattern":"^[A-Z][A-Z0-9_]{0,63}$","example":"READ"},"explain":{"type":"boolean","description":"Include the evaluation trace."}},"required":["feature","action"]}}}},"responses":{"200":{"description":"The decision (allowed or not).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Decision"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/check/batch":{"post":{"tags":["Checks"],"summary":"Check up to 100 feature/actions for one subject and scope","operationId":"checkBatch","security":[{"secretKey":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"subject":{"type":"string","pattern":"^\\S{1,256}$","example":"user_123","description":"Required unless `identity` is given."},"identity":{"$ref":"#/components/schemas/AuthValentIdentity"},"scope":{"type":"string","maxLength":1100,"example":"org:42/property:9","description":"Scope path (`*` or empty = tenant-wide)."},"account":{"type":"string","minLength":1,"maxLength":256,"example":"org:42","description":"Billing account; defaults to the first scope segment, then the subject."},"roles":{"type":"array","items":{"type":"string","pattern":"^[A-Z][A-Z0-9_]{0,63}$","example":"OWNER"},"maxItems":20,"description":"Roles asserted by the trusted caller (secret key only)."},"namespace":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,31}$","example":"nestx","description":"Namespace for bare feature keys."},"checks":{"type":"array","items":{"type":"object","properties":{"feature":{"type":"string","minLength":1,"maxLength":128,"example":"nestx.COMMON_AREAS","description":"Qualified feature id, or a bare key with `namespace`."},"action":{"type":"string","pattern":"^[A-Z][A-Z0-9_]{0,63}$","example":"READ"}},"required":["feature","action"]},"minItems":1,"maxItems":100},"explain":{"type":"boolean"}},"required":["checks"]}}}},"responses":{"200":{"description":"Decisions, in order.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckBatchResult"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/authorize":{"post":{"tags":["Checks"],"summary":"Authorize one feature/action dimension","description":"Evaluates only AccessValent role policy using stable product context. This read-safe decision never resolves FlagValent rollout, BillValent entitlement or product lifecycle state. The product must compose all dimensions and deny unless every required dimension allows.","operationId":"authorizeFeatureAction","security":[{"secretKey":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FeatureAuthorizationRequest"}}}},"responses":{"200":{"description":"The AccessValent authorization dimension.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FeatureAuthorizationDecision"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/permissions":{"get":{"tags":["Permission maps"],"summary":"Permission map of a subject in a scope","operationId":"getPermissions","security":[{"secretKey":[]}],"parameters":[{"schema":{"type":"string","maxLength":1100,"example":"org:42/property:9","description":"Scope path (`*` or empty = tenant-wide)."},"required":false,"description":"Scope path (`*` or empty = tenant-wide).","name":"scope","in":"query"},{"schema":{"type":"string","maxLength":400,"description":"Comma-separated namespaces to include."},"required":false,"description":"Comma-separated namespaces to include.","name":"namespaces","in":"query"},{"schema":{"type":"string","pattern":"^\\S{1,256}$","example":"user_123","description":"Required unless `identity` is given."},"required":false,"description":"Required unless `identity` is given.","name":"subject","in":"query"},{"schema":{"type":"string","maxLength":1024,"description":"JSON-encoded AuthValent identity (`{\"issuer\":\"…\",\"sub\":\"…\"}`); verified by the tenant `authvalentIssuer`."},"required":false,"description":"JSON-encoded AuthValent identity (`{\"issuer\":\"…\",\"sub\":\"…\"}`); verified by the tenant `authvalentIssuer`.","name":"identity","in":"query"},{"schema":{"type":"string","minLength":1,"maxLength":256,"example":"org:42","description":"Billing account; defaults to the first scope segment, then the subject."},"required":false,"description":"Billing account; defaults to the first scope segment, then the subject.","name":"account","in":"query"},{"schema":{"type":"string","maxLength":400,"description":"Comma-separated asserted role keys."},"required":false,"description":"Comma-separated asserted role keys.","name":"roles","in":"query"}],"responses":{"200":{"description":"Permission map. Carries `ETag` and `Cache-Control: private, max-age=30, stale-while-revalidate=60`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermissionMap"}}}},"304":{"description":"Not modified (`If-None-Match` matched the current version)."},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/subject-tokens":{"post":{"tags":["Subject tokens"],"summary":"Mint a short-lived subject token for a browser","description":"HMAC-signed, bound to the tenant and subject and optionally to scope prefixes; at most 15 minutes. Browsers send it as `Authorization: Bearer <token>` with the publishable key in `x-api-key`.","operationId":"createSubjectToken","security":[{"secretKey":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"subject":{"type":"string","pattern":"^\\S{1,256}$","example":"user_123","description":"Required unless `identity` is given."},"identity":{"$ref":"#/components/schemas/AuthValentIdentity"},"scopes":{"type":"array","items":{"type":"string","maxLength":1100,"example":"org:42/property:9","description":"Scope path (`*` or empty = tenant-wide)."},"minItems":1,"maxItems":20,"description":"Scope prefixes the token may be used in (omitted = any scope)."},"ttlSeconds":{"type":"integer","minimum":30,"maximum":900},"email":{"type":"string","maxLength":320,"format":"email","description":"Copied onto access requests only."},"name":{"type":"string","minLength":1,"maxLength":200},"roles":{"type":"array","items":{"type":"string","pattern":"^[A-Z][A-Z0-9_]{0,63}$","example":"OWNER"},"maxItems":20,"description":"Roles asserted by the host; `/v1/me/permissions` evaluates with them."},"account":{"type":"string","minLength":1,"maxLength":256,"example":"org:42","description":"Billing account asserted by the host; `/v1/me/permissions` evaluates with it."}}}}}},"responses":{"201":{"description":"The token (shown once).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubjectToken"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/me/permissions":{"get":{"tags":["Permission maps"],"summary":"Permission map of the subject token's subject","operationId":"getMyPermissions","security":[{"publishableKey":[],"subjectToken":[]}],"parameters":[{"schema":{"type":"string","maxLength":1100,"example":"org:42/property:9","description":"Scope path (`*` or empty = tenant-wide)."},"required":false,"description":"Scope path (`*` or empty = tenant-wide).","name":"scope","in":"query"},{"schema":{"type":"string","maxLength":400,"description":"Comma-separated namespaces to include."},"required":false,"description":"Comma-separated namespaces to include.","name":"namespaces","in":"query"}],"responses":{"200":{"description":"Permission map. Carries `ETag` and `Cache-Control: private, max-age=30, stale-while-revalidate=60`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermissionMap"}}}},"304":{"description":"Not modified (`If-None-Match` matched the current version)."},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/registry":{"get":{"tags":["Registry"],"summary":"Merged catalog metadata (labels, groups, actions, roles)","description":"UI metadata only: default roles, entitlements and flags are not exposed.","operationId":"getRegistry","security":[{"publishableKey":[]},{"secretKey":[]}],"parameters":[{"schema":{"type":"string","maxLength":400,"description":"Comma-separated namespaces to include."},"required":false,"description":"Comma-separated namespaces to include.","name":"namespaces","in":"query"}],"responses":{"200":{"description":"Registry. Carries `ETag`; `If-None-Match` → 304.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Registry"}}}},"304":{"description":"Not modified."},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/me/access-requests":{"get":{"tags":["Access requests"],"summary":"List my access requests (newest first)","operationId":"listMyAccessRequests","security":[{"publishableKey":[],"subjectToken":[]}],"parameters":[{"schema":{"type":"string","enum":["pending","approved","denied","canceled","expired"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":200},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","maxLength":512,"description":"Opaque cursor from `nextCursor`."},"required":false,"description":"Opaque cursor from `nextCursor`.","name":"cursor","in":"query"}],"responses":{"200":{"description":"A page of requests.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccessRequestList"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Access requests"],"summary":"Request access (a role, or a feature/action)","description":"Deduplicated: an identical pending request is returned with `200` instead of a new `201`.","operationId":"createMyAccessRequest","security":[{"publishableKey":[],"subjectToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"scope":{"type":"string","maxLength":1100,"example":"org:42/property:9","description":"Scope path (`*` or empty = tenant-wide)."},"want":{"$ref":"#/components/schemas/AccessRequestWant"},"message":{"type":"string","maxLength":1000},"namespace":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,31}$","example":"nestx"}},"required":["want"]}}}},"responses":{"200":{"description":"An identical pending request already exists.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccessRequest"}}}},"201":{"description":"Created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccessRequest"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/me/access-requests/{id}/cancel":{"post":{"tags":["Access requests"],"summary":"Cancel one of my pending requests","operationId":"cancelMyAccessRequest","security":[{"publishableKey":[],"subjectToken":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Canceled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccessRequest"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflicting state (`conflict`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/catalogs":{"get":{"tags":["Admin: policy"],"summary":"List registered catalogs","operationId":"adminListCatalogs","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"responses":{"200":{"description":"Catalogs by namespace.","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/StoredCatalog"}}},"required":["items"]}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/catalogs/{namespace}":{"get":{"tags":["Admin: policy"],"summary":"Get one catalog","operationId":"adminGetCatalog","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,31}$","example":"nestx"},"required":true,"name":"namespace","in":"path"}],"responses":{"200":{"description":"The catalog.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StoredCatalog"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["Admin: policy"],"summary":"Register or replace a catalog","description":"Validated with the module-contract parser plus tenant-wide rules (role kinds agree across catalogs, flag key length). An identical catalog is a no-op (`changed: false`). Deviations that no longer match become `orphans` (kept, ignored by resolution).","operationId":"adminPutCatalog","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,31}$","example":"nestx"},"required":true,"name":"namespace","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":{},"description":"module-contract `PermissionsCatalog`."}}}},"responses":{"200":{"description":"Stored.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CatalogWriteResult"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Admin: policy"],"summary":"Remove a catalog","operationId":"adminDeleteCatalog","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,31}$","example":"nestx"},"required":true,"name":"namespace","in":"path"}],"responses":{"200":{"description":"Removed.","content":{"application/json":{"schema":{"type":"object","properties":{"deleted":{"type":"boolean","enum":[true]},"orphans":{"type":"array","items":{"$ref":"#/components/schemas/Orphan"}}},"required":["deleted","orphans"]}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/role-templates":{"get":{"tags":["Admin: policy"],"summary":"List role templates","description":"Ready-made catalogs (for example `store`: `STORE_OWNER` > `STORE_EDITOR` > `STORE_SUPPORT` with permissions on products, orders, payments, content, settings and staff).","operationId":"adminListRoleTemplates","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"responses":{"200":{"description":"Templates.","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/RoleTemplate"}}},"required":["items"]}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/role-templates/{key}/apply":{"post":{"tags":["Admin: policy"],"summary":"Apply a role template","description":"Registers the template catalog under its namespace like `PUT /v1/admin/catalogs/{namespace}`. Re-applying an unchanged template is a no-op (`changed: false`); matrix overrides are kept.","operationId":"adminApplyRoleTemplate","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","enum":["store"],"example":"store"},"required":true,"name":"key","in":"path"}],"responses":{"200":{"description":"Applied.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/CatalogWriteResult"},{"type":"object","properties":{"template":{"type":"string"}},"required":["template"]}]}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/overrides":{"get":{"tags":["Admin: policy"],"summary":"List matrix overrides","operationId":"adminListOverrides","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":128,"example":"nestx.COMMON_AREAS","description":"Qualified feature id, or a bare key with `namespace`."},"required":false,"description":"Qualified feature id, or a bare key with `namespace`.","name":"featureId","in":"query"},{"schema":{"type":"string","pattern":"^[A-Z][A-Z0-9_]{0,63}$","example":"OWNER"},"required":false,"name":"roleKey","in":"query"},{"schema":{"type":"string","maxLength":128,"description":"`*` = overrides for every plan."},"required":false,"description":"`*` = overrides for every plan.","name":"planKey","in":"query"}],"responses":{"200":{"description":"Overrides.","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/MatrixOverride"}}},"required":["items"]}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["Admin: policy"],"summary":"Create or update an override (identity: plan, role, feature, action)","operationId":"adminPutOverride","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"planKey":{"type":["string","null"],"minLength":1,"maxLength":128,"description":"`null` = every plan."},"roleKey":{"type":"string","pattern":"^[A-Z][A-Z0-9_]{0,63}$","example":"OWNER"},"featureId":{"type":"string","minLength":1,"maxLength":128,"example":"nestx.COMMON_AREAS","description":"Qualified feature id, or a bare key with `namespace`."},"action":{"type":["string","null"],"pattern":"^[A-Z][A-Z0-9_]{0,63}$","example":"READ","description":"`null` = every action."},"effect":{"type":"string","enum":["allow","deny"]}},"required":["roleKey","featureId","effect"]}}}},"responses":{"200":{"description":"Stored.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MatrixOverride"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/overrides/{id}":{"delete":{"tags":["Admin: policy"],"summary":"Delete an override (back to the catalog default)","operationId":"adminDeleteOverride","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted."},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/matrix":{"get":{"tags":["Admin: policy"],"summary":"Effective role matrix for a plan","description":"Role × feature × action with the rule that decides each cell (override precedence, then defaults).","operationId":"adminGetMatrix","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":128,"description":"Plan key (omitted = overrides for every plan)."},"required":false,"description":"Plan key (omitted = overrides for every plan).","name":"plan","in":"query"},{"schema":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,31}$","example":"nestx"},"required":false,"name":"namespace","in":"query"}],"responses":{"200":{"description":"The matrix.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EffectiveMatrix"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/settings":{"get":{"tags":["Admin: policy"],"summary":"Tenant settings","operationId":"adminGetSettings","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"responses":{"200":{"description":"Settings.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TenantSettings"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["Admin: policy"],"summary":"Update tenant settings","operationId":"adminPatchSettings","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"onMissingPlan":{"type":"string","enum":["deny","allow"]},"flagvalentTenantId":{"type":["string","null"],"pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i","description":"FlagValent tenant UUID. Set by the console (contract v1); this endpoint only accepts it when the dev fakes are enabled (`FAKE_PORTS=true`), otherwise `403`."},"accessRequestTtlDays":{"type":"integer","minimum":1,"maximum":365},"authvalentIssuer":{"type":["string","null"],"maxLength":512,"example":"https://auth.ambvalent.com/t/0b7c5c1e-3f7a-4c39-9a51-0d6f8f0b7a11","description":"AuthValent issuer of this environment; `{ issuer, sub }` identities from it map to the subject `sub`."},"expectedAuthvalentIssuer":{"type":["string","null"],"maxLength":512,"example":"https://auth.ambvalent.com/t/0b7c5c1e-3f7a-4c39-9a51-0d6f8f0b7a11","description":"Optional compare-and-set precondition for settings PATCH. Must match the current issuer (ignoring trailing slashes); null requires an unset issuer. A mismatch returns 409 conflict, including for a no-op. Omit for existing unconditional behavior."}}}}}},"responses":{"200":{"description":"Updated settings.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TenantSettings"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflicting state (`conflict`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/custom-roles":{"get":{"tags":["Admin: policy"],"summary":"List custom roles and templates","operationId":"adminListCustomRoles","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","enum":["template","custom"]},"required":false,"name":"kind","in":"query"},{"schema":{"type":"string","maxLength":1100,"example":"org:42/property:9","description":"Scope path (`*` or empty = tenant-wide)."},"required":false,"description":"Scope path (`*` or empty = tenant-wide).","name":"ownerScope","in":"query"}],"responses":{"200":{"description":"Roles.","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/CustomRole"}}},"required":["items"]}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Admin: policy"],"summary":"Create a custom role or template","description":"Templates are defined per organization and instantiated into custom roles; custom roles apply in their owner scope and below.","operationId":"adminCreateCustomRole","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"key":{"type":"string","pattern":"^[A-Z][A-Z0-9_]{0,63}$","example":"OWNER"},"name":{"type":"string","minLength":1,"maxLength":200},"kind":{"type":"string","enum":["template","custom"]},"ownerScope":{"type":"string","maxLength":1100,"example":"org:42/property:9","description":"Scope path (`*` or empty = tenant-wide)."},"baseRole":{"type":["string","null"],"pattern":"^[A-Z][A-Z0-9_]{0,63}$","example":"OWNER"},"grants":{"type":"array","items":{"type":"string","maxLength":200,"example":"nestx.COMMON_AREAS:BOOK"},"maxItems":500,"default":[],"description":"Permission ids `<namespace>.<FEATURE>:<ACTION>` or `<namespace>.<FEATURE>:*`."},"denies":{"type":"array","items":{"type":"string","maxLength":200,"example":"nestx.COMMON_AREAS:BOOK"},"maxItems":500,"default":[],"description":"Permission ids `<namespace>.<FEATURE>:<ACTION>` or `<namespace>.<FEATURE>:*`."}},"required":["key","name","kind","ownerScope"]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomRole"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflicting state (`conflict`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/custom-roles/{id}":{"get":{"tags":["Admin: policy"],"summary":"Get a custom role or template","operationId":"adminGetCustomRole","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"The role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomRole"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["Admin: policy"],"summary":"Update a custom role or template (key, kind and owner scope are immutable)","operationId":"adminUpdateCustomRole","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"baseRole":{"type":["string","null"],"pattern":"^[A-Z][A-Z0-9_]{0,63}$","example":"OWNER"},"grants":{"type":"array","items":{"type":"string","maxLength":200,"example":"nestx.COMMON_AREAS:BOOK"},"maxItems":500,"description":"Permission ids `<namespace>.<FEATURE>:<ACTION>` or `<namespace>.<FEATURE>:*`."},"denies":{"type":"array","items":{"type":"string","maxLength":200,"example":"nestx.COMMON_AREAS:BOOK"},"maxItems":500,"description":"Permission ids `<namespace>.<FEATURE>:<ACTION>` or `<namespace>.<FEATURE>:*`."}}}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomRole"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Admin: policy"],"summary":"Delete a custom role or template (and the assignments of a custom role)","description":"Custom roles instantiated from a template are independent copies and are kept.","operationId":"adminDeleteCustomRole","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted."},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/custom-roles/{id}/instantiate":{"post":{"tags":["Admin: policy"],"summary":"Create a custom role from a template","description":"Copies the template into `ownerScope` (inside the template owner scope); later template edits do not propagate.","operationId":"adminInstantiateTemplate","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"ownerScope":{"type":"string","maxLength":1100,"example":"org:42/property:9","description":"Scope path (`*` or empty = tenant-wide)."},"key":{"type":"string","pattern":"^[A-Z][A-Z0-9_]{0,63}$","example":"OWNER"},"name":{"type":"string","minLength":1,"maxLength":200}},"required":["ownerScope"]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomRole"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflicting state (`conflict`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/simulate":{"post":{"tags":["Admin: simulator"],"summary":"\"Can X do Y?\" with the full evaluation trace","description":"Same evaluation as `/v1/check` (live inputs), always with `explain`. Read-only.","operationId":"adminSimulate","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"subject":{"type":"string","pattern":"^\\S{1,256}$","example":"user_123"},"scope":{"type":"string","maxLength":1100,"example":"org:42/property:9","description":"Scope path (`*` or empty = tenant-wide)."},"account":{"type":"string","minLength":1,"maxLength":256,"example":"org:42","description":"Billing account; defaults to the first scope segment, then the subject."},"roles":{"type":"array","items":{"type":"string","pattern":"^[A-Z][A-Z0-9_]{0,63}$","example":"OWNER"},"maxItems":20,"description":"Roles asserted by the trusted caller (secret key only)."},"namespace":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,31}$","example":"nestx"},"feature":{"type":"string","minLength":1,"maxLength":128,"example":"nestx.COMMON_AREAS","description":"Qualified feature id, or a bare key with `namespace`."},"action":{"type":"string","pattern":"^[A-Z][A-Z0-9_]{0,63}$","example":"READ"}},"required":["subject","feature","action"]}}}},"responses":{"200":{"description":"Decision with trace.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimulationResult"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/store-admins":{"put":{"tags":["Admin: assignments & requests"],"summary":"Reconcile one Store administrator grant by canonical AuthValent identity","description":"The body requires `identity` (`issuer` + `sub`) and has no subject/email fallback. The exclusive Store role set is reconciled idempotently and atomically. `role: null` revokes every Store role; `active: false` deactivates them without deleting Auth identities.","operationId":"adminReconcileStoreAdmin","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReconcileStoreAdminRequest"}}}},"responses":{"200":{"description":"The resulting grant state.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReconcileStoreAdminResult"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"tags":["Admin: assignments & requests"],"summary":"List and count active Store administrator seats in one exact scope","description":"A seat is one canonical principal identity with at least one active, unexpired `STORE_OWNER`, `STORE_EDITOR` or `STORE_SUPPORT` assignment. Duplicate roles for the same identity consume one seat.","operationId":"adminListStoreAdmins","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","maxLength":1100,"example":"org:42/property:9","description":"Scope path (`*` or empty = tenant-wide)."},"required":true,"description":"Scope path (`*` or empty = tenant-wide).","name":"scope","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","maxLength":512,"description":"Opaque cursor from `nextCursor`."},"required":false,"description":"Opaque cursor from `nextCursor`.","name":"cursor","in":"query"}],"responses":{"200":{"description":"Active Store administrator seats.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StoreAdminSeatPage"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/assignments":{"get":{"tags":["Admin: assignments & requests"],"summary":"List assignments (oldest first, cursor-paginated)","operationId":"adminListAssignments","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","pattern":"^\\S{1,256}$","example":"user_123"},"required":false,"name":"subject","in":"query"},{"schema":{"type":"string","maxLength":1100,"example":"org:42/property:9","description":"Scope path (`*` or empty = tenant-wide)."},"required":false,"description":"Scope path (`*` or empty = tenant-wide).","name":"scope","in":"query"},{"schema":{"type":"string","pattern":"^[A-Z][A-Z0-9_]{0,63}$","example":"OWNER"},"required":false,"name":"roleKey","in":"query"},{"schema":{"type":"string","maxLength":64},"required":false,"name":"customRoleId","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":200},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","maxLength":512,"description":"Opaque cursor from `nextCursor`."},"required":false,"description":"Opaque cursor from `nextCursor`.","name":"cursor","in":"query"}],"responses":{"200":{"description":"A page of assignments.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssignmentList"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Admin: assignments & requests"],"summary":"Assign a role to a subject in a scope","description":"Idempotent on (subject, scope, role): an existing row is re-activated and updated (`200`), otherwise created (`201`).","operationId":"adminCreateAssignment","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"subject":{"type":"string","pattern":"^\\S{1,256}$","example":"user_123","description":"Required unless `identity` is given."},"identity":{"$ref":"#/components/schemas/AuthValentIdentity"},"roleKey":{"type":"string","pattern":"^[A-Z][A-Z0-9_]{0,63}$","example":"OWNER"},"customRoleId":{"type":"string","minLength":1,"maxLength":64},"scope":{"type":"string","maxLength":1100,"example":"org:42/property:9","description":"Scope path (`*` or empty = tenant-wide)."},"expiresAt":{"type":["string","null"],"format":"date-time","example":"2027-01-01T00:00:00Z"}}}}}},"responses":{"200":{"description":"Existing assignment re-activated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Assignment"}}}},"201":{"description":"Created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Assignment"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/assignments/{id}":{"get":{"tags":["Admin: assignments & requests"],"summary":"Get an assignment","operationId":"adminGetAssignment","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"The assignment.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Assignment"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["Admin: assignments & requests"],"summary":"Activate/deactivate an assignment or change its expiry","operationId":"adminUpdateAssignment","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"active":{"type":"boolean"},"expiresAt":{"type":["string","null"],"format":"date-time","example":"2027-01-01T00:00:00Z"}}}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Assignment"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Admin: assignments & requests"],"summary":"Revoke (delete) an assignment","operationId":"adminDeleteAssignment","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Revoked."},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/access-requests":{"get":{"tags":["Admin: assignments & requests"],"summary":"List access requests (newest first, cursor-paginated)","description":"Pending requests past their TTL are reported as `expired` (and excluded from `status=pending`).","operationId":"adminListAccessRequests","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","enum":["pending","approved","denied","canceled","expired"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","pattern":"^\\S{1,256}$","example":"user_123"},"required":false,"name":"subject","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":200},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","maxLength":512,"description":"Opaque cursor from `nextCursor`."},"required":false,"description":"Opaque cursor from `nextCursor`.","name":"cursor","in":"query"}],"responses":{"200":{"description":"A page of requests.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccessRequestList"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/access-requests/{id}":{"get":{"tags":["Admin: assignments & requests"],"summary":"Get an access request","operationId":"adminGetAccessRequest","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"The request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccessRequest"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/access-requests/{id}/approve":{"post":{"tags":["Admin: assignments & requests"],"summary":"Approve a pending request (creates the assignment in the same batch)","description":"Role requests grant the requested role unless `grant` overrides it; feature/action requests require `grant`. Expired or already-handled requests return `409`.","operationId":"adminApproveAccessRequest","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"grant":{"$ref":"#/components/schemas/RoleGrant"},"message":{"type":"string","maxLength":1000}}}}}},"responses":{"200":{"description":"Approved.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccessRequestApproval"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflicting state (`conflict`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/access-requests/{id}/deny":{"post":{"tags":["Admin: assignments & requests"],"summary":"Deny a pending request","operationId":"adminDenyAccessRequest","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","maxLength":1000}}}}}},"responses":{"200":{"description":"Denied.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccessRequest"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflicting state (`conflict`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/me/access-requests/inbox":{"get":{"tags":["Access requests"],"summary":"Pending requests I can decide (approver inbox)","description":"Pending requests (other than the caller's own) in scopes where the subject is allowed `access.REQUESTS:APPROVE` (evaluated live). With `scope`, only that scope is listed and the right is required there (403 otherwise).","operationId":"listMyAccessRequestInbox","security":[{"publishableKey":[],"subjectToken":[]}],"parameters":[{"schema":{"type":"string","maxLength":1100,"example":"org:42/property:9","description":"Scope path (`*` or empty = tenant-wide)."},"required":false,"description":"Scope path (`*` or empty = tenant-wide).","name":"scope","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":200},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","maxLength":512,"description":"Opaque cursor from `nextCursor`."},"required":false,"description":"Opaque cursor from `nextCursor`.","name":"cursor","in":"query"}],"responses":{"200":{"description":"Pending requests the subject can decide.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccessRequestList"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/me/access-requests/{id}/approve":{"post":{"tags":["Access requests"],"summary":"Approve a request as a subject approver","description":"Needs `access.REQUESTS:APPROVE` in the request scope; own requests cannot be decided. Subject approvers can only grant `org`/`consumer` roles without `tier`/`internal`/`bypass` in their inherits closure, or custom roles owned by a scope containing the request scope.","operationId":"approveAsSubject","security":[{"publishableKey":[],"subjectToken":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"grant":{"$ref":"#/components/schemas/RoleGrant"},"message":{"type":"string","maxLength":1000}}}}}},"responses":{"200":{"description":"Approved.","content":{"application/json":{"schema":{"type":"object","properties":{"request":{"$ref":"#/components/schemas/AccessRequest"},"assignment":{"$ref":"#/components/schemas/Assignment"}},"required":["request","assignment"]}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflicting state (`conflict`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/me/access-requests/{id}/deny":{"post":{"tags":["Access requests"],"summary":"Deny a request as a subject approver","operationId":"denyAsSubject","security":[{"publishableKey":[],"subjectToken":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","maxLength":1000}}}}}},"responses":{"200":{"description":"Denied.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccessRequest"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflicting state (`conflict`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/audit":{"get":{"tags":["Admin: audit & privacy"],"summary":"Audit log (newest first, cursor-paginated)","operationId":"adminListAudit","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","enum":["access","app"]},"required":false,"name":"source","in":"query"},{"schema":{"type":"string","maxLength":64},"required":false,"name":"entity","in":"query"},{"schema":{"type":"string","maxLength":256},"required":false,"name":"entityId","in":"query"},{"schema":{"type":"string","maxLength":300},"required":false,"name":"actor","in":"query"},{"schema":{"type":"string","pattern":"^\\S{1,256}$","example":"user_123","description":"Events about this subject (`subject` on the event): `assignment.*` and `access_request.*` events whose snapshot names the subject, and `subject.*` events for it."},"required":false,"description":"Events about this subject (`subject` on the event): `assignment.*` and `access_request.*` events whose snapshot names the subject, and `subject.*` events for it.","name":"subject","in":"query"},{"schema":{"type":"string","maxLength":130},"required":false,"name":"action","in":"query"},{"schema":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,31}(\\.[a-z][a-z0-9_]{0,31}){0,3}$","description":"`product` matches `product` and `product.*` (`product.update`, `product.variant.update`)."},"required":false,"description":"`product` matches `product` and `product.*` (`product.update`, `product.variant.update`).","name":"actionPrefix","in":"query"},{"schema":{"type":"string","enum":["success","failure","pending"]},"required":false,"name":"outcome","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Inclusive lower bound on `createdAt`."},"required":false,"description":"Inclusive lower bound on `createdAt`.","name":"since","in":"query"},{"schema":{"type":"string","format":"date-time","description":"Exclusive upper bound on `createdAt`."},"required":false,"description":"Exclusive upper bound on `createdAt`.","name":"until","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":200},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","maxLength":512,"description":"Opaque cursor from `nextCursor`."},"required":false,"description":"Opaque cursor from `nextCursor`.","name":"cursor","in":"query"}],"responses":{"200":{"description":"A page of audit events.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuditPage"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Admin: audit & privacy"],"summary":"Write a host audit event","description":"Appends an `app` event to the tenant audit log (for example the store admin: `auth.login`, `product.update`, `order.status_change`). Actions are dotted lowercase (2-4 segments); AccessValent actions are reserved. `actor` is `subject:<id>`, `user:<id>` or `system:<name>` (defaults to `x-valent-actor` as `user:<id>`, else the caller); the caller is kept in `recordedBy`. Secrets in `before`/`after` are redacted; together they are limited to 16 KiB. Send an `Idempotency-Key` to retry safely.","operationId":"adminWriteAudit","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuditWriteRequest"}}}},"responses":{"201":{"description":"Recorded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuditEvent"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/subjects/{subject}":{"delete":{"tags":["Admin: audit & privacy"],"summary":"Erase a subject's assignments, access requests and version","description":"Audit rows keep the opaque subject id only (access-request audit payloads never contain e-mail or name).","operationId":"adminEraseSubject","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","pattern":"^\\S{1,256}$","example":"user_123"},"required":true,"name":"subject","in":"path"}],"responses":{"200":{"description":"Erased (counts of deleted rows).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubjectErasure"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/subjects/{subject}/roles":{"put":{"tags":["Admin: assignments & requests"],"summary":"Replace a subject's role within a role set (change role, disable/enable)","description":"Atomic (one D1 batch, one `subject.roles_replaced` audit event): ensures the `role` assignment exists in `scope` and deletes the subject's other assignments of `roleSet` there; `active: false` deactivates the set instead. Idempotent: repeating the call writes nothing (`changed: false`).","operationId":"adminReplaceSubjectRoles","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","pattern":"^\\S{1,256}$","example":"user_123"},"required":true,"name":"subject","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReplaceSubjectRolesRequest"}}}},"responses":{"200":{"description":"The resulting state.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReplaceSubjectRolesResult"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/api-keys":{"get":{"tags":["Admin: API keys"],"summary":"List API keys (prefix only)","operationId":"adminListApiKeys","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"responses":{"200":{"description":"Keys.","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/ApiKey"}}},"required":["items"]}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Admin: API keys"],"summary":"Create an API key (the plaintext is returned once)","operationId":"adminCreateApiKey","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"kind":{"type":"string","enum":["publishable","secret"]},"name":{"type":"string","minLength":1,"maxLength":100}},"required":["kind","name"]}}}},"responses":{"201":{"description":"Created; store `plaintext` now, it is never shown again.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreatedApiKey"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/api-keys/{id}":{"delete":{"tags":["Admin: API keys"],"summary":"Revoke an API key","operationId":"adminRevokeApiKey","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Revoked.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiKey"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflicting state (`conflict`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/me":{"get":{"tags":["Admin: tenant admin (module-contract)"],"summary":"Who am I (tenant, credential, scopes)","description":"Module-contract `GET /v1/admin/me`. Legacy `av_sk_` keys and the ValentConsole principal hold every scope.","operationId":"adminWhoAmI","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"responses":{"200":{"description":"Caller.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/TenantAdminWhoAmI"}},"required":["data"]}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/keys":{"get":{"tags":["Admin: tenant admin (module-contract)"],"summary":"List scoped secret keys (`acv_sk_`)","operationId":"adminListKeys","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":100},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","maxLength":500},"required":false,"name":"cursor","in":"query"}],"responses":{"200":{"description":"Keys.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/ApiKey"}},"nextCursor":{"type":["string","null"]}},"required":["items","nextCursor"]}},"required":["data"]}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Admin: tenant admin (module-contract)"],"summary":"Create a scoped secret key (the secret is returned once)","description":"`scopes` defaults to `[\"read\"]` (`read` ⊂ `write` ⊂ `admin`). `Idempotency-Key` is ignored: the response carries a secret and is never stored.","operationId":"adminCreateKey","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"kind":{"type":"string","enum":["secret"]},"name":{"type":"string","minLength":1,"maxLength":200},"scopes":{"type":"array","items":{"type":"string","enum":["read","write","admin"]},"minItems":1},"expiresAt":{"type":"string","format":"date-time"}},"required":["kind","name"]}}}},"responses":{"201":{"description":"Created; store `secret` now.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/CreatedScopedApiKey"}},"required":["data"]}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/keys/{id}":{"delete":{"tags":["Admin: tenant admin (module-contract)"],"summary":"Revoke a scoped secret key","operationId":"adminRevokeKey","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Revoked.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ApiKey"}},"required":["data"]}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflicting state (`conflict`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/keys/{id}/rotate":{"post":{"tags":["Admin: tenant admin (module-contract)"],"summary":"Rotate a scoped secret key","description":"Issues a replacement with the same name and scopes. The previous key keeps working for `graceSeconds` (0-604800, default 86400; `0` revokes it now).","operationId":"adminRotateKey","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Rotated; store `key.secret` now.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/RotatedApiKey"}},"required":["data"]}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflicting state (`conflict`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/fake/plans":{"get":{"tags":["Admin: dev fakes"],"summary":"List fake plans","description":"Dev only: backs the in-memory BillValent (entitlements) and FlagValent (flags) stand-ins. Returns `404` unless the Worker runs with `FAKE_PORTS=true`.","operationId":"adminListFakePlans","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"responses":{"200":{"description":"Fake plans.","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/FakePlan"}}},"required":["items"]}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/fake/plans/{account}":{"put":{"tags":["Admin: dev fakes"],"summary":"Set an account's fake plan","description":"Dev only: backs the in-memory BillValent (entitlements) and FlagValent (flags) stand-ins. Returns `404` unless the Worker runs with `FAKE_PORTS=true`.","operationId":"adminPutFakePlan","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":256,"example":"org:42","description":"Billing account; defaults to the first scope segment, then the subject."},"required":true,"description":"Billing account; defaults to the first scope segment, then the subject.","name":"account","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"planKey":{"type":"string","minLength":1,"maxLength":64},"state":{"type":"string","enum":["active","trialing","past_due","free","suspended","canceled"],"default":"active"},"features":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"maxItems":500,"default":[]},"upgradeTo":{"type":["string","null"],"minLength":1,"maxLength":64,"default":null}},"required":["planKey"]}}}},"responses":{"200":{"description":"Stored.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FakePlan"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Admin: dev fakes"],"summary":"Remove an account's fake plan (the account then has no plan)","description":"Dev only: backs the in-memory BillValent (entitlements) and FlagValent (flags) stand-ins. Returns `404` unless the Worker runs with `FAKE_PORTS=true`.","operationId":"adminDeleteFakePlan","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":256,"example":"org:42","description":"Billing account; defaults to the first scope segment, then the subject."},"required":true,"description":"Billing account; defaults to the first scope segment, then the subject.","name":"account","in":"path"}],"responses":{"204":{"description":"Removed."},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/fake/flags":{"get":{"tags":["Admin: dev fakes"],"summary":"List fake flags (flags without a row evaluate as on)","description":"Dev only: backs the in-memory BillValent (entitlements) and FlagValent (flags) stand-ins. Returns `404` unless the Worker runs with `FAKE_PORTS=true`.","operationId":"adminListFakeFlags","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"responses":{"200":{"description":"Fake flags.","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/FakeFlag"}}},"required":["items"]}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/admin/fake/flags/{flag}":{"put":{"tags":["Admin: dev fakes"],"summary":"Set a fake flag (keys are lower-cased)","description":"Dev only: backs the in-memory BillValent (entitlements) and FlagValent (flags) stand-ins. Returns `404` unless the Worker runs with `FAKE_PORTS=true`.","operationId":"adminPutFakeFlag","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":128,"example":"invoices"},"required":true,"name":"flag","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"enabled":{"type":"boolean","default":true},"killed":{"type":"boolean","default":false}}}}}},"responses":{"200":{"description":"Stored.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FakeFlag"}}}},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Admin: dev fakes"],"summary":"Remove a fake flag (it evaluates as on again)","description":"Dev only: backs the in-memory BillValent (entitlements) and FlagValent (flags) stand-ins. Returns `404` unless the Worker runs with `FAKE_PORTS=true`.","operationId":"adminDeleteFakeFlag","security":[{"secretKey":[]},{"serviceAccountToken":[]}],"parameters":[{"schema":{"type":"string","minLength":1,"maxLength":128,"example":"invoices"},"required":true,"name":"flag","in":"path"}],"responses":{"204":{"description":"Removed."},"400":{"description":"Invalid request (`invalid_request`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing, invalid or revoked credentials (`unauthorized`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Wrong key kind or tenant (`forbidden`), missing scope (`insufficient_scope`) or disabled tenant (`tenant_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"A dependency is unavailable (`unavailable`); the caller must fail closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"webhooks":{}}