openapi: 3.1.0 info: title: Tenant Registry version: 0.1.0 description: | Internal platform API. Owns the multi-tenant glue: tenants, projects, product entitlements, API keys, audit log. See `PLATFORM_ARCHITECTURE.md §5c` for the schema, and `PRODUCT_INTEGRATION_SPEC.md §8.4` for the audit shape. Auth (RBAC Phase 1): with AUTH_ENABLED=true every route except /healthz and /readyz requires a Keycloak-issued bearer token whose audience contains AUTH_EXPECTED_AUDIENCE (INTERNAL_SERVICE_ONLY posture). With AUTH_ENABLED=false (dev default) the API is open. Per-client authorization (M-MIG-5): AUTHZ_RULES maps each client (JWT azp) to route groups — tenants(.read|.write), catalog, entitlements, api-keys(.verify), audit(.read|.write), users, keycloak, erp, usage, licences. Unlisted clients get 403. Tenant status ladder (ERP/02): demo, trial, active (Betriebsbereit), warning (Warnung), restricted (Eingeschränkt, read-only), halted (Angehalten), archived. 'frozen' is legacy = restricted. contact: email: oncall@breakpilot.com license: name: Proprietary servers: - url: http://localhost:8090 description: Local dev - url: https://registry-stage.breakpilot.com description: Stage - url: https://registry.breakpilot.com description: Production paths: /healthz: get: summary: Liveness probe responses: "200": description: Always returns ok. content: application/json: schema: type: object properties: { status: { type: string, example: ok } } /readyz: get: summary: Readiness probe — pings the store. responses: "200": description: Store reachable. "503": description: Store unreachable. content: application/json: { schema: { $ref: "#/components/schemas/Error" } } /v1/tenants: get: summary: List tenants (service-only; keyset paginated). parameters: - in: query name: status schema: { $ref: "#/components/schemas/TenantStatus" } - in: query name: kind schema: { type: string, enum: [customer, demo] } - in: query name: limit schema: { type: integer, minimum: 1, maximum: 500, default: 100 } - in: query name: cursor schema: { type: string, description: "next_cursor from the previous page" } responses: "200": description: Page of tenants; next_cursor omitted on the last page. content: application/json: schema: type: object properties: items: type: array items: { $ref: "#/components/schemas/Tenant" } next_cursor: { type: string } "400": { $ref: "#/components/responses/BadRequest" } post: summary: Create a tenant. description: | Creates the tenant row, and if `admin_email` is provided, also creates a Keycloak organization + invites the user as IT_ADMIN. Keycloak failures DO NOT roll the tenant back — they emit a `keycloak.provision_failed` audit event so the operator can resend the invite from the KC admin UI. requestBody: required: true content: application/json: { schema: { $ref: "#/components/schemas/TenantCreate" } } responses: "201": description: Created. `invite_url` is non-empty when an `admin_email` was passed and Keycloak provisioning succeeded. content: application/json: { schema: { $ref: "#/components/schemas/TenantCreated" } } "400": { $ref: "#/components/responses/BadRequest" } "409": { $ref: "#/components/responses/Conflict" } /v1/tenants/{id}: get: summary: Get tenant by id. parameters: - in: path name: id required: true schema: { type: string, format: uuid } responses: "200": description: Found. content: application/json: { schema: { $ref: "#/components/schemas/Tenant" } } "404": { $ref: "#/components/responses/NotFound" } /v1/tenants/by-slug/{slug}: get: summary: Get tenant by slug. parameters: - in: path name: slug required: true schema: { type: string, pattern: '^[a-z0-9][a-z0-9-]{1,38}[a-z0-9]$' } responses: "200": description: Found. content: application/json: { schema: { $ref: "#/components/schemas/Tenant" } } "404": { $ref: "#/components/responses/NotFound" } /v1/tenants/{id}/activate: post: summary: Move tenant to status=active. parameters: - in: path name: id required: true schema: { type: string, format: uuid } requestBody: required: false content: application/json: { schema: { $ref: "#/components/schemas/TenantActivate" } } responses: "200": description: Updated. content: application/json: { schema: { $ref: "#/components/schemas/Tenant" } } "400": { $ref: "#/components/responses/BadRequest" } "404": { $ref: "#/components/responses/NotFound" } /v1/tenants/{id}/status: post: summary: Move a tenant along the status ladder (ERP link, Backstage). description: | The one transition endpoint outside activate/cancel. Syncs the coarse `tenant_status` claim to every Keycloak member of the tenant's organization and writes a `tenant.status_changed` audit event. parameters: - in: path name: id required: true schema: { type: string, format: uuid } requestBody: required: true content: application/json: schema: type: object required: [status] properties: status: { $ref: "#/components/schemas/TenantStatus" } reason: { type: string } source: { type: string, enum: [erp, backstage, system, test] } responses: "200": description: Updated. content: application/json: { schema: { $ref: "#/components/schemas/Tenant" } } "400": { $ref: "#/components/responses/BadRequest" } "404": { $ref: "#/components/responses/NotFound" } /v1/tenants/{id}/cancel: post: summary: Move tenant to status=halted (Angehalten). parameters: - in: path name: id required: true schema: { type: string, format: uuid } requestBody: required: false content: application/json: { schema: { $ref: "#/components/schemas/TenantCancel" } } responses: "200": description: Updated. content: application/json: { schema: { $ref: "#/components/schemas/Tenant" } } "404": { $ref: "#/components/responses/NotFound" } /v1/tenants/{id}/members: get: summary: List the tenant's Keycloak organization members. description: | The portal's Settings/Users page. A user token may only read its own tenant — another tenant's id answers 404, never a hint that it exists. Service clients are gated on the `tenants.read` route group. A tenant whose organization was never created (sales-led) answers with an empty list rather than an error. parameters: - in: path name: id required: true schema: { type: string, format: uuid } responses: "200": description: Members of the organization. content: application/json: schema: type: object required: [members] properties: members: type: array items: { $ref: "#/components/schemas/OrgMember" } "404": { $ref: "#/components/responses/NotFound" } /v1/tenants/{id}/invites: post: summary: Invite a user into the tenant's organization. description: | Creates the Keycloak user if needed, adds it to the tenant's organization, writes the tenant-context user attributes and sends the same execute-actions email the first admin receives. Idempotent: an existing member answers `200 {status: member}` and sends no mail. User tokens need the `IT_ADMIN` or `OWNER` org role; service clients need the `tenants.write` route group. parameters: - in: path name: id required: true schema: { type: string, format: uuid } requestBody: required: true content: application/json: schema: type: object required: [email] properties: email: { type: string, format: email } first_name: { type: string, maxLength: 100 } last_name: { type: string, maxLength: 100 } role: type: string pattern: '^[A-Z][A-Z0-9_]{1,31}$' default: USER description: "org_roles attribute written for the user" responses: "202": description: Invited; the mail is on its way. content: application/json: { schema: { $ref: "#/components/schemas/Invite" } } "200": description: Already a member; nothing sent. content: application/json: { schema: { $ref: "#/components/schemas/Invite" } } "400": { $ref: "#/components/responses/BadRequest" } "403": { $ref: "#/components/responses/Forbidden" } "404": { $ref: "#/components/responses/NotFound" } /v1/entitlements: get: summary: List product entitlements for a tenant. parameters: - in: query name: tenant_id required: true schema: { type: string, format: uuid } responses: "200": description: List response. content: application/json: schema: type: object properties: items: type: array items: { $ref: "#/components/schemas/TenantProduct" } "400": { $ref: "#/components/responses/BadRequest" } "404": { $ref: "#/components/responses/NotFound" } /v1/internal/entitlements/check: post: summary: Is this tenant entitled to this product (and add-on) right now? description: | The authoritative entitlement answer (PRODUCT_INTEGRATION_SPEC 2.0 §4.4). Products cache it for ≤ 60 s and fail closed when the registry is unreachable. `read_only` reflects the ladder (restricted); `halted` and `archived` are never allowed. requestBody: required: true content: application/json: schema: type: object required: [tenant_id, product] properties: tenant_id: { type: string, format: uuid } product: { type: string } addon: { type: string, description: "add-on id from the catalog, e.g. werkbank" } responses: "200": description: Decision. content: application/json: { schema: { $ref: "#/components/schemas/EntitlementCheck" } } "400": { $ref: "#/components/responses/BadRequest" } /v1/catalog: get: summary: List the products available for any tenant to request. responses: "200": description: Catalog. content: application/json: schema: type: object properties: items: type: array items: { $ref: "#/components/schemas/CatalogEntry" } /v1/catalog/request: post: summary: Request a product (creates an audit event; sales follows up). requestBody: required: true content: application/json: { schema: { $ref: "#/components/schemas/CatalogRequest" } } responses: "202": description: Accepted. "400": { $ref: "#/components/responses/BadRequest" } "404": { $ref: "#/components/responses/NotFound" } /v1/catalog/trial-request: post: summary: Self-serve a 14-day trial. requestBody: required: true content: application/json: { schema: { $ref: "#/components/schemas/CatalogRequest" } } responses: "201": description: Trial entitlement created. content: application/json: { schema: { $ref: "#/components/schemas/TenantProduct" } } "400": { $ref: "#/components/responses/BadRequest" } "404": { $ref: "#/components/responses/NotFound" } /v1/api-keys: get: summary: List API keys for a tenant. parameters: - in: query name: tenant_id required: true schema: { type: string, format: uuid } responses: "200": description: List response. The plaintext key is NOT returned; use the create endpoint and store the value immediately. content: application/json: schema: type: object properties: items: type: array items: { $ref: "#/components/schemas/APIKey" } "400": { $ref: "#/components/responses/BadRequest" } "404": { $ref: "#/components/responses/NotFound" } post: summary: Create an API key. The plaintext is returned ONCE. requestBody: required: true content: application/json: { schema: { $ref: "#/components/schemas/APIKeyCreate" } } responses: "201": description: Created. The plaintext field is shown only here. content: application/json: { schema: { $ref: "#/components/schemas/APIKeyCreated" } } "400": { $ref: "#/components/responses/BadRequest" } "404": { $ref: "#/components/responses/NotFound" } /v1/api-keys/{id}: delete: summary: Revoke an API key (sets revoked_at). parameters: - in: path name: id required: true schema: { type: string, format: uuid } responses: "204": description: Revoked. "404": { $ref: "#/components/responses/NotFound" } /v1/users/{id}/memberships: get: summary: Resolve which tenants a user belongs to (membership authority). description: | The B2 membership-authority endpoint (ratified compliance auth design). Product backends call this with the JWT `sub` instead of trusting token claims or client-supplied headers. Keycloak supplies the user→tenant links and org_roles; where the tenant is registered here, tenant_status / plan / products are overridden from registry tables (source: "registry"), otherwise the Keycloak attribute projection is returned as-is (source: "keycloak"). parameters: - name: id in: path required: true description: Keycloak user id (the JWT `sub`). schema: { type: string } responses: "200": description: Memberships (possibly empty) for the user. content: application/json: schema: type: object required: [user_id, memberships] properties: user_id: { type: string } memberships: type: array items: allOf: - $ref: "#/components/schemas/Claims" - type: object required: [source] properties: source: { type: string, enum: [registry, keycloak] } "400": { $ref: "#/components/responses/BadRequest" } "404": { $ref: "#/components/responses/NotFound" } "503": description: Keycloak unreachable — membership cannot be resolved. content: application/json: { schema: { $ref: "#/components/schemas/Error" } } /v1/internal/keycloak/claims: post: summary: Resolve the up-to-date claim bundle for a user/tenant. description: | Called by Keycloak's protocol mapper at token issuance (or by any operator on demand) to fetch the current tenant_id / tenant_slug / org_roles / products / plan / tenant_status claims. Lookup tries tenant_id, then tenant_slug, then user_attrs.tenant_id, then user_attrs.tenant_slug. requestBody: required: true content: application/json: schema: type: object properties: tenant_id: { type: string, format: uuid } tenant_slug: { type: string } user_attrs: type: object additionalProperties: { type: string } responses: "200": description: Resolved claim bundle. content: application/json: { schema: { $ref: "#/components/schemas/Claims" } } "400": { $ref: "#/components/responses/BadRequest" } "404": { $ref: "#/components/responses/NotFound" } /v1/internal/api-keys/verify: post: summary: Verify an API key. Used by headless products. Returns 200 with valid=false on any failure (never 401). requestBody: required: true content: application/json: schema: type: object required: [key] properties: key: { type: string } responses: "200": description: Verification result. content: application/json: { schema: { $ref: "#/components/schemas/APIKeyVerify" } } /v1/audit: post: summary: Append an audit event. requestBody: required: true content: application/json: { schema: { $ref: "#/components/schemas/AuditAppend" } } responses: "201": description: Created. content: application/json: { schema: { $ref: "#/components/schemas/AuditEvent" } } "400": { $ref: "#/components/responses/BadRequest" } get: summary: List audit events (paginated, cursor-based). parameters: - in: query name: tenant_id schema: { type: string, format: uuid } - in: query name: product schema: { type: string } - in: query name: actor_id schema: { type: string } - in: query name: action schema: { type: string } - in: query name: since schema: { type: string, format: date-time } - in: query name: until schema: { type: string, format: date-time } - in: query name: limit schema: { type: integer, minimum: 1, maximum: 500 } - in: query name: cursor schema: { type: integer, format: int64 } responses: "200": description: Paginated response. next_cursor is omitted when there are no more pages. content: application/json: schema: type: object properties: items: type: array items: { $ref: "#/components/schemas/AuditEvent" } next_cursor: type: integer format: int64 "400": { $ref: "#/components/responses/BadRequest" } /v1/internal/erp/webhook: post: summary: ERPNext webhook receiver (HMAC-signed, no bearer token). description: | PUBLIC_EXPLICIT. Body is signed with ERP_WEBHOOK_SECRET (X-Frappe-Webhook-Signature = base64 HMAC-SHA256, or X-Hub-Signature-256 = sha256=hex). Idempotent by X-Frappe-Event-Id (fallback: hash of event+name+modified+body). Events: sales_order.submit → subscriptions + entitlements + active; sales_invoice.overdue → warning / restricted (days_overdue ≥ ERP_RESTRICT_AFTER_DAYS) / halted; payment_entry.submit → active; subscription.cancel → halted. Unknown customers are acknowledged (202). requestBody: required: true content: application/json: { schema: { $ref: "#/components/schemas/ErpWebhookEvent" } } responses: "200": { description: "Applied, unchanged or duplicate." } "202": { description: "Ignored (tenant not found)." } "401": { description: Bad signature. } "503": { description: ERP_WEBHOOK_SECRET not configured. } /v1/internal/erp/status: get: summary: ERP link status (outbox backlog, webhook/licence configuration). responses: "200": description: Status. content: application/json: schema: type: object properties: erp_configured: { type: boolean } webhook_enabled: { type: boolean } outbox_pending: { type: integer } licences_enabled: { type: boolean } llm_keys_enabled: { type: boolean } /v1/internal/erp/reconcile: post: summary: Run one reconcile pass now (ops / tests). description: | Mirrors ERP subscriptions for every tenant with an ERP customer and applies the time-based ladder steps (trial expiry, warning → restricted, restricted → halted, halted → archived). Runs every ERP_RECONCILE_INTERVAL in the background as well. responses: "200": description: Report. content: application/json: { schema: { $ref: "#/components/schemas/ReconcileReport" } } /v1/subscriptions: get: summary: Subscriptions mirrored from ERPNext for one tenant. parameters: - in: query name: tenant_id required: true schema: { type: string, format: uuid } responses: "200": description: List. content: application/json: schema: type: object properties: items: type: array items: { $ref: "#/components/schemas/Subscription" } "404": { $ref: "#/components/responses/NotFound" } /v1/usage/events: post: summary: Push usage events (PRODUCT_INTEGRATION_SPEC 2.0 §9.2). description: | One event, an array, or {"events": [...]} (≤ 500). Idempotent by idempotency_key; each new event is forwarded to ERPNext as a Usage Record through the outbox. User tokens may only report for their own tenant. requestBody: required: true content: application/json: schema: oneOf: - $ref: "#/components/schemas/UsageEventIn" - type: array items: { $ref: "#/components/schemas/UsageEventIn" } - type: object properties: events: type: array items: { $ref: "#/components/schemas/UsageEventIn" } responses: "202": description: "Accepted (partial rejections listed)." content: application/json: schema: type: object properties: accepted: { type: integer } duplicates: { type: integer } rejected: { type: array, items: { type: object } } "400": { $ref: "#/components/responses/BadRequest" } get: summary: Query usage events. parameters: - { in: query, name: tenant_id, required: true, schema: { type: string, format: uuid } } - { in: query, name: product, schema: { type: string } } - { in: query, name: metric, schema: { type: string } } - { in: query, name: since, schema: { type: string, format: date-time } } - { in: query, name: until, schema: { type: string, format: date-time } } - { in: query, name: limit, schema: { type: integer, minimum: 1, maximum: 1000 } } responses: "200": description: Newest first. content: application/json: schema: type: object properties: items: type: array items: { $ref: "#/components/schemas/UsageEvent" } "400": { $ref: "#/components/responses/BadRequest" } /v1/licences: post: summary: Issue a CLI licence JWT (Werkpilot, Firmwerk). description: | Requires an active entitlement for the product. User tokens (device flow, tenant-context claims) get a licence for their own tenant; service tokens pass tenant_id. Ed25519-signed (EdDSA), verifiable offline against /.well-known/licence-keys.json; expiry = min(ttl, entitlement expiry). Grace ladder inside the token. For product=werkpilot the registry also provisions a per-tenant LiteLLM virtual key (budget by plan) and returns it once as llm_api_key; a LiteLLM failure does not fail the licence (warnings: ["llm_key_unavailable"]). Revoking the licence deletes the key. requestBody: required: true content: application/json: schema: type: object required: [product] properties: tenant_id: { type: string, format: uuid } product: { type: string } device: { type: string } ttl_days: { type: integer } responses: "201": description: Issued. content: application/json: { schema: { $ref: "#/components/schemas/LicenceIssued" } } "400": { $ref: "#/components/responses/BadRequest" } "403": { description: Not entitled. } "503": { description: Licence signer not configured. } get: summary: List licences of a tenant. parameters: - { in: query, name: tenant_id, required: true, schema: { type: string, format: uuid } } responses: "200": description: List. content: application/json: schema: type: object properties: items: type: array items: { $ref: "#/components/schemas/Licence" } "404": { $ref: "#/components/responses/NotFound" } /v1/licences/{id}/revoke: post: summary: Revoke a licence (next heartbeat reports `revoked`). parameters: - in: path name: id required: true schema: { type: string, format: uuid } responses: "200": description: Revoked. content: application/json: { schema: { $ref: "#/components/schemas/Licence" } } "404": { $ref: "#/components/responses/NotFound" } /v1/licences/heartbeat: post: summary: CLI phone-home (PUBLIC_EXPLICIT — the licence JWT is the credential). description: | Reports ok | warning | degraded | hard_stop | revoked from the tenant ladder and the token's grace policy, records last_seen, and returns a renewed licence once the current one is past half-life while the tenant is still entitled. requestBody: required: true content: application/json: schema: type: object required: [licence] properties: licence: { type: string } responses: "200": description: State. content: application/json: { schema: { $ref: "#/components/schemas/LicenceHeartbeat" } } "401": { description: "Signature invalid or licence unknown." } "503": { description: Licence signer not configured. } /.well-known/licence-keys.json: get: summary: Licence verification keys (JWKS, OKP/Ed25519). PUBLIC_EXPLICIT. responses: "200": description: JWKS. content: application/json: schema: type: object properties: keys: { type: array, items: { type: object } } components: securitySchemes: bearerAuth: type: http scheme: bearer bearerFormat: JWT description: | Keycloak-issued token (client_credentials for services). Enforced on all non-health routes when AUTH_ENABLED=true. responses: BadRequest: description: Input failed validation. content: application/json: { schema: { $ref: "#/components/schemas/Error" } } NotFound: description: Resource does not exist. content: application/json: { schema: { $ref: "#/components/schemas/Error" } } Conflict: description: Resource already exists / unique violation. content: application/json: { schema: { $ref: "#/components/schemas/Error" } } Forbidden: description: The caller may not perform this operation. content: application/json: { schema: { $ref: "#/components/schemas/Error" } } schemas: ErpWebhookEvent: type: object required: [event, name] properties: event: { type: string, enum: [sales_order.submit, sales_invoice.overdue, payment_entry.submit, subscription.cancel] } doctype: { type: string } name: { type: string } modified: { type: string } customer: { type: string, description: "ERP customer name (tenants.erp_customer_id)" } tenant_id: { type: string, format: uuid, description: "Custom field on the Customer; preferred over customer" } items: type: array items: type: object properties: item_code: { type: string, description: "Platform SKU" } qty: { type: number } days_overdue: { type: integer } subscription: { type: string } invoice: { type: string } amount: { type: number } ReconcileReport: type: object properties: tenants: { type: integer } erp_checked: { type: integer } changed: { type: array, items: { type: string } } escalated: { type: array, items: { type: string } } errors: { type: array, items: { type: string } } erp_available: { type: boolean } Subscription: type: object properties: id: { type: string, format: uuid } tenant_id: { type: string, format: uuid } product: { type: string } sku: { type: string } plan: { type: string } seats: { type: integer } status: { type: string, enum: [active, cancelled] } erp_sales_order: { type: string } erp_subscription: { type: string } period_start: { type: string, format: date-time } period_end: { type: string, format: date-time } created_at: { type: string, format: date-time } updated_at: { type: string, format: date-time } UsageEventIn: type: object required: [idempotency_key, tenant_id, product, metric] properties: idempotency_key: { type: string } tenant_id: { type: string, format: uuid } product: { type: string } metric: { type: string, description: "e.g. scan.completed, target.added, seat.login" } quantity: { type: number, default: 1 } occurred_at: { type: string, format: date-time } properties: { type: object, additionalProperties: true } UsageEvent: allOf: - $ref: "#/components/schemas/UsageEventIn" - type: object properties: id: { type: integer } received_at: { type: string, format: date-time } erp_synced_at: { type: string, format: date-time } Licence: type: object properties: id: { type: string, format: uuid } kid: { type: string } tenant_id: { type: string, format: uuid } product: { type: string } subject: { type: string } device: { type: string } expires_at: { type: string, format: date-time } revoked_at: { type: string, format: date-time } last_seen_at: { type: string, format: date-time } created_at: { type: string, format: date-time } llm_key_id: { type: string, description: "LiteLLM hashed token id of the key issued with a Werkpilot licence (handle for revoke; never the secret)." } LicenceIssued: type: object properties: id: { type: string, format: uuid } licence: { type: string, description: "EdDSA JWT" } kid: { type: string } expires_at: { type: string, format: date-time } grace: type: object properties: warning_days: { type: integer } degraded_days: { type: integer } hard_stop_days: { type: integer } status: { type: string } llm_api_key: type: string description: | Werkpilot only: per-tenant LiteLLM virtual key (sk-…). Returned in THIS response only — never persisted, never returned again. Absent on heartbeat renewals (the CLI keeps the key it stored) and when LiteLLM is unavailable (see warnings). llm_base_url: { type: string, description: "OpenAI-compatible proxy root the key is valid for." } warnings: type: array items: { type: string, enum: [llm_key_unavailable] } description: Non-fatal issue notes; the licence itself is valid. LicenceHeartbeat: type: object properties: status: { type: string, enum: [ok, warning, degraded, hard_stop, revoked] } tenant_status: { $ref: "#/components/schemas/TenantStatus" } expires_at: { type: string, format: date-time } reason: { type: string } renewed: { $ref: "#/components/schemas/LicenceIssued" } TenantStatus: type: string enum: [demo, trial, active, warning, restricted, frozen, halted, archived] EntitlementCheck: type: object required: [allowed, read_only] properties: allowed: { type: boolean } read_only: { type: boolean } status: { $ref: "#/components/schemas/TenantStatus" } limits: { type: object, additionalProperties: true, description: "tenant_products.config — purchased limits" } expires_at: { type: string, format: date-time, nullable: true } reason: { type: string, enum: [unknown_product, unknown_addon, tenant_not_found, tenant_archived, tenant_halted, entitlement_disabled, entitlement_expired, addon_not_purchased, not_entitled] } ProductAddon: type: object required: [id, name] properties: id: { type: string } name: { type: string } limit_key: { type: string } skus: { type: array, items: { type: string } } Claims: type: object required: [tenant_id, tenant_slug, plan, tenant_status] properties: tenant_id: { type: string, format: uuid } tenant_slug: { type: string } org_roles: { type: array, items: { type: string } } products: { type: array, items: { type: string } } plan: { type: string } tenant_status: { $ref: "#/components/schemas/TenantStatus" } Error: type: object required: [error] properties: error: { type: string, example: invalid_input } message: { type: string } Tenant: type: object required: [id, slug, name, status, kind, plan, created_at, updated_at] properties: id: { type: string, format: uuid } slug: { type: string } name: { type: string } status: { $ref: "#/components/schemas/TenantStatus" } kind: { type: string, enum: [customer, demo] } plan: { type: string } erp_customer_id: { type: string } stripe_cust_id: { type: string } trial_ends_at: { type: string, format: date-time, nullable: true } contract_start: { type: string, format: date, nullable: true } contract_end: { type: string, format: date, nullable: true } sales_owner: { type: string } admin_email: { type: string, format: email, description: "the tenant's first admin; empty for sales-led tenants" } created_at: { type: string, format: date-time } updated_at: { type: string, format: date-time } OrgMember: type: object required: [user_id, email, enabled] properties: user_id: { type: string } email: { type: string, format: email } first_name: { type: string } last_name: { type: string } org_roles: type: array items: { type: string } enabled: { type: boolean } created_at: { type: string, format: date-time, nullable: true } Invite: type: object required: [user_id, email, status] properties: user_id: { type: string } email: { type: string, format: email } status: { type: string, enum: [invited, member] } TenantCreate: type: object required: [slug, name] properties: slug: { type: string, pattern: '^[a-z0-9][a-z0-9-]{1,38}[a-z0-9]$' } name: { type: string, minLength: 1, maxLength: 255 } plan: { type: string, default: starter } kind: { type: string, enum: [customer, demo], default: customer } sales_owner: { type: string } admin_email: { type: string, format: email, description: "IT_ADMIN to invite via Keycloak" } admin_name: { type: string } TenantCreated: type: object required: [tenant] properties: tenant: { $ref: "#/components/schemas/Tenant" } invite_url: { type: string, description: "KC action-token URL — present only when admin_email was set and KC provisioning succeeded" } TenantActivate: type: object properties: plan: { type: string } contract_start: { type: string, format: date } contract_end: { type: string, format: date } erp_customer_id: { type: string } products: type: array description: Entitlements granted with the activation (SKU limits in config). items: type: object required: [key] properties: key: { type: string } config: { type: object, additionalProperties: true } expires_at: { type: string, format: date-time } TenantCancel: type: object properties: reason: { type: string } at_period_end: { type: boolean } TenantProduct: type: object required: [tenant_id, product, enabled, config, created_at, updated_at] properties: tenant_id: { type: string, format: uuid } product: { type: string } enabled: { type: boolean } config: { type: object, additionalProperties: true } expires_at: { type: string, format: date-time, nullable: true } created_at: { type: string, format: date-time } updated_at: { type: string, format: date-time } CatalogEntry: type: object required: [key, name, description, type, plans_required, supports_trial] properties: key: { type: string } name: { type: string } description: { type: string } type: { type: string, enum: [standalone, headless, cli] } launch_url: { type: string, description: "product host for this environment (standalone) or download page (cli)" } skus: { type: array, items: { type: string } } addons: { type: array, items: { $ref: "#/components/schemas/ProductAddon" } } plans_required: { type: array, items: { type: string } } demo_url: { type: string } supports_trial: { type: boolean } trial_days: { type: integer } CatalogRequest: type: object required: [tenant_id, product] properties: tenant_id: { type: string, format: uuid } product: { type: string } APIKey: type: object required: [id, tenant_id, name, scopes, prefix, created_at] properties: id: { type: string, format: uuid } tenant_id: { type: string, format: uuid } product: { type: string } name: { type: string } scopes: { type: array, items: { type: string } } prefix: { type: string } created_by: { type: string } last_used_at: { type: string, format: date-time, nullable: true } revoked_at: { type: string, format: date-time, nullable: true } created_at: { type: string, format: date-time } APIKeyCreate: type: object required: [tenant_id, name] properties: tenant_id: { type: string, format: uuid } name: { type: string, maxLength: 100 } product: { type: string } scopes: { type: array, items: { type: string } } created_by: { type: string } APIKeyCreated: type: object required: [api_key, plaintext, warning] properties: api_key: { $ref: "#/components/schemas/APIKey" } plaintext: { type: string } warning: { type: string } APIKeyVerify: type: object required: [valid] properties: valid: { type: boolean } tenant_id: { type: string, format: uuid } product: { type: string } scopes: { type: array, items: { type: string } } AuditAppend: type: object required: [action] properties: tenant_id: { type: string, format: uuid } project_id: { type: string, format: uuid } actor_id: { type: string } actor_name: { type: string } actor_type: { type: string } action: { type: string } target_id: { type: string } target_type: { type: string } target_name: { type: string } product: { type: string } metadata: { type: object, additionalProperties: true } AuditEvent: allOf: - $ref: "#/components/schemas/AuditAppend" - type: object required: [id, created_at] properties: id: { type: integer, format: int64 } source_ip: { type: string } user_agent: { type: string } created_at: { type: string, format: date-time }