{
  "openapi": "3.0.3",
  "info": {
    "title": "editpdf.tools Compress PDF API",
    "version": "1.0.0",
    "description": "Compress PDF files over HTTPS. Free plan: up to 10 MB per file, 30 files per month, 1 file per minute. Files are deleted right after the response.",
    "termsOfService": "https://editpdf.tools/api-terms",
    "contact": {
      "name": "editpdf.tools support",
      "url": "https://editpdf.tools/contact",
      "email": "support@editpdf.tools"
    },
    "license": {
      "name": "AGPL-3.0-only (API source code)",
      "url": "https://github.com/chanbuilsdai/compress-pdf-api/blob/main/LICENSE"
    }
  },
  "externalDocs": {
    "description": "Documentation",
    "url": "https://editpdf.tools/compress-pdf-api"
  },
  "servers": [
    {
      "url": "https://api.editpdf.tools"
    }
  ],
  "security": [
    {
      "ApiKeyHeader": []
    }
  ],
  "paths": {
    "/v1/compress": {
      "post": {
        "operationId": "compressPdf",
        "summary": "Compress a PDF",
        "description": "Upload one PDF as multipart/form-data. Returns the compressed PDF. If compression does not reduce the size, the original file is returned and X-Compressed is false. Image-heavy files near 10 MB can take up to about 2 minutes.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "The PDF file (max 10 MB on the free plan)."
                  },
                  "level": {
                    "type": "string",
                    "enum": [
                      "light",
                      "recommended",
                      "strong"
                    ],
                    "default": "recommended",
                    "description": "light = 300 dpi images, recommended = 150 dpi, strong = 72 dpi."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The compressed PDF.",
            "headers": {
              "X-Original-Size": {
                "description": "Input size in bytes.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-Compressed-Size": {
                "description": "Output size in bytes.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-Compressed": {
                "description": "false if the original was returned unchanged.",
                "schema": {
                  "type": "string",
                  "enum": [
                    "true",
                    "false"
                  ]
                }
              },
              "X-Level": {
                "description": "Compression level used.",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Remaining": {
                "description": "Files left this month.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Bad request. Possible error codes: missing_file, bad_level.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key. Possible error codes: invalid_api_key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account blocked. Possible error codes: account_blocked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "411": {
            "description": "Content-Length header missing. Possible error codes: content_length_required.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "File larger than your limit. Possible error codes: file_too_large.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Wrong content type or not a PDF. Possible error codes: use_multipart_form_data, not_a_pdf.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The PDF could not be processed. Possible error codes: pdf_is_password_protected, could_not_read_pdf, could_not_process_pdf.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit or monthly quota reached. Possible error codes: rate_limited, monthly_quota_reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Temporarily unavailable; retry after the Retry-After header. Possible error codes: service_starting_retry_in_60s, processing_timeout, service_capacity_reached_this_month, temporarily_unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/me": {
      "get": {
        "operationId": "getAccount",
        "summary": "Check your key, limits and usage",
        "responses": {
          "200": {
            "description": "Your current limits and usage.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key. Possible error codes: invalid_api_key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account blocked. Possible error codes: account_blocked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Get a free key at https://api.editpdf.tools/signup"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "example": "file_too_large"
          },
          "message": {
            "type": "string",
            "example": "File must be 10 MB or smaller on your plan."
          },
          "max_mb": {
            "type": "integer",
            "example": 10
          },
          "retry_after_seconds": {
            "type": "integer",
            "example": 42
          }
        }
      },
      "Account": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "month": {
            "type": "string",
            "example": "2026-11"
          },
          "files_used": {
            "type": "integer"
          },
          "monthly_quota": {
            "type": "integer"
          },
          "files_remaining": {
            "type": "integer"
          },
          "max_file_mb": {
            "type": "integer",
            "example": 10
          },
          "seconds_between_files": {
            "type": "integer",
            "example": 60
          }
        }
      }
    }
  }
}