{
  "openapi": "3.1.0",
  "info": {
    "title": "EigerTrust API",
    "version": "1.0.0",
    "description": "Verification of signed EigerTrust web assessments and authorised tenant operations. API tokens are scoped and expire after 30 days. All timestamps are UTC."
  },
  "servers": [
    {
      "url": "/api/v1"
    }
  ],
  "paths": {
    "/certificates/{certificate}": {
      "get": {
        "summary": "Signed certificate envelope",
        "operationId": "certificate",
        "security": [],
        "parameters": [
          {
            "name": "certificate",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^et_[a-f0-9]{40}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Certificate"
                }
              }
            }
          },
          "404": {
            "description": "Resource absent or belongs to another tenant"
          },
          "409": {
            "description": "Invalid signature"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/certificates/{certificate}/status": {
      "get": {
        "summary": "Current certificate and key status",
        "operationId": "status",
        "security": [],
        "parameters": [
          {
            "name": "certificate",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^et_[a-f0-9]{40}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Status"
                }
              }
            }
          },
          "404": {
            "description": "Resource absent or belongs to another tenant"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/seals/{certificate}/status": {
      "get": {
        "summary": "Live status and current verification link for an embedded seal",
        "operationId": "sealStatus",
        "security": [],
        "parameters": [
          {
            "name": "certificate",
            "in": "path",
            "required": true,
            "schema": {"type": "string", "pattern": "^et_[a-f0-9]{40}$"}
          }
        ],
        "responses": {
          "200": {
            "description": "Live status, served without caching",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {"$ref": "#/components/schemas/Status"},
                    {
                      "type": "object",
                      "properties": {
                        "anchor_id": {"type": "string", "pattern": "^et_[a-f0-9]{40}$"},
                        "verification_url": {"type": "string", "format": "uri-reference"}
                      },
                      "required": ["anchor_id", "verification_url"]
                    }
                  ]
                }
              }
            }
          },
          "404": {"description": "Certificate absent"},
          "429": {"description": "Rate limit exceeded"}
        }
      }
    },
    "/keys": {
      "get": {
        "summary": "Published verification keys",
        "operationId": "keys",
        "security": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Key"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Resource absent or belongs to another tenant"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/domains": {
      "get": {
        "summary": "List accessible domains",
        "operationId": "domains",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-ability": "domains:read",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Domain"
                      }
                    },
                    "current_page": {
                      "type": "integer"
                    },
                    "last_page": {
                      "type": "integer"
                    },
                    "per_page": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "data",
                    "current_page",
                    "last_page",
                    "per_page",
                    "total"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or expired bearer token"
          },
          "403": {
            "description": "Account disabled, MFA missing or token scope denied"
          },
          "404": {
            "description": "Resource absent or belongs to another tenant"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      },
      "post": {
        "summary": "Register a hostname",
        "operationId": "createDomain",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-ability": "domains:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "hostname": {
                    "type": "string"
                  },
                  "customer_id": {
                    "type": "integer",
                    "description": "Required for operators; prohibited for customers"
                  }
                },
                "required": [
                  "hostname"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Domain"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or expired bearer token"
          },
          "403": {
            "description": "Account disabled, MFA missing or token scope denied"
          },
          "404": {
            "description": "Resource absent or belongs to another tenant"
          },
          "422": {
            "description": "Validation, ownership or queue precondition failed"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/domains/{domain}": {
      "get": {
        "summary": "Get a domain",
        "operationId": "domain",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-ability": "domains:read",
        "parameters": [
          {
            "name": "domain",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Domain"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or expired bearer token"
          },
          "403": {
            "description": "Account disabled, MFA missing or token scope denied"
          },
          "404": {
            "description": "Resource absent or belongs to another tenant"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      },
      "patch": {
        "summary": "Update monitoring settings",
        "operationId": "updateDomain",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-ability": "domains:write",
        "parameters": [
          {
            "name": "domain",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "interval_hours": {
                    "enum": [
                      6,
                      12,
                      24
                    ]
                  },
                  "dkim_selectors": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "maxItems": 5
                  }
                },
                "required": []
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Domain"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or expired bearer token"
          },
          "403": {
            "description": "Account disabled, MFA missing or token scope denied"
          },
          "404": {
            "description": "Resource absent or belongs to another tenant"
          },
          "422": {
            "description": "Validation, ownership or queue precondition failed"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/domains/{domain}/challenge": {
      "post": {
        "summary": "Create a one-hour ownership challenge",
        "operationId": "challenge",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-ability": "domains:write",
        "parameters": [
          {
            "name": "domain",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "method": {
                    "enum": [
                      "dns",
                      "http"
                    ]
                  }
                },
                "required": [
                  "method"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Challenge"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or expired bearer token"
          },
          "403": {
            "description": "Account disabled, MFA missing or token scope denied"
          },
          "404": {
            "description": "Resource absent or belongs to another tenant"
          },
          "422": {
            "description": "Validation, ownership or queue precondition failed"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/domains/{domain}/verify": {
      "post": {
        "summary": "Queue ownership verification",
        "operationId": "verifyDomain",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-ability": "domains:write",
        "parameters": [
          {
            "name": "domain",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "challenge_id": {
                    "type": "integer"
                  }
                },
                "required": [
                  "challenge_id"
                ]
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Task"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or expired bearer token"
          },
          "403": {
            "description": "Account disabled, MFA missing or token scope denied"
          },
          "404": {
            "description": "Resource absent or belongs to another tenant"
          },
          "422": {
            "description": "Validation, ownership or queue precondition failed"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/domains/{domain}/scans": {
      "get": {
        "summary": "List stored assessments",
        "operationId": "domainScans",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-ability": "scans:read",
        "parameters": [
          {
            "name": "domain",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Scan"
                      }
                    },
                    "current_page": {
                      "type": "integer"
                    },
                    "last_page": {
                      "type": "integer"
                    },
                    "per_page": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "data",
                    "current_page",
                    "last_page",
                    "per_page",
                    "total"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or expired bearer token"
          },
          "403": {
            "description": "Account disabled, MFA missing or token scope denied"
          },
          "404": {
            "description": "Resource absent or belongs to another tenant"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      },
      "post": {
        "summary": "Request an assessment",
        "operationId": "requestScan",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-ability": "scans:request",
        "parameters": [
          {
            "name": "domain",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Task"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or expired bearer token"
          },
          "403": {
            "description": "Account disabled, MFA missing or token scope denied"
          },
          "404": {
            "description": "Resource absent or belongs to another tenant"
          },
          "422": {
            "description": "Validation, ownership or queue precondition failed"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/domains/{domain}/scans/{scan}": {
      "get": {
        "summary": "Get an assessment and its findings",
        "operationId": "scan",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-ability": "scans:read",
        "parameters": [
          {
            "name": "domain",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "scan",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Scan"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or expired bearer token"
          },
          "403": {
            "description": "Account disabled, MFA missing or token scope denied"
          },
          "404": {
            "description": "Resource absent or belongs to another tenant"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Sanctum opaque token"
      }
    },
    "schemas": {
      "Domain": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "hostname": {
            "type": "string"
          },
          "customer_id": {
            "type": "integer"
          },
          "interval_hours": {
            "type": "integer",
            "enum": [
              6,
              12,
              24
            ]
          },
          "dkim_selectors": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "verified": {
            "type": "boolean"
          },
          "ownership_valid_until": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "next_scan_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "hostname",
          "customer_id",
          "interval_hours",
          "dkim_selectors",
          "verified",
          "ownership_valid_until",
          "next_scan_at"
        ]
      },
      "Certificate": {
        "type": "object",
        "properties": {
          "payload": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^et_[a-f0-9]{40}$"
              },
              "number": {
                "type": "string"
              },
              "hostname": {
                "type": "string"
              },
              "issuer": {
                "type": "string"
              },
              "issued_at": {
                "type": "string",
                "format": "date-time"
              },
              "expires_at": {
                "type": "string",
                "format": "date-time"
              },
              "assessed_at": {
                "type": "string",
                "format": "date-time"
              },
              "policy": {
                "type": "string"
              },
              "score": {
                "type": "integer",
                "minimum": 0,
                "maximum": 100
              },
              "evidence_sha256": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$"
              },
              "algorithm": {
                "const": "Ed25519"
              },
              "kid": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "number",
              "hostname",
              "issuer",
              "issued_at",
              "expires_at",
              "assessed_at",
              "policy",
              "score",
              "evidence_sha256",
              "algorithm",
              "kid"
            ]
          },
          "signature": {
            "type": "string"
          }
        },
        "required": [
          "payload",
          "signature"
        ]
      },
      "Status": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^et_[a-f0-9]{40}$"
          },
          "hostname": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "suspended",
              "expired",
              "revoked"
            ]
          },
          "signature_valid": {
            "type": "boolean"
          },
          "revoked": {
            "type": "boolean"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "hostname",
          "status",
          "signature_valid",
          "revoked",
          "expires_at"
        ]
      },
      "Key": {
        "type": "object",
        "properties": {
          "kid": {
            "type": "string"
          },
          "algorithm": {
            "const": "Ed25519"
          },
          "public_key": {
            "type": "string"
          },
          "state": {
            "enum": [
              "active",
              "retired",
              "revoked"
            ]
          },
          "revoked_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "kid",
          "algorithm",
          "public_key",
          "state",
          "revoked_at"
        ]
      },
      "Challenge": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "method": {
            "enum": [
              "dns",
              "http"
            ]
          },
          "token": {
            "type": "string"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "location": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "method",
          "token",
          "expires_at",
          "location"
        ]
      },
      "Task": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "status": {
            "const": "queued"
          }
        },
        "required": [
          "id",
          "status"
        ]
      },
      "Finding": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "status": {
            "enum": [
              "pass",
              "fail",
              "unknown",
              "na"
            ]
          },
          "severity": {
            "enum": [
              "info",
              "low",
              "medium",
              "high",
              "critical"
            ]
          },
          "evidence": {
            "type": [
              "object",
              "array"
            ]
          },
          "remediation": {
            "type": "string"
          },
          "observed_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "code",
          "category",
          "status",
          "severity",
          "evidence",
          "remediation",
          "observed_at"
        ]
      },
      "Scan": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "domain_id": {
            "type": "integer"
          },
          "score": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "conclusive": {
            "type": "boolean"
          },
          "eligible": {
            "type": "boolean"
          },
          "assessed_at": {
            "type": "string",
            "format": "date-time"
          },
          "evidence_hash": {
            "type": "string"
          },
          "category_scores": {
            "type": "object"
          },
          "findings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Finding"
            }
          }
        },
        "required": [
          "id",
          "domain_id",
          "score",
          "eligible",
          "conclusive",
          "assessed_at",
          "evidence_hash",
          "category_scores"
        ]
      }
    }
  }
}
