> ## Documentation Index
> Fetch the complete documentation index at: https://docs.omocaptcha.com/llms.txt
> Use this file to discover all available pages before exploring further.

# RecaptchaV2ImageTask

> Solve reCAPTCHA v2 image challenge

reCAPTCHA-v2, also known as the **I'M NOT A ROBOT** captcha, is one of the most common image-based verification systems.

<Frame>
  <img src="https://mintcdn.com/omocaptcha/Jc1mwaiUF23R0W3R/images/recaptcha-v2-image-grid.png?fit=max&auto=format&n=Jc1mwaiUF23R0W3R&q=85&s=f9b13ec6c4c34b64dc7e5e44aa331a5f" alt="reCAPTCHA v2 image challenge example — Select all images with cars" width="402" height="580" data-path="images/recaptcha-v2-image-grid.png" />
</Frame>

## 1. Create task

### Request

```http theme={null}
POST https://api.omocaptcha.com/v2/createTask
Content-Type: application/json
```

#### Body Parameters

| Parameter          | Type     | Required | Description                                         |
| ------------------ | -------- | :------: | --------------------------------------------------- |
| `clientKey`        | `String` |     ✅    | Your account API key                                |
| `task.type`        | `String` |     ✅    | Captcha service class name (`RecaptchaV2ImageTask`) |
| `task.imageBase64` | `String` |     ✅    | The captcha image encoded as base64                 |
| `task.question`    | `String` |     ✅    | The challenge question                              |

<Warning>
  The image must be resized to a **standard** resolution (`100x100`, `300x300`, or `450x450`) so the service can identify the image type.
</Warning>

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.omocaptcha.com/v2/createTask \
    -H "Content-Type: application/json" \
    -d '{
      "clientKey": "OMO_API_KEY",
      "task": {
        "type": "RecaptchaV2ImageTask",
        "imageBase64": "/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDc.",
        "question": "traffic lights"
      }
    }'
  ```

  ```javascript Node.js theme={null}
  const res = await fetch("https://api.omocaptcha.com/v2/createTask", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      clientKey: "OMO_API_KEY",
      task: {
        type: "RecaptchaV2ImageTask",
        imageBase64: "/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDc.",
        question: "traffic lights"
      }
    })
  });
  console.log(await res.json());
  ```

  ```python Python theme={null}
  import requests

  res = requests.post(
      "https://api.omocaptcha.com/v2/createTask",
      json={
          "clientKey": "OMO_API_KEY",
          "task": {
              "type": "RecaptchaV2ImageTask",
              "imageBase64": "/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDc.",
              "question": "traffic lights"
          }
      }
  )
  print(res.json())
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init("https://api.omocaptcha.com/v2/createTask");
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type: application/json"]);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
      "clientKey" => "OMO_API_KEY",
      "task" => [
          "type" => "RecaptchaV2ImageTask",
          "imageBase64" => "/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDc.",
          "question" => "traffic lights"
      ]
  ]));
  echo curl_exec($ch);
  ```
</CodeGroup>

### Response

<CodeGroup>
  ```json Success theme={null}
  {
    "errorId": 0,
    "taskId": "49f9f60a-c809-4af0-93c0-0409b72e67e0"
  }
  ```

  ```json Failure theme={null}
  {
    "errorId": 1,
    "errorCode": "",
    "errorDescription": ""
  }
  ```
</CodeGroup>

* `errorId = 0` and `taskId` → success
* `errorId = 1` and `errorCode` → failure (see [Error codes](/en/api/error-codes))

## 2. Retrieve the result

### Request

```http theme={null}
POST https://api.omocaptcha.com/v2/getTaskResult
Content-Type: application/json
```

```json theme={null}
{
  "clientKey": "OMO_API_KEY",
  "taskId": "49f9f60a-c809-4af0-93c0-0409b72e67e0"
}
```

### Response

<CodeGroup>
  ```json Success theme={null}
  {
    "errorId": 0,
    "status": "ready",
    "solution": {
      "objects": [1, 5, 8],
      "type": "multi"
    }
  }
  ```

  ```json Processing theme={null}
  {
    "status": "processing",
    "errorId": 0,
    "errorCode": "",
    "errorDescription": ""
  }
  ```

  ```json Failure theme={null}
  {
    "errorId": 1,
    "errorCode": "ERROR_JOB_STATUS",
    "errorDescription": "Job failed",
    "status": "fail",
    "solution": {}
  }
  ```
</CodeGroup>

* `errorId = 0` & `status = "ready"` → read the result in `solution.objects` (positions of tiles to click)
* `errorId = 0` & `status = "processing"` → still processing, **wait 2 seconds** and retry
* `errorId = 1` → failure, look up `errorCode` in the [Error codes](/en/api/error-codes) table
