{
  "openapi": "3.1.0",
  "info": {
    "title": "Fiscor PDF API",
    "summary": "Document processing API for PDF conversion, merging, compression, OCR, images, and automation workflows.",
    "description": "The Fiscor PDF API lets developers create asynchronous document processing jobs, poll job status, and download completed results.",
    "version": "1.0.0",
    "contact": {
      "name": "Fiscor",
      "url": "https://pdf.fiscor.am/pdf-api",
      "email": "info@fiscor.am"
    }
  },
  "servers": [
    {
      "url": "https://pdf.fiscor.am/api/v1",
      "description": "Production"
    }
  ],
  "externalDocs": {
    "description": "Fiscor PDF API documentation",
    "url": "https://pdf.fiscor.am/pdf-api/docs"
  },
  "tags": [
    {
      "name": "Operations",
      "description": "Discover supported document processing operations."
    },
    {
      "name": "Jobs",
      "description": "Create, poll, and download asynchronous processing jobs."
    },
    {
      "name": "Account",
      "description": "Read account-specific history and API access."
    },
    {
      "name": "Billing",
      "description": "Start API plan billing flows."
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/operations": {
      "get": {
        "tags": ["Operations"],
        "summary": "List supported operations",
        "description": "Returns supported public operation slugs and metadata. Use this endpoint as the source of truth because available tools can change.",
        "operationId": "listOperations",
        "responses": {
          "200": {
            "description": "Supported operations.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationsResponse"
                }
              }
            }
          }
        }
      }
    },
    "/jobs/{operation}": {
      "post": {
        "tags": ["Jobs"],
        "summary": "Create a processing job",
        "description": "Creates an asynchronous processing job for an operation such as pdf-to-word, word-to-pdf, merge-pdf, split-pdf, compress-pdf, pdf-ocr, pdf-to-jpg, or jpg-to-pdf.",
        "operationId": "createJob",
        "parameters": [
          {
            "name": "operation",
            "in": "path",
            "required": true,
            "description": "Operation slug returned by /operations.",
            "schema": {
              "type": "string",
              "examples": ["pdf-to-word", "word-to-pdf", "merge-pdf", "compress-pdf", "pdf-ocr", "pdf-to-jpg", "jpg-to-pdf"]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "Single input file for one-file operations."
                  },
                  "files": {
                    "type": "array",
                    "description": "Multiple input files for operations such as merge-pdf.",
                    "items": {
                      "type": "string",
                      "format": "binary"
                    }
                  }
                }
              },
              "encoding": {
                "file": {
                  "contentType": "application/pdf,application/vnd.openxmlformats-officedocument.wordprocessingml.document,image/jpeg,image/png,image/webp"
                },
                "files": {
                  "contentType": "application/pdf,image/jpeg,image/png,image/webp"
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Job accepted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateJobResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/jobs/{jobId}": {
      "get": {
        "tags": ["Jobs"],
        "summary": "Get job status",
        "description": "Poll this endpoint until status is Completed or Failed.",
        "operationId": "getJob",
        "parameters": [
          {
            "$ref": "#/components/parameters/JobId"
          }
        ],
        "responses": {
          "200": {
            "description": "Current job state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobStatusResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/jobs/{jobId}/download": {
      "get": {
        "tags": ["Jobs"],
        "summary": "Download job result",
        "description": "Downloads the processed output file after the job status is Completed.",
        "operationId": "downloadJob",
        "parameters": [
          {
            "$ref": "#/components/parameters/JobId"
          }
        ],
        "responses": {
          "200": {
            "description": "Processed file.",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "Job is not completed yet.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/me/history": {
      "get": {
        "tags": ["Account"],
        "summary": "List recent jobs",
        "description": "Returns recent jobs for the authenticated user.",
        "operationId": "listHistory",
        "responses": {
          "200": {
            "description": "Recent jobs.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/JobStatusResponse"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/billing/api/start": {
      "post": {
        "tags": ["Billing"],
        "summary": "Start API plan payment",
        "description": "Starts an API plan payment flow for the current user.",
        "operationId": "startApiBilling",
        "responses": {
          "200": {
            "description": "Payment session information.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Use your Fiscor PDF API key in the Authorization header."
      }
    },
    "parameters": {
      "JobId": {
        "name": "jobId",
        "in": "path",
        "required": true,
        "description": "Job id returned by the create job endpoint.",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Invalid request.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing or invalid API key.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "NotFound": {
        "description": "Resource was not found.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "Plan or rate limit reached.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      }
    },
    "schemas": {
      "OperationsResponse": {
        "type": "array",
        "items": {
          "$ref": "#/components/schemas/Operation"
        }
      },
      "Operation": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "slug": {
            "type": "string",
            "examples": ["pdf-to-word", "merge-pdf", "compress-pdf"]
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          }
        }
      },
      "CreateJobResponse": {
        "type": "object",
        "required": ["jobId", "status"],
        "properties": {
          "jobId": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "$ref": "#/components/schemas/JobStatus"
          }
        },
        "additionalProperties": true
      },
      "JobStatusResponse": {
        "type": "object",
        "required": ["jobId", "status"],
        "properties": {
          "jobId": {
            "type": "string",
            "format": "uuid"
          },
          "operation": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/JobStatus"
          },
          "failureReason": {
            "type": ["string", "null"]
          },
          "resultFileName": {
            "type": ["string", "null"]
          },
          "resultFileSize": {
            "type": ["integer", "null"],
            "format": "int64"
          },
          "createdAt": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "completedAt": {
            "type": ["string", "null"],
            "format": "date-time"
          }
        },
        "additionalProperties": true
      },
      "JobStatus": {
        "type": "string",
        "enum": ["Queued", "Processing", "Completed", "Failed"]
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        },
        "additionalProperties": true
      }
    }
  }
}
