Criar sessão
curl --request POST \
--url https://apizap.loce.io/v1/session/connect \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"sessionName": "<string>",
"webhookUrl": "<string>",
"webhookMessages": true
}
'import requests
url = "https://apizap.loce.io/v1/session/connect"
payload = {
"sessionName": "<string>",
"webhookUrl": "<string>",
"webhookMessages": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({sessionName: '<string>', webhookUrl: '<string>', webhookMessages: true})
};
fetch('https://apizap.loce.io/v1/session/connect', 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://apizap.loce.io/v1/session/connect",
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([
'sessionName' => '<string>',
'webhookUrl' => '<string>',
'webhookMessages' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://apizap.loce.io/v1/session/connect"
payload := strings.NewReader("{\n \"sessionName\": \"<string>\",\n \"webhookUrl\": \"<string>\",\n \"webhookMessages\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://apizap.loce.io/v1/session/connect")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"sessionName\": \"<string>\",\n \"webhookUrl\": \"<string>\",\n \"webhookMessages\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apizap.loce.io/v1/session/connect")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"sessionName\": \"<string>\",\n \"webhookUrl\": \"<string>\",\n \"webhookMessages\": true\n}"
response = http.request(request)
puts response.read_body{
"sessionId": "<string>",
"status": "<string>",
"qrCode": "<string>",
"webhookUrl": "<string>",
"webhookMessages": true
}{
"error": "<string>",
"message": "<string>",
"details": {}
}Session
Conectar WhatsApp
Abre uma nova sessão do WhatsApp e retorna o payload do QR Code para parear o dispositivo.
POST
/
session
/
connect
Criar sessão
curl --request POST \
--url https://apizap.loce.io/v1/session/connect \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"sessionName": "<string>",
"webhookUrl": "<string>",
"webhookMessages": true
}
'import requests
url = "https://apizap.loce.io/v1/session/connect"
payload = {
"sessionName": "<string>",
"webhookUrl": "<string>",
"webhookMessages": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({sessionName: '<string>', webhookUrl: '<string>', webhookMessages: true})
};
fetch('https://apizap.loce.io/v1/session/connect', 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://apizap.loce.io/v1/session/connect",
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([
'sessionName' => '<string>',
'webhookUrl' => '<string>',
'webhookMessages' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://apizap.loce.io/v1/session/connect"
payload := strings.NewReader("{\n \"sessionName\": \"<string>\",\n \"webhookUrl\": \"<string>\",\n \"webhookMessages\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://apizap.loce.io/v1/session/connect")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"sessionName\": \"<string>\",\n \"webhookUrl\": \"<string>\",\n \"webhookMessages\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apizap.loce.io/v1/session/connect")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"sessionName\": \"<string>\",\n \"webhookUrl\": \"<string>\",\n \"webhookMessages\": true\n}"
response = http.request(request)
puts response.read_body{
"sessionId": "<string>",
"status": "<string>",
"qrCode": "<string>",
"webhookUrl": "<string>",
"webhookMessages": true
}{
"error": "<string>",
"message": "<string>",
"details": {}
}POST /session/connect
curl -X POST "BASE_URL/v1/session/connect" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer TOKEN" \
-d '{
"sessionName": "NOME_DA_SESSAO",
"webhookUrl": "https://seu-webhook.com/eventos",
"webhookMessages": true,
"mode": "qr",
"pairingNumber": "5511999999999"
}'
sessionName(string) ewebhookUrl(URL) sao obrigatorios.webhookMessagesbool (defaulttrue).mode:qroupairing(defaultqr).pairingNumber: so quandomode = pairing(DDI+numero).- Se o ambiente exigir API key, adicione o header extra (ex.:
-H "x-api-key: SUA_API_KEY").
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
⌘I

