{
  "openapi": "3.1.0",
  "info": {
    "title": "Captcha Platform API",
    "description": "CapSolver-compatible captcha recognition API. All endpoints return HTTP 200; errors are conveyed via errorId and errorCode in the JSON body.",
    "license": {
      "name": ""
    },
    "version": "0.1.0"
  },
  "paths": {
    "/createTask": {
      "post": {
        "tags": [
          "Tasks"
        ],
        "operationId": "handle",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTaskRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/getBalance": {
      "post": {
        "tags": [
          "Account"
        ],
        "operationId": "handle",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GetBalanceRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/getTaskResult": {
      "post": {
        "tags": [
          "Tasks"
        ],
        "operationId": "handle",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GetTaskResultRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/submit": {
      "post": {
        "tags": [
          "Tasks"
        ],
        "operationId": "handle",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubmitRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CreateTaskRequest": {
        "type": "object",
        "description": "POST /createTask request body",
        "required": [
          "clientKey",
          "task"
        ],
        "properties": {
          "callbackUrl": {
            "type": [
              "string",
              "null"
            ]
          },
          "clientKey": {
            "type": "string"
          },
          "task": {
            "$ref": "#/components/schemas/TaskBody"
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "description": "Error response (all endpoints may return this with HTTP 200)",
        "required": [
          "errorId",
          "errorCode",
          "errorDescription"
        ],
        "properties": {
          "errorCode": {
            "type": "string"
          },
          "errorDescription": {
            "type": "string"
          },
          "errorId": {
            "type": "integer",
            "format": "int32",
            "description": "0 = success, 1 = error"
          }
        }
      },
      "GetBalanceRequest": {
        "type": "object",
        "description": "POST /getBalance request body",
        "required": [
          "clientKey"
        ],
        "properties": {
          "clientKey": {
            "type": "string"
          }
        }
      },
      "GetBalanceResponse": {
        "type": "object",
        "description": "Successful response from POST /getBalance",
        "required": [
          "errorId",
          "balance",
          "availableBalance",
          "frozenAmount",
          "packages"
        ],
        "properties": {
          "availableBalance": {
            "type": "number",
            "format": "double"
          },
          "balance": {
            "type": "number",
            "format": "double"
          },
          "errorId": {
            "type": "integer",
            "format": "int32"
          },
          "frozenAmount": {
            "type": "number",
            "format": "double"
          },
          "packages": {
            "type": "array",
            "items": {}
          }
        }
      },
      "GetTaskResultRequest": {
        "type": "object",
        "description": "POST /getTaskResult request body",
        "required": [
          "clientKey",
          "taskId"
        ],
        "properties": {
          "clientKey": {
            "type": "string"
          },
          "taskId": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "SubmitRequest": {
        "type": "object",
        "description": "POST /submit request body for continuing a stateful task.",
        "required": [
          "clientKey",
          "taskId",
          "data"
        ],
        "properties": {
          "clientKey": {
            "type": "string"
          },
          "data": {},
          "taskId": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "TaskBody": {
        "type": "object",
        "description": "The \"task\" object inside CreateTaskRequest",
        "required": [
          "type"
        ],
        "properties": {
          "type": {
            "type": "string"
          }
        },
        "additionalProperties": {
          "description": "Remaining fields captured as a map (e.g. body, module, score)"
        }
      },
      "TaskResultResponse": {
        "type": "object",
        "description": "Unified task-result body returned by both POST /createTask and POST /getTaskResult.\n\n`errorId` is always 0; inspect `status` (`ready` / `failure` / `processing`)\nfor the outcome. `solution` is set when `status == ready`; `errorCode` /\n`errorDescription` are set when `status == failure`.",
        "required": [
          "errorId",
          "taskId",
          "status"
        ],
        "properties": {
          "errorCode": {
            "type": [
              "string",
              "null"
            ]
          },
          "errorDescription": {
            "type": [
              "string",
              "null"
            ]
          },
          "errorId": {
            "type": "integer",
            "format": "int32"
          },
          "solution": {},
          "status": {
            "type": "string"
          },
          "taskId": {
            "type": "string"
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Tasks",
      "description": "Task creation and result polling"
    },
    {
      "name": "Account",
      "description": "Account balance"
    }
  ],
  "servers": [
    {
      "url": "https://api.kaptra.ai"
    }
  ]
}