# Send a picture (2Captcha style)

> 2Captcha's in.php for picture captchas and reCAPTCHA image grids.

`POST https://api.solvecha.com/in.php`


Takes the `in.php` request of 2Captcha for two kinds of picture: a normal captcha (`method` `base64` or `post`) and a reCAPTCHA image grid (`recaptcha` `1`). Send the fields as a form, as a JSON body (like the JavaScript packages) or in the query string. Other methods, such as `userrecaptcha`, `hcaptcha` or `coordinatescaptcha`, answer `ERROR_NO_SUCH_METHOD`. The call waits for the answer, up to 15 seconds, so the first [res.php](https://solvecha.com/docs/api/twocaptcha-res.md) call has it. Keys, limits and billing are the same as on the other paths: a task is charged once, when its solution is returned. See [Migrating from 2Captcha](https://solvecha.com/docs/migrate-from-2captcha.md).

## 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).

## Headers

| Name | Type | Required | Description |
|---|---|---|---|
| `X-Solvecha-Partner` | string | No | Optional partner code of an integration. It only counts for a customer who has no partner yet and has not paid yet. An unknown code is ignored. See [Partner integrations](https://solvecha.com/docs/partner-integrations.md). |

## Request body

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

| Name | Type | Required | Description |
|---|---|---|---|
| `key` | string | Yes | Your Solvecha API key. |
| `method` | string | No | `base64` (picture in `body`) or `post` (picture as the multipart file `file`). Default: `post`. |
| `body` | string | No | The picture as base64, for `method` `base64`. |
| `recaptcha` | integer | No | `1` for a reCAPTCHA image grid. Then send `textinstructions` (up to 140 characters) and, if you like, `recaptcharows` and `recaptchacols` (`3x3`, `4x4` or `1x1`). Without them the picture size decides. |
| `json` | integer | No | `1` answers with JSON: `{"status": 1, "request": "<id>"}`. |
| `soft_id` | string | No | Optional partner code of an integration. A value that is not a known code is ignored. See [Partner integrations](https://solvecha.com/docs/partner-integrations.md). |

## Example request


**cURL**

```bash
curl -X POST "https://api.solvecha.com/in.php" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "key": "YOUR_API_KEY",
  "method": "base64",
  "body": "BASE64_IMAGE",
  "json": 1
}'
```

**Python**

```python
import requests

response = requests.post(
    "https://api.solvecha.com/in.php",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={
        "key": "YOUR_API_KEY",
        "method": "base64",
        "body": "BASE64_IMAGE",
        "json": 1
    },
)
print(response.status_code, response.json())
```

**Node.js**

```js
const response = await fetch("https://api.solvecha.com/in.php", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "key": "YOUR_API_KEY",
    "method": "base64",
    "body": "BASE64_IMAGE",
    "json": 1
  }),
});
console.log(response.status, await response.json());
```

**Go**

```go
package main

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

func main() {
	body := strings.NewReader(`{
  "key": "YOUR_API_KEY",
  "method": "base64",
  "body": "BASE64_IMAGE",
  "json": 1
}`)
	req, err := http.NewRequest("POST", "https://api.solvecha.com/in.php", 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 picture was accepted. `request` is the id for res.php.

```json
{
  "status": 1,
  "request": "1234567"
}
```

## Notes

Without `json`, the answer is the text `OK|1234567` or an error code such as `ERROR_KEY_DOES_NOT_EXIST`, `ERROR_ZERO_BALANCE`, `ERROR_ZERO_CAPTCHA_FILESIZE`, `ERROR_BAD_PARAMETERS`, `ERROR_NO_SUCH_METHOD` or `ERROR_CAPTCHA_UNSOLVABLE`. With `json`, an error is `{"status": 0, "request": "ERROR_..."}`. Every answer has HTTP status 200. The options `phrase`, `regsense`, `numeric`, `min_len`, `max_len`, `calc` and `language` are accepted and ignored.
