{
  "openapi": "3.1.0",
  "info": {
    "title": "GroundIT — Deployment resolution and version probe",
    "version": "0.1.0",
    "license": {
      "name": "Proprietary — GroundIT/Sysmedac internal"
    },
    "description": "Public, unauthenticated endpoints the mobile app uses BEFORE sign-in to connect to an on-prem GroundIT deployment by company code, and to check an API's compatibility with the app. Served by the cloud API (the app's build-time default) for `resolve`/`public-key`; `meta/version` is served by every API. No database is involved: the deployment registry and the Ed25519 signing key are configuration. See planning/ops-docs/deployment-registry-and-company-code.md.\n"
  },
  "servers": [
    {
      "url": "/api/v1"
    }
  ],
  "security": [],
  "tags": [
    {
      "name": "public-deployments",
      "description": "Company-code resolution and API version probe."
    }
  ],
  "paths": {
    "/deployments/resolve": {
      "get": {
        "operationId": "xc.public_deployments.resolve",
        "summary": "Resolve a company code to a signed on-prem deployment descriptor",
        "description": "Case-insensitive `code` (`^[A-Za-z0-9-]{2,32}$`). The answer is signed (Ed25519) over the canonical JSON of every other field — keys sorted lexicographically, no whitespace, UTF-8, `min_app_version` omitted when absent. Clients MUST verify the signature against the published public key, MUST reject an expired answer, and MUST require https on `api_base_url`. Rate-limited per client IP (429 with `Retry-After`). An unknown code is a generic 404.\n",
        "tags": [
          "public-deployments"
        ],
        "x-token": "xc.public_deployments.resolve",
        "x-realizes-features": [],
        "x-screens": [],
        "x-touches-entities": [],
        "x-idempotent": true,
        "x-market": "both",
        "x-sync-async": "sync",
        "x-emits-event": null,
        "x-rls-scope": "tenant",
        "x-append-only": false,
        "x-entitlement": null,
        "x-provisional": null,
        "parameters": [
          {
            "name": "code",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9-]{2,32}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The signed deployment descriptor.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignedDeployment"
                }
              }
            }
          },
          "400": {
            "description": "The code does not match the strict format.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/deployments/public-key": {
      "get": {
        "operationId": "xc.public_deployments.get_public_key",
        "summary": "The Ed25519 public key that verifies resolve answers",
        "description": "For operators to copy into the app build (`--dart-define=DEPLOYMENT_PUBLIC_KEY=<public_key>`). The app must NOT fetch its trust anchor from this endpoint at run time.\n",
        "tags": [
          "public-deployments"
        ],
        "x-token": "xc.public_deployments.get_public_key",
        "x-realizes-features": [],
        "x-screens": [],
        "x-touches-entities": [],
        "x-idempotent": true,
        "x-market": "both",
        "x-sync-async": "sync",
        "x-emits-event": null,
        "x-rls-scope": "tenant",
        "x-append-only": false,
        "x-entitlement": null,
        "x-provisional": null,
        "responses": {
          "200": {
            "description": "The public key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeploymentPublicKey"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/meta/version": {
      "get": {
        "operationId": "xc.public_meta.get_version",
        "summary": "API version and minimum supported app version",
        "description": "Cheap compatibility probe (no database, unlike `/health`). The app compares its own version with `min_app_version` and refuses an on-prem API it cannot speak to.\n",
        "tags": [
          "public-deployments"
        ],
        "x-token": "xc.public_meta.get_version",
        "x-realizes-features": [],
        "x-screens": [],
        "x-touches-entities": [],
        "x-idempotent": true,
        "x-market": "both",
        "x-sync-async": "sync",
        "x-emits-event": null,
        "x-rls-scope": "tenant",
        "x-append-only": false,
        "x-entitlement": null,
        "x-provisional": null,
        "responses": {
          "200": {
            "description": "Versions.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MetaVersion"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "SignedDeployment": {
        "type": "object",
        "required": [
          "code",
          "display_name",
          "api_base_url",
          "web_url",
          "issued_at",
          "expires_at",
          "signature"
        ],
        "additionalProperties": false,
        "properties": {
          "code": {
            "type": "string",
            "description": "Canonical upper-case company code."
          },
          "display_name": {
            "type": "string"
          },
          "api_base_url": {
            "type": "string",
            "format": "uri",
            "description": "https origin only; no path, query or credentials."
          },
          "web_url": {
            "type": "string",
            "format": "uri"
          },
          "min_app_version": {
            "type": "string",
            "description": "Minimum app version for this deployment (semver); omitted when unset."
          },
          "issued_at": {
            "type": "string",
            "format": "date-time"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "signature": {
            "type": "string",
            "description": "Base64 (standard, padded) Ed25519 signature over the canonical JSON of all other fields."
          }
        }
      },
      "DeploymentPublicKey": {
        "type": "object",
        "required": [
          "algorithm",
          "public_key",
          "public_key_pem"
        ],
        "additionalProperties": false,
        "properties": {
          "algorithm": {
            "type": "string",
            "enum": [
              "Ed25519"
            ]
          },
          "public_key": {
            "type": "string",
            "description": "Base64 of the raw 32-byte public key."
          },
          "public_key_pem": {
            "type": "string"
          }
        }
      },
      "MetaVersion": {
        "type": "object",
        "required": [
          "api_version",
          "min_app_version"
        ],
        "additionalProperties": false,
        "properties": {
          "api_version": {
            "type": "string"
          },
          "min_app_version": {
            "type": "string",
            "description": "Semver; `0.0.0` when the operator sets no floor."
          }
        }
      },
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem detail (application/problem+json). The platform-wide error envelope (03 §1).",
        "required": [
          "type",
          "title",
          "status"
        ],
        "properties": {
          "type": {
            "type": "string",
            "format": "uri",
            "default": "about:blank",
            "description": "Problem-type URI."
          },
          "title": {
            "type": "string",
            "description": "Short, human-readable summary (stable per type)."
          },
          "status": {
            "type": "integer",
            "description": "HTTP status code, duplicated for convenience."
          },
          "detail": {
            "type": "string",
            "description": "Human-readable explanation specific to this occurrence."
          },
          "instance": {
            "type": "string",
            "description": "URI reference for this specific occurrence."
          },
          "code": {
            "$ref": "#/components/schemas/ErrorCode"
          },
          "correlation_id": {
            "$ref": "#/components/schemas/Uuid"
          }
        }
      },
      "ErrorCode": {
        "type": "string",
        "description": "Machine-stable error code (paired with the HTTP status; drives client handling, not display copy).",
        "enum": [
          "VALIDATION_FAILED",
          "IDEMPOTENCY_KEY_REUSE",
          "VERSION_CONFLICT",
          "PRECONDITION_REQUIRED",
          "MAKER_EQUALS_CHECKER",
          "STEP_UP_REQUIRED",
          "CONSENT_REQUIRED",
          "TOKEN_DENIED",
          "SCOPE_DENIED",
          "OWNERSHIP_DENIED",
          "STATE_TRANSITION_INVALID",
          "FACE_MISMATCH",
          "FACE_VERIFICATION_REQUIRED",
          "WITHHOLDING_REVIEW_REQUIRED",
          "FEATURE_NOT_IN_PLAN",
          "PLAN_LIMIT_REACHED",
          "READ_ONLY_SESSION",
          "TRIAL_EXPIRED",
          "SUPPORT_GRANT_EXISTS",
          "SUPPORT_GRANT_NOT_FOUND",
          "CUSTOM_DOMAIN_TAKEN",
          "TENANT_BIND_CONFLICT",
          "OWNER_NOT_FOUND",
          "PASSWORD_CHANGE_NOT_REQUIRED",
          "TENANT_PAST_DUE",
          "TENANT_PROTECTED",
          "TENANT_SUSPENDED",
          "TENANT_CANCELLED",
          "RATE_LIMITED",
          "NOT_FOUND"
        ]
      },
      "Uuid": {
        "type": "string",
        "format": "uuid",
        "description": "UUIDv7 surrogate primary key (db-docs/00 §3). Never the business identifier."
      }
    },
    "responses": {
      "NotFound": {
        "description": "Resource does not exist OR is masked by RLS (tenant/self/team/branch scope) — the API does not distinguish, so existence is never confirmed across a scope boundary (02 §4 disclosure posture).\n",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "Per-principal/route rate limit exceeded.",
        "headers": {
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      }
    },
    "headers": {
      "RetryAfter": {
        "description": "Seconds to wait before retrying (on 429 / 503).",
        "schema": {
          "type": "integer"
        }
      }
    }
  }
}