{
  "openapi": "3.1.0",
  "info": {
    "title": "RedactTool REST API",
    "version": "1.3.0",
    "description": "Bearer-authenticated document redaction. Configure the service base URL."
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v1/files": {
      "post": {
        "operationId": "uploadFile",
        "summary": "Upload document bytes",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Uploaded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "file_id",
                    "bytes",
                    "extension"
                  ],
                  "properties": {
                    "file_id": {
                      "type": "string"
                    },
                    "bytes": {
                      "type": "integer"
                    },
                    "extension": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "HTTP error; inspect detail",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "detail": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/redactions": {
      "post": {
        "operationId": "createRedaction",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 100,
              "pattern": "^[A-Za-z0-9_-]+$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "file_id",
                  "mode"
                ],
                "properties": {
                  "file_id": {
                    "type": "string"
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "blackout",
                      "placeholder"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Job accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "default": {
            "description": "HTTP error; inspect detail",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "detail": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/redactions/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "getRedaction",
        "responses": {
          "200": {
            "description": "Job state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "default": {
            "description": "HTTP error; inspect detail",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "detail": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/redactions/{id}/file": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "downloadRedaction",
        "responses": {
          "200": {
            "description": "Processed file",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "default": {
            "description": "HTTP error; inspect detail",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "detail": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "Job": {
        "type": "object",
        "required": [
          "id",
          "status"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "completed",
              "failed"
            ]
          },
          "stage": {
            "type": "string"
          },
          "done": {
            "type": "integer"
          },
          "total": {
            "type": "integer"
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "mode": {
            "type": "string",
            "enum": [
              "blackout",
              "placeholder"
            ]
          },
          "redactions": {
            "type": "integer"
          },
          "download_url": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      }
    }
  }
}