{
  "openapi": "3.1.0",
  "info": {
    "title": "TempFiles API",
    "version": "1.0.0",
    "description": "Temporary file hosting. Upload files up to 100 MB; they are deleted automatically after the chosen time. No authentication.",
    "contact": {
      "email": "abuse@tempfiles.xyz"
    },
    "termsOfService": "https://tempfiles.xyz/tos"
  },
  "servers": [
    {
      "url": "https://tempfiles.xyz"
    }
  ],
  "paths": {
    "/api/v1/upload": {
      "post": {
        "operationId": "uploadFile",
        "summary": "Upload a file and get a shareable link",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "Max 100 MB"
                  },
                  "expire": {
                    "type": "integer",
                    "minimum": 60,
                    "maximum": 172800,
                    "default": 3600,
                    "description": "Seconds until deletion"
                  },
                  "password": {
                    "type": "string",
                    "maxLength": 128,
                    "description": "Optional download password"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Uploaded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UploadResult"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/files/{id}": {
      "get": {
        "operationId": "getFileInfo",
        "summary": "Get metadata for an uploaded file",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "File info",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FileInfoResult"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/delete": {
      "post": {
        "operationId": "deleteFile",
        "summary": "Delete a file before it expires",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "id",
                  "token"
                ],
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "token": {
                    "type": "string",
                    "description": "delete_token from the upload response"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deleted (or already gone)"
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "status": {
            "const": "error"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "UploadResult": {
        "type": "object",
        "properties": {
          "status": {
            "const": "success"
          },
          "data": {
            "type": "object",
            "properties": {
              "url": {
                "type": "string",
                "format": "uri",
                "description": "Share page"
              },
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "size": {
                "type": "integer"
              },
              "expires_at": {
                "type": "integer",
                "description": "Unix seconds"
              },
              "delete_token": {
                "type": "string"
              }
            }
          }
        }
      },
      "FileInfoResult": {
        "type": "object",
        "properties": {
          "status": {
            "const": "success"
          },
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "size": {
                "type": "integer"
              },
              "type": {
                "type": "string"
              },
              "expires_at": {
                "type": "integer"
              },
              "password_protected": {
                "type": "boolean"
              },
              "scan_status": {
                "type": "string",
                "enum": [
                  "pending",
                  "clean",
                  "infected",
                  "error",
                  "skipped"
                ]
              },
              "downloadable": {
                "type": "boolean"
              },
              "url": {
                "type": "string",
                "format": "uri"
              },
              "download_url": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}