Request authentication code.
curl --request POST \
--url https://{host}/api/{session}/auth/request-code \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"phoneNumber": "12132132130",
"method": null
}
'import requests
url = "https://{host}/api/{session}/auth/request-code"
payload = {
"phoneNumber": "12132132130",
"method": None
}
headers = {
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({phoneNumber: '12132132130', method: null})
};
fetch('https://{host}/api/{session}/auth/request-code', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{host}/api/{session}/auth/request-code",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'phoneNumber' => '12132132130',
'method' => null
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apikey: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{host}/api/{session}/auth/request-code"
payload := strings.NewReader("{\n \"phoneNumber\": \"12132132130\",\n \"method\": null\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{host}/api/{session}/auth/request-code")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"phoneNumber\": \"12132132130\",\n \"method\": null\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/api/{session}/auth/request-code")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"phoneNumber\": \"12132132130\",\n \"method\": null\n}"
response = http.request(request)
puts response.read_body{
"code": "ABCD-1234"
}
Authentication
Request Pairing Code
Request pairing code for authentication via phone number
POST
/
api
/
{session}
/
auth
/
request-code
Request authentication code.
curl --request POST \
--url https://{host}/api/{session}/auth/request-code \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"phoneNumber": "12132132130",
"method": null
}
'import requests
url = "https://{host}/api/{session}/auth/request-code"
payload = {
"phoneNumber": "12132132130",
"method": None
}
headers = {
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({phoneNumber: '12132132130', method: null})
};
fetch('https://{host}/api/{session}/auth/request-code', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{host}/api/{session}/auth/request-code",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'phoneNumber' => '12132132130',
'method' => null
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apikey: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{host}/api/{session}/auth/request-code"
payload := strings.NewReader("{\n \"phoneNumber\": \"12132132130\",\n \"method\": null\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{host}/api/{session}/auth/request-code")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"phoneNumber\": \"12132132130\",\n \"method\": null\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/api/{session}/auth/request-code")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"phoneNumber\": \"12132132130\",\n \"method\": null\n}"
response = http.request(request)
puts response.read_body{
"code": "ABCD-1234"
}
Description
This endpoint allows requesting a pairing code as alternative method of authentication, without the need to scan the QR Code. The received code must be entered in the WhatsApp app to establish the connection.URL Parameters
string
required
Unique ID of the session to be authenticated
Body
{
"phone": "5511999999999"
}
Body Parameters
| Property | Type | Required | Description |
|---|---|---|---|
phone | string | ✅ Yes | Phone number for which the pairing code will be requested |
Response
string
required
Pairing code generated. This code must be entered in the WhatsApp app to complete authentication.
{
"code": "ABCD-1234"
}
Status Codes
200- Code generated successfully400- Invalid parameters (ex: invalid phone number)401- Unauthorized
Usage Example
curl -X POST https://api.wappfy.com.br/api/my-session/auth/request-code \
-H "Content-Type: application/json" \
-d '{
"phone": "5511999999999"
}'
const session = 'my-session';
const response = await fetch(`https://api.wappfy.com.br/api/${session}/auth/request-code`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
phone: '5511999999999'
})
});
const data = await response.json();
console.log(data.code);
import requests
session = 'my-session'
response = requests.post(
f'https://api.wappfy.com.br/api/{session}/auth/request-code',
json={
'phone': '5511999999999'
}
)
data = response.json()
print(data['code'])
Authorizations
Your Wappfy API key (get it at dash.wappfy.com.br)
Path Parameters
The session name (instanceName) you want to authenticate
Body
application/json
Response
201 - undefined
