curl --request POST \
--url https://api.wegly.com.br/integrations/external/chats \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"whatsapp_phone_id": "0b28ee57-7a57-4407-a9c5-5cd4e5a5fd6c",
"wa_contact_id": "11999999999",
"template": {
"name": "saudacao_inicial",
"language": "pt_BR"
},
"template_fields": [
{
"component": "BODY",
"type": "TEXT",
"index": 1,
"value": "João"
}
]
}
'import requests
url = "https://api.wegly.com.br/integrations/external/chats"
payload = {
"whatsapp_phone_id": "0b28ee57-7a57-4407-a9c5-5cd4e5a5fd6c",
"wa_contact_id": "11999999999",
"template": {
"name": "saudacao_inicial",
"language": "pt_BR"
},
"template_fields": [
{
"component": "BODY",
"type": "TEXT",
"index": 1,
"value": "João"
}
]
}
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({
whatsapp_phone_id: '0b28ee57-7a57-4407-a9c5-5cd4e5a5fd6c',
wa_contact_id: '11999999999',
template: {name: 'saudacao_inicial', language: 'pt_BR'},
template_fields: [{component: 'BODY', type: 'TEXT', index: 1, value: 'João'}]
})
};
fetch('https://api.wegly.com.br/integrations/external/chats', 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://api.wegly.com.br/integrations/external/chats",
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([
'whatsapp_phone_id' => '0b28ee57-7a57-4407-a9c5-5cd4e5a5fd6c',
'wa_contact_id' => '11999999999',
'template' => [
'name' => 'saudacao_inicial',
'language' => 'pt_BR'
],
'template_fields' => [
[
'component' => 'BODY',
'type' => 'TEXT',
'index' => 1,
'value' => 'João'
]
]
]),
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://api.wegly.com.br/integrations/external/chats"
payload := strings.NewReader("{\n \"whatsapp_phone_id\": \"0b28ee57-7a57-4407-a9c5-5cd4e5a5fd6c\",\n \"wa_contact_id\": \"11999999999\",\n \"template\": {\n \"name\": \"saudacao_inicial\",\n \"language\": \"pt_BR\"\n },\n \"template_fields\": [\n {\n \"component\": \"BODY\",\n \"type\": \"TEXT\",\n \"index\": 1,\n \"value\": \"João\"\n }\n ]\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://api.wegly.com.br/integrations/external/chats")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"whatsapp_phone_id\": \"0b28ee57-7a57-4407-a9c5-5cd4e5a5fd6c\",\n \"wa_contact_id\": \"11999999999\",\n \"template\": {\n \"name\": \"saudacao_inicial\",\n \"language\": \"pt_BR\"\n },\n \"template_fields\": [\n {\n \"component\": \"BODY\",\n \"type\": \"TEXT\",\n \"index\": 1,\n \"value\": \"João\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.wegly.com.br/integrations/external/chats")
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 \"whatsapp_phone_id\": \"0b28ee57-7a57-4407-a9c5-5cd4e5a5fd6c\",\n \"wa_contact_id\": \"11999999999\",\n \"template\": {\n \"name\": \"saudacao_inicial\",\n \"language\": \"pt_BR\"\n },\n \"template_fields\": [\n {\n \"component\": \"BODY\",\n \"type\": \"TEXT\",\n \"index\": 1,\n \"value\": \"João\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"wa_contact_id": "<string>",
"contact_name": "<string>",
"contact_number": "<string>",
"unread_count": 123,
"is_manually_unread": true,
"archived_at": "2023-11-07T05:31:56Z",
"assigned_agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"phone_number": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"display_number": "<string>"
},
"assigned_agent": {
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"user": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"avatar": "<string>"
}
},
"last_message_at": "2023-11-07T05:31:56Z",
"last_message": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"from_me": true,
"body_text": "<string>",
"content_payload": {},
"reactions": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"emoji": "<string>",
"reactor_wa_id": "<string>",
"reactor_user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z"
}
],
"meta_timestamp": "<string>",
"is_history": true,
"history_phase": 123,
"history_chunk_order": 123,
"history_progress": 123,
"is_media_placeholder": true,
"agent": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"user": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"avatar": "<string>"
}
},
"user": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"avatar": "<string>"
},
"crm_marketing_lead_source": [
{}
]
},
"crm_person": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
}
}Criação manual de chat
Cria ou reaproveita um chat manualmente e sempre dispara um template do WhatsApp como primeira mensagem. - É obrigatório informar template.name e template.language. - O destino deve ser enviado por wa_contact_id ou person_contact_id. - Quando person_contact_id é usado, ele tem prioridade sobre wa_contact_id. - O retorno segue o mesmo formato da listagem resumida de chats.
curl --request POST \
--url https://api.wegly.com.br/integrations/external/chats \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"whatsapp_phone_id": "0b28ee57-7a57-4407-a9c5-5cd4e5a5fd6c",
"wa_contact_id": "11999999999",
"template": {
"name": "saudacao_inicial",
"language": "pt_BR"
},
"template_fields": [
{
"component": "BODY",
"type": "TEXT",
"index": 1,
"value": "João"
}
]
}
'import requests
url = "https://api.wegly.com.br/integrations/external/chats"
payload = {
"whatsapp_phone_id": "0b28ee57-7a57-4407-a9c5-5cd4e5a5fd6c",
"wa_contact_id": "11999999999",
"template": {
"name": "saudacao_inicial",
"language": "pt_BR"
},
"template_fields": [
{
"component": "BODY",
"type": "TEXT",
"index": 1,
"value": "João"
}
]
}
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({
whatsapp_phone_id: '0b28ee57-7a57-4407-a9c5-5cd4e5a5fd6c',
wa_contact_id: '11999999999',
template: {name: 'saudacao_inicial', language: 'pt_BR'},
template_fields: [{component: 'BODY', type: 'TEXT', index: 1, value: 'João'}]
})
};
fetch('https://api.wegly.com.br/integrations/external/chats', 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://api.wegly.com.br/integrations/external/chats",
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([
'whatsapp_phone_id' => '0b28ee57-7a57-4407-a9c5-5cd4e5a5fd6c',
'wa_contact_id' => '11999999999',
'template' => [
'name' => 'saudacao_inicial',
'language' => 'pt_BR'
],
'template_fields' => [
[
'component' => 'BODY',
'type' => 'TEXT',
'index' => 1,
'value' => 'João'
]
]
]),
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://api.wegly.com.br/integrations/external/chats"
payload := strings.NewReader("{\n \"whatsapp_phone_id\": \"0b28ee57-7a57-4407-a9c5-5cd4e5a5fd6c\",\n \"wa_contact_id\": \"11999999999\",\n \"template\": {\n \"name\": \"saudacao_inicial\",\n \"language\": \"pt_BR\"\n },\n \"template_fields\": [\n {\n \"component\": \"BODY\",\n \"type\": \"TEXT\",\n \"index\": 1,\n \"value\": \"João\"\n }\n ]\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://api.wegly.com.br/integrations/external/chats")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"whatsapp_phone_id\": \"0b28ee57-7a57-4407-a9c5-5cd4e5a5fd6c\",\n \"wa_contact_id\": \"11999999999\",\n \"template\": {\n \"name\": \"saudacao_inicial\",\n \"language\": \"pt_BR\"\n },\n \"template_fields\": [\n {\n \"component\": \"BODY\",\n \"type\": \"TEXT\",\n \"index\": 1,\n \"value\": \"João\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.wegly.com.br/integrations/external/chats")
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 \"whatsapp_phone_id\": \"0b28ee57-7a57-4407-a9c5-5cd4e5a5fd6c\",\n \"wa_contact_id\": \"11999999999\",\n \"template\": {\n \"name\": \"saudacao_inicial\",\n \"language\": \"pt_BR\"\n },\n \"template_fields\": [\n {\n \"component\": \"BODY\",\n \"type\": \"TEXT\",\n \"index\": 1,\n \"value\": \"João\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"wa_contact_id": "<string>",
"contact_name": "<string>",
"contact_number": "<string>",
"unread_count": 123,
"is_manually_unread": true,
"archived_at": "2023-11-07T05:31:56Z",
"assigned_agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"phone_number": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"display_number": "<string>"
},
"assigned_agent": {
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"user": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"avatar": "<string>"
}
},
"last_message_at": "2023-11-07T05:31:56Z",
"last_message": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"from_me": true,
"body_text": "<string>",
"content_payload": {},
"reactions": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"emoji": "<string>",
"reactor_wa_id": "<string>",
"reactor_user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z"
}
],
"meta_timestamp": "<string>",
"is_history": true,
"history_phase": 123,
"history_chunk_order": 123,
"history_progress": 123,
"is_media_placeholder": true,
"agent": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"user": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"avatar": "<string>"
}
},
"user": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"avatar": "<string>"
},
"crm_marketing_lead_source": [
{}
]
},
"crm_person": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>"
}
}Authorizations
Utilize o token de integração no header Authorization: Bearer {token}. O domínio de origem (Origin/Referer) deve respeitar allowed_domain, quando configurado na chave.
Body
- Option 1
- Option 2
50Show child attributes
Show child attributes
255OPEN, RESOLVED, SNOOZED Show child attributes
Show child attributes
Response
Chat criado ou reaproveitado com sucesso.
OPEN, RESOLVED, SNOOZED INDIVIDUAL, GROUP 0 = baixa, 1 = normal, 2 = alta, 3 = urgente.
0, 1, 2, 3 Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
