{
  "openapi": "3.1.0",
  "info": {
    "title": "Vision Platform API",
    "version": "1.0.0-preview.2",
    "description": "Machine-readable preview contract for Vision Core identity and installation metadata. Public v1 stability remains acceptance-gated."
  },
  "servers": [
    {
      "url": "https://vision.ivisionstudios.com"
    }
  ],
  "paths": {
    "/oauth/token": {
      "post": {
        "operationId": "exchangeClientCredentials",
        "summary": "Exchange a client credential for a short-lived access token",
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": [
                  "grant_type"
                ],
                "properties": {
                  "grant_type": {
                    "type": "string",
                    "const": "client_credentials"
                  },
                  "client_id": {
                    "type": "string"
                  },
                  "client_secret": {
                    "type": "string",
                    "format": "password",
                    "writeOnly": true
                  },
                  "scope": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Short-lived bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/OAuthError"
          },
          "401": {
            "$ref": "#/components/responses/OAuthError"
          },
          "429": {
            "$ref": "#/components/responses/OAuthError"
          },
          "503": {
            "$ref": "#/components/responses/OAuthError"
          }
        },
        "security": []
      }
    },
    "/platform/v1/organization": {
      "get": {
        "operationId": "getOrganizationBasics",
        "summary": "Read organization and installation metadata",
        "security": [
          {
            "visionBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Authorized organization basics",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrganizationBasics"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiError"
          },
          "403": {
            "$ref": "#/components/responses/ApiError"
          }
        },
        "x-required-scope": "vision.organization.basic:read"
      }
    },
    "/platform/v1/apps": {
      "get": {
        "operationId": "listInstalledApps",
        "summary": "List installed App API metadata",
        "security": [
          {
            "visionBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Installed Apps visible to this client",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiError"
          },
          "403": {
            "$ref": "#/components/responses/ApiError"
          }
        },
        "x-required-scope": "vision.apps:read"
      }
    },
    "/platform/v1/publications/{appId}/{resourceType}/{sourceRecordId}": {
      "get": {
        "operationId": "getPublishedProjection",
        "summary": "Read one allowlisted published App projection",
        "security": [
          {
            "visionBearer": []
          }
        ],
        "parameters": [
          {
            "name": "appId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "resourceType",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceRecordId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Published allowlisted projection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicationProjection"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/ApiError"
          },
          "403": {
            "$ref": "#/components/responses/ApiError"
          },
          "404": {
            "$ref": "#/components/responses/ApiError"
          }
        },
        "x-required-scope": "platform.publications:read"
      }
    },
    "/.well-known/jwks.json": {
      "get": {
        "operationId": "getVerificationKeys",
        "summary": "Read active public token verification keys",
        "responses": {
          "200": {
            "description": "JSON Web Key Set"
          }
        },
        "security": []
      }
    }
  },
  "components": {
    "securitySchemes": {
      "visionBearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Vision-issued access token (JWT). Obtain via the token endpoint of the identity provider configured for this installation."
      }
    },
    "responses": {
      "ApiError": {
        "description": "Safe Platform API error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "OAuthError": {
        "description": "OAuth token endpoint error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/OAuthError"
            }
          }
        }
      }
    },
    "schemas": {
      "TokenResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "access_token",
          "token_type",
          "expires_in",
          "scope"
        ],
        "properties": {
          "access_token": {
            "type": "string"
          },
          "token_type": {
            "type": "string",
            "const": "Bearer"
          },
          "expires_in": {
            "type": "integer",
            "minimum": 60,
            "maximum": 300
          },
          "scope": {
            "type": "string"
          }
        }
      },
      "OAuthError": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "error_description": {
            "type": "string"
          }
        }
      },
      "ApiError": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "code",
              "message",
              "requestId",
              "retryable"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "requestId": {
                "type": "string"
              },
              "retryable": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "OrganizationBasics": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "organization",
          "installation"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "vision-platform-organization.v1"
          },
          "organization": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name"
            ],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "installation": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id"
            ],
            "properties": {
              "id": {
                "type": "string"
              }
            }
          }
        }
      },
      "PublicationProjection": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "appId",
          "resourceType",
          "sourceRecordId",
          "projectionVersion",
          "contentHash",
          "publishedAt",
          "fields"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "vision-publication-projection.v1"
          },
          "appId": {
            "type": "string"
          },
          "resourceType": {
            "type": "string"
          },
          "sourceRecordId": {
            "type": "string"
          },
          "projectionVersion": {
            "type": "string"
          },
          "contentHash": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "publishedAt": {
            "type": "string",
            "format": "date-time"
          },
          "fields": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "AppList": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "items",
          "page"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "vision-platform-app-list.v1"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id",
                "name",
                "version",
                "status"
              ],
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "version": {
                  "type": "string"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "installed",
                    "degraded",
                    "unavailable"
                  ]
                }
              }
            }
          },
          "page": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "nextCursor",
              "hasMore"
            ],
            "properties": {
              "nextCursor": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "hasMore": {
                "type": "boolean"
              }
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "visionBearer": []
    }
  ]
}
