API - SISTEMA | BAILEYS | OFIC...
Criar Contato (com validação)
2min
PHP
1<?php
2
3$curl = curl_init();
4
5curl_setopt_array($curl, array(
6 CURLOPT_URL => 'https://{BACKEND_URL}/api/contactswv',
7 CURLOPT_RETURNTRANSFER => true,
8 CURLOPT_ENCODING => '',
9 CURLOPT_MAXREDIRS => 10,
10 CURLOPT_TIMEOUT => 0,
11 CURLOPT_FOLLOWLOCATION => true,
12 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
13 CURLOPT_CUSTOMREQUEST => 'POST',
14 CURLOPT_POSTFIELDS =>'{
15 "name": "teste extra22 2",
16 "number": "5521995027350",
17 "email": "[email protected]",
18 "carteiraId": "", // null ou vazio para não utilizar
19 "extraInfo": [
20 {
21 "name": "Código",
22 "value": "0"
23 },
24 {
25 "name": "Valor do Lead",
26 "value": "0"
27 },
28 {
29 "name": "CEP",
30 "value": "0"
31 }
32 ]
33}',
34 CURLOPT_HTTPHEADER => array(
35 'Content-Type: application/json',
36 'Authorization: Bearer tokenmeu'
37 ),
38));
39
40$response = curl_exec($curl);
41
42curl_close($curl);
43echo $response;
44
JSON
1{
2 "profilePicUrl": "",
3 "isGroup": false,
4 "disableBot": false,
5 "acceptAudioMessage": true,
6 "active": true,
7 "channel": "whatsapp",
8 "perfexId": "",
9 "rdId": "",
10 "cvId": "",
11 "id": 24294,
12 "name": "teste extra22 2",
13 "number": "5521995027350",
14 "email": "[email protected]",
15 "extraInfo": [
16 {
17 "id": 8,
18 "name": "Código",
19 "value": "0",
20 "contactId": 24294,
21 "updatedAt": "2023-12-10T19:48:59.252Z",
22 "createdAt": "2023-12-10T19:48:59.252Z"
23 },
24 {
25 "id": 9,
26 "name": "Valor do Lead",
27 "value": "0",
28 "contactId": 24294,
29 "updatedAt": "2023-12-10T19:48:59.252Z",
30 "createdAt": "2023-12-10T19:48:59.252Z"
31 },
32 {
33 "id": 10,
34 "name": "CEP",
35 "value": "0",
36 "contactId": 24294,
37 "updatedAt": "2023-12-10T19:48:59.252Z",
38 "createdAt": "2023-12-10T19:48:59.252Z"
39 }
40 ],
41 "companyId": 1,
42 "updatedAt": "2023-12-10T19:48:59.248Z",
43 "createdAt": "2023-12-10T19:48:59.248Z",
44 "picupdatedAt": null
45}
JSON
1{
2 "alreadyExists": true, // Somente em caso de já existir o contato
3 "existingContact": {
4 "id": 9698,
5 "name": "Casas Bahia",
6 "number": "5521995027179",
7 "email": "",
8 "profilePicUrl": "",
9 "isGroup": false,
10 "disableBot": false,
11 "acceptAudioMessage": true,
12 "active": true,
13 "channel": "whatsapp",
14 "perfexId": "",
15 "rdId": "",
16 "cvId": "",
17 "picupdatedAt": null,
18 "companyId": 1,
19 "createdAt": "2023-11-25T17:34:51.008Z",
20 "updatedAt": "2023-11-25T17:34:51.008Z"
21 }
22}
Updated 19 Apr 2024
![Doc contributor](https://s3.amazonaws.com/archbee-animals/koala.png)
Did this page help you?