{
  "openapi": "3.1.0",
  "info": {
    "title": "Peak Solutions API",
    "version": "1.0.0",
    "summary": "Solve captchas and bot challenges, such as Cloudflare Turnstile and the Cloudflare 5-second challenge (WAF), with one HTTPS request.",
    "description": "Send a task to POST /solve and get the result in the same response, with no polling. Failed solves return HTTP 200 with \"success\": false and are not charged. Branch on error_code, not on the error text. Each key has a solves-per-minute limit: requests over it queue for up to 10 seconds, then get HTTP 429 rate_limited with a Retry-After header. Full docs: https://docs.peak.fo/docs The same server also answers the createTask API of 2Captcha (API v2), Anti-Captcha, CapMonster Cloud and CapSolver at /createTask, /getTaskResult, /getBalance, /reportIncorrect, /reportCorrect and /feedbackTask: change the base URL and key, keep your code. https://docs.peak.fo/docs/compat",
    "contact": {
      "name": "Peak Solutions support",
      "url": "https://peak.fo/support",
      "email": "support@peak.fo"
    },
    "termsOfService": "https://peak.fo/terms"
  },
  "externalDocs": {
    "description": "Peak Solutions docs",
    "url": "https://docs.peak.fo/docs"
  },
  "servers": [
    {
      "url": "https://api.peak.fo"
    }
  ],
  "security": [
    {
      "ApiKeyHeader": []
    },
    {
      "BearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Solve",
      "description": "Solve a challenge."
    },
    {
      "name": "Feedback",
      "description": "Report whether a solve's result worked."
    },
    {
      "name": "Account",
      "description": "Check what your API key can spend."
    },
    {
      "name": "Status",
      "description": "Check that the API is up."
    },
    {
      "name": "Compatible API",
      "description": "The createTask API of 2Captcha (API v2), Anti-Captcha, CapMonster Cloud and CapSolver. The key goes in the body as clientKey. Always HTTP 200: failure is errorId > 0."
    }
  ],
  "paths": {
    "/solve": {
      "post": {
        "tags": [
          "Solve"
        ],
        "operationId": "solve",
        "summary": "Solve a task",
        "description": "Solves the task named by task_type and returns the result. Turnstile returns data.token. The 5-second challenge returns cookies, headers, form attributes and cf_rt to complete the challenge from your own client.",
        "externalDocs": {
          "url": "https://docs.peak.fo/docs/api/solve"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SolveRequest"
              },
              "examples": {
                "turnstile": {
                  "summary": "Turnstile through your proxy",
                  "value": {
                    "task_type": "turnstiletask",
                    "url": "https://example.com/login",
                    "sitekey": "0x4AAAAAAA...",
                    "proxy": "http://user:pass@1.2.3.4:8080"
                  }
                },
                "turnstileProxyless": {
                  "summary": "Turnstile without a proxy",
                  "value": {
                    "task_type": "turnstiletaskproxyless",
                    "url": "https://example.com/login",
                    "sitekey": "0x4AAAAAAA..."
                  }
                },
                "cloudflare5s": {
                  "summary": "Cloudflare 5-second challenge (WAF)",
                  "value": {
                    "task_type": "cloudflare5stask",
                    "url": "https://example.com/",
                    "proxy": "http://user:pass@1.2.3.4:8080",
                    "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36",
                    "html": "<!DOCTYPE html><html>...challenge page...</html>"
                  }
                },
                "splitProxy": {
                  "summary": "Turnstile with proxy parameters",
                  "value": {
                    "task_type": "turnstiletask",
                    "url": "https://example.com/login",
                    "sitekey": "0x4AAAAAAA...",
                    "proxy_type": "socks5",
                    "proxy_address": "1.2.3.4",
                    "proxy_port": 1080,
                    "proxy_login": "user",
                    "proxy_password": "pass"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The solve worked, or it was tried and failed. Check success. Failed solves are not charged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SolveResponse"
                },
                "examples": {
                  "turnstile": {
                    "summary": "Turnstile solved",
                    "value": {
                      "success": true,
                      "data": {
                        "token": "0.AgAAAB..."
                      },
                      "cost": 0.0009,
                      "task_id": "5f0c2b1e-8a4d-4c3e-9b7a-2d6e1f4a8c90"
                    }
                  },
                  "cloudflare5s": {
                    "summary": "5-second challenge solved",
                    "value": {
                      "success": true,
                      "data": {
                        "cookies": {
                          "cf_clearance": "abc123..."
                        },
                        "headers": {
                          "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) ..."
                        },
                        "attributes": {
                          "<form field>": "<value>"
                        },
                        "cf_rt": "..."
                      },
                      "cost": 0.001,
                      "task_id": "5f0c2b1e-8a4d-4c3e-9b7a-2d6e1f4a8c90"
                    }
                  },
                  "failed": {
                    "summary": "Solve failed (not charged)",
                    "value": {
                      "success": false,
                      "error": "Challenge was flagged - try using a different proxy with a cleaner IP reputation",
                      "error_code": "challenge_flagged",
                      "task_id": "5f0c2b1e-8a4d-4c3e-9b7a-2d6e1f4a8c90"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Rejected"
          },
          "401": {
            "$ref": "#/components/responses/Rejected"
          },
          "402": {
            "$ref": "#/components/responses/Rejected"
          },
          "403": {
            "$ref": "#/components/responses/Rejected"
          },
          "413": {
            "$ref": "#/components/responses/Rejected"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/Rejected"
          },
          "503": {
            "$ref": "#/components/responses/Rejected"
          }
        }
      }
    },
    "/feedback": {
      "post": {
        "tags": [
          "Feedback"
        ],
        "operationId": "feedback",
        "summary": "Report a solve's result",
        "description": "Stores whether the token or cookies from a solve worked on the site. Doesn't change your balance. The task_id must be from your account and under 24 hours old. A later report on the same task replaces the earlier one. Counts toward the key's rate limit.",
        "externalDocs": {
          "url": "https://docs.peak.fo/docs/api/feedback"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FeedbackRequest"
              },
              "example": {
                "task_id": "5f0c2b1e-8a4d-4c3e-9b7a-2d6e1f4a8c90",
                "correct": false,
                "reason": "login returned 403 with the token"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    }
                  }
                },
                "example": {
                  "success": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Rejected"
          },
          "401": {
            "$ref": "#/components/responses/Rejected"
          },
          "404": {
            "description": "No solve on your account in the last 24 hours has that task_id.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": "Task not found",
                  "error_code": "task_not_found"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/Rejected"
          }
        }
      }
    },
    "/balance": {
      "get": {
        "tags": [
          "Account"
        ],
        "operationId": "getBalance",
        "summary": "Get balance",
        "description": "Returns the balance of a pay-per-solve key, or what is left on a package key. Free to call.",
        "externalDocs": {
          "url": "https://docs.peak.fo/docs/api/balance"
        },
        "responses": {
          "200": {
            "description": "The key works.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BalanceResponse"
                },
                "examples": {
                  "payPerSolve": {
                    "value": {
                      "success": true,
                      "data": {
                        "type": "pay_per_solve",
                        "balance": 12.5
                      }
                    }
                  },
                  "package": {
                    "value": {
                      "success": true,
                      "data": {
                        "type": "package",
                        "package_name": "Turnstile 500K",
                        "remaining_solves": 342819,
                        "total_solves": 500000,
                        "allowed_tasks": [
                          "turnstiletask",
                          "turnstiletaskproxyless"
                        ],
                        "expires_at": "2026-12-25T00:00:00Z",
                        "days_remaining": 30
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Rejected"
          },
          "500": {
            "$ref": "#/components/responses/Rejected"
          }
        }
      }
    },
    "/health": {
      "get": {
        "tags": [
          "Status"
        ],
        "operationId": "getHealth",
        "summary": "Health check",
        "description": "Returns {\"status\":\"ok\"} when the API is up. Needs no API key.",
        "security": [],
        "externalDocs": {
          "url": "https://docs.peak.fo/docs/api/health"
        },
        "responses": {
          "200": {
            "description": "The API is up.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "const": "ok"
                    }
                  },
                  "required": [
                    "status"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/createTask": {
      "post": {
        "tags": [
          "Compatible API"
        ],
        "security": [],
        "operationId": "compatCreateTask",
        "summary": "Create a task (createTask API)",
        "description": "Checks the task, starts the solve and returns a taskId. Poll /getTaskResult for the result. Charged only if the solve works.",
        "externalDocs": {
          "url": "https://docs.peak.fo/docs/compat/create-task"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompatCreateTaskRequest"
              },
              "example": {
                "clientKey": "pk_your_api_key",
                "task": {
                  "type": "TurnstileTaskProxyless",
                  "websiteURL": "https://example.com/login",
                  "websiteKey": "0x4AAAAAAA..."
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Task created, or rejected. Always HTTP 200: check errorId.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "required": [
                        "errorId",
                        "taskId"
                      ],
                      "properties": {
                        "errorId": {
                          "const": 0
                        },
                        "taskId": {
                          "$ref": "#/components/schemas/CompatTaskId"
                        }
                      }
                    },
                    {
                      "$ref": "#/components/schemas/CompatError"
                    }
                  ]
                },
                "examples": {
                  "created": {
                    "value": {
                      "errorId": 0,
                      "taskId": 4826153907261
                    }
                  },
                  "capsolver": {
                    "value": {
                      "errorId": 0,
                      "taskId": "5f0c2b1e-8a4d-4c3e-9b7a-2d6e1f4a8c90"
                    }
                  },
                  "error": {
                    "value": {
                      "errorId": 10,
                      "errorCode": "ERROR_ZERO_BALANCE",
                      "errorDescription": "insufficient balance"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/getTaskResult": {
      "post": {
        "tags": [
          "Compatible API"
        ],
        "security": [],
        "operationId": "compatGetTaskResult",
        "summary": "Get a task's result (createTask API)",
        "description": "processing until the solve finishes, then ready with the solution. Finished tasks are kept 5 minutes. Unknown, expired and other accounts' tasks answer ERROR_NO_SUCH_CAPCHA_ID.",
        "externalDocs": {
          "url": "https://docs.peak.fo/docs/compat/get-task-result"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompatTaskRequest"
              },
              "example": {
                "clientKey": "pk_your_api_key",
                "taskId": 4826153907261
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The task's status, or an error. Always HTTP 200: check errorId.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "required": [
                        "errorId",
                        "status"
                      ],
                      "properties": {
                        "errorId": {
                          "const": 0
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "processing",
                            "ready"
                          ]
                        },
                        "solution": {
                          "type": "object",
                          "description": "Turnstile: token. 5-second challenge: cf_clearance and userAgent (CapMonster code), or cookies, token and userAgent (CapSolver code)."
                        },
                        "cost": {
                          "type": "string",
                          "description": "USD, as a string."
                        },
                        "createTime": {
                          "type": "integer"
                        },
                        "endTime": {
                          "type": "integer"
                        },
                        "solveCount": {
                          "type": "integer"
                        },
                        "taskId": {
                          "type": "string",
                          "description": "CapSolver tasks only."
                        }
                      }
                    },
                    {
                      "$ref": "#/components/schemas/CompatError"
                    }
                  ]
                },
                "examples": {
                  "processing": {
                    "value": {
                      "errorId": 0,
                      "status": "processing"
                    }
                  },
                  "ready": {
                    "value": {
                      "errorId": 0,
                      "status": "ready",
                      "solution": {
                        "token": "0.AgAAAB..."
                      },
                      "cost": "0.0009",
                      "createTime": 1795094012,
                      "endTime": 1795094019,
                      "solveCount": 1
                    }
                  },
                  "failed": {
                    "value": {
                      "errorId": 12,
                      "errorCode": "ERROR_CAPTCHA_UNSOLVABLE",
                      "errorDescription": "Challenge was flagged - try using a different proxy with a cleaner IP reputation"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/getBalance": {
      "post": {
        "tags": [
          "Compatible API"
        ],
        "security": [],
        "operationId": "compatGetBalance",
        "summary": "Get the balance (createTask API)",
        "description": "USD the key can spend. Package keys: solves left x the package's price per solve, rounded down to 4 decimals; 0 when used up or expired.",
        "externalDocs": {
          "url": "https://docs.peak.fo/docs/compat/get-balance"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "clientKey"
                ],
                "properties": {
                  "clientKey": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "clientKey": "pk_your_api_key"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The balance, or an error. Always HTTP 200: check errorId.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "required": [
                        "errorId",
                        "balance"
                      ],
                      "properties": {
                        "errorId": {
                          "const": 0
                        },
                        "balance": {
                          "type": "number"
                        },
                        "packages": {
                          "type": "array",
                          "maxItems": 0,
                          "description": "Always empty."
                        }
                      }
                    },
                    {
                      "$ref": "#/components/schemas/CompatError"
                    }
                  ]
                },
                "examples": {
                  "balance": {
                    "value": {
                      "errorId": 0,
                      "balance": 12.5,
                      "packages": []
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/reportIncorrect": {
      "post": {
        "tags": [
          "Compatible API"
        ],
        "security": [],
        "operationId": "compatReportIncorrect",
        "summary": "Report a solution that didn't work (2Captcha format)",
        "description": "Stores the report for the Peak Solutions team. Doesn't change your balance. Number task ids can be reported while getTaskResult still has the task (5 minutes after it finishes); UUID task ids for 24 hours.",
        "externalDocs": {
          "url": "https://docs.peak.fo/docs/compat/reports"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompatTaskRequest"
              },
              "example": {
                "clientKey": "pk_your_api_key",
                "taskId": 4826153907261
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved, or not found. Always HTTP 200: check errorId.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "required": [
                        "errorId",
                        "status"
                      ],
                      "properties": {
                        "errorId": {
                          "const": 0
                        },
                        "status": {
                          "const": "success"
                        }
                      }
                    },
                    {
                      "$ref": "#/components/schemas/CompatError"
                    }
                  ]
                },
                "examples": {
                  "saved": {
                    "value": {
                      "errorId": 0,
                      "status": "success"
                    }
                  },
                  "notFound": {
                    "value": {
                      "errorId": 16,
                      "errorCode": "ERROR_NO_SUCH_CAPCHA_ID",
                      "errorDescription": "Task not found or expired"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/reportCorrect": {
      "post": {
        "tags": [
          "Compatible API"
        ],
        "security": [],
        "operationId": "compatReportCorrect",
        "summary": "Report a solution that worked (2Captcha format)",
        "description": "Stores the report for the Peak Solutions team. Doesn't change your balance. Number task ids can be reported while getTaskResult still has the task (5 minutes after it finishes); UUID task ids for 24 hours.",
        "externalDocs": {
          "url": "https://docs.peak.fo/docs/compat/reports"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompatTaskRequest"
              },
              "example": {
                "clientKey": "pk_your_api_key",
                "taskId": 4826153907261
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved, or not found. Always HTTP 200: check errorId.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "required": [
                        "errorId",
                        "status"
                      ],
                      "properties": {
                        "errorId": {
                          "const": 0
                        },
                        "status": {
                          "const": "success"
                        }
                      }
                    },
                    {
                      "$ref": "#/components/schemas/CompatError"
                    }
                  ]
                },
                "examples": {
                  "saved": {
                    "value": {
                      "errorId": 0,
                      "status": "success"
                    }
                  },
                  "notFound": {
                    "value": {
                      "errorId": 16,
                      "errorCode": "ERROR_NO_SUCH_CAPCHA_ID",
                      "errorDescription": "Task not found or expired"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/feedbackTask": {
      "post": {
        "tags": [
          "Compatible API"
        ],
        "security": [],
        "operationId": "compatFeedbackTask",
        "summary": "Report a task's result (CapSolver format)",
        "description": "result.invalid true means the solution didn't work. result.code and result.message are stored together, up to 500 characters. Doesn't change your balance.",
        "externalDocs": {
          "url": "https://docs.peak.fo/docs/compat/reports"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "clientKey",
                  "taskId"
                ],
                "properties": {
                  "clientKey": {
                    "type": "string"
                  },
                  "taskId": {
                    "$ref": "#/components/schemas/CompatTaskId"
                  },
                  "result": {
                    "type": "object",
                    "properties": {
                      "invalid": {
                        "type": "boolean"
                      },
                      "code": {
                        "oneOf": [
                          {
                            "type": "integer"
                          },
                          {
                            "type": "string"
                          }
                        ]
                      },
                      "message": {
                        "type": "string"
                      }
                    }
                  }
                }
              },
              "example": {
                "clientKey": "pk_your_api_key",
                "taskId": "5f0c2b1e-8a4d-4c3e-9b7a-2d6e1f4a8c90",
                "result": {
                  "invalid": true,
                  "code": 403,
                  "message": "the site rejected the token"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved, or not found. Always HTTP 200: check errorId.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "required": [
                        "errorId",
                        "status"
                      ],
                      "properties": {
                        "errorId": {
                          "const": 0
                        },
                        "status": {
                          "const": "success"
                        }
                      }
                    },
                    {
                      "$ref": "#/components/schemas/CompatError"
                    }
                  ]
                },
                "examples": {
                  "saved": {
                    "value": {
                      "errorId": 0,
                      "status": "success"
                    }
                  },
                  "notFound": {
                    "value": {
                      "errorId": 16,
                      "errorCode": "ERROR_NO_SUCH_CAPCHA_ID",
                      "errorDescription": "Task not found or expired"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Your API key. Starts with pk_."
      },
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Your API key as a bearer token. X-API-Key wins if both are sent."
      }
    },
    "responses": {
      "Rejected": {
        "description": "The request was rejected before any solving. Not charged. See error_code.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "success": false,
              "error": "invalid API key",
              "error_code": "invalid_api_key"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Over the key's solves-per-minute limit (or the service-wide limit), and the queue wait would be longer than 10 seconds. Not charged. Retry after Retry-After seconds (currently always 1).",
        "headers": {
          "Retry-After": {
            "description": "Seconds to wait before retrying. Currently always 1.",
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "success": false,
              "error": "Rate limit exceeded - slow down or contact support for a higher limit",
              "error_code": "rate_limited"
            }
          }
        }
      }
    },
    "schemas": {
      "SolveRequest": {
        "type": "object",
        "required": [
          "task_type",
          "url"
        ],
        "properties": {
          "task_type": {
            "type": "string",
            "enum": [
              "turnstiletask",
              "turnstiletaskproxyless",
              "cloudflare5stask"
            ],
            "description": "What to solve. Not case-sensitive."
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "The page with the challenge."
          },
          "proxy": {
            "type": "string",
            "description": "protocol://user:pass@host:port. Any protocol. Required for turnstiletask and cloudflare5stask (sticky session). Optional for turnstiletaskproxyless. Or send the proxy parameters (proxy_type, proxy_address, proxy_port, proxy_login, proxy_password) instead; proxy wins if both are sent."
          },
          "proxy_type": {
            "type": "string",
            "default": "http",
            "description": "Proxy parameter: the protocol, such as http, https, socks4 or socks5."
          },
          "proxy_address": {
            "type": "string",
            "description": "Proxy parameter: host name or IP, without protocol or port. Required when using proxy parameters."
          },
          "proxy_port": {
            "oneOf": [
              {
                "type": "integer",
                "minimum": 1,
                "maximum": 65535
              },
              {
                "type": "string",
                "pattern": "^[0-9]{1,5}$"
              }
            ],
            "description": "Proxy parameter: port, 1-65535. Required when using proxy parameters."
          },
          "proxy_login": {
            "type": "string",
            "description": "Proxy parameter: username, if the proxy has one."
          },
          "proxy_password": {
            "type": "string",
            "description": "Proxy parameter: password. Needs proxy_login."
          },
          "sitekey": {
            "type": "string",
            "description": "Turnstile only. The widget's data-sitekey. Required for Turnstile tasks."
          },
          "action": {
            "type": "string",
            "description": "Turnstile only. The widget's data-action, if the page sets one."
          },
          "cdata": {
            "type": "string",
            "description": "Turnstile only. The widget's data-cdata, if the page sets one."
          },
          "user_agent": {
            "type": "string",
            "description": "cloudflare5stask only. The Windows Chrome user-agent your client sends."
          },
          "html": {
            "type": "string",
            "description": "cloudflare5stask only. The challenge page HTML you already loaded."
          },
          "appId": {
            "type": "string",
            "description": "Optional. Your app ID, to earn a share of solves made through your tool. app_id is also accepted."
          }
        }
      },
      "SolveResponse": {
        "type": "object",
        "required": [
          "success"
        ],
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/TurnstileResult"
              },
              {
                "$ref": "#/components/schemas/Cloudflare5sResult"
              }
            ]
          },
          "cost": {
            "type": "number",
            "description": "What the solve was charged, in USD. Only on success."
          },
          "error": {
            "type": "string",
            "description": "On failure: what went wrong, in words. Wording can change."
          },
          "error_code": {
            "$ref": "#/components/schemas/ErrorCode"
          },
          "task_id": {
            "type": "string",
            "format": "uuid",
            "description": "The solve's id. Returned when a solve was tried, whether it worked or not; absent on rejected requests. Send it to POST /feedback."
          }
        }
      },
      "TurnstileResult": {
        "type": "object",
        "required": [
          "token"
        ],
        "properties": {
          "token": {
            "type": "string",
            "description": "The Turnstile token (cf-turnstile-response)."
          },
          "secondary_token": {
            "type": "string",
            "description": "Only when the widget also issues a second token."
          }
        }
      },
      "Cloudflare5sResult": {
        "type": "object",
        "required": [
          "cookies",
          "headers",
          "attributes",
          "cf_rt"
        ],
        "properties": {
          "cookies": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Add these to your client's cookie jar."
          },
          "headers": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Send these headers on your requests."
          },
          "attributes": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Form fields to POST back to the page URL."
          },
          "cf_rt": {
            "type": "string",
            "description": "Use as __cf_chl_tk in the referer of the form POST."
          }
        }
      },
      "BalanceResponse": {
        "type": "object",
        "required": [
          "success"
        ],
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "oneOf": [
              {
                "type": "object",
                "title": "PayPerSolveBalance",
                "required": [
                  "type",
                  "balance"
                ],
                "properties": {
                  "type": {
                    "const": "pay_per_solve"
                  },
                  "balance": {
                    "type": "number",
                    "description": "USD."
                  }
                }
              },
              {
                "type": "object",
                "title": "PackageBalance",
                "required": [
                  "type",
                  "remaining_solves",
                  "total_solves"
                ],
                "properties": {
                  "type": {
                    "const": "package"
                  },
                  "package_name": {
                    "type": "string"
                  },
                  "remaining_solves": {
                    "type": "integer"
                  },
                  "total_solves": {
                    "type": "integer"
                  },
                  "allowed_tasks": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "The task_type values this key can solve, or [\"all\"]. A Turnstile package covers both Turnstile task types."
                  },
                  "expires_at": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "days_remaining": {
                    "type": "integer"
                  }
                }
              }
            ]
          },
          "error": {
            "type": "string"
          },
          "error_code": {
            "$ref": "#/components/schemas/ErrorCode"
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": [
          "success",
          "error",
          "error_code"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "const": false
          },
          "error": {
            "type": "string"
          },
          "error_code": {
            "$ref": "#/components/schemas/ErrorCode"
          }
        }
      },
      "ErrorCode": {
        "type": "string",
        "description": "Stable machine-readable code. Rejections: missing_api_key, invalid_api_key, api_key_inactive, account_suspended, auth_error, invalid_request_body, request_too_large, invalid_task_type, missing_fields, invalid_proxy, task_not_authorized, insufficient_balance, package_exhausted, task_blocked, rate_limited, task_disabled, proxyless_unavailable, billing_error, internal_error, task_not_found (POST /feedback only, HTTP 404). Failed solves (HTTP 200): proxy_error, timeout, solve_failed, no_servers, proxy_required, solver_error, unknown, challenge_flagged, invalid_sitekey, invalid_action, invalid_cdata, no_challenge, ip_blocked, unsupported_user_agent, invalid_html, invalid_request_data, turnstile_failed. New codes may be added. Full list: https://docs.peak.fo/docs/api/errors",
        "examples": [
          "challenge_flagged",
          "invalid_api_key"
        ]
      },
      "FeedbackRequest": {
        "type": "object",
        "required": [
          "task_id",
          "correct"
        ],
        "properties": {
          "task_id": {
            "type": "string",
            "format": "uuid",
            "description": "The task_id from a /solve response."
          },
          "correct": {
            "type": "boolean",
            "description": "false if the result didn't work on the site."
          },
          "reason": {
            "type": "string",
            "maxLength": 500,
            "description": "What happened. Optional."
          }
        }
      },
      "CompatError": {
        "type": "object",
        "title": "CompatError",
        "required": [
          "errorId",
          "errorCode",
          "errorDescription"
        ],
        "properties": {
          "errorId": {
            "type": "integer",
            "minimum": 1,
            "description": "The code's number for 2Captcha / Anti-Captcha / CapMonster code; always 1 for CapSolver code."
          },
          "errorCode": {
            "type": "string",
            "description": "For example ERROR_KEY_DOES_NOT_EXIST, ERROR_ZERO_BALANCE, ERROR_NO_SLOT_AVAILABLE, ERROR_BAD_PARAMETERS, ERROR_TASK_NOT_SUPPORTED, ERROR_IP_BLOCKED, ERROR_NO_SUCH_CAPCHA_ID, ERROR_CAPTCHA_UNSOLVABLE, ERROR_PROXY_CONNECT_REFUSED. CapSolver code gets CapSolver's names. Full list: https://docs.peak.fo/docs/compat/errors"
          },
          "errorDescription": {
            "type": "string",
            "description": "What went wrong, in words."
          }
        }
      },
      "CompatTaskId": {
        "description": "A number below 2^53 for 2Captcha / Anti-Captcha / CapMonster code; a UUID string for CapSolver code.",
        "oneOf": [
          {
            "type": "integer"
          },
          {
            "type": "string"
          }
        ]
      },
      "CompatCreateTaskRequest": {
        "type": "object",
        "required": [
          "clientKey",
          "task"
        ],
        "properties": {
          "clientKey": {
            "type": "string",
            "description": "Your Peak Solutions API key (pk_...)."
          },
          "appId": {
            "type": "string",
            "description": "Optional app ID for revenue share."
          },
          "softId": {
            "description": "Accepted and ignored."
          },
          "languagePool": {
            "type": "string",
            "description": "Accepted and ignored."
          },
          "callbackUrl": {
            "type": "string",
            "description": "Accepted and ignored: poll getTaskResult."
          },
          "task": {
            "type": "object",
            "required": [
              "type",
              "websiteURL"
            ],
            "properties": {
              "type": {
                "type": "string",
                "description": "Not case-sensitive. TurnstileTaskProxyless, TurnstileTask (proxyless without proxy fields; with cloudflareTaskType cf_clearance it is the 5-second challenge), AntiTurnstileTaskProxyLess, AntiCloudflareTask."
              },
              "websiteURL": {
                "type": "string"
              },
              "websiteKey": {
                "type": "string",
                "description": "Required for Turnstile."
              },
              "action": {
                "type": "string",
                "description": "Also read from pageAction or metadata.action."
              },
              "cData": {
                "type": "string",
                "description": "Also read from data or metadata.cdata."
              },
              "metadata": {
                "type": "object",
                "properties": {
                  "action": {
                    "type": "string"
                  },
                  "cdata": {
                    "type": "string"
                  }
                }
              },
              "cloudflareTaskType": {
                "type": "string",
                "enum": [
                  "cf_clearance"
                ]
              },
              "userAgent": {
                "type": "string",
                "description": "5-second challenge: the Windows Chrome user-agent your code sends."
              },
              "htmlPageBase64": {
                "type": "string",
                "description": "5-second challenge: the challenge page, base64."
              },
              "html": {
                "type": "string",
                "description": "5-second challenge: the challenge page."
              },
              "proxyType": {
                "type": "string",
                "enum": [
                  "http",
                  "https",
                  "socks4",
                  "socks5"
                ]
              },
              "proxyAddress": {
                "type": "string"
              },
              "proxyPort": {
                "oneOf": [
                  {
                    "type": "integer"
                  },
                  {
                    "type": "string"
                  }
                ]
              },
              "proxyLogin": {
                "type": "string"
              },
              "proxyPassword": {
                "type": "string"
              },
              "proxy": {
                "type": "string",
                "description": "The proxy as one string: host:port:user:pass, scheme:host:port:user:pass, host:port, or a URL. Wins over the split fields."
              }
            }
          }
        }
      },
      "CompatTaskRequest": {
        "type": "object",
        "required": [
          "clientKey",
          "taskId"
        ],
        "properties": {
          "clientKey": {
            "type": "string"
          },
          "taskId": {
            "$ref": "#/components/schemas/CompatTaskId"
          }
        }
      }
    }
  }
}
