Skip to content

GetAuthorizationCode Test#

The method is intended to authorize an instance by phone number. The method is used as an alternative to the QR method.

Authorization process:

  1. The official WhatsApp or WhatsApp Business application must be installed on your phone.
  2. You need to register in your console and create an instance.
  3. In the WhatsApp application, select the menu item "Linked devices" -> "Link a device" -> "Link with phone number instead".
  4. Call the GetAuthorizationCode method from console or through Postman collection by indicating your phone number in the body of the request (the phoneNumber field). In response to calling the GetAuthorizationCode method, you will receive 2 fields: status and code.

    The code for authorization by phone number is valid for approximately 2.5 minutes.

  5. Enter the received code in the WhatsApp application, authorization is successful.

To receive the code, the account must be in an unauthorized state. If the account is authorized, then you first need to log out the account using the Logout method.

The authorization procedure is described in more detail in the section Before you start.

After successfully entering the code and authorizing the account, an incoming notification of the form Account Status is generated.


To retrieve the code, you need to execute a query at:

POST {{apiUrl}}/waInstance{{idInstance}}/getAuthorizationCode/{{apiTokenInstance}}

Refer to Before-Start for the apiUrl, idInstance and apiTokenInstance request parameters.

Request parameters#

Parameter Type Mandatory Description
phoneNumber integer Yes Phone number in international format without + or 00

Request example body#

    "phoneNumber": 441234567890


Response parameters#

Field Type Description
status boolean Status of code receipt, possible values are true, false.
true - code received successfully
false - an error occurred while receiving the code (try again to receive the code)
code string Authorization code

Response example body#

    "status": true,

It may take up to 30 seconds to receive the code


For a list of errors common to all methods, see Standard errors

Code Examples#

import requests
import json

url = "{{apiUrl}}/waInstance{{idInstance}}/getAuthorizationCode/{{apiTokenInstance}}"

payload = json.dumps({
  "phoneNumber": 441234567890
headers= {}

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

  curl --location 'http://localhost:6001/waInstance9903789715/getAuthorizationCode/f4fc69110b364ecfbc75cdd800d0516e4933b4d4e9574ea688' \
  --header 'Content-Type: application/json' \
  --data '{
      "phoneNumber": 441234567890
var requestUrl = new StringBuilder();

var response =
    .header("Content-Type", "application/json")
    .body("{\n    \"phoneNumber\": 441234567890,\n}")
Sub GetAuthorizationCode()
    Dim url As String
    Dim RequestBody As String
    Dim http As Object
    Dim response As String

    ' The apiUrl, idInstance and apiTokenInstance values are available in console, double brackets must be removed
    url = "{{apiUrl}}/waInstance{{idInstance}}/getAuthorizationCode/{{apiTokenInstance}}"

    ' phoneNumber - Phone number in international format without + and 00
    RequestBody = "{""phoneNumber"":79123456780}"

    Set http = CreateObject("MSXML2.XMLHTTP")

    With http
        .Open "POST", url, False
        .setRequestHeader "Content-Type", "application/json"
        .send RequestBody
    End With

    response = http.responseText

    Debug.Print response

    ' Outputting the answer to the desired cell
    Range("A1").Value = response

    Set http = Nothing
End Sub