{
  "openapi": "3.1.0",
  "info": {
    "title": "CertLocker API",
    "version": "1.0.1",
    "description": "The CertLocker API covers certificate management, secret storage, token lifecycle, and the Agent API for AI agents and automation.\n\n## Authentication\n\nEndpoints require an `x-api-token` header, except OIDC exchange which authenticates the `id_token` JWT in its request body. For human/app access use a standard token; for AI agents use a scoped MCP token (max 90-day TTL).\n\n## Agent flows\n\n1. `POST /api/agent/session/start`\n2. `GET /api/agent/permissions` — check available scopes\n3. Use metadata endpoints before raw-value endpoints\n4. `POST /api/agent/ssh/session?dryRun=true` before any SSH request\n5. `POST /api/agent/token/revoke` when done\n\n## Privileged endpoints\n\nEndpoints marked ⚠️ **Privileged** return raw values (secret text, private keys). Every call is audited. Prefer metadata endpoints where the raw value is not needed.",
    "contact": {
      "name": "CertLocker Support",
      "url": "https://certlocker.io/contact",
      "email": "support@certlocker.io"
    },
    "license": {
      "name": "Proprietary",
      "identifier": "LicenseRef-CertLocker-Proprietary"
    }
  },
  "servers": [
    {
      "url": "{apiBaseUrl}",
      "description": "CertLocker API",
      "variables": {
        "apiBaseUrl": {
          "default": "https://trust.certlocker.io/rest",
          "description": "Base URL configured by CERTLOCKER_PUBLIC_API_BASE_URL"
        }
      }
    }
  ],
  "security": [
    {
      "ApiToken": []
    }
  ],
  "tags": [
    {
      "name": "OIDC",
      "description": "Exchange workload or enrolled device identity for a short-lived CertLocker token."
    },
    {
      "name": "Agent API",
      "description": "AI agent and MCP integration. All endpoints require a scoped MCP token."
    },
    {
      "name": "Certificates",
      "description": "Certificate fetch and metadata. Fetch-bundle returns the private key — treat as privileged."
    },
    {
      "name": "Secrets",
      "description": "Secret storage management. Fetch returns the raw value — treat as privileged."
    },
    {
      "name": "Tokens",
      "description": "Token lifecycle: get details, list available hosts."
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiToken": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-token",
        "description": "CertLocker token. For agents: a scoped MCP token (max 90-day TTL). Do not embed in source code — use a secrets manager."
      }
    },
    "responses": {
      "AccessDenied": {
        "description": "Forbidden — token lacks required scope or group access",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/error"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Unauthorized — missing or invalid x-api-token",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/error"
            }
          }
        }
      }
    },
    "schemas": {
      "AgentApprovalRequestDTO": {
        "type": "object",
        "properties": {
          "payload": {
            "type": "string"
          }
        }
      },
      "AgentAuditEventRequestDTO": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "resource_id": {
            "type": "string"
          }
        }
      },
      "AgentProbeRequestDTO": {
        "type": "object",
        "properties": {
          "host": {
            "type": "string"
          },
          "port": {
            "type": "integer",
            "format": "int32"
          },
          "dry_run": {
            "type": "boolean"
          }
        }
      },
      "AgentSessionStartRequestDTO": {
        "type": "object",
        "properties": {
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        }
      },
      "AgentSshSessionRequestDTO": {
        "type": "object",
        "properties": {
          "host_id": {
            "type": "string"
          },
          "dry_run": {
            "type": "boolean"
          }
        }
      },
      "AssetStatus": {
        "type": "string",
        "enum": [
          "ACTIVE",
          "SUSPENDED",
          "EXPIRED",
          "REVOKED"
        ]
      },
      "CertValidation": {
        "type": "string",
        "enum": [
          "DV",
          "OV",
          "EV",
          "SS",
          "UNKNOWN"
        ]
      },
      "OidcExchangeRequestDTO": {
        "type": "object",
        "properties": {
          "idToken": {
            "type": "string"
          },
          "tokenType": {
            "$ref": "#/components/schemas/TokenType"
          }
        }
      },
      "OidcExchangeResponseDTO": {
        "type": "object",
        "properties": {
          "error_message": {
            "type": "string"
          },
          "requires_access_code": {
            "type": "boolean"
          },
          "requires2f_a": {
            "type": "boolean"
          },
          "access_response": {
            "type": "string"
          },
          "tokenId": {
            "type": "string"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "examples": [
              "2022-03-10T12:15:50"
            ]
          },
          "tokenType": {
            "$ref": "#/components/schemas/TokenType"
          },
          "accountId": {
            "type": "string"
          },
          "principalId": {
            "type": "string"
          }
        }
      },
      "Protocol": {
        "type": "string",
        "enum": [
          "SSH",
          "SFTP",
          "HTTPS",
          "ACME",
          "MCP",
          "RDP",
          "VNC"
        ]
      },
      "SecretType": {
        "type": "string",
        "enum": [
          "PRIVATE_KEY",
          "PEM",
          "PASSWORD",
          "CREDENTIALS",
          "CONFIGURATION"
        ]
      },
      "SuccessResponseDO": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "TokenType": {
        "type": "string",
        "enum": [
          "CERTIFICATE",
          "HOST",
          "BASTION",
          "SECRET",
          "ROOT",
          "MCP",
          "WILDCARD"
        ]
      },
      "certificate": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "account_id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/AssetStatus"
          },
          "groups": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "created_by": {
            "type": "string"
          },
          "updated_by": {
            "type": "string"
          },
          "date_created": {
            "type": "string",
            "format": "date-time",
            "examples": [
              "2022-03-10T12:15:50"
            ]
          },
          "date_updated": {
            "type": "string",
            "format": "date-time",
            "examples": [
              "2022-03-10T12:15:50"
            ]
          },
          "primary_domain": {
            "type": "string"
          },
          "san_domains": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "not_before": {
            "type": "string",
            "format": "date-time",
            "examples": [
              "2022-03-10T12:15:50"
            ]
          },
          "entries": {
            "type": "integer",
            "format": "int32"
          },
          "serial_number": {
            "type": "string"
          },
          "public_key_algo": {
            "type": "string"
          },
          "issuer_cn": {
            "type": "string"
          },
          "issuer_o": {
            "type": "string"
          },
          "fingerprint_sha256": {
            "type": "string"
          },
          "fingerprint_sha1": {
            "type": "string"
          },
          "cert_validation": {
            "$ref": "#/components/schemas/CertValidation"
          }
        }
      },
      "error": {
        "type": "object",
        "properties": {
          "error_message": {
            "type": "string"
          }
        }
      },
      "host": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "account_id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/AssetStatus"
          },
          "groups": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "created_by": {
            "type": "string"
          },
          "updated_by": {
            "type": "string"
          },
          "date_created": {
            "type": "string",
            "format": "date-time",
            "examples": [
              "2022-03-10T12:15:50"
            ]
          },
          "date_updated": {
            "type": "string",
            "format": "date-time",
            "examples": [
              "2022-03-10T12:15:50"
            ]
          },
          "ip_address": {
            "type": "string"
          },
          "port": {
            "type": "integer",
            "format": "int32"
          },
          "operating_system": {
            "type": "string"
          },
          "secret_id": {
            "type": "string"
          },
          "bastion_id": {
            "type": "string"
          }
        }
      },
      "hosts": {
        "type": "object",
        "properties": {
          "hosts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/host"
            }
          }
        }
      },
      "secret": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/AssetStatus"
          },
          "groups": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "secret_type": {
            "$ref": "#/components/schemas/SecretType"
          },
          "secret": {
            "type": "string",
            "writeOnly": true,
            "description": "Secret value to store. Never returned by metadata endpoints."
          }
        }
      },
      "secret1": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "account_id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/AssetStatus"
          },
          "groups": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "created_by": {
            "type": "string"
          },
          "updated_by": {
            "type": "string"
          },
          "date_created": {
            "type": "string",
            "format": "date-time",
            "examples": [
              "2022-03-10T12:15:50"
            ]
          },
          "date_updated": {
            "type": "string",
            "format": "date-time",
            "examples": [
              "2022-03-10T12:15:50"
            ]
          },
          "secret_type": {
            "$ref": "#/components/schemas/SecretType"
          },
          "version": {
            "type": "integer",
            "format": "int32"
          }
        }
      },
      "token": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "account_id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/AssetStatus"
          },
          "groups": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "created_by": {
            "type": "string"
          },
          "updated_by": {
            "type": "string"
          },
          "date_created": {
            "type": "string",
            "format": "date-time",
            "examples": [
              "2022-03-10T12:15:50"
            ]
          },
          "date_updated": {
            "type": "string",
            "format": "date-time",
            "examples": [
              "2022-03-10T12:15:50"
            ]
          },
          "single_use": {
            "type": "boolean"
          },
          "protocols": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Protocol"
            }
          },
          "token_type": {
            "$ref": "#/components/schemas/TokenType"
          },
          "hosts": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "group_access": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "secret_id": {
            "type": "string"
          },
          "access_code": {
            "type": "string"
          },
          "bastion_id": {
            "type": "string"
          },
          "cert_id": {
            "type": "string"
          },
          "auto_rotate": {
            "type": "boolean"
          },
          "user_id": {
            "type": "string"
          }
        }
      }
    }
  },
  "paths": {
    "/api/agent/approval/request": {
      "post": {
        "summary": "Request human approval",
        "tags": [
          "Agent API"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentApprovalRequestDTO"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Missing or invalid x-api-token"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        },
        "description": "Submits an approval request to a human operator. Required before dangerous or production-scoped actions. Requires `approval:request` scope."
      }
    },
    "/api/agent/audit/event": {
      "post": {
        "summary": "Write agent audit event",
        "tags": [
          "Agent API"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentAuditEventRequestDTO"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Missing or invalid x-api-token"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        },
        "description": "Writes an agent-authored audit event. Requires `audit:write` scope."
      }
    },
    "/api/agent/certificates/{id}": {
      "get": {
        "summary": "Get certificate by id or name",
        "tags": [
          "Agent API"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Missing or invalid x-api-token"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        },
        "description": "Returns certificate metadata including domain, expiry, and fingerprint. Does not return private key material. Requires `certificate:read` scope."
      }
    },
    "/api/agent/hosts": {
      "get": {
        "summary": "List allowed hosts",
        "tags": [
          "Agent API"
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Missing or invalid x-api-token"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        },
        "description": "Lists allowed hosts visible to this token. Host names and ids only — no credentials."
      }
    },
    "/api/agent/permissions": {
      "get": {
        "summary": "Agent permissions",
        "tags": [
          "Agent API"
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Missing or invalid x-api-token"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        },
        "description": "Returns the scopes and group access granted to this token. Call this first to understand what actions are available before attempting them."
      }
    },
    "/api/agent/probes": {
      "post": {
        "summary": "Create probe — use dryRun=true to validate permissions without creating a probe",
        "tags": [
          "Agent API"
        ],
        "parameters": [
          {
            "description": "Validate only, do not create probe",
            "in": "query",
            "name": "dryRun",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentProbeRequestDTO"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Missing or invalid x-api-token"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        },
        "description": "Creates a connectivity probe for the given host and port. Requires `probe:create` scope. Use `dryRun=true` to validate permissions without creating a probe."
      }
    },
    "/api/agent/profile": {
      "get": {
        "summary": "Agent profile",
        "tags": [
          "Agent API"
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Missing or invalid x-api-token"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        },
        "description": "Returns the agent name, id, owner, and risk level. Requires an active session."
      }
    },
    "/api/agent/secrets": {
      "get": {
        "summary": "List allowed secrets",
        "tags": [
          "Agent API"
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Missing or invalid x-api-token"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        },
        "description": "Lists secret names and ids visible to this token. Does not return raw values."
      }
    },
    "/api/agent/secrets/{id}": {
      "get": {
        "summary": "Get secret by id or name — returns raw value; requires explicit authorization",
        "tags": [
          "Agent API"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Missing or invalid x-api-token"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        },
        "description": "⚠️ **Privileged.** Returns the raw secret value. Requires `secret:read` scope. This action is audited. Prefer `GET /api/agent/secrets/{id}/metadata` unless the value is explicitly needed.",
        "x-certlocker-privileged": true
      }
    },
    "/api/agent/secrets/{id}/metadata": {
      "get": {
        "summary": "Get secret metadata (id, name, expiry) — never returns raw secret value",
        "tags": [
          "Agent API"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Missing or invalid x-api-token"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        },
        "description": "Returns secret id, name, and expiry. Never returns the raw value. Use this to inspect a secret safely before deciding whether to fetch the value."
      }
    },
    "/api/agent/session/end": {
      "post": {
        "summary": "End agent session",
        "tags": [
          "Agent API"
        ],
        "responses": {
          "201": {
            "description": "Created"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Missing or invalid x-api-token"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        },
        "description": "Ends the current agent session."
      }
    },
    "/api/agent/session/start": {
      "post": {
        "summary": "Start agent session",
        "tags": [
          "Agent API"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentSessionStartRequestDTO"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Missing or invalid x-api-token"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        },
        "description": "Starts an agent session and returns a session id. The session id must be included in subsequent requests. Requires a valid MCP token in `x-api-token`."
      }
    },
    "/api/agent/ssh/session": {
      "post": {
        "summary": "Request SSH session — use dryRun=true to validate permissions without creating a session",
        "tags": [
          "Agent API"
        ],
        "parameters": [
          {
            "description": "Validate only, do not create session",
            "in": "query",
            "name": "dryRun",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentSshSessionRequestDTO"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Missing or invalid x-api-token"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        },
        "description": "⚠️ **Dangerous.** Requests a JIT SSH session for an allowed host. Requires `ssh_session:request` scope. This action is audited. Use `dryRun=true` to validate permissions without creating a session."
      }
    },
    "/api/agent/token/revoke": {
      "post": {
        "summary": "Revoke the current MCP token — the token cannot be used after this call",
        "tags": [
          "Agent API"
        ],
        "responses": {
          "201": {
            "description": "Created"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Missing or invalid x-api-token"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        },
        "description": "Immediately revokes the MCP token used in this request. No further calls can be made with it after revocation."
      }
    },
    "/api/v1/cert/{account}/fetch-bundle/{token}": {
      "get": {
        "summary": "Fetch Certificate, with the private key.",
        "description": "⚠️ **Privileged.** Returns the full certificate bundle including private key as PEM. Use only when private key material is explicitly required. This action is audited.",
        "tags": [
          "Certificates"
        ],
        "parameters": [
          {
            "description": "account",
            "required": true,
            "name": "account",
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "token",
            "required": true,
            "name": "token",
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Fetch Certificate",
            "content": {
              "text/plain": {}
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Missing or invalid x-api-token"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        },
        "x-certlocker-privileged": true
      }
    },
    "/api/v1/cert/{account}/fetch/{token}": {
      "get": {
        "summary": "Fetch Certificate",
        "description": "Returns the certificate as PEM text. Public certificate only — no private key.",
        "tags": [
          "Certificates"
        ],
        "parameters": [
          {
            "description": "account",
            "required": true,
            "name": "account",
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "token",
            "required": true,
            "name": "token",
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Fetch Certificate",
            "content": {
              "text/plain": {}
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Missing or invalid x-api-token"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        }
      }
    },
    "/api/v1/cert/{account}/get/{token}": {
      "get": {
        "summary": "Get certificate details",
        "description": "Returns certificate metadata: id, name, status, groups, validity dates.",
        "tags": [
          "Certificates"
        ],
        "parameters": [
          {
            "description": "account",
            "required": true,
            "name": "account",
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "token",
            "required": true,
            "name": "token",
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Certificate Details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/certificate"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Missing or invalid x-api-token"
          },
          "404": {
            "description": "Not found"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        }
      }
    },
    "/api/v1/oidc/exchange": {
      "post": {
        "summary": "Exchange OIDC JWT",
        "description": "Authenticates the id_token JWT in the JSON body and returns a short-lived token_id for subsequent x-api-token requests. No existing CertLocker API token is required.",
        "tags": [
          "OIDC"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OidcExchangeRequestDTO"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Minted token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OidcExchangeResponseDTO"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Identity or requested token type is not authorized"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        },
        "security": []
      }
    },
    "/api/v1/secret/{account}/create": {
      "post": {
        "summary": "Create secret",
        "description": "Creates a new secret. Returns confirmation with the secret id.",
        "tags": [
          "Secrets"
        ],
        "parameters": [
          {
            "description": "account",
            "required": true,
            "name": "account",
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "secret",
          "content": {
            "*/*": {
              "schema": {
                "$ref": "#/components/schemas/secret"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "secret details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/secret1"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Missing or invalid x-api-token"
          },
          "404": {
            "description": "Not found"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        }
      }
    },
    "/api/v1/secret/{account}/fetch": {
      "get": {
        "summary": "Fetch Secret",
        "description": "Privileged. Returns the raw value of the secret assigned to the authentication token.",
        "tags": [
          "Secrets"
        ],
        "parameters": [
          {
            "description": "account",
            "required": true,
            "name": "account",
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Fetch Secret",
            "content": {
              "text/plain": {},
              "application/json": {}
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Missing or invalid x-api-token"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        },
        "x-certlocker-privileged": true
      }
    },
    "/api/v1/secret/{account}/fetch/{secret}": {
      "get": {
        "summary": "Fetch Secret",
        "description": "⚠️ **Privileged.** Returns the raw secret value as plain text. This action is audited. Use `GET /api/v1/secret/{account}/get/{secret}` for metadata-only access.",
        "tags": [
          "Secrets"
        ],
        "parameters": [
          {
            "description": "account",
            "required": true,
            "name": "account",
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "secret",
            "required": true,
            "name": "secret",
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Fetch Secret",
            "content": {
              "text/plain": {},
              "application/json": {}
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Missing or invalid x-api-token"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        },
        "x-certlocker-privileged": true
      }
    },
    "/api/v1/secret/{account}/get/{secret}": {
      "get": {
        "summary": "Get secret",
        "description": "Returns secret metadata: id, name, status, groups, created_by. Never returns the raw value.",
        "tags": [
          "Secrets"
        ],
        "parameters": [
          {
            "description": "account",
            "required": true,
            "name": "account",
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "secret",
            "required": true,
            "name": "secret",
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "secret Details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/secret1"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Missing or invalid x-api-token"
          },
          "404": {
            "description": "Not found"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        }
      }
    },
    "/api/v1/secret/{account}/lookup": {
      "get": {
        "summary": "Lookup secret",
        "description": "Looks up a secret by name. Returns metadata only, no raw value.",
        "tags": [
          "Secrets"
        ],
        "parameters": [
          {
            "description": "Any number of dynamic query parameters (e.g. ?name=my-secret&status=EXPIRED)",
            "in": "query",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            },
            "style": "form"
          },
          {
            "description": "account",
            "required": true,
            "name": "account",
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "secret Details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/secret1"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Missing or invalid x-api-token"
          },
          "404": {
            "description": "Not found"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        }
      }
    },
    "/api/v1/secret/{account}/revoke/{secret}": {
      "post": {
        "summary": "Revoke secret",
        "description": "Revokes a secret, preventing further use.",
        "tags": [
          "Secrets"
        ],
        "parameters": [
          {
            "description": "account",
            "required": true,
            "name": "account",
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "secret",
            "required": true,
            "name": "secret",
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "If successful",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponseDO"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Missing or invalid x-api-token"
          },
          "404": {
            "description": "Not found"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        }
      }
    },
    "/api/v1/token/{account}/get/{token}": {
      "get": {
        "summary": "Get Token",
        "description": "Returns token metadata: id, name, status, type, groups, expiry.",
        "tags": [
          "Tokens"
        ],
        "parameters": [
          {
            "description": "account",
            "required": true,
            "name": "account",
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "token",
            "required": true,
            "name": "token",
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Token Details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/token"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Missing or invalid x-api-token"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        }
      }
    },
    "/api/v1/token/{account}/hosts-available/{token}": {
      "post": {
        "summary": "Hosts Available",
        "description": "Lists the hosts available for use with a given token.",
        "tags": [
          "Tokens"
        ],
        "parameters": [
          {
            "description": "account",
            "required": true,
            "name": "account",
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "token",
            "required": true,
            "name": "token",
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of hosts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/hosts"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error"
                }
              }
            }
          },
          "403": {
            "description": "Missing or invalid x-api-token"
          },
          "429": {
            "description": "Too many requests"
          },
          "500": {
            "description": "Internal Error"
          }
        }
      }
    }
  }
}