Skip to content

SendContact#

Test Postman

The method is intended for sending a message with a contact.

The message is added to the sending queue.
The rate at which messages are sent from the queue is set by the message sending interval.

The method uses limits on the request rate per second.

Request#

To send a message with a contact, you need to execute a request at:

POST
{{apiUrl}}/waInstance{{idInstance}}/sendContact/{{apiTokenInstance}}

To get the apiUrl, idInstance and apiTokenInstance request parameters, refer to the Before you start section.

Request parameters#

Parameter Type Required Description
chatId string Yes Chat identifier
contact object Yes Contact object
quotedMessageId string No Identifier of the quoted message
typingTime integer No The time the typing notification is displayed in the correspondent's chat.
Takes a value in the range from 1000 to 20000 milliseconds (from 1 to 20 seconds)
typingType string No Typing type. Possible values:
text - "typing..." (default)
record_voice_note - "recording a voice message..."
upload_voice_note - "sending a voice message..."
record_video_note - "recording a video message..".
upload_video_note - "sending a video message..."
record_video - "recording a video..."
upload_video - "sending a video..."
upload_photo - "sending a photo..."
upload_document - "sending a file..."
choose_sticker - "choosing a sticker..."
choose_location - "choosing a location..."
choose_contact - "choosing a contact..."

Parameters of the contact object:

Parameter Type Required Description
phoneContact integer Yes Contact's phone number
firstName string Yes Contact's first name
lastName string No Contact's last name
company string No Contact's company

Request body example#

Sending a message to a personal chat#

{
  "chatId": "10000000",
  "contact": {
    "phoneContact": 79876543210,
    "firstName": "Ivan",
    "lastName": "Ivanov",
    "company": ""
  }
}

Sending a message to a group chat#

{
  "chatId": "-10000000000000",
  "contact": {
    "phoneContact": 79876543210,
    "firstName": "Ivan",
    "lastName": "Ivanov",
    "company": ""
  }
}

Sending a message with quoting#

{
  "chatId": "10000000",
  "quotedMessageId": "1769676078000",
  "contact": {
    "phoneContact": 79876543210,
    "firstName": "Ivan",
    "lastName": "Ivanov",
    "company": ""
  }
}

Response#

Response fields#

Field Type Description
idMessage string Identifier of the sent message

Response body example#

{
    "idMessage": "1769676078000"
}

Errors#

For the list of errors common to all methods, see the Common errors section

HTTP code Error identifier Description
400 Bad Request
Validation failed
Validation error

Code examples#

import requests

url = "{{apiUrl}}/waInstance{{idInstance}}/sendContact/{{apiTokenInstance}}"

payload = {
    "chatId": "10000000",
    "contact": {
        "phoneContact": 79876543210,
        "firstName": "Ivan",
        "lastName": "Ivanov",
        "company": ""
    }
}

headers = {'Content-Type': 'application/json'}

response = requests.post(url, json=payload, headers=headers)

print(response.text.encode('utf8'))
curl --location '{{apiUrl}}/waInstance{{idInstance}}/sendContact/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
      "chatId": "10000000",
        "contact": {
            "phoneContact": 79876543210,
            "firstName": "Ivan",
            "lastName": "Ivanov",
            "company": ""
        }
}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
    .append({{apiUrl}})
    .append("/waInstance").append({{idInstance}})
    .append("/sendContact/")
    .append({{apiTokenInstance}});

var headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);

var jsonBody = "{\r\n\t\"chatId\": \"10000000\",\r\n\t\"contact\": {\r\n\t\t\"chatId\": \"10000000\",\r\n" };

var requestEntity = new HttpEntity<>(jsonBody, headers);

var response = restTemplate.exchange(requestUrl.toString(), HttpMethod.POST, requestEntity, String.class);
System.out.println(response);
var requestUrl = new StringBuilder();
requestUrl
    .append({{apiUrl}})
    .append("/waInstance").append({{idInstance}})
    .append("/sendContact/")
    .append({{apiTokenInstance}});

var response = Unirest.post(requestUrl.toString())
    .header("Content-Type", "application/json")
    .body("{\r\n\t\"chatId\": \"10000000\",\r\n\t\"contact\": {\r\n\t\t\"chatId\": \"10000000\",\r\n")
    .asString();

System.out.println(response);