Skip to content

QR#

It is recommended to use the Phone Number Authorization Method

The method is aimed for getting QR code. To authorize your account, you have to scan a QR code from application WhatsApp Business on your phone. You can also get a QR code and authorize your account in your profile. The procedure for authorizing an account in your profile is described in section Before you start.

QR code is updated every 20 seconds, therefore, it is recommended to request the method for getting a QR code with a delay in 1 second.

To get a QR code, the account must have an unauthorized status. If the account is authorized, you have first to log out the account using Logout method. After successful scanning a QR code and authorizing the account incoming notification in form of Account Status is generated.

You can also get a QR code via websocket-connection

Request#

To get a QR code, you have to execute a request at:

GET {{APIUrl}}/waInstance{{idInstance}}/qr/{{apiTokenInstance}}

For APIUrl, idInstance and apiTokenInstance request parameters, refer to Before you start section.

Response#

Response parameters#

Parameter Type Description
type string Message type, possible variants qrCode, error, alreadyLogged
message string Message content. Takes on different values depending on type

Got QR code#

Parameter Type Description
type string qrCode - got QR code image
message string base64 QR code image. To display in the browser, you need to add a string data:image/png;base64, {message}

Error occurred#

Parameter Type Description
type string error - an error is occurred
message string Error description
Instance has auth. You need to make log out - there is authorization data, but they are not suitable for authorization, it is necessary to execute the logout method and rescan the QR code

Getting a QR code can take up to 10 minutes

Account already authorized#

Parameter Type Description
type string alreadyLogged - account is already authorized. To get a QR code, you have first to log out of your account using Logout method
message string Takes on the value instance account already authorized

Example of getting a QR code in a browser#

https://qr.green-api.com/waInstance{{idInstance}}/{{apiTokenInstance}}

For APIUrl, idInstance and apiTokenInstance request parameters, refer to Before you start section.

You need to replace the idInstance and apiTokenInstance values with yours to get a link like this:

https://qr.green-api.com/waInstance11015502/ccc44689b17435537c15a939d0a478b71c3bd7d7d52d312345

You can also see an example of getting a QR code in a browser in the file browserExampleQRcode

QR errors#

For a list of errors common to all methods, refer to Common errors section

Error Possible solutions
When getting the QR code from the links
above, an error may appear and it will take an infinitely long time to download the code
1. Check the correctness of the generated link.
2. Check the correctness of IdInstance and ApiTokenInstance data

Request examples#

import requests

url = "{{APIUrl}}/waInstance{{idInstance}}/qr/{{apiTokenInstance}}"

payload = {}
headers= {}

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

print(response.text.encode('utf8'))
curl --location '{{APIUrl}}/waInstance{{idInstance}}/qr/{{apiTokenInstance}}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
    .append("https://api.greenapi.com")
    .append("/waInstance").append({{idInstance}})
    .append("/qr/")
    .append({{apiTokenInstance}});

var response = restTemplate.exchange(requestUrl.toString(), HttpMethod.GET, null, String.class);
System.out.println(response);
var requestUrl = new StringBuilder();
requestUrl
    .append("https://api.greenapi.com")
    .append("/waInstance").append({{idInstance}})
    .append("/qr/")
    .append({{apiTokenInstance}});

var response = Unirest.get(requestUrl.toString())
    .header("Content-Type", "application/json")
    .asString();

System.out.println(response);
Sub qr()
    Dim url As String
    Dim http As Object
    Dim response As String

    ' The idInstance and apiTokenInstance values are available in your account, double brackets must be removed
    url = "{{APIUrl}}/waInstance{{idInstance}}/qr/{{apiTokenInstance}}"

    Set http = CreateObject("MSXML2.XMLHTTP")

    http.Open "GET", url, False
    http.Send

    response = http.responseText

    Debug.Print response

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

    Set http = Nothing
End Sub