{
  "openapi": "3.1.0",
  "info": {
    "title": "Varity Public Platform API",
    "version": "2026-07-10",
    "description": "Gateway-owned resource API for deploying and operating Varity apps."
  },
  "servers": [
    {
      "url": "https://varity.app/api"
    }
  ],
  "security": [
    {
      "ApiKeyAuth": []
    }
  ],
  "paths": {
    "/deployments": {
      "get": {
        "operationId": "listDeployments",
        "summary": "List deployments",
        "responses": {
          "200": {
            "description": "Deployment list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeploymentList"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/PublicError"
          }
        }
      },
      "post": {
        "operationId": "createDeployment",
        "summary": "Create a deployment",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDeploymentRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Deployment accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AcceptedDeployment"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/PublicError"
          }
        }
      }
    },
    "/deployments/runs/{run_id}": {
      "get": {
        "operationId": "getDeploymentRun",
        "summary": "Get deployment run status",
        "parameters": [
          {
            "$ref": "#/components/parameters/RunId"
          },
          {
            "name": "app",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deployment run status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeploymentRunStatus"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/PublicError"
          }
        }
      }
    },
    "/deployments/{deployment_id}": {
      "get": {
        "operationId": "getDeployment",
        "summary": "Get a deployment",
        "parameters": [
          {
            "$ref": "#/components/parameters/DeploymentId"
          }
        ],
        "responses": {
          "200": {
            "description": "Deployment",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deployment"
                  ],
                  "properties": {
                    "deployment": {
                      "$ref": "#/components/schemas/Deployment"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/PublicError"
          }
        }
      },
      "delete": {
        "operationId": "deleteDeployment",
        "summary": "Delete a deployment",
        "parameters": [
          {
            "$ref": "#/components/parameters/DeploymentId"
          }
        ],
        "responses": {
          "200": {
            "description": "Deployment deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "status",
                    "deleted"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "const": "deleted"
                    },
                    "deleted": {
                      "const": true
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/PublicError"
          }
        }
      }
    },
    "/deployments/{deployment_id}/redeploy": {
      "post": {
        "operationId": "redeployDeployment",
        "summary": "Redeploy in place",
        "parameters": [
          {
            "$ref": "#/components/parameters/DeploymentId"
          }
        ],
        "responses": {
          "202": {
            "description": "Redeploy accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AcceptedMutation"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/PublicError"
          }
        }
      }
    },
    "/deployments/{deployment_id}/restart": {
      "post": {
        "operationId": "restartDeployment",
        "summary": "Restart in place",
        "parameters": [
          {
            "$ref": "#/components/parameters/DeploymentId"
          }
        ],
        "responses": {
          "202": {
            "description": "Restart accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AcceptedMutation"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/PublicError"
          }
        }
      }
    },
    "/deployments/{deployment_id}/logs": {
      "get": {
        "operationId": "listDeploymentLogs",
        "summary": "Read deployment logs",
        "parameters": [
          {
            "$ref": "#/components/parameters/DeploymentId"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 200
            }
          },
          {
            "name": "since_seq",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deployment logs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LogList"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/PublicError"
          }
        }
      }
    },
    "/deployments/{deployment_id}/events": {
      "get": {
        "operationId": "listDeploymentEvents",
        "summary": "Read deployment events",
        "parameters": [
          {
            "$ref": "#/components/parameters/DeploymentId"
          }
        ],
        "responses": {
          "200": {
            "description": "Deployment events",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventList"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/PublicError"
          }
        }
      }
    },
    "/deployments/{deployment_id}/health-history": {
      "get": {
        "operationId": "readDeploymentHealthHistory",
        "summary": "Read durable runtime and route health history",
        "parameters": [
          {
            "$ref": "#/components/parameters/DeploymentId"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Durable health history",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthHistory"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/PublicError"
          }
        }
      }
    },
    "/deployments/{deployment_id}/env": {
      "get": {
        "operationId": "listDeploymentEnv",
        "summary": "List environment variable keys",
        "parameters": [
          {
            "$ref": "#/components/parameters/DeploymentId"
          }
        ],
        "responses": {
          "200": {
            "description": "Environment variable keys",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnvKeyList"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/PublicError"
          }
        }
      },
      "patch": {
        "operationId": "patchDeploymentEnv",
        "summary": "Update environment variables",
        "parameters": [
          {
            "$ref": "#/components/parameters/DeploymentId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EnvUpdateRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Update accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AcceptedMutation"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/PublicError"
          }
        }
      }
    },
    "/templates": {
      "get": {
        "operationId": "listTemplates",
        "summary": "List templates",
        "responses": {
          "200": {
            "description": "Template list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateList"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/PublicError"
          }
        }
      }
    },
    "/templates/{template_id}": {
      "get": {
        "operationId": "getTemplate",
        "summary": "Get a template",
        "parameters": [
          {
            "$ref": "#/components/parameters/TemplateId"
          }
        ],
        "responses": {
          "200": {
            "description": "Template",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "template"
                  ],
                  "properties": {
                    "template": {
                      "$ref": "#/components/schemas/Template"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/PublicError"
          }
        }
      }
    },
    "/templates/{template_id}/deploy": {
      "post": {
        "operationId": "deployTemplate",
        "summary": "Deploy a template",
        "parameters": [
          {
            "$ref": "#/components/parameters/TemplateId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateDeployRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Deployment accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AcceptedDeployment"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/PublicError"
          }
        }
      }
    },
    "/pricing/estimate": {
      "get": {
        "operationId": "estimatePricing",
        "summary": "Estimate fixed monthly cost",
        "parameters": [
          {
            "name": "profile",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "examples": [
                "web-app",
                "static-site",
                "web-app-db"
              ]
            }
          },
          {
            "name": "cpu",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "minimum": 0.25
            }
          },
          {
            "name": "memory_gb",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "minimum": 0.25
            }
          },
          {
            "name": "ephemeral_gb",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "minimum": 1
            }
          },
          {
            "name": "persistent_gb",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "minimum": 0
            }
          },
          {
            "name": "has_db",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Pricing estimate",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PricingEstimate"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/PublicError"
          }
        }
      }
    },
    "/credits": {
      "get": {
        "operationId": "getCredits",
        "summary": "Get credit and payment state",
        "responses": {
          "200": {
            "description": "Credit and payment state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreditState"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/PublicError"
          }
        }
      }
    },
    "/webhooks": {
      "get": {
        "operationId": "listWebhooks",
        "summary": "List webhooks",
        "parameters": [
          {
            "name": "include_deliveries",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Webhook list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookList"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/PublicError"
          }
        }
      },
      "post": {
        "operationId": "createWebhook",
        "summary": "Create a webhook",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWebhookRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Webhook created; signing_secret is shown once",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedWebhook"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/PublicError"
          }
        }
      }
    },
    "/webhooks/{webhook_id}": {
      "delete": {
        "operationId": "deleteWebhook",
        "summary": "Delete a webhook",
        "parameters": [
          {
            "name": "webhook_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Webhook deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "deleted"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "deleted": {
                      "const": true
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/PublicError"
          }
        }
      }
    },
    "/api-keys": {
      "get": {
        "security": [
          {
            "PortalSession": []
          }
        ],
        "operationId": "listApiKeys",
        "summary": "List API keys in the Developer Portal",
        "description": "Requires an authenticated Developer Portal session. Plaintext API keys are never returned.",
        "responses": {
          "200": {
            "description": "API key metadata",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKeyList"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/PublicError"
          }
        }
      },
      "post": {
        "security": [
          {
            "PortalSession": []
          }
        ],
        "operationId": "createApiKey",
        "summary": "Create an API key in the Developer Portal",
        "description": "Requires an authenticated Developer Portal session and active deploy eligibility. The plaintext key is shown once.",
        "responses": {
          "200": {
            "description": "New API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IssuedApiKey"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/PublicError"
          }
        }
      }
    },
    "/api-keys/{key_id}": {
      "delete": {
        "security": [
          {
            "PortalSession": []
          }
        ],
        "operationId": "deleteApiKey",
        "summary": "Revoke an API key in the Developer Portal",
        "description": "Requires an authenticated Developer Portal session. Revocation is owner-scoped.",
        "parameters": [
          {
            "name": "key_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "API key revoked",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "revoked": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/PublicError"
          }
        }
      }
    },
    "/openapi.json": {
      "get": {
        "security": [],
        "operationId": "getOpenApiDocument",
        "summary": "Get the public API contract",
        "responses": {
          "200": {
            "description": "OpenAPI document"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Varity API key"
      },
      "PortalSession": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Developer Portal session credential"
      }
    },
    "parameters": {
      "DeploymentId": {
        "name": "deployment_id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "RunId": {
        "name": "run_id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "TemplateId": {
        "name": "template_id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": false,
        "schema": {
          "type": "string",
          "maxLength": 160
        }
      }
    },
    "responses": {
      "PublicError": {
        "description": "Public API error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/PublicError"
            }
          }
        }
      }
    },
    "schemas": {
      "PublicError": {
        "type": "object",
        "required": [
          "code",
          "message",
          "action",
          "retryable",
          "docs_url"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "action": {
            "type": "string"
          },
          "retryable": {
            "type": "boolean"
          },
          "docs_url": {
            "type": "string",
            "format": "uri"
          },
          "field": {
            "type": "string"
          },
          "correlation_id": {
            "type": "string"
          }
        }
      },
      "Deployment": {
        "type": "object",
        "required": [
          "id",
          "app_name",
          "subdomain",
          "status",
          "runtime",
          "public_url"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "app_name": {
            "type": "string"
          },
          "subdomain": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "deploying",
              "live",
              "deleted",
              "unknown"
            ]
          },
          "runtime": {
            "type": "string",
            "enum": [
              "static",
              "dynamic"
            ]
          },
          "public_url": {
            "type": "string",
            "format": "uri"
          },
          "created_at": {
            "type": "string"
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "deleted_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "closure_reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "source": {
            "$ref": "#/components/schemas/DeploymentSource"
          },
          "resource_profile": {
            "$ref": "#/components/schemas/ResourceProfile"
          },
          "billing": {
            "$ref": "#/components/schemas/DeploymentBilling"
          }
        }
      },
      "DeploymentSource": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "repository",
              "image",
              "template",
              "unknown"
            ]
          },
          "template_id": {
            "type": "string"
          }
        }
      },
      "ResourceProfile": {
        "type": [
          "object",
          "null"
        ],
        "properties": {
          "cpu_units": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0.25,
            "maximum": 4
          },
          "memory_mb": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 256,
            "maximum": 8192
          },
          "storage_mb": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 512,
            "maximum": 20480
          },
          "persistent_storage_gb": {
            "type": [
              "integer",
              "null"
            ]
          },
          "attached_resources": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "DeploymentBilling": {
        "type": [
          "object",
          "null"
        ],
        "properties": {
          "fixed_monthly_cost_usd": {
            "type": "number"
          },
          "fixed_monthly_usd": {
            "type": "number"
          },
          "accrued_this_month_usd": {
            "type": "number"
          },
          "currency": {
            "type": "string"
          }
        }
      },
      "DeploymentList": {
        "type": "object",
        "required": [
          "deployments"
        ],
        "properties": {
          "deployments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Deployment"
            }
          }
        }
      },
      "AcceptedDeployment": {
        "type": "object",
        "required": [
          "id",
          "app_name",
          "status",
          "runtime",
          "public_url",
          "run_id",
          "status_url"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "app_name": {
            "type": "string"
          },
          "subdomain": {
            "type": "string"
          },
          "status": {
            "const": "deploying"
          },
          "runtime": {
            "type": "string",
            "enum": [
              "static",
              "dynamic"
            ]
          },
          "public_url": {
            "type": "string",
            "format": "uri"
          },
          "run_id": {
            "type": "string"
          },
          "status_url": {
            "type": "string"
          }
        }
      },
      "AcceptedMutation": {
        "type": "object",
        "required": [
          "id",
          "status"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "app_name": {
            "type": "string"
          },
          "subdomain": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "run_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "status_url": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "DeploymentRunStatus": {
        "type": "object",
        "properties": {
          "runId": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "succeeded",
              "failed"
            ]
          },
          "stage": {
            "type": [
              "string",
              "null"
            ]
          },
          "frontendUrl": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "errorMessage": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "LogList": {
        "type": "object",
        "required": [
          "lines",
          "count",
          "complete"
        ],
        "properties": {
          "lines": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "count": {
            "type": "integer"
          },
          "complete": {
            "type": "boolean",
            "description": "False when the returned window may be partial, for example when the live runtime source was momentarily unavailable. When false, warning_code is set and the request is safe to retry for a complete window."
          },
          "observed_at": {
            "type": ["string", "null"],
            "description": "ISO 8601 timestamp of the live runtime read behind this window, or null when no live read was captured."
          },
          "warning_code": {
            "type": "string",
            "description": "Present only when `complete` is false (e.g. `logs_incomplete`)."
          },
          "retryable": {
            "type": "boolean",
            "description": "Present only when `complete` is false; the read is safe to retry."
          }
        }
      },
      "EventList": {
        "type": "object",
        "required": [
          "events",
          "complete"
        ],
        "properties": {
          "complete": {
            "type": "boolean",
            "description": "False when the returned events may be partial, for example when the live runtime source was momentarily unavailable. When false, warning_code is set and the request is safe to retry."
          },
          "observed_at": {
            "type": ["string", "null"],
            "description": "ISO 8601 timestamp of the live runtime read behind these events, or null when no live read was captured."
          },
          "warning_code": {
            "type": "string",
            "description": "Present only when `complete` is false (e.g. `events_incomplete`)."
          },
          "retryable": {
            "type": "boolean",
            "description": "Present only when `complete` is false; the read is safe to retry."
          },
          "events": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "id",
                "type",
                "message",
                "created_at"
              ],
              "properties": {
                "id": {
                  "type": "string"
                },
                "type": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                },
                "created_at": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "HealthHistory": {
        "type": "object",
        "required": [
          "summary",
          "observations"
        ],
        "properties": {
          "summary": {
            "type": "object",
            "required": [
              "runtime_state",
              "runtime_reason",
              "route_state",
              "route_reason",
              "consecutive_runtime_failures",
              "consecutive_route_failures",
              "freshness_at",
              "services"
            ],
            "properties": {
              "runtime_state": {
                "type": ["string", "null"],
                "enum": ["healthy", "unhealthy", "unknown", null]
              },
              "runtime_reason": {
                "type": ["string", "null"]
              },
              "route_state": {
                "type": ["string", "null"],
                "enum": ["healthy", "unhealthy", "unknown", null]
              },
              "route_reason": {
                "type": ["string", "null"]
              },
              "consecutive_runtime_failures": {
                "type": "integer"
              },
              "consecutive_route_failures": {
                "type": "integer"
              },
              "freshness_at": {
                "type": ["string", "null"],
                "format": "date-time"
              },
              "services": {
                "type": "array",
                "description": "Latest observation's bounded per-service facts; empty when no per-service status was observable.",
                "items": {
                  "type": "object",
                  "required": [
                    "name",
                    "state",
                    "replicas",
                    "updated_replicas",
                    "ready_replicas",
                    "available_replicas",
                    "public_endpoint_count",
                    "forwarded_port_count",
                    "dedicated_ip_count",
                    "restart_count",
                    "restart_count_supported"
                  ],
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "state": {
                      "type": "string",
                      "enum": ["healthy", "degraded"]
                    },
                    "replicas": {
                      "type": "integer"
                    },
                    "updated_replicas": {
                      "type": "integer"
                    },
                    "ready_replicas": {
                      "type": "integer"
                    },
                    "available_replicas": {
                      "type": "integer"
                    },
                    "public_endpoint_count": {
                      "type": "integer"
                    },
                    "forwarded_port_count": {
                      "type": "integer"
                    },
                    "dedicated_ip_count": {
                      "type": "integer"
                    },
                    "restart_count": {
                      "type": "null",
                      "description": "Restart counting is not supported by the current runtime substrate."
                    },
                    "restart_count_supported": {
                      "const": false
                    }
                  }
                }
              }
            }
          },
          "observations": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "runtime_state",
                "runtime_reason",
                "route_state",
                "route_reason",
                "route_status",
                "observed_at"
              ],
              "properties": {
                "runtime_state": {
                  "type": "string",
                  "enum": ["healthy", "unhealthy", "unknown"]
                },
                "runtime_reason": {
                  "type": "string"
                },
                "route_state": {
                  "type": "string",
                  "enum": ["healthy", "unhealthy", "unknown"]
                },
                "route_reason": {
                  "type": "string"
                },
                "route_status": {
                  "type": ["integer", "null"]
                },
                "observed_at": {
                  "type": ["string", "null"],
                  "format": "date-time"
                }
              }
            }
          }
        }
      },
      "EnvKeyList": {
        "type": "object",
        "required": [
          "keys",
          "variables",
          "count"
        ],
        "properties": {
          "keys": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "variables": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "key",
                "value",
                "write_only"
              ],
              "properties": {
                "key": {
                  "type": "string"
                },
                "value": {
                  "type": "null"
                },
                "write_only": {
                  "const": true
                }
              }
            }
          },
          "count": {
            "type": "integer"
          }
        }
      },
      "EnvUpdateRequest": {
        "type": "object",
        "required": [
          "env"
        ],
        "properties": {
          "env": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "replace": {
            "type": "boolean",
            "default": false
          }
        }
      },
      "CreateDeploymentRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "repository": {
            "type": "object",
            "properties": {
              "url": {
                "type": "string",
                "format": "uri"
              },
              "ref": {
                "type": "string"
              },
              "dockerfile_path": {
                "type": "string"
              },
              "docker_context_path": {
                "type": "string"
              }
            }
          },
          "image": {
            "type": "object",
            "properties": {
              "ref": {
                "type": "string"
              },
              "port": {
                "type": "integer"
              },
              "credentials": {
                "type": "object",
                "writeOnly": true
              }
            }
          },
          "template_id": {
            "type": "string"
          },
          "env": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "writeOnly": true
          },
          "port": {
            "type": "integer"
          },
          "command": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "args": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "health_path": {
            "type": "string"
          },
          "resource_profile": {
            "$ref": "#/components/schemas/ResourceProfile"
          }
        }
      },
      "TemplateDeployRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "subdomain": {
            "type": "string"
          },
          "env": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "writeOnly": true
          }
        }
      },
      "Template": {
        "type": "object",
        "required": [
          "id",
          "name",
          "description",
          "required_env",
          "resource_profile",
          "certification"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "framework": {
            "type": "string"
          },
          "language": {
            "type": "string"
          },
          "logo": {
            "type": "string"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "category": {
            "type": "string"
          },
          "required_env": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "resource_profile": {
            "type": "object"
          },
          "resources": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "private": {
            "type": "boolean"
          },
          "certification": {
            "type": "object",
            "properties": {
              "state": {
                "type": "string"
              }
            }
          }
        }
      },
      "TemplateList": {
        "type": "object",
        "required": [
          "templates",
          "count"
        ],
        "properties": {
          "templates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Template"
            }
          },
          "count": {
            "type": "integer"
          }
        }
      },
      "PricingEstimate": {
        "type": "object",
        "required": [
          "profile",
          "currency",
          "fixed_monthly_cost_usd",
          "billing_model"
        ],
        "properties": {
          "profile": {
            "type": "string"
          },
          "verified": {
            "type": "boolean"
          },
          "currency": {
            "type": "string"
          },
          "fixed_monthly_cost_usd": {
            "type": "number"
          },
          "billing_model": {
            "const": "fixed_monthly_resource_reservation"
          },
          "mode": {
            "type": "string"
          }
        }
      },
      "CreditState": {
        "type": "object",
        "properties": {
          "has_payment_method": {
            "type": "boolean"
          },
          "deploy_allowed": {
            "type": "boolean"
          },
          "reason": {
            "type": "string"
          },
          "starter_credit": {
            "type": [
              "object",
              "null"
            ]
          },
          "billing_summary": {
            "type": [
              "object",
              "null"
            ]
          }
        }
      },
      "ApiKeyList": {
        "type": "object",
        "required": [
          "api_keys"
        ],
        "properties": {
          "api_keys": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ApiKey"
            }
          }
        }
      },
      "ApiKey": {
        "type": "object",
        "required": [
          "id",
          "tier",
          "active"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "tier": {
            "type": "string"
          },
          "created_at": {
            "type": [
              "integer",
              "null"
            ]
          },
          "last_used_at": {
            "type": [
              "integer",
              "null"
            ]
          },
          "revoked_at": {
            "type": [
              "integer",
              "null"
            ]
          },
          "active": {
            "type": "boolean"
          }
        }
      },
      "IssuedApiKey": {
        "type": "object",
        "required": [
          "api_key",
          "tier"
        ],
        "properties": {
          "api_key": {
            "type": "string",
            "writeOnly": true
          },
          "tier": {
            "type": "string"
          }
        }
      },
      "WebhookEventType": {
        "type": "string",
        "enum": [
          "deployment.accepted",
          "deployment.progress",
          "deployment.live",
          "deployment.failed",
          "deployment.unhealthy",
          "deployment.env_updated",
          "deployment.redeploy_requested",
          "deployment.redeploy_completed",
          "deployment.restart_requested",
          "deployment.deleted",
          "credit.updated"
        ]
      },
      "Webhook": {
        "type": "object",
        "required": [
          "id",
          "url",
          "events",
          "active",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookEventType"
            }
          },
          "active": {
            "type": "boolean"
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "WebhookDelivery": {
        "type": "object",
        "required": [
          "id",
          "webhook_id",
          "event_id",
          "event_type",
          "status",
          "attempts"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "webhook_id": {
            "type": "string"
          },
          "event_id": {
            "type": "string"
          },
          "event_type": {
            "$ref": "#/components/schemas/WebhookEventType"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "delivered",
              "retrying",
              "failed"
            ]
          },
          "attempts": {
            "type": "integer"
          },
          "status_code": {
            "type": [
              "integer",
              "null"
            ]
          },
          "last_error": {
            "type": [
              "string",
              "null"
            ]
          },
          "next_retry_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string"
          },
          "updated_at": {
            "type": "string"
          }
        }
      },
      "WebhookList": {
        "type": "object",
        "required": [
          "webhooks",
          "count"
        ],
        "properties": {
          "webhooks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Webhook"
            }
          },
          "count": {
            "type": "integer"
          },
          "deliveries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookDelivery"
            }
          }
        }
      },
      "CreateWebhookRequest": {
        "type": "object",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Absolute HTTPS endpoint URL. Private and local hosts are rejected."
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookEventType"
            }
          }
        }
      },
      "CreatedWebhook": {
        "type": "object",
        "required": [
          "webhook",
          "signing_secret"
        ],
        "properties": {
          "webhook": {
            "$ref": "#/components/schemas/Webhook"
          },
          "signing_secret": {
            "type": "string",
            "writeOnly": true,
            "description": "Shown once. Store it to verify X-Varity-Signature."
          }
        }
      }
    }
  }
}
