{
  "openapi": "3.0.0",
  "info": {
    "title": "Vault Cloud Public API",
    "description": "API pública do Vault Cloud",
    "version": "1.0.1"
  },
  "paths": {
    "/certificates": {
      "post": {
        "tags": ["Certificates"],
        "summary": "Requests the emission of a new certificate",
        "description": "Creates an emission request for a new certificate.",
        "operationId": "b7248d4b8e80cf3816058a199ab09bf7",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "required": [
                  "username",
                  "password",
                  "email",
                  "name",
                  "certificate_profile"
                ],
                "properties": {
                  "username": {
                    "type": "string",
                    "example": "DUI-12345678-9"
                  },
                  "password": {
                    "type": "string",
                    "format": "password",
                    "example": "P@ssw0rd!"
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "example": "john.doe@example.com"
                  },
                  "name": {
                    "type": "string",
                    "example": "John Doe"
                  },
                  "phone_number": {
                    "type": "string",
                    "example": "+50391234567"
                  },
                  "certificate_profile": {
                    "type": "string",
                    "example": "A1_STANDARD"
                  },
                  "alias": {
                    "type": "string",
                    "example": "john_doe_cert"
                  },
                  "metadata": {
                    "type": "object",
                    "example": {
                      "CN": "John doe",
                      "givenName": "John",
                      "surname": "doe",
                      "serialNumber": "DUI-12345678-9",
                      "C": "SV",
                      "ST": "San Salvador",
                      "L": "San Salvador",
                      "streetAddress": "Corner Street, 20",
                      "postalCode": "36576300"
                    },
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "callback_url": {
                    "type": "string",
                    "format": "uri",
                    "example": "https://example.com/callback"
                  }
                },
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Certificate enrollment request created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "serial_number": {
                      "type": "string",
                      "example": "1234567890"
                    }
                  },
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          }
        }
      }
    },
    "/certificates/{serial_number}": {
      "get": {
        "tags": ["Certificates"],
        "summary": "Fetches user certificates",
        "description": "Retrieves the certificate and its status associated with a specific serial number.",
        "operationId": "fd425cfc61b23c71833b4e059ec06668",
        "parameters": [
          {
            "name": "serial_number",
            "in": "path",
            "description": "The serial number of the certificate to be fetched",
            "required": true,
            "schema": {
              "type": "string",
              "example": "1234567890"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Certificate emission fetched successfully",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "string",
                      "example": "1234567890 john_doe"
                    },
                    "status": {
                      "description": "0: Pending, 1-4: Processing, 5: Finished, 900-905: Error states",
                      "type": "integer",
                      "example": 0
                    },
                    "date_start": {
                      "type": "string",
                      "format": "date-time",
                      "example": "2024-01-01T12:00:00Z"
                    },
                    "date_end": {
                      "type": "string",
                      "format": "date-time",
                      "example": "2024-01-01T12:00:00Z"
                    },
                    "certificate": {
                      "properties": {
                        "alias": {
                          "type": "string",
                          "example": "john_doe_cert"
                        },
                        "crt": {
                          "type": "string",
                          "example": "-----BEGIN CERTIFICATE-----MIID...-----END CERTIFICATE-----"
                        },
                        "is_revoked": {
                          "type": "boolean",
                          "example": false
                        },
                        "expire_time": {
                          "type": "string",
                          "format": "date-time",
                          "example": "2024-01-01T12:00:00Z"
                        }
                      },
                      "type": "object"
                    }
                  },
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/certificates/revoke/{serialNumber}": {
      "put": {
        "tags": ["Revoke"],
        "summary": "Revokes a certificate",
        "description": "Revokes a certificate using the certificate serial number.",
        "operationId": "revokeCertificate",
        "parameters": [
          {
            "name": "serialNumber",
            "in": "path",
            "description": "Certificate serial number (hexadecimal)",
            "required": true,
            "schema": {
              "type": "string",
              "example": "2E4A7DD27F8B775E"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "required": ["issuer_dn", "reason"],
                "properties": {
                  "issuer_dn": {
                    "description": "Issuer Distinguished Name",
                    "type": "string",
                    "example": "UID=c-01ubfek040v2byazr,CN=ManagementCA,O=EJBCA Container Quickstart"
                  },
                  "reason": {
                    "description": "Revocation reason according to RFC 5280",
                    "type": "string",
                    "enum": [
                      "KEY_COMPROMISE",
                      "CA_COMPROMISE",
                      "AFFILIATION_CHANGED",
                      "SUPERSEDED",
                      "CESSATION_OF_OPERATION",
                      "PRIVILEGES_WITHDRAWN",
                      "AA_COMPROMISE",
                      "REMOVE_FROM_CRL",
                      "CERTIFICATE_HOLD",
                      "UNSPECIFIED "
                    ],
                    "example": "KEY_COMPROMISE"
                  }
                },
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Certificate revoked successfully",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "issuer_dn": {
                      "type": "string",
                      "example": "UID=c-01ubfek040v2byazr,CN=ManagementCA,O=EJBCA Container Quickstart"
                    },
                    "revocation_reason": {
                      "type": "string",
                      "example": "KEY_COMPROMISE"
                    },
                    "revocation_date": {
                      "type": "string",
                      "format": "date-time",
                      "example": "2026-01-14T20:18:08Z"
                    },
                    "serial_number": {
                      "type": "string",
                      "example": "2E4A7DD27F8B775E"
                    },
                    "message": {
                      "type": "string",
                      "example": "Successfully revoked"
                    },
                    "revoked": {
                      "type": "boolean",
                      "example": true
                    },
                    "invalidity_date": {
                      "type": "string",
                      "format": "date-time",
                      "example": null,
                      "nullable": true
                    },
                    "detail": {
                      "properties": {
                        "code": {
                          "type": "integer",
                          "example": 1270
                        },
                        "status": {
                          "type": "string",
                          "example": "CRT_REVOKED_SUCCESS"
                        },
                        "message": {
                          "type": "string",
                          "example": "Certificate successfully revoked."
                        }
                      },
                      "type": "object"
                    }
                  },
                  "type": "object"
                }
              }
            }
          },
          "422": {
            "description": "Issuer DN incompatible with certificate",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "code": {
                      "type": "integer",
                      "example": 1272
                    },
                    "status": {
                      "type": "string",
                      "example": "FAILED_INCOMPATIBLE_ISSUER_DN"
                    },
                    "message": {
                      "type": "string",
                      "example": "Provided issuerDN does not match the certificate."
                    }
                  },
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid emission code",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "type": {
                      "type": "string",
                      "format": "uri",
                      "example": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html"
                    },
                    "title": {
                      "type": "string",
                      "example": "Bad Request"
                    },
                    "status": {
                      "type": "integer",
                      "example": 400
                    },
                    "detail": {
                      "properties": {
                        "code": {
                          "type": "integer",
                          "example": 1061
                        },
                        "status": {
                          "type": "string",
                          "example": "INVALID_EMISSION_CODE"
                        },
                        "message": {
                          "type": "string",
                          "example": "Invalid Emission Code"
                        }
                      },
                      "type": "object"
                    }
                  },
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/user/recover-pin": {
      "post": {
        "tags": ["RecoverPin"],
        "summary": "Recuperação de PIN do usuário",
        "description": "Endpoint responsible for initiating the user's PIN recovery process.",
        "operationId": "recoverPin",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "required": ["username", "password", "email"],
                "properties": {
                  "username": {
                    "description": "Identificador do usuário",
                    "type": "string",
                    "example": "DUI-12345678-9"
                  },
                  "password": {
                    "description": "Senha do usuário",
                    "type": "string",
                    "example": "123456789"
                  },
                  "email": {
                    "description": "E-mail cadastrado para recuperação do PIN",
                    "type": "string",
                    "format": "email",
                    "example": "teste@teste.com.br"
                  }
                },
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Certificates",
      "description": "Certificates"
    },
    {
      "name": "Revoke",
      "description": "Revoke"
    },
    {
      "name": "RecoverPin",
      "description": "RecoverPin"
    }
  ]
}
