{"openapi":"3.0.3","info":{"title":"License Migration Service API","version":"1.0.0","description":"Self-service OST → GCIP license-migration orchestrator. Verifies a legacy Flexera license and provisions a GCIP user + seat. Wave mapping upload is an admin surface. This spec is auto-generated from the service’s zod request-validation schemas; it never contains secrets or real license codes."},"servers":[{"url":"/license-migration","description":"Base path behind the Apigee gateway — prepend the environment host, e.g. https://api-dev.io.constructconnect.com. For a direct local run the base path is \"/\"; the docs UI computes the correct base from its own URL."}],"tags":[{"name":"Migration","description":"Self-service migration flow called by the SPA."},{"name":"Flexera Admin","description":"Privileged surfaces: the scheduled deactivation sweep, wave licence-to-org mapping upload, and (non-production) fixture reset."}],"components":{"securitySchemes":{"FlexeraUploadSharedHeader":{"type":"apiKey","in":"header","name":"x-api-key","description":"A shared credential accepted as an ALTERNATIVE to the requestor JWT documented on this operation (additive OR — either is sufficient, never both required). A correct value is accepted outright; a missing or incorrect value falls through to the JWT + allowlist check unchanged, so a stale value here can never break a caller who also holds a valid JWT."}},"schemas":{"ApiError":{"type":"object","properties":{"error":{"type":"string","enum":["INVALID_CODE","ALREADY_MIGRATED","IN_PROGRESS","NO_AVAILABLE_SEAT","EMAIL_IN_OTHER_ORG","ALREADY_HAS_ACCESS","ORG_INACTIVE","ORG_NOT_PROVISIONED","UPSTREAM_ERROR","BAD_REQUEST","RATE_LIMITED","UNSUPPORTED_MULTI_PARENT","DEACTIVATION_FAILED","REACTIVATION_FAILED","UNAUTHORIZED","FORBIDDEN"],"example":"INVALID_CODE"},"message":{"type":"string","example":"Unrecognized or expired license code."}},"required":["error","message"],"description":"Typed error body returned by every /api endpoint on failure."},"ProvisionResponse":{"type":"object","properties":{"email":{"type":"string","format":"email","description":"The address the welcome/reset email was sent to.","example":"jane.doe@example.com"},"orgName":{"type":"string","description":"The organization the seat was granted in, for display. Moved here from the removed GET /api/session — it was the only field of that response the SPA consumed. The organization ID is deliberately absent and never reaches the browser.","example":"Example Drywall Co."},"seatAssigned":{"type":"boolean","description":"False when no seat could be granted: the account was still created/kept (migrate-without-seat) but no module was assigned — a success-with-warning the SPA surfaces.","example":true},"seatWithheldReason":{"type":"string","enum":["MIGRATION_CAPACITY_EXHAUSTED"],"description":"Present only when the seat was withheld because every seat the LICENCE paid for is already claimed — as opposed to the organization’s module being full, which is the unqualified seatAssigned:false. The account is still created either way.","example":"MIGRATION_CAPACITY_EXHAUSTED"},"tier":{"type":"string","description":"The licence’s access tier as a display name (Standard | Advanced | Premium), for the Success screen’s \"On-Screen Takeoff <tier>\" copy. Derived from the entitlement’s Flexera line-item product name; present in every success outcome where a tier resolved, whether or not a seat was granted, and absent only when no line item matched a configured tier filter.","example":"Standard"},"moduleSelectionReason":{"type":"string","enum":["no-tier-match","no-matching-module","no-free-seats","not-assignable","multiple-matches"],"description":"Non-production diagnostic only. Present when selectModule refused a seat, so QA can assert the exact reason. Never set in production; never a substitute for seatWithheldReason.","example":"no-free-seats"}},"required":["email","orgName","seatAssigned"]},"SeatMappingUploadResponse":{"type":"object","properties":{"uploadId":{"type":"string","description":"Correlates this upload with its audit lines.","example":"5f6c1e2a-0000-4a00-8000-0000000000aa"},"sourceDigest":{"type":"string","description":"SHA-256 of the uploaded bytes — the audit’s file digest.","example":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},"parsed":{"type":"integer","description":"Data rows accepted by the parser.","example":10},"written":{"type":"integer","description":"Rows whose organization changed (or were new).","example":10},"unchanged":{"type":"integer","description":"Rows already current — a re-upload of the same file writes nothing.","example":0},"skipped":{"type":"object","additionalProperties":{"type":"integer"},"description":"Benign noise, counted by reason (blank-row, pre-header-row, duplicate-row). Reported separately from a rejection so \"skipped N blank rows\" is never read as an error.","example":{"blank-row":1}},"notes":{"type":"object","additionalProperties":{"type":"integer"},"description":"Non-fatal observations, counted by reason (padded-value, unknown-columns-ignored).","example":{"unknown-columns-ignored":1}}},"required":["uploadId","sourceDigest","parsed","written","unchanged","skipped","notes"]},"ProvisionRequest":{"type":"object","properties":{"code":{"type":"string","minLength":4,"maxLength":128},"firstName":{"type":"string","minLength":1,"maxLength":50},"lastName":{"type":"string","minLength":1,"maxLength":50},"email":{"type":"string","maxLength":254,"format":"email"}},"required":["code","firstName","lastName","email"],"example":{"code":"OST+ABCD1-2345E-FGH67-89JKL-MNPQR","firstName":"Jane","lastName":"Doe","email":"jane.doe@example.com"}},"FixtureResetRequest":{"type":"object","properties":{"accounts":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string","minLength":4,"maxLength":128},"migrantEmails":{"type":"array","items":{"type":"string","maxLength":254,"format":"email"},"minItems":1,"maxItems":32}},"required":["code","migrantEmails"]},"minItems":1,"maxItems":32}},"required":["accounts"],"example":{"accounts":[{"code":"OST+ABCD1-2345E-FGH67-89JKL-MNPQR","migrantEmails":["migrant@example.com"]}]}},"FixtureResetResponse":{"type":"object","properties":{"status":{"type":"string","enum":["reset","failed"],"description":"\"reset\" on a clean run; \"failed\" when any account did not fully reset. Failed batches return 502 when any account failed with UPSTREAM_ERROR or FORBIDDEN, otherwise 409.","example":"reset"},"accounts":{"type":"array","items":{"type":"object","properties":{"codeFingerprint":{"type":"string","example":"a1b2c3d4e5f6"},"ok":{"type":"boolean"},"errorCode":{"type":"string","enum":["INVALID_CODE","ALREADY_MIGRATED","IN_PROGRESS","NO_AVAILABLE_SEAT","EMAIL_IN_OTHER_ORG","ALREADY_HAS_ACCESS","ORG_INACTIVE","ORG_NOT_PROVISIONED","UPSTREAM_ERROR","BAD_REQUEST","RATE_LIMITED","UNSUPPORTED_MULTI_PARENT","DEACTIVATION_FAILED","REACTIVATION_FAILED","UNAUTHORIZED","FORBIDDEN"],"description":"Typed MigrationErrorCode when ok is false."},"error":{"type":"string","description":"Generic, value-free message when ok is false. Never an upstream reason."},"layers":{"type":"object","properties":{"gcip":{"type":"array","items":{"type":"object","properties":{"emailFingerprint":{"type":"string"},"outcome":{"type":"string","enum":["unassigned","already-clear","absent"]}},"required":["emailFingerprint","outcome"]}},"ledger":{"type":"array","items":{"type":"object","properties":{"emailFingerprint":{"type":"string"},"outcome":{"type":"string","enum":["deleted","absent"]}},"required":["emailFingerprint","outcome"]}},"flexera":{"type":"string","enum":["deployed"],"description":"The reactivate path verified the entitlement is DEPLOYED. Prior state is not reported."}},"required":["gcip","ledger","flexera"]},"protectedHoldersVerified":{"type":"boolean"}},"required":["codeFingerprint","ok"]}}},"required":["status","accounts"]}},"parameters":{}},"paths":{"/api/provision":{"post":{"tags":["Migration"],"summary":"Provision a GCIP user + license (single-use per person)","description":"Mutating, and single-use per (licence, email): one licence carries as many seats as it purchased, so N different people may migrate on it, but each of them only once. Resolves the license code through the licence-to-organization mapping BEFORE ANY MUTATION (and before anything is reserved) — a code that is not in an uploaded wave is 404 INVALID_CODE and is never even reservable. An OST@ device code additionally resolves to its single parent entitlement, concurrently, because single use is keyed on that parent. Then claims this person’s migration together with a purchased-seat permit, resolves the organization server-side from the id THE MAPPING supplied (the client sends no organization id and never learns one), resolves the email against existing users (rejecting a cross-org duplicate or one that already holds a seat), creates or refreshes the GCIP user (which triggers the welcome/reset email), and assigns the seat for the Classic module matching the licence’s own access tier (derived from the entitlement’s Flexera line-item product name). When the organization has no module for that tier, the module is full, the tier cannot be determined, OR every seat the licence paid for is already claimed, the migration still succeeds: the account is created without a module and the response carries seatAssigned:false, with the reason audited — and for the licence-capacity case, reported as seatWithheldReason. A trial module is never granted. On any failure after the claim it is released so that person can retry.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProvisionRequest"}}}},"responses":{"201":{"description":"Account provisioned. seatAssigned is false when no seat could be granted (success-with-warning); seatWithheldReason is present only when the cause was the licence’s own purchased seats being exhausted rather than the organization’s module.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProvisionResponse"}}}},"400":{"description":"Missing or invalid fields (BAD_REQUEST): a license code containing a space, outside the length bounds, or not carrying an anchored \"OST+\"/\"OST@\" prefix — this funnel migrates OST licences only, and a Boost code is named as such rather than being told the rule. Nothing is forwarded upstream.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"The license code does not belong to the link’s account (INVALID_CODE).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"This person has already migrated this licence (ALREADY_MIGRATED), their own attempt is in progress (IN_PROGRESS), no organization exists for the id yet (ORG_NOT_PROVISIONED), inactive org (ORG_INACTIVE), email exists in another organization (EMAIL_IN_OTHER_ORG), the user already holds a seat (ALREADY_HAS_ACCESS), or a server code resolves to more than one parent entitlement (UNSUPPORTED_MULTI_PARENT — only single-parent server codes are supported).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"429":{"description":"Too many requests — the per-IP /api rate limit was exceeded (RATE_LIMITED).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"502":{"description":"A dependent upstream service failed (UPSTREAM_ERROR).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/admin/flexera-license-to-entitlement-org":{"post":{"tags":["Flexera Admin"],"summary":"Upload the wave licence-to-organization mapping (CSV)","description":"Manually operated by a named few. Uploads the wave CSV that binds each Flexera licence code to the GCIP organization whose seat it grants — the mapping the migration flow resolves against, which is why it is the highest-value target in the service. Requires EITHER the requestor JWT that Apigee forwards in x-gw-authorization — the verified identity must appear on a per-environment allowlist, and a refusal is audited with the identity that was refused — OR the shared header credential described by the FlexeraUploadSharedHeader security scheme below (additive OR: either is sufficient; a wrong or absent shared value simply falls through to the JWT check). Body is text/csv, not JSON, and is parsed by HEADER NAME: the two required columns are \"Entitlement Org ID\" and \"Activation ID\", in any order, among any number of ignored ones. Synchronous and idempotent — an unchanged row is a no-op, so re-running the same file is also the documented recovery from a partial write. Pass force=true to bypass that idempotency check and rewrite every row regardless (see the force parameter below) — the recovery for a row that is unreadable under the currently-configured key but whose digest still matches. The whole file is validated before the first write: benign noise (blank rows, a title row above the header, padded values) is skipped and reported, while ambiguous data (an unparseable code, a malformed GUID, one code claiming two organizations) rejects the entire upload. Errors report by ROW NUMBER and never echo a licence code or an organization id. Organization ids are stored encrypted.","security":[{"FlexeraUploadSharedHeader":[]}],"parameters":[{"schema":{"type":"string","enum":["true"],"description":"Rewrites every row even when its organization id is unchanged, bypassing the orgIdDigest/schemaVersion comparator that otherwise makes an unchanged row a no-op. This is the recovery path for a row whose sealed value cannot be read with the currently-configured key (e.g. right after a KMS key rotation/rename) while its digest still matches what a normal re-run would compare against and skip. Any value other than exactly \"true\" behaves as a normal upload."},"required":false,"description":"Rewrites every row even when its organization id is unchanged, bypassing the orgIdDigest/schemaVersion comparator that otherwise makes an unchanged row a no-op. This is the recovery path for a row whose sealed value cannot be read with the currently-configured key (e.g. right after a KMS key rotation/rename) while its digest still matches what a normal re-run would compare against and skip. Any value other than exactly \"true\" behaves as a normal upload.","name":"force","in":"query"}],"requestBody":{"required":true,"content":{"text/csv":{"schema":{"type":"string","description":"The wave CSV, as exported. A UTF-8 BOM, CRLF endings, quoted fields containing commas and trailing blank rows are all tolerated.","example":"Entitlement Org ID,Activation ID\r\n0a0a0a0a-0b0b-4c0c-8d0d-0e0e0f0f1a1a,OST+ABCD1-2345E-FGH67-89JKL-MNPQR\r\n"}}}},"responses":{"200":{"description":"The wave was applied. Row counts distinguish what was written from what was already current, and \"skipped\" (benign noise) is reported separately from a rejection.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SeatMappingUploadResponse"}}}},"400":{"description":"The file was rejected and NOTHING was written (BAD_REQUEST): a missing required column, or one or more ambiguous rows. The error body carries a `details` object listing errors by row number and column name, capped with a total.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"401":{"description":"Neither credential authenticated the request (UNAUTHORIZED): the requestor JWT was missing or invalid, and the alternative shared header, if presented, did not match either.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"The caller authenticated via the requestor JWT but is not on the upload allowlist (FORBIDDEN) — only that path can produce a 403; a correct shared-header credential never reaches the allowlist check. The refusal is audited with the identity; the response never says who is permitted.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"413":{"description":"The body exceeded the configured size cap (BAD_REQUEST).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"429":{"description":"Too many requests — the per-IP /api rate limit was exceeded (RATE_LIMITED).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/admin/fixture-reset":{"post":{"tags":["Flexera Admin"],"summary":"Reset sandbox fixture state (non-production only)","description":"Guarded, non-production-only endpoint that clears GCIP migrant seats + per-email ledger claims and restores the Flexera parent to DEPLOYED for codes named in a server-owned digest manifest. A request may only name a code that has a manifest entry, and that entry — not the caller — fixes the organization and module the reset may touch; an unlisted code, or a protected seat holder named as a migrant, refuses the WHOLE request before any mutation. Auth is a service-account OIDC token (not the human uploader gate). Never registered in production.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FixtureResetRequest"}}}},"responses":{"200":{"description":"Every named account reset cleanly.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FixtureResetResponse"}}}},"400":{"description":"Schema-invalid body, or the batch failed the manifest check (BAD_REQUEST).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"401":{"description":"The service-account token was missing or invalid (UNAUTHORIZED).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"403":{"description":"The caller authenticated but is not on the fixture-reset allowlist (FORBIDDEN). The refusal is audited with the identity.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"409":{"description":"One or more accounts failed with a non-upstream error (e.g. REACTIVATION_FAILED, BAD_REQUEST); every account’s outcome is returned.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FixtureResetResponse"}}}},"429":{"description":"Too many requests — the per-IP /api rate limit was exceeded (RATE_LIMITED).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"502":{"description":"One or more accounts failed with UPSTREAM_ERROR or an entitlements authorization failure (FORBIDDEN); every account’s outcome is returned.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FixtureResetResponse"}}}}}}}}}