> For the complete documentation index, see [llms.txt](https://anticaptcha-pro.gitbook.io/v1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://anticaptcha-pro.gitbook.io/v1/su-dung-api/giai-captcha/publish-your-docs-3.md).

# Giải captcha hình ảnh

## Endpoint

```
POST https://api.anticaptcha.pro/v1/createTask
```

## Các tham số body

<table><thead><tr><th width="117">Tên trường</th><th width="114">Kiểu dữ liệu</th><th width="94">Bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>apiKey</td><td>string</td><td>✔️</td><td>Api key sử dụng dịch vụ </td></tr><tr><td>method</td><td>string</td><td>✔️</td><td>Giá trị <code>image</code></td></tr><tr><td>body</td><td>string</td><td>✔️</td><td>chuỗi base64 của hình ảnh, ví dụ: <code>iVBORw0KGgoAAAANSUhEUgAAAPIA...</code></td></tr><tr><td>version</td><td>string</td><td></td><td>Version cho task image, giá trị  mặc định: <code>default</code> , click vào <a href="/v1/su-dung-api/giai-captcha/publish-your-docs-3/cac-version-cua-captcha-hinh-anh.md">đây </a>để xem các version hỗ trợ</td></tr></tbody></table>

## Request mẫu

{% tabs %}
{% tab title="Curl" %}

```powershell
curl --location 'https://api.anticaptcha.pro/v1/createTask' \
--header 'Content-Type: application/json' \
--data '{
    "apiKey": "T8B13MX-ABCDEFG-Q0XNP00-NYKJM4N",
    "method": "image",
    "version": "default",
    "body": "<BASE64_IMAGE>"
}'
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");

const raw = JSON.stringify({
  "apiKey": "T8B13MX-ABCDEFG-Q0XNP00-NYKJM4N",
  "method": "image",
  "version": "default",
  "body": "<BASE64_IMAGE>"
});

const requestOptions = {
  method: "POST",
  headers: myHeaders,
  body: raw,
  redirect: "follow"
};

fetch("https://api.anticaptcha.pro/v1/createTask", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.anticaptcha.pro/v1/createTask"

payload = json.dumps({
  "apiKey": "T8B13MX-ABCDEFG-Q0XNP00-NYKJM4N",
  "method": "image",
  "version": "default",
  "body": "<BASE64_IMAGE>"
})
headers = {
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.anticaptcha.pro/v1/createTask");
var content = new StringContent("{\r\n    \"apiKey\": \"T8B13MX-ABCDEFG-Q0XNP00-NYKJM4N\",\r\n    \"method\": \"image\",\r\n    \"version\": \"default\",\r\n    \"body\": \"<BASE64_IMAGE>\"\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

{% endtab %}
{% endtabs %}

## Kết quả trả về

{% tabs %}
{% tab title="Thành công" %}

```json
{
    "success": true,
    "data": {
        "status": "idle",
        "taskId": "add42add-02c3-431b-91ce-e8646bd7eea4" //Bạn cần lưu taskId để có thể lấy kết quả của captcha
    }
}
```

{% endtab %}

{% tab title="Thất bại" %}

```json
{
    "success": false,
    "code": 404,
    "msg": "Apikey is invalid"
}
```

{% endtab %}

{% tab title="Không đủ số dư" %}

```json
{
    "success": false,
    "code": 400,
    "msg": "Insufficient balance"
}
```

{% endtab %}

{% tab title="Lỗi validation" %}

```json
{
    "success": false,
    "code": 400,
    "msg": [
        "body must be a string",
        "version must be one of the following values: onlynumber, default, invidual, invidual6, media, steam, yandex, amazon, garena, hotmail, facebook"
    ]
}
```

{% endtab %}
{% endtabs %}
