{
  "openapi": "3.1.0",
  "info": {
    "title": "Hellositey Deployment API",
    "version": "1.0.0",
    "description": "Import static websites, publish reviewed revisions and roll back live releases."
  },
  "servers": [
    {
      "url": "https://app.hellositey.com"
    }
  ],
  "security": [
    {
      "bearerToken": []
    }
  ],
  "paths": {
    "/v1/deployments": {
      "parameters": [
        {
          "in": "header",
          "name": "X-Hellositey-Site",
          "description": "Defaults to the token\u2019s original website. Selecting a different assigned site requires agency:sites.",
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "getDeployment",
        "summary": "Read the current draft revision and live release",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Status"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or a blocking publishing check",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Connection, package or role does not permit this action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Revision or live release changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "deployWebsite",
        "summary": "Publish a reviewed revision with release:publish",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deployment"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or a blocking publishing check",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Connection, package or role does not permit this action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Revision or live release changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "revision": {
                    "type": "integer",
                    "minimum": 1
                  }
                },
                "required": [
                  "revision"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/deployments/rollback": {
      "parameters": [
        {
          "in": "header",
          "name": "X-Hellositey-Site",
          "description": "Defaults to the token\u2019s original website. Selecting a different assigned site requires agency:sites.",
          "schema": {
            "type": "string"
          }
        }
      ],
      "post": {
        "operationId": "rollbackDeployment",
        "summary": "Restore an existing release with release:publish",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or a blocking publishing check",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Connection, package or role does not permit this action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Revision or live release changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "live_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "id",
                  "live_id"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/deployments/import": {
      "post": {
        "operationId": "importWebsite",
        "summary": "Import a static website ZIP as a new draft with agency:import",
        "responses": {
          "400": {
            "description": "Invalid input or a blocking publishing check",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Connection, package or role does not permit this action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Revision or live release changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id"
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "query",
            "name": "name",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/zip": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        }
      }
    },
    "/v1/deployments/checks": {
      "parameters": [
        {
          "in": "header",
          "name": "X-Hellositey-Site",
          "description": "Defaults to the token\u2019s original website. Selecting a different assigned site requires agency:sites.",
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "checkDeployment",
        "summary": "Inspect publishing checks for this draft revision",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "revision": {
                      "type": "integer"
                    },
                    "ready": {
                      "type": "boolean"
                    },
                    "issues": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "severity": {
                            "enum": [
                              "warning",
                              "error"
                            ]
                          },
                          "page": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "severity",
                          "page",
                          "message"
                        ]
                      }
                    }
                  },
                  "required": [
                    "revision",
                    "ready",
                    "issues"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or a blocking publishing check",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Connection, package or role does not permit this action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Revision or live release changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/deployments/history": {
      "parameters": [
        {
          "in": "header",
          "name": "X-Hellositey-Site",
          "description": "Defaults to the token\u2019s original website. Selecting a different assigned site requires agency:sites.",
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "getDeploymentHistory",
        "summary": "Read the 50 most recent website releases",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "releases": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "revision": {
                            "type": "integer"
                          },
                          "created_at": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "id",
                          "revision",
                          "created_at"
                        ]
                      }
                    }
                  },
                  "required": [
                    "releases"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or a blocking publishing check",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Connection, package or role does not permit this action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Revision or live release changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/deployments/updates": {
      "parameters": [
        {
          "in": "header",
          "name": "X-Hellositey-Site",
          "description": "Defaults to the token\u2019s original website. Selecting a different assigned site requires agency:sites.",
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "listBuildComparisons",
        "summary": "List open comparisons and previously applied builds for this site.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "state": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "id",
                      "state"
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or a blocking publishing check",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Connection, package or role does not permit this action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Revision or live release changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "compareBuild",
        "summary": "Compare an uploaded ZIP to the current website. Requires site:operate and draft:write.",
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or a blocking publishing check",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Connection, package or role does not permit this action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Revision or live release changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/zip": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        }
      }
    },
    "/v1/deployments/updates/{reviewId}": {
      "parameters": [
        {
          "in": "header",
          "name": "X-Hellositey-Site",
          "description": "Defaults to the token\u2019s original website. Selecting a different assigned site requires agency:sites.",
          "schema": {
            "type": "string"
          }
        },
        {
          "name": "reviewId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "readBuildComparison",
        "summary": "Read per-file changes and the revision that was compared.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "revision": {
                      "type": "integer",
                      "minimum": 1
                    },
                    "hasBaseline": {
                      "type": "boolean"
                    },
                    "rows": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  },
                  "required": [
                    "id",
                    "revision",
                    "hasBaseline",
                    "rows"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or a blocking publishing check",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Connection, package or role does not permit this action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Revision or live release changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "applyBuildComparison",
        "summary": "Apply a reviewed build to the existing draft using explicit choices for conflicts.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "revision": {
                      "type": "integer",
                      "minimum": 1
                    }
                  },
                  "required": [
                    "revision"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or a blocking publishing check",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Connection, package or role does not permit this action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Revision or live release changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action": {
                    "const": "apply"
                  },
                  "revision": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "choices": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string",
                      "enum": [
                        "keep",
                        "update",
                        "duplicate"
                      ]
                    }
                  }
                },
                "required": [
                  "action",
                  "revision",
                  "choices"
                ]
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "discardBuildComparison",
        "summary": "Discard an open comparison.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "discarded": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "discarded"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or a blocking publishing check",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Connection, package or role does not permit this action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Revision or live release changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerToken": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "Release": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "revision": {
            "type": "integer",
            "minimum": 1
          },
          "url": {
            "type": "string",
            "format": "uri"
          }
        },
        "required": [
          "id",
          "revision",
          "url"
        ]
      },
      "Deployment": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Release"
          },
          {
            "type": "object",
            "properties": {
              "site_id": {
                "type": "string"
              }
            },
            "required": [
              "site_id"
            ]
          }
        ]
      },
      "Status": {
        "type": "object",
        "properties": {
          "site_id": {
            "type": "string"
          },
          "draft_revision": {
            "type": "integer",
            "minimum": 1
          },
          "live": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Release"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "site_id",
          "draft_revision",
          "live"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      }
    }
  }
}
