{
  "openapi": "3.0.3",
  "info": {
    "title": "File Room API",
    "version": "0.1.0",
    "description": "Development contract. Unknown file. Clear picture. No public endpoint, pricing or checkout is live. Browser inspection remains independent and local."
  },
  "servers": [
    {
      "url": "http://127.0.0.1:4180",
      "description": "Local development service"
    }
  ],
  "security": [
    {
      "ApiKey": []
    }
  ],
  "paths": {
    "/v1/inspect": {
      "post": {
        "operationId": "inspectFile",
        "summary": "Identify an unknown file",
        "description": "One credit per completed inspection. No stored results or replay. A lost response may still have consumed a credit. No malware verdict.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Random lowercase UUID v4. Reused IDs return 409 without rerunning or charging."
          },
          {
            "name": "X-File-Name",
            "in": "header",
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "description": "Optional name; bytes determine format."
          },
          {
            "name": "X-Include-Preview",
            "in": "header",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Include a requested bounded preview."
          },
          {
            "name": "X-Include-Fingerprint",
            "in": "header",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Include a requested SHA-256."
          },
          {
            "name": "X-Max-Preview-Chars",
            "in": "header",
            "schema": {
              "type": "integer",
              "minimum": 200,
              "maximum": 8000,
              "default": 2000
            },
            "description": "Preview character budget."
          }
        ],
        "requestBody": {
          "required": true,
          "description": "Raw file bytes, at most 20 MiB.",
          "content": {
            "application/octet-stream": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Identification and requested optional preview",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "schema",
                    "usage"
                  ],
                  "properties": {
                    "schema": {
                      "type": "string"
                    },
                    "usage": {
                      "$ref": "#/components/schemas/UsageCharge"
                    }
                  },
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or revoked key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Credits exhausted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Host or Origin not allowed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Duplicate ID; no replay or additional charge",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "20 MiB limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Unsupported content type or encoding",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "File retrieval failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "20 attempts per minute exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Inspection failed; reservation released",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Busy; no charge",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/reports": {
      "post": {
        "operationId": "createInspectionReport",
        "summary": "Create an explicitly requested unsigned report",
        "description": "One credit per completed inspection. No stored results or replay. A lost response may still have consumed a credit. No malware verdict.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Random lowercase UUID v4. Reused IDs return 409 without rerunning or charging."
          },
          {
            "name": "X-File-Name",
            "in": "header",
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "description": "Optional name; bytes determine format."
          },
          {
            "name": "X-Include-Preview",
            "in": "header",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Include a requested bounded preview."
          },
          {
            "name": "X-Include-Fingerprint",
            "in": "header",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Include a requested SHA-256."
          },
          {
            "name": "X-Max-Preview-Chars",
            "in": "header",
            "schema": {
              "type": "integer",
              "minimum": 200,
              "maximum": 8000,
              "default": 2000
            },
            "description": "Preview character budget."
          },
          {
            "name": "X-Report-Requested",
            "in": "header",
            "required": true,
            "schema": {
              "type": "boolean",
              "enum": [
                true
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "description": "Raw file bytes, at most 20 MiB.",
          "content": {
            "application/octet-stream": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Unsigned observation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "schema",
                    "usage"
                  ],
                  "properties": {
                    "schema": {
                      "type": "string"
                    },
                    "usage": {
                      "$ref": "#/components/schemas/UsageCharge"
                    }
                  },
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or revoked key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Credits exhausted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Host or Origin not allowed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Duplicate ID; no replay or additional charge",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "20 MiB limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Unsupported content type or encoding",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "File retrieval failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "20 attempts per minute exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Inspection failed; reservation released",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Busy; no charge",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/usage": {
      "get": {
        "operationId": "getUsage",
        "summary": "Get this account’s balance without a charge",
        "responses": {
          "200": {
            "description": "Balance and inspection counts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "account_id",
                    "credits_remaining",
                    "inspections_charged",
                    "attempts_released"
                  ],
                  "properties": {
                    "account_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "credits_remaining": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "inspections_charged": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "attempts_released": {
                      "type": "integer",
                      "minimum": 0
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid or revoked key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Host or Origin not allowed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "File Room API key"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "UsageCharge": {
        "type": "object",
        "required": [
          "request_id",
          "credits_consumed"
        ],
        "properties": {
          "request_id": {
            "type": "string",
            "format": "uuid"
          },
          "credits_consumed": {
            "type": "integer",
            "enum": [
              1
            ]
          }
        }
      }
    }
  }
}
