SendAuthorizationCode#
The method works with limitations
There are limitations on the use of the method on the Telegram side. Even if the method is called successfully, the verification code may not arrive.
For authorization, it is recommended to use the QR and SendAuthorizationPassword methods.
The method is intended for completing the instance authorization process.
Use the verification code received from SMS or the system chat when calling the StartAuthorization method.
The authorization code remains valid for 5 minutes, even after an incorrect code/password has been sent.
If the correct code is entered but the password is not, authorization is considered incomplete - you should send the password using the SendAuthorizationPassword method.
The method uses limits on the request rate per second.
We recommend performing authorization by the QR method, as authorization through it is more stable and simpler.
Request#
To send the instance authorization code, you need to execute a request at:
{{apiUrl}}/waInstance{{idInstance}}/sendAuthorizationCode/{{apiTokenInstance}}
To get the apiUrl, idInstance and apiTokenInstance request parameters, refer to the Before you start section.
The code should be sent immediately after it is received, otherwise you may get a timeout error.
Request parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
code | string | Yes | Confirmation code received in the Telegram application or by SMS |
password | string | No | Two-factor authentication password (Cloud Password), if it is set on the account |
Request body example#
Request body example:
{
"code": "123456",
"password": "qwerty"
}
Response#
Response fields#
| Field | Type | Description |
|---|---|---|
status | boolean | Status of the sent authorization code |
true - The request executed successfully | ||
false - The request executed with an error | ||
data | object | Details of the sent authorization code |
Fields of the data object#
| Field | Type | Description |
|---|---|---|
status | string | Result of the authorization: |
success - Authorization completed successfully | ||
fail - Authorization failed | ||
reason | string | Reasons in case of fail: |
already_registered — the instance is already authorized | ||
2fa_required — the code is correct, but a password must be entered | ||
invalid_password — an incorrect password was specified | ||
verify_code_wrong — incorrect code | ||
code_expired — the code has expired | ||
rate_limit_exceeded — too many attempts, try again later | ||
authorization_not_started — the startAuthorization method was not called | ||
timeout — the waiting time for a response from Telegram servers has expired |
Response body example#
Successful execution of the method#
{
"status": true,
"data": {
"status": "success",
"reason": ""
}
}
Execution of the method with an error#
A password is required (2FA):
{
"status": false,
"data": {
"status": "fail",
"reason": "2fa_required"
}
}
The attempt limit has been exceeded:
{
"status": false,
"data": {
"status": "fail",
"reason": "rate_limit_exceeded"
}
}
Errors#
For the list of errors common to all methods, see the Common errors section