{
  "openapi": "3.1.0",
  "info": {
    "title": "SSLNexus Client Server Management API",
    "version": "1.0.0",
    "description": "Self-hosted certificate lifecycle API. All tiers. Credentials inherit the selected estate, target scope and current operation entitlements."
  },
  "servers": [
    {
      "url": "/api/v1"
    }
  ],
  "components": {
    "securitySchemes": {
      "machine": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "security": [
    {
      "machine": []
    }
  ],
  "paths": {
    "/targets": {
      "get": {
        "summary": "List target bindings",
        "x-required-scope": "read",
        "parameters": [
          {
            "in": "query",
            "name": "after",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Visible targets",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "platform": {
                            "type": "string"
                          },
                          "application": {
                            "type": "string"
                          },
                          "provider": {
                            "type": "string"
                          }
                        },
                        "required": []
                      }
                    },
                    "next_after": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "items",
                    "next_after"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Identifier recorded in the local read audit event.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Request rejected or resource unavailable. JSON errors include a machine-readable code. Hidden or unknown resources may return HTTP 404."
          }
        }
      }
    },
    "/certificates": {
      "get": {
        "summary": "List certificates",
        "x-required-scope": "read",
        "parameters": [
          {
            "in": "query",
            "name": "after",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Visible inventory",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "common_name": {
                            "type": "string"
                          },
                          "sans": {
                            "type": [
                              "array",
                              "null"
                            ],
                            "items": {
                              "type": "string"
                            }
                          },
                          "provider": {
                            "type": "string"
                          },
                          "target": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "management_state": {
                            "type": "string"
                          },
                          "last_job_id": {
                            "type": "string"
                          },
                          "next_renewal_at": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "revocation_supported": {
                            "type": "boolean"
                          },
                          "expires_at": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "renewal_mode": {
                            "type": "string"
                          },
                          "renewal_before_days": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 3650,
                            "description": "Whole days before expiry for a day-based policy."
                          },
                          "removal_names": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            },
                            "description": "Ordered exact names for management removal, including previous renewal names."
                          },
                          "renewal_retry_count": {
                            "type": "integer"
                          },
                          "renewal_retry_delay_minutes": {
                            "type": "integer"
                          },
                          "maintenance_window_start": {
                            "type": "string"
                          },
                          "maintenance_window_end": {
                            "type": "string"
                          },
                          "renewal_window_type": {
                            "type": "string",
                            "enum": [
                              "days",
                              "percentage"
                            ],
                            "description": "Unit used for the renewal threshold."
                          },
                          "renewal_remaining_percent": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 99,
                            "description": "Percentage of the current leaf lifetime remaining when renewal becomes eligible."
                          },
                          "valid_from": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "renewal_schedule_conflict": {
                            "type": "string"
                          },
                          "renewal_recovery_warning": {
                            "type": "string"
                          }
                        },
                        "required": []
                      }
                    },
                    "next_after": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "items",
                    "next_after"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Identifier recorded in the local read audit event.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Request rejected or resource unavailable. JSON errors include a machine-readable code. Hidden or unknown resources may return HTTP 404."
          }
        }
      },
      "post": {
        "summary": "Create and queue first issuance",
        "x-required-scope": "create",
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "description": "Reuse the same key and exact request bytes when retrying."
          }
        ],
        "responses": {
          "201": {
            "description": "Certificate and initial job IDs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "certificate_id": {
                      "type": "string"
                    },
                    "job_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "adopted": {
                      "type": "boolean"
                    },
                    "managed": {
                      "type": "boolean"
                    },
                    "deleted": {
                      "type": "boolean"
                    },
                    "reuses_existing_certificate": {
                      "type": "boolean"
                    },
                    "certificate_capacity_release_pending": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "certificate_id"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Request rejected or resource unavailable. JSON errors include a machine-readable code. Hidden or unknown resources may return HTTP 404."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "common_name": {
                    "type": "string"
                  },
                  "target": {
                    "type": "string"
                  },
                  "provider": {
                    "type": "string"
                  },
                  "sans": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "key_size": {
                    "type": "integer"
                  },
                  "renewal_before_days": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 3650,
                    "description": "Whole days before expiry for a day-based policy."
                  },
                  "renewal_mode": {
                    "enum": [
                      "approval",
                      "automatic"
                    ]
                  },
                  "renewal_retry_count": {
                    "type": "integer"
                  },
                  "renewal_retry_delay_minutes": {
                    "type": "integer"
                  },
                  "maintenance_window_start": {
                    "type": "string"
                  },
                  "maintenance_window_end": {
                    "type": "string"
                  },
                  "renewal_window_type": {
                    "type": "string",
                    "enum": [
                      "days",
                      "percentage"
                    ],
                    "description": "Unit used for the renewal threshold."
                  },
                  "renewal_remaining_percent": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 99,
                    "description": "Percentage of the current leaf lifetime remaining when renewal becomes eligible."
                  }
                },
                "required": [
                  "common_name"
                ],
                "not": {
                  "required": [
                    "renewal_before_days",
                    "renewal_remaining_percent"
                  ]
                },
                "allOf": [
                  {
                    "if": {
                      "required": [
                        "renewal_window_type"
                      ],
                      "properties": {
                        "renewal_window_type": {
                          "const": "percentage"
                        }
                      }
                    },
                    "then": {
                      "required": [
                        "renewal_remaining_percent"
                      ]
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "renewal_window_type"
                      ],
                      "properties": {
                        "renewal_window_type": {
                          "const": "days"
                        }
                      }
                    },
                    "then": {
                      "required": [
                        "renewal_before_days"
                      ]
                    }
                  }
                ]
              }
            }
          }
        },
        "description": "Choose one timing unit. Omit both timing values to retain day-based defaults for new records or the existing timing on adoption."
      }
    },
    "/certificates/{id}": {
      "get": {
        "summary": "Read certificate",
        "x-required-scope": "read",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Certificate",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "common_name": {
                      "type": "string"
                    },
                    "sans": {
                      "type": [
                        "array",
                        "null"
                      ],
                      "items": {
                        "type": "string"
                      }
                    },
                    "provider": {
                      "type": "string"
                    },
                    "target": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "management_state": {
                      "type": "string"
                    },
                    "last_job_id": {
                      "type": "string"
                    },
                    "next_renewal_at": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "revocation_supported": {
                      "type": "boolean"
                    },
                    "expires_at": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "renewal_mode": {
                      "type": "string"
                    },
                    "renewal_before_days": {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 3650,
                      "description": "Whole days before expiry for a day-based policy."
                    },
                    "removal_names": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Ordered exact names for management removal, including previous renewal names."
                    },
                    "renewal_retry_count": {
                      "type": "integer"
                    },
                    "renewal_retry_delay_minutes": {
                      "type": "integer"
                    },
                    "maintenance_window_start": {
                      "type": "string"
                    },
                    "maintenance_window_end": {
                      "type": "string"
                    },
                    "renewal_window_type": {
                      "type": "string",
                      "enum": [
                        "days",
                        "percentage"
                      ],
                      "description": "Unit used for the renewal threshold."
                    },
                    "renewal_remaining_percent": {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 99,
                      "description": "Percentage of the current leaf lifetime remaining when renewal becomes eligible."
                    },
                    "valid_from": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "renewal_schedule_conflict": {
                      "type": "string"
                    },
                    "renewal_recovery_warning": {
                      "type": "string"
                    }
                  },
                  "required": []
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Identifier recorded in the local read audit event.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Request rejected or resource unavailable. JSON errors include a machine-readable code. Hidden or unknown resources may return HTTP 404."
          }
        }
      },
      "delete": {
        "summary": "Remove from management",
        "x-required-scope": "delete",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "description": "Reuse the same key and exact request bytes when retrying."
          }
        ],
        "responses": {
          "200": {
            "description": "Removal recorded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "certificate_id": {
                      "type": "string"
                    },
                    "job_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "adopted": {
                      "type": "boolean"
                    },
                    "managed": {
                      "type": "boolean"
                    },
                    "deleted": {
                      "type": "boolean"
                    },
                    "reuses_existing_certificate": {
                      "type": "boolean"
                    },
                    "certificate_capacity_release_pending": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "certificate_id"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Request rejected or resource unavailable. JSON errors include a machine-readable code. Hidden or unknown resources may return HTTP 404."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "confirm_certificate_id": {
                    "type": "string"
                  },
                  "names": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "confirm_certificate_id",
                  "names"
                ]
              }
            }
          }
        },
        "description": "Send confirm_certificate_id and the exact ordered removal_names from GET as names. A stale name set returns 409. Removal preserves installed and retained certificate material."
      }
    },
    "/jobs/{job}": {
      "get": {
        "summary": "Read operation progress",
        "x-required-scope": "read",
        "parameters": [
          {
            "in": "path",
            "name": "job",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Job status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "operation": {
                      "type": "string"
                    },
                    "certificate_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "stage": {
                      "type": "string"
                    },
                    "progress": {
                      "type": "integer"
                    },
                    "error_code": {
                      "type": "string"
                    },
                    "retryable": {
                      "type": "boolean"
                    }
                  },
                  "required": []
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Identifier recorded in the local read audit event.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Request rejected or resource unavailable. JSON errors include a machine-readable code. Hidden or unknown resources may return HTTP 404."
          }
        }
      }
    },
    "/certificates/{id}/versions": {
      "get": {
        "summary": "List public certificate versions",
        "x-required-scope": "read",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Target-limited credentials see the current version only",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "certificate_id": {
                      "type": "string"
                    },
                    "common_name": {
                      "type": "string"
                    },
                    "certificates": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "fingerprint_sha256": {
                            "type": "string"
                          },
                          "serial_number": {
                            "type": "string"
                          },
                          "issuer": {
                            "type": "string"
                          },
                          "sans": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "not_before": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "not_after": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          }
                        },
                        "required": []
                      }
                    }
                  },
                  "required": []
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Identifier recorded in the local read audit event.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Request rejected or resource unavailable. JSON errors include a machine-readable code. Hidden or unknown resources may return HTTP 404."
          }
        }
      }
    },
    "/certificates/{id}/versions/{version}": {
      "get": {
        "summary": "Download public PEM",
        "x-required-scope": "read",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "version",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Certificate chain",
            "content": {
              "application/x-pem-file": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Identifier recorded in the local read audit event.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Request rejected or resource unavailable. JSON errors include a machine-readable code. Hidden or unknown resources may return HTTP 404."
          }
        }
      }
    },
    "/certificates/import": {
      "post": {
        "summary": "Import inventory or deploy managed import",
        "x-required-scope": "import",
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "description": "Reuse the same key and exact request bytes when retrying."
          }
        ],
        "responses": {
          "201": {
            "description": "Imported certificate. Managed import requires deploy permission.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "certificate_id": {
                      "type": "string"
                    },
                    "job_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "adopted": {
                      "type": "boolean"
                    },
                    "managed": {
                      "type": "boolean"
                    },
                    "deleted": {
                      "type": "boolean"
                    },
                    "reuses_existing_certificate": {
                      "type": "boolean"
                    },
                    "certificate_capacity_release_pending": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "certificate_id"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Request rejected or resource unavailable. JSON errors include a machine-readable code. Hidden or unknown resources may return HTTP 404."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "certificate_pem": {
                    "type": "string"
                  },
                  "private_key_pem": {
                    "type": "string",
                    "writeOnly": true
                  },
                  "target": {
                    "type": "string"
                  },
                  "domain": {
                    "type": "string"
                  },
                  "deploy": {
                    "type": "boolean"
                  },
                  "deployment_plugin": {
                    "type": "string"
                  },
                  "renewal_window_type": {
                    "type": "string",
                    "enum": [
                      "days",
                      "percentage"
                    ],
                    "description": "Unit used for the renewal threshold."
                  },
                  "renewal_before_days": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 3650,
                    "description": "Whole days before expiry for a day-based policy."
                  },
                  "renewal_remaining_percent": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 99,
                    "description": "Percentage of the current leaf lifetime remaining when renewal becomes eligible."
                  }
                },
                "required": [
                  "certificate_pem"
                ],
                "not": {
                  "required": [
                    "renewal_before_days",
                    "renewal_remaining_percent"
                  ]
                },
                "allOf": [
                  {
                    "if": {
                      "required": [
                        "renewal_window_type"
                      ],
                      "properties": {
                        "renewal_window_type": {
                          "const": "percentage"
                        }
                      }
                    },
                    "then": {
                      "required": [
                        "renewal_remaining_percent"
                      ]
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "renewal_window_type"
                      ],
                      "properties": {
                        "renewal_window_type": {
                          "const": "days"
                        }
                      }
                    },
                    "then": {
                      "required": [
                        "renewal_before_days"
                      ]
                    }
                  }
                ]
              }
            }
          }
        },
        "description": "Choose one timing unit. Omit both timing values to retain day-based defaults for new records or the existing timing on adoption."
      }
    },
    "/certificates/{id}/renewal-policy": {
      "patch": {
        "summary": "Set renewal policy and synchronise schedule",
        "x-required-scope": "policy",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "description": "Reuse the same key and exact request bytes when retrying."
          }
        ],
        "responses": {
          "200": {
            "description": "Updated policy",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "certificate_id": {
                      "type": "string"
                    },
                    "job_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "adopted": {
                      "type": "boolean"
                    },
                    "managed": {
                      "type": "boolean"
                    },
                    "deleted": {
                      "type": "boolean"
                    },
                    "reuses_existing_certificate": {
                      "type": "boolean"
                    },
                    "certificate_capacity_release_pending": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "certificate_id"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Request rejected or resource unavailable. JSON errors include a machine-readable code. Hidden or unknown resources may return HTTP 404."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "renewal_before_days": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 3650,
                    "description": "Whole days before expiry for a day-based policy."
                  },
                  "renewal_mode": {
                    "enum": [
                      "approval",
                      "automatic"
                    ]
                  },
                  "renewal_retry_count": {
                    "type": "integer"
                  },
                  "renewal_retry_delay_minutes": {
                    "type": "integer"
                  },
                  "maintenance_window_start": {
                    "type": "string"
                  },
                  "maintenance_window_end": {
                    "type": "string"
                  },
                  "renewal_window_type": {
                    "type": "string",
                    "enum": [
                      "days",
                      "percentage"
                    ],
                    "description": "Unit used for the renewal threshold."
                  },
                  "renewal_remaining_percent": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 99,
                    "description": "Percentage of the current leaf lifetime remaining when renewal becomes eligible."
                  },
                  "expected_updated_at": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Use reviewed_at from the preview to reject a write if the certificate has changed."
                  }
                },
                "not": {
                  "required": [
                    "renewal_before_days",
                    "renewal_remaining_percent"
                  ]
                },
                "allOf": [
                  {
                    "if": {
                      "required": [
                        "renewal_window_type"
                      ],
                      "properties": {
                        "renewal_window_type": {
                          "const": "percentage"
                        }
                      }
                    },
                    "then": {
                      "required": [
                        "renewal_remaining_percent"
                      ]
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "renewal_window_type"
                      ],
                      "properties": {
                        "renewal_window_type": {
                          "const": "days"
                        }
                      }
                    },
                    "then": {
                      "required": [
                        "renewal_before_days"
                      ]
                    }
                  }
                ]
              },
              "examples": {
                "percentage": {
                  "value": {
                    "renewal_window_type": "percentage",
                    "renewal_remaining_percent": 30
                  }
                },
                "days": {
                  "value": {
                    "renewal_before_days": 20
                  }
                },
                "retryOnly": {
                  "value": {
                    "renewal_retry_count": 2
                  }
                }
              }
            }
          }
        },
        "description": "Update the supplied fields. Omitted settings retain their saved values. A successful write recalculates the schedule for eligible issued certificates. Read the certificate to retrieve the resulting policy."
      }
    },
    "/certificates/{id}/actions/issue": {
      "post": {
        "summary": "Issue a pending certificate",
        "x-required-scope": "issue",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "description": "Reuse the same key and exact request bytes when retrying."
          }
        ],
        "responses": {
          "202": {
            "description": "Existing or newly accepted job",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "certificate_id": {
                      "type": "string"
                    },
                    "job_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "adopted": {
                      "type": "boolean"
                    },
                    "managed": {
                      "type": "boolean"
                    },
                    "deleted": {
                      "type": "boolean"
                    },
                    "reuses_existing_certificate": {
                      "type": "boolean"
                    },
                    "certificate_capacity_release_pending": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "certificate_id"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Request rejected or resource unavailable. JSON errors include a machine-readable code. Hidden or unknown resources may return HTTP 404."
          }
        }
      }
    },
    "/certificates/{id}/actions/renew": {
      "post": {
        "summary": "Request renewal",
        "x-required-scope": "renew",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "description": "Reuse the same key and exact request bytes when retrying."
          }
        ],
        "responses": {
          "202": {
            "description": "Existing or newly accepted job",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "certificate_id": {
                      "type": "string"
                    },
                    "job_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "adopted": {
                      "type": "boolean"
                    },
                    "managed": {
                      "type": "boolean"
                    },
                    "deleted": {
                      "type": "boolean"
                    },
                    "reuses_existing_certificate": {
                      "type": "boolean"
                    },
                    "certificate_capacity_release_pending": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "certificate_id"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Request rejected or resource unavailable. JSON errors include a machine-readable code. Hidden or unknown resources may return HTTP 404."
          }
        },
        "description": "For a fresh renewal, approval mode returns a pending_approval job. Approve that job through the separate approve-renewal action. Poll the job for its current state."
      }
    },
    "/certificates/{id}/actions/approve-renewal": {
      "post": {
        "summary": "Approve pending renewal",
        "x-required-scope": "approve-renewal",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "description": "Reuse the same key and exact request bytes when retrying."
          }
        ],
        "responses": {
          "202": {
            "description": "Existing or newly accepted job",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "certificate_id": {
                      "type": "string"
                    },
                    "job_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "adopted": {
                      "type": "boolean"
                    },
                    "managed": {
                      "type": "boolean"
                    },
                    "deleted": {
                      "type": "boolean"
                    },
                    "reuses_existing_certificate": {
                      "type": "boolean"
                    },
                    "certificate_capacity_release_pending": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "certificate_id"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Request rejected or resource unavailable. JSON errors include a machine-readable code. Hidden or unknown resources may return HTTP 404."
          }
        }
      }
    },
    "/certificates/{id}/actions/deploy": {
      "post": {
        "summary": "Deploy existing material",
        "x-required-scope": "deploy",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "description": "Reuse the same key and exact request bytes when retrying."
          }
        ],
        "responses": {
          "202": {
            "description": "Existing or newly accepted job",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "certificate_id": {
                      "type": "string"
                    },
                    "job_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "adopted": {
                      "type": "boolean"
                    },
                    "managed": {
                      "type": "boolean"
                    },
                    "deleted": {
                      "type": "boolean"
                    },
                    "reuses_existing_certificate": {
                      "type": "boolean"
                    },
                    "certificate_capacity_release_pending": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "certificate_id"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Request rejected or resource unavailable. JSON errors include a machine-readable code. Hidden or unknown resources may return HTTP 404."
          }
        }
      }
    },
    "/certificates/{id}/actions/replace": {
      "post": {
        "summary": "Request replacement",
        "x-required-scope": "replace",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "description": "Reuse the same key and exact request bytes when retrying."
          }
        ],
        "responses": {
          "202": {
            "description": "Existing or newly accepted job",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "certificate_id": {
                      "type": "string"
                    },
                    "job_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "adopted": {
                      "type": "boolean"
                    },
                    "managed": {
                      "type": "boolean"
                    },
                    "deleted": {
                      "type": "boolean"
                    },
                    "reuses_existing_certificate": {
                      "type": "boolean"
                    },
                    "certificate_capacity_release_pending": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "certificate_id"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Request rejected or resource unavailable. JSON errors include a machine-readable code. Hidden or unknown resources may return HTTP 404."
          }
        }
      }
    },
    "/certificates/{id}/actions/reissue": {
      "post": {
        "summary": "Redeploy retained certificate material",
        "x-required-scope": "reissue",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "description": "Reuse the same key and exact request bytes when retrying."
          }
        ],
        "responses": {
          "202": {
            "description": "Existing or newly accepted job",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "certificate_id": {
                      "type": "string"
                    },
                    "job_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "adopted": {
                      "type": "boolean"
                    },
                    "managed": {
                      "type": "boolean"
                    },
                    "deleted": {
                      "type": "boolean"
                    },
                    "reuses_existing_certificate": {
                      "type": "boolean"
                    },
                    "certificate_capacity_release_pending": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "certificate_id"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Request rejected or resource unavailable. JSON errors include a machine-readable code. Hidden or unknown resources may return HTTP 404."
          }
        }
      }
    },
    "/certificates/{id}/actions/recover": {
      "post": {
        "summary": "Recover failed deployment",
        "x-required-scope": "recover",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "description": "Reuse the same key and exact request bytes when retrying."
          }
        ],
        "responses": {
          "202": {
            "description": "Existing or newly accepted job",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "certificate_id": {
                      "type": "string"
                    },
                    "job_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "adopted": {
                      "type": "boolean"
                    },
                    "managed": {
                      "type": "boolean"
                    },
                    "deleted": {
                      "type": "boolean"
                    },
                    "reuses_existing_certificate": {
                      "type": "boolean"
                    },
                    "certificate_capacity_release_pending": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "certificate_id"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Request rejected or resource unavailable. JSON errors include a machine-readable code. Hidden or unknown resources may return HTTP 404."
          }
        }
      }
    },
    "/certificates/{id}/actions/adopt": {
      "post": {
        "summary": "Adopt discovered inventory",
        "x-required-scope": "adopt",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "description": "Reuse the same key and exact request bytes when retrying."
          }
        ],
        "responses": {
          "200": {
            "description": "Certificate adopted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "certificate_id": {
                      "type": "string"
                    },
                    "job_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "adopted": {
                      "type": "boolean"
                    },
                    "managed": {
                      "type": "boolean"
                    },
                    "deleted": {
                      "type": "boolean"
                    },
                    "reuses_existing_certificate": {
                      "type": "boolean"
                    },
                    "certificate_capacity_release_pending": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "certificate_id"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Request rejected or resource unavailable. JSON errors include a machine-readable code. Hidden or unknown resources may return HTTP 404."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "target_id": {
                    "type": "string"
                  },
                  "provider": {
                    "type": "string"
                  },
                  "renewal_before_days": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 3650,
                    "description": "Whole days before expiry for a day-based policy."
                  },
                  "renewal_mode": {
                    "enum": [
                      "approval",
                      "automatic"
                    ]
                  },
                  "renewal_retry_count": {
                    "type": "integer"
                  },
                  "renewal_retry_delay_minutes": {
                    "type": "integer"
                  },
                  "maintenance_window_start": {
                    "type": "string"
                  },
                  "maintenance_window_end": {
                    "type": "string"
                  },
                  "renewal_window_type": {
                    "type": "string",
                    "enum": [
                      "days",
                      "percentage"
                    ],
                    "description": "Unit used for the renewal threshold."
                  },
                  "renewal_remaining_percent": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 99,
                    "description": "Percentage of the current leaf lifetime remaining when renewal becomes eligible."
                  }
                },
                "required": [],
                "not": {
                  "required": [
                    "renewal_before_days",
                    "renewal_remaining_percent"
                  ]
                },
                "allOf": [
                  {
                    "if": {
                      "required": [
                        "renewal_window_type"
                      ],
                      "properties": {
                        "renewal_window_type": {
                          "const": "percentage"
                        }
                      }
                    },
                    "then": {
                      "required": [
                        "renewal_remaining_percent"
                      ]
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "renewal_window_type"
                      ],
                      "properties": {
                        "renewal_window_type": {
                          "const": "days"
                        }
                      }
                    },
                    "then": {
                      "required": [
                        "renewal_before_days"
                      ]
                    }
                  }
                ]
              }
            }
          }
        },
        "description": "Choose one timing unit. Omit both timing values to retain day-based defaults for new records or the existing timing on adoption."
      }
    },
    "/certificates/{id}/actions/revoke": {
      "post": {
        "summary": "Revoke the issued certificate",
        "x-required-scope": "revoke",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "description": "Reuse the same key and exact request bytes when retrying."
          }
        ],
        "responses": {
          "202": {
            "description": "Existing or newly accepted job",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "certificate_id": {
                      "type": "string"
                    },
                    "job_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "adopted": {
                      "type": "boolean"
                    },
                    "managed": {
                      "type": "boolean"
                    },
                    "deleted": {
                      "type": "boolean"
                    },
                    "reuses_existing_certificate": {
                      "type": "boolean"
                    },
                    "certificate_capacity_release_pending": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "certificate_id"
                  ]
                }
              }
            }
          },
          "200": {
            "description": "Internal ACME revocation completed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "certificate_id": {
                      "type": "string"
                    },
                    "job_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "adopted": {
                      "type": "boolean"
                    },
                    "managed": {
                      "type": "boolean"
                    },
                    "deleted": {
                      "type": "boolean"
                    },
                    "reuses_existing_certificate": {
                      "type": "boolean"
                    },
                    "certificate_capacity_release_pending": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "certificate_id"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Request rejected or resource unavailable. JSON errors include a machine-readable code. Hidden or unknown resources may return HTTP 404."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "enum": [
                      "unspecified",
                      "key_compromise",
                      "affiliation_changed",
                      "superseded",
                      "cessation_of_operation"
                    ]
                  },
                  "message": {
                    "type": "string"
                  }
                },
                "required": [
                  "reason"
                ]
              }
            }
          }
        },
        "description": "Internal ACME completes synchronously for the exact issued certificate. Supported external adapters return a job to poll. An unsupported adapter or conflicting in-flight revocation returns 409."
      }
    },
    "/certificates/{id}/renewal-preview": {
      "get": {
        "summary": "Preview renewal timing",
        "x-required-scope": "read",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "renewal_window_type",
            "schema": {
              "type": "string",
              "enum": [
                "days",
                "percentage"
              ],
              "description": "Unit used for the renewal threshold."
            }
          },
          {
            "in": "query",
            "name": "renewal_before_days",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 3650,
              "description": "Whole days before expiry for a day-based policy."
            }
          },
          {
            "in": "query",
            "name": "renewal_remaining_percent",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 99,
              "description": "Percentage of the current leaf lifetime remaining when renewal becomes eligible."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Projected timing, recovery margin and any conflicts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "eligible_from": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "next_check": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "next_attempt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "reviewed_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "conflict": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "warning": {
                      "type": "string"
                    },
                    "unknown_dates": {
                      "type": "boolean"
                    },
                    "newly_due": {
                      "type": "boolean"
                    },
                    "minimum_lead_conflict": {
                      "type": "boolean"
                    },
                    "recovery_seconds": {
                      "type": "integer",
                      "description": "Time between the estimated permitted attempt and expiry, in seconds."
                    }
                  }
                },
                "example": {
                  "eligible_from": "2026-11-02T21:36:00Z",
                  "next_check": "2026-11-03T02:00:00Z",
                  "next_attempt": "2026-11-03T02:00:00Z",
                  "recovery_seconds": 1202400
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Identifier recorded in the local read audit event.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Request rejected or resource unavailable. JSON errors include a machine-readable code. Hidden or unknown resources may return HTTP 404."
          }
        },
        "description": "Omit query parameters to inspect the saved policy. Supply one timing value to preview a change. The response only includes dates that can be determined for the current leaf. A preview does not change a policy or queue a renewal."
      }
    }
  }
}
