# Create a task (CapSolver style)

> CapSolver-style createTask for reCAPTCHA grid pictures and text pictures. The answer comes in the same response.

`POST https://api.solvecha.com/createTask`


Takes CapSolver's `createTask` format for two task types: `ReCaptchaV2Classification` (a reCAPTCHA picture) and `ImageToTextTask` (a text picture). Other task types answer `ERROR_TASK_NOT_SUPPORTED`. The call waits for the answer, up to 15 seconds, and returns it as `solution`. If it takes longer, the status is `processing` and you fetch the answer with [getTaskResult](https://solvecha.com/docs/api/capsolver-get-task-result.md). Keys, limits and billing are the same as on the other paths: a task is charged once, when its solution is returned.

## Authorization

Send your API key as `Authorization: Bearer YOUR_API_KEY`. Other ways are the `key` field of the body and the `key` query parameter. See [Authentication](https://solvecha.com/docs/authentication.md).

## Request body

JSON, or url-encoded form data. The body is limited to 4.5 MB.

| Name | Type | Required | Description |
|---|---|---|---|
| `clientKey` | string | Yes | Your Solvecha API key. |
| `task` | object | Yes | `type` is `ReCaptchaV2Classification` or `ImageToTextTask`. For `ReCaptchaV2Classification` send `image` (base64) and `question`: a reCAPTCHA object code such as `/m/04_sv`, or the instruction as words. A picture up to 160 px is one tile (`single`). Larger pictures are a 3x3 grid (up to 380 px) or a 4x4 grid. For `ImageToTextTask` send `body` (base64) and, if you like, `module` `common`. |

## Example request


**cURL**

```bash
curl -X POST "https://api.solvecha.com/createTask" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "clientKey": "YOUR_API_KEY",
  "task": {"type": "ReCaptchaV2Classification", "image": "BASE64_IMAGE", "question": "/m/04_sv"}
}'
```

**Python**

```python
import requests

response = requests.post(
    "https://api.solvecha.com/createTask",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={
        "clientKey": "YOUR_API_KEY",
        "task": {"type": "ReCaptchaV2Classification", "image": "BASE64_IMAGE", "question": "/m/04_sv"}
    },
)
print(response.status_code, response.json())
```

**Node.js**

```js
const response = await fetch("https://api.solvecha.com/createTask", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "clientKey": "YOUR_API_KEY",
    "task": {"type": "ReCaptchaV2Classification", "image": "BASE64_IMAGE", "question": "/m/04_sv"}
  }),
});
console.log(response.status, await response.json());
```

**Go**

```go
package main

import (
	"fmt"
	"io"
	"net/http"
	"strings"
)

func main() {
	body := strings.NewReader(`{
  "clientKey": "YOUR_API_KEY",
  "task": {"type": "ReCaptchaV2Classification", "image": "BASE64_IMAGE", "question": "/m/04_sv"}
}`)
	req, err := http.NewRequest("POST", "https://api.solvecha.com/createTask", body)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
	req.Header.Set("Content-Type", "application/json")
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	out, _ := io.ReadAll(resp.Body)
	fmt.Println(resp.StatusCode, string(out))
}
```


## Response

### 200 OK

The task was accepted. When `status` is `ready`, `solution` holds the answer.

```json
{
  "errorId": 0,
  "errorCode": "",
  "errorDescription": "",
  "status": "ready",
  "taskId": "1234567",
  "solution": {"type": "multi", "objects": [0, 2, 5], "size": 3}
}
```

## Notes

Errors use CapSolver's shape: `{"errorId": 1, "errorCode": "ERROR_ZERO_BALANCE", "errorDescription": "..."}`. Codes: `ERROR_KEY_DENIED_ACCESS` (HTTP 401), `ERROR_ZERO_BALANCE`, `ERROR_INVALID_TASK_DATA` (HTTP 400), `ERROR_TASK_NOT_SUPPORTED`, `ERROR_RATE_LIMIT` (HTTP 429), `ERROR_CAPTCHA_UNSOLVABLE`. Tile numbers start at 0. Compare this with your CapSolver code before you switch.
