Skip to main content
GET
/
devices
/
{device_id}
/
login
Login Device
curl --request GET \
  --url https://api.example.com/devices/{device_id}/login
{
  "404": {},
  "500": {},
  "code": "<string>",
  "message": "<string>",
  "results": {
    "pair_code": "<string>"
  }
}
Initiate the QR code login process for a specific device. This endpoint generates a QR code that can be scanned with WhatsApp mobile app to authenticate the device.

Endpoint

GET /devices/{device_id}/login
For pairing code login (alternative to QR code):
POST /devices/{device_id}/login/code?phone=628912344551

Authentication

This endpoint requires HTTP Basic Authentication.

Path Parameters

device_id
string
required
Device ID to initiate login for

QR Code Login

Response

code
string
Response code
message
string
Response message
results
object
QR code information

Response Example

{
  "code": "SUCCESS",
  "message": "QR code generated successfully",
  "results": {
    "qr_duration": 30,
    "qr_link": "http://localhost:3000/statics/images/qrcode/scan-qr-b0b7bb43-9a22-455a-814f-5a225c743310.png"
  }
}

Example Request

curl -X GET http://localhost:3000/devices/my-device-id/login \
  -u username:password

Pairing Code Login

Alternative login method using a pairing code instead of QR code scanning.

Query Parameters

phone
string
required
Phone number to pair with (with country code, without + or spaces)

Response

code
string
Response code
message
string
Response message
results
object
Pairing code information

Response Example

{
  "code": "SUCCESS",
  "message": "Pairing code generated successfully",
  "results": {
    "pair_code": "ABCD-1234"
  }
}

Example Request

curl -X POST "http://localhost:3000/devices/my-device-id/login/code?phone=628912344551" \
  -u username:password

Error Responses

404
object
Device Not Found
500
object
Internal Server Error

Login Process

QR Code Method

  1. Call the login endpoint to generate a QR code
  2. Display the QR code image from the qr_link URL
  3. Open WhatsApp on your phone
  4. Go to Settings > Linked Devices > Link a Device
  5. Scan the QR code displayed
  6. Device will be automatically logged in

Pairing Code Method

  1. Call the pairing code endpoint with your phone number
  2. Copy the 8-character pairing code from the response
  3. Open WhatsApp on your phone
  4. Go to Settings > Linked Devices > Link a Device
  5. Select Link with phone number instead
  6. Enter the pairing code
  7. Device will be automatically logged in
QR codes are valid for 30 seconds. If the QR code expires, call the endpoint again to generate a new one.
After successful login, the device state will change to logged_in and you can start using it to send/receive messages.

Build docs developers (and LLMs) love