SendAuthorizationCode#
Beta version
The functionality is in beta. Features may change and may also work unstably.
The method completes the login if, in the response of the Login method, Instagram requests a two-factor authentication code or a login confirmation code.
The method uses the limits on the number of requests per second.
Request#
To confirm a code, you have to execute a request at:
POST
{{apiUrl}}/waInstance{{idInstance}}/sendAuthorizationCode/{{apiTokenInstance}}
For apiUrl, idInstance and apiTokenInstance request parameters, refer to the Before you start section.
Request parameters#
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
code | string | Yes | The confirmation code. The maximum length is 20 characters |
Request body example#
{
"code": "123456"
}
Response#
Response parameters#
| Field | Type | Description |
|---|---|---|
status | boolean | The flag of a successful confirmation: true - the code is accepted, false - rejected |
data | object | The confirmation result and the refusal reason. |
Fields of the data object#
| Field | Type | Description |
|---|---|---|
status | string | The confirmation result: success - the code is accepted, fail - rejected |
reason | string | The refusal reason. An empty string for a successful confirmation. Takes the values: |
- already_registered - The instance is already authorized, no confirmation is needed. The code has not been sent to Instagram | ||
- no_code_sent - Instagram has not requested a code. Start the authorization with the Login method | ||
- not_accepted - Instagram has not accepted the code. Check the code and repeat the request | ||
- code entry screen is closed; call login again - the code entry screen is closed. Start the authorization again by the Login method | ||
- Instagram error - Instagram has rejected the confirmation without naming the reason. Start the authorization again by the Login method later | ||
- another value - the rejection text as is, or code verification failed if the reason has not been named |
Response body example#
The code is accepted:#
{
"status": true,
"data": {
"status": "success",
"reason": ""
}
}
The instance is already authorized:#
{
"status": false,
"data": {
"status": "fail",
"reason": "already_registered"
}
}
No code has been requested:#
{
"status": false,
"data": {
"status": "fail",
"reason": "no_code_sent"
}
}
The code has not been accepted:#
{
"status": false,
"data": {
"status": "fail",
"reason": "not_accepted"
}
}
SendAuthorizationCode errors#
For a list of errors common to all methods, refer to the Common errors section
| HTTP code | Error ID | Description |
|---|---|---|
| 400 | Bad Request Validation failed | Validation error |
| 400 | Validation failed. Details: 'code' is required | The code is not passed |
| 400 | Validation failed. Details: 'code' must be a string | The code is not passed as a string |
| 400 | Validation failed. Details: 'code' is not allowed to be empty | An empty code is passed |
| 400 | Validation failed. Details: 'code' length must be less than or equal to 20 characters long | The code is longer than 20 characters |
Request examples#
import requests
url = "{{apiUrl}}/waInstance{{idInstance}}/sendAuthorizationCode/{{apiTokenInstance}}"
payload = {
"code": "123456"
}
headers = {
'Content-Type': 'application/json'
}
response = requests.post(url, json=payload, headers=headers)
print(response.text.encode('utf8'))
<?php
$url = '{{apiUrl}}/waInstance{{idInstance}}/sendAuthorizationCode/{{apiTokenInstance}}';
$data = array('code' => '123456');
$options = array(
'http' => array(
'header' => "Content-Type: application/json\r\n",
'method' => 'POST',
'content' => json_encode($data)
)
);
$context = stream_context_create($options);
echo file_get_contents($url, false, $context);
?>
curl --location '{{apiUrl}}/waInstance{{idInstance}}/sendAuthorizationCode/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"code": "123456"
}'