Skip to content

Connecting a phone number to the GREEN API service#

You can connect your WhatsApp phone number to the API instance in your integration in two ways.


Before retrieving the authorization code, make sure the instance is unauthorized. To deauthorize, use the method Logout method to deauthorize.

Connect via QR code#

  1. Get a QR code via websocket.

    • Create a file in HTML format;
    • Add the code from the example;

      The connection is set up by JavaScript code.

    • Create local page hosting;
    • Put apiUrl, idInstance and apiTokenInstance in the fields.

      You can find out where to find apiUrl, idInstance and apiTokenInstance in article;

    • Click on the Get QR button. The QR code will appear on the screen.

    When receiving a QR code via websocket, the Get QR button can be clicked several times and you will always be returned an up-to-date image of the QR code.

  2. Through the browser.

    • You can get the QR code directly through your browser's search bar.******/0654934b277d4ef693b01ab073d9cd2e97f02db9a53******
  3. Through QR method.
    Code example.

    • Add apiUrl, idInstance and apiTokenInstance from console;
    • The message field will return a base64 encoded QR code string;
    • To see an image with a QR code, put data:image/png;base64, {message} in the browser search bar.


For successful authorization via QR code, you need to scan it within 20 seconds. Otherwise, the QR code will be updated on the WhatsApp side and the whole procedure will have to be started again.

Bind by phone number#

Code example.

  • Send a POST request using the getAutoriationCode method.
  • Customize the body of the request - enter the phone number in international format in the phoneNumber field.

    Do not use plus signs, zeros, parentheses, or dashes when entering the phone number in international format. For example:

  • The code field in the body of the reply will show the eight-digit code to be entered in the WhatsApp app.


The phone number method has no time limit for authorization. You can easily send the code to another person by mail or messenger. No camera is required for authorization by phone number. You can read more in our article.