{
  "openapi": "3.1.0",
  "info": {
    "title": "SafeCert API",
    "version": "1.0.0",
    "summary": "Check whether Chrome will block a site on March 15, 2027 because its certificate chain includes a P-256 certificate authority.",
    "description": "From 2027-03-15 00:00 UTC, Chrome 164 and later rejects TLS certificate chains that include a CA certificate with a P-256 key. This API checks a domain and up to 20 of its subdomains. No key is needed. Limits: 12 new checks per 10 minutes per IP; cached results (10 minutes) do not count."
  },
  "servers": [{ "url": "https://safecert.dev" }],
  "paths": {
    "/api/check": {
      "get": {
        "operationId": "checkDomain",
        "summary": "Check a domain and its subdomains for P-256 certificate authorities",
        "parameters": [
          { "name": "d", "in": "query", "required": true, "description": "Domain or URL, for example example.com or https://shop.example.com/", "schema": { "type": "string", "examples": ["example.com"] } },
          { "name": "format", "in": "query", "required": false, "description": "md returns a Markdown summary instead of JSON", "schema": { "type": "string", "enum": ["json", "md"], "default": "json" } }
        ],
        "responses": {
          "200": {
            "description": "Check result",
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/CheckResult" } },
              "text/markdown": { "schema": { "type": "string" } }
            }
          },
          "400": { "description": "Not a valid public domain", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "503": { "description": "Too many checks are running. Retry after the Retry-After header.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "429": { "description": "Too many new checks from this IP. Retry after the Retry-After header.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Status": {
        "type": "string",
        "enum": ["red", "amber", "broken", "green", "error"],
        "description": "red: will be blocked on the deadline. amber: a P-256 CA is in the chain but the certificate expires before the deadline, or another path without P-256 exists. broken: browsers already warn. green: no P-256 CA. error: could not connect."
      },
      "Key": {
        "type": "object",
        "properties": {
          "alg": { "type": "string", "examples": ["ECDSA", "RSA"] },
          "bits": { "type": "integer" },
          "label": { "type": "string", "examples": ["P-256", "P-384", "RSA 2048"] },
          "p256": { "type": "boolean" }
        }
      },
      "Cert": {
        "type": "object",
        "properties": {
          "role": { "type": "string", "enum": ["leaf", "intermediate", "root"] },
          "name": { "type": "string" },
          "key": { "$ref": "#/components/schemas/Key" },
          "notAfter": { "type": "string", "format": "date-time" },
          "weak": { "type": "boolean", "description": "True for a CA certificate with a P-256 key, the link Chrome blocks" }
        }
      },
      "Host": {
        "type": "object",
        "properties": {
          "host": { "type": "string" },
          "status": { "$ref": "#/components/schemas/Status" },
          "reason": { "type": "string", "examples": ["p256_ca_after_deadline", "p256_ca_renew", "p256_ca_alt_path", "name_mismatch", "unknown_ca", "expired"] },
          "error": { "type": "string", "examples": ["dns", "timeout", "refused", "tls", "private"] },
          "chain": { "type": "array", "items": { "$ref": "#/components/schemas/Cert" } },
          "leafP256": { "type": "boolean", "description": "The site certificate itself uses a P-256 key (allowed for now)" },
          "pq": { "type": "boolean", "description": "Supports X25519MLKEM768 key exchange. Only reported for the domain you entered." },
          "issuer": { "type": "string" },
          "notAfter": { "type": "string", "format": "date-time" }
        }
      },
      "CheckResult": {
        "type": "object",
        "properties": {
          "domain": { "type": "string" },
          "deadline": { "type": "string", "format": "date-time" },
          "status": { "$ref": "#/components/schemas/Status" },
          "hosts": { "type": "array", "items": { "$ref": "#/components/schemas/Host" } },
          "unreached": { "type": "integer" },
          "ctNames": { "type": "integer" },
          "ctSource": { "type": "string" },
          "ctError": { "type": "string" },
          "wildcard": { "type": "boolean" },
          "guessed": { "type": "integer" },
          "truncated": { "type": "boolean" },
          "checkedAt": { "type": "string", "format": "date-time" },
          "fromCache": { "type": "boolean" },
          "alerts": { "type": "boolean", "description": "Whether email alert signups are open" }
        }
      },
      "Error": { "type": "object", "properties": { "error": { "type": "string", "enum": ["bad_domain", "rate", "busy", "method", "server"] } } }
    }
  }
}
