Skip to content

Whatsapp Contacts Messages

Contacts messages allow you to send rich contact information directly to WhatsApp users, such as names, phone numbers, physical addresses, and email addresses.

Image Alt Text

Contacts Object

Parameter Type Description
*name Object Full contact name formatted as a name object.
addresses Array (Object) Full contact address(es) formatted as an addresses object.
birthday String YYYY-MM-DD formatted string.
emails Array (Object) Contact email address(es) formatted as an emails object.
org Object Contact organization information formatted as an org object.
phones Array (Object) Contact phone number(s) formatted as a phone object.
urls Array (Object) Contact URL(s) formatted as a urls object.

Parameter Type Description
*formatted_name String Full name, as it normally appears. At least one of the optional parameters needs to be included along with the formatted_name parameter.
first_name String First name of the contact you wants to send.
last_name String Last name of the contact you wants to send.
middle_name String Middle name of the contact you wants to send.
suffix String Name suffix.
prefix String Name prefix.
Parameter Type Description
street String Street number and name.
city String City name.
state String State abbreviation.
zip String Zip Code
country String Full country name.
country_code String Two-letter country abbreviation.
type String Standard values are HOME and WORK.
Parameter Type Description
email String Email Address.
type String Supported values are HOME and WORK.
Parameter Type Description
company String Name of the contact's company.
department String Name of the contact's department.
title String Contact's business title.
Parameter Type Description
phone String Automatically populated with the wa_id value as a formatted phone number.
type String Standard Values are CELL, MAIN, IPHONE, HOME, and WORK.
wa_id String WhatsApp ID.
Parameter Type Description
url String URL.
type String Supported values are HOME and WORK.
"contacts": [
                {
                    "addresses": [{
                                    "street": "STREET",
                                    "city": "CITY",
                                    "state": "STATE",
                                    "zip": "ZIP",
                                    "country": "COUNTRY",
                                    "country_code": "COUNTRY_CODE",
                                    "type": "HOME"
                                  },
                                  {
                                    "street": "STREET",
                                    "city": "CITY",
                                    "state": "STATE",
                                    "zip": "ZIP",
                                    "country": "COUNTRY",
                                    "country_code": "COUNTRY_CODE",
                                    "type": "WORK"
                                  }],
                    "birthday": "YEAR_MONTH_DAY",
                    "emails": [{
                                  "email": "EMAIL",
                                  "type": "WORK"
                                },
                                {
                                  "email": "EMAIL",
                                  "type": "HOME"
                                }],
                    "name": {
                              "formatted_name": "NAME",
                              "first_name": "FIRST_NAME",
                              "last_name": "LAST_NAME",
                              "middle_name": "MIDDLE_NAME",
                              "suffix": "SUFFIX",
                              "prefix": "PREFIX"
                           },
                    "org": {
                                "company": "COMPANY",
                                "department": "DEPARTMENT",
                                "title": "TITLE"
                            },
                    "phones": [{
                                  "phone": "PHONE_NUMBER",
                                  "type": "HOME"
                                },
                                {
                                  "phone": "PHONE_NUMBER",
                                  "type": "WORK",
                                  "wa_id": "PHONE_OR_WA_ID"
                                }],
                    "urls": [{
                                "url": "URL",
                                "type": "WORK"
                              },
                              {
                                "url": "URL",
                                "type": "HOME"
                            }]
                }
            ]

Programing Examples:

curl --location 'https://apialpha.d7networks.com/whatsapp/v2/send' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiZjM0N2JhMDktMTllMi00MmIxLWE3ZjYtZDIyOGNlOTczN2U2In0.-ECRlIIiXGoF01JJEf7lmZjHCzny0vAKSlTFGbHQuwc' \
--data-raw '{
    "messages": [
        {
            "originator": "{registered_phone_number}",
            "content": {
                "message_type": "CONTACTS",
                "contacts": [{
                    "name": {
                        "first_name": "Alice",
                        "last_name": "Jane",
                        "formatted_name": "Alice Jane"},
                    "birthday":"1994-12-12",
                    "phones": [{"phone": "{recipient}"}, {"phone": "+91815678xxxx"}],
                    "emails":[{"email": "[email protected]"}],
                    "urls":[{"url": "https://d7networks.com"}]
                }]
            },
            "recipients": [{
                "recipient": "{recipient}",
                "recipient_type": "individual",
            }]
        }
    ]
}'
npm i direct7
const Client = require('direct7')

const client = new Client(apiToken="Your API token")

let contact_addresses = [
            {
                "street": "1 Lucky Shrub Way",
                "city": "Menlo Park",
                "state": "CA",
                "zip": "94025",
                "country": "United States",
                "country_code": "US",
                "type": "WORK"
            }
        ]

let phones = [
        {
            "phone": "+16505559999",
            "type": "HOME"
        }
    ]

let emails = [
        {
            "email": "[email protected]",
            "type": "WORK"
        }
    ]
let urls = [
        {
            "url": "https://www.luckyshrub.com",
            "type": "WORK"
        }
    ]

const response = await client.whatsapp.sendWhatsAppFreeformMessage({
    originator:"{registered_phone_number}",
    recipients: [{"recipient": "{recipient}", "recipient_type": "individual"}],
    message_type: "CONTACTS",
    first_name: "Barbara",
    last_name: "Johnson",
    formatted_name: "Barbara J. Johnson",
    middle_name: "Joana", suffix: "Esq.",
    prefix: "Dr.",
    phones: phones, emails: emails,
    contact_addresses: contact_addresses,
    urls:urls
});

console.log(response);
pip install direct7
from direct7 import Client

client = Client(api_token="Your API token")

contact_addresses = [
    {
        "street": "1 Lucky Shrub Way",
        "city": "Menlo Park",
        "state": "CA",
        "zip": "94025",
        "country": "United States",
        "country_code": "US",
        "type": "WORK"
    }
]

phones = [
    {
        "phone": "+16505559999",
        "type": "HOME"
    }
]

emails = [
    {
        "email": "[email protected]",
        "type": "WORK"
    }
]
urls = [
    {
        "url": "https://www.luckyshrub.com",
        "type": "WORK"
    }
]

client.whatsapp.send_whatsapp_freeform_message(originator="{originator}",
                                                recipients=[{"recipient": "{recipient}", "recipient_type": "individual"}],
                                                message_type="CONTACTS",
                                                first_name="Barbara",
                                                last_name="Johnson",
                                                formatted_name="Barbara J. Johnson",
                                                middle_name="Joana", suffix="Esq.",
                                                prefix="Dr.",
                                                phones=phones, emails=emails,
                                                contact_addresses=contact_addresses,
                                                urls=urls)    

composer require direct7/direct7-php
require_once 'vendor/autoload.php';
require_once __DIR__ . '/vendor/autoload.php';

use direct7\Direct7\Client;

$client = new Client(api_token="Your API token")

$contact_addresses = [
    [
        "street" => "1 Lucky Shrub Way",
        "city" => "Menlo Park",
        "state" => "CA",
        "zip" => "94025",
        "country" => "United States",
        "country_code" => "US",
        "type" => "WORK"
    ]
];

$phones = [
    [
        "phone" => "+16505559999",
        "type" => "HOME"
    ]
];

$emails = [
    [
        "email" => "[email protected]",
        "type" => "WORK"
    ]
];
$urls = [
    [
        "url" => "https://www.luckyshrub.com",
        "type"=> "WORK"
    ]
];

$response = $direct7->whatsapp->sendWhatsAppFreeformMessage(
    originator:"{originator}", 
    recipients:[["recipient" => "{recipient}", "recipient_type" => "individual"]], 
    message_type:"CONTACTS", 
    first_name:"Alice", 
    last_name:"Jane", 
    formatted_name:"Alice Jane", 
    middle_name:"Joana", 
    suffix:"Esq.",
    prefix:"Dr.",
    phones:$phones, 
    emails:$emails,
    contact_addresses:$contact_addresses,
    urls:$urls
);

var_dump($response);
go get -u github.com/d7networks/direct7-go-sdk
import (
"github.com/d7networks/direct7-go-sdk/direct7"
)
apiToken := "Your Api Token"
client := direct7.NewClient(apiToken)
whatsapp := direct7.NewWhatsApp(client)
originator := "{registered_phonenumber}"
recipients := []map[string]string{
    "recipient": "{recipient}",
    "recipient_type": "individual",
}
messageType := "CONTACTS"
contactAddresses := []map[string]string{
    {
        "Street":      "1 Lucky Shrub Way",
        "City":        "Menlo Park",
        "State":       "CA",
        "Zip":         "94025",
        "Country":     "United States",
        "CountryCode": "US",
        "Type":        "WORK",
    },
    {
        "Street":      "1 Hacker Way",
        "City":        "Menlo Park",
        "State":       "CA",
        "Zip":         "94025",
        "Country":     "United States",
        "CountryCode": "US",
        "Type":        "WORK",
    },
}
phones := []map[string]string{
    {
        "Phone": "+16505559999",
        "Type":  "HOME",
    },
    {
        "Phone": "+19175559999",
        "Type":  "WORK",
        "WaID":  "19175559999",
    },
}
emails := []map[string]string{
    {
        "Email": "[email protected]",
        "Type":  "WORK",
    },
    {
        "Email": "[email protected]",
        "Type":  "HOME",
    },
}
urls := []map[string]string{
    {
        "URL":  "https://www.luckyshrub.com",
        "Type": "WORK",
    },
    {
        "URL":  "https://www.facebook.com/luckyshrubplants",
        "Type": "WORK",
    },
}
optParams := &OptionalParams{
    firstName:        "Alice",
    lastName:         "Jane",
    formattedName:    "Alice Jane",
    middleName:       "Joana",
    suffix:           "Esq.",
    prefix:           "Dr.",
    phones:           phones,
    emails:           emails,
    contactAddresses: contactAddresses,
    urls:             urls,
}
response, err := client.whatsapp.SendWhatsAppFreeformMessage(originator, recipients, messageType, optParams)
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"messages\": [\n        {\n            \"originator\": \"{registered phone_number}\",\n            \"content\": {\n                \"message_type\": \"CONTACTS\",\n                \"contacts\": [{\n                    \"name\": {\n                        \"first_name\": \"Alice\",\n                        \"last_name\": \"Jane\",\n                        \"formatted_name\": \"Alice Jane\"},\n                    \"birthday\":\"1994-12-12\",\n                    \"phones\": [{\"phone\": \"{recipient}\"}, {\"phone\": \"+91815678xxxx\"}],\n                    \"emails\":[{\"email\": \"[email protected]\"}],\n                    \"urls\":[{\"url\": \"https://d7networks.com\"}]\n                }]\n            },\n            \"recipients\": [{\n                \"recipient\": \"{recipient}\",\n                \"recipient_type\": \"individual\"\n            }]\n        }\n    ]\n}");
Request request = new Request.Builder()
  .url("https://apialpha.d7networks.com/whatsapp/v2/send")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiZjM0N2JhMDktMTllMi00MmIxLWE3ZjYtZDIyOGNlOTczN2U2In0.-ECRlIIiXGoF01JJEf7lmZjHCzny0vAKSlTFGbHQuwc")
  .build();
Response response = client.newCall(request).execute();
  var headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiZjM0N2JhMDktMTllMi00MmIxLWE3ZjYtZDIyOGNlOTczN2U2In0.-ECRlIIiXGoF01JJEf7lmZjHCzny0vAKSlTFGbHQuwc'
  };
  var request = http.Request('POST', Uri.parse('https://apialpha.d7networks.com/whatsapp/v2/send'));
  request.body = json.encode({
  "messages": [
  {
  "originator": "{registered phone_number}",
  "content": {
  "message_type": "CONTACTS",
  "contacts": [
  {
  "name": {
  "first_name": "Alice",
  "last_name": "Jane",
  "formatted_name": "Alice Jane"
  },
  "birthday": "1994-12-12",
  "phones": [
  {
  "phone": "{recipient}"
  },
  {
  "phone": "+91815678xxxx"
  }
  ],
  "emails": [
  {
  "email": "[email protected]"
  }
  ],
  "urls": [
  {
  "url": "https://d7networks.com"
  }
  ]
  }
  ]
  },
  "recipients": [
  {
    "recipient": "{recipient}",
    "recipient_type": "individual",
  }
  ]
  }
  ]
  });
  request.headers.addAll(headers);

  http.StreamedResponse response = await request.send();

  if (response.statusCode == 200) {
  print(await response.stream.bytesToString());
  }
  else {
  print(response.reasonPhrase);
  }
 $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
 $headers.Add("Content-Type", "application/json")
 $headers.Add("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiZjM0N2JhMDktMTllMi00MmIxLWE3ZjYtZDIyOGNlOTczN2U2In0.-ECRlIIiXGoF01JJEf7lmZjHCzny0vAKSlTFGbHQuwc")

 $body = @"
 {
     `"messages`": [
         {
             `"originator`": `"{registered phone_number}`",
             `"content`": {
                 `"message_type`": `"CONTACTS`",
                 `"contacts`": [{
                     `"name`": {
                         `"first_name`": `"Alice`",
                         `"last_name`": `"Jane`",
                         `"formatted_name`": `"Alice Jane`"},
                     `"birthday`":`"1994-12-12`",
                     `"phones`": [{`"phone`": `"{recipient}`"}, {`"phone`": `"+91815678xxxx`"}],
                     `"emails`":[{`"email`": `"[email protected]`"}],
                     `"urls`":[{`"url`": `"https://d7networks.com`"}]
                 }]
             },
             `"recipients`": [{
                 `"recipient`": `"{recipient}`",
                 `"recipient_type`": `"individual`",
             }]
         }
     ]
 }
 "@

 $response = Invoke-RestMethod 'https://apialpha.d7networks.com/whatsapp/v2/send' -Method 'POST' -Headers $headers -Body $body
 $response | ConvertTo-Json
gem install direct7
require 'direct7'

client = Direct7::Client.new('Your API token')

client.whatsapp.send_whatsapp_freeform_message(
    originator= "{originator}",
    recipients=[{ "recipient" => "{recipient}", "recipient_type" => "individual"}],
    message_type="CONTACTS", 
    body=nil,
    first_name="Barbara",
    last_name="Johnson",
    formatted_name="Barbara J. Johnson",
    middle_name="Joana", 
    suffix="Esq.",
    prefix="Dr.",
    birthday='4567-12-12',
    phones=phones, 
    emails=emails,
    urls=urls,
    latitude=nil, longitude=nil, name=nil, address=nil, type=nil, url=nil, caption=nil, filename=nil, message_id=nil, emoji=nil,
    contact_addresses=contact_addresses,
)
1
2
3
4
5
6
7
8
 var client = new HttpClient();
 var request = new HttpRequestMessage(HttpMethod.Post, "https://apialpha.d7networks.com/whatsapp/v2/send");
 request.Headers.Add("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoLWJhY2tlbmQ6YXBwIiwic3ViIjoiZjM0N2JhMDktMTllMi00MmIxLWE3ZjYtZDIyOGNlOTczN2U2In0.-ECRlIIiXGoF01JJEf7lmZjHCzny0vAKSlTFGbHQuwc");
 var content = new StringContent("{\n    \"messages\": [\n        {\n            \"originator\": \"{registered phone_number}\",\n            \"content\": {\n                \"message_type\": \"CONTACTS\",\n                \"contacts\": [{\n                    \"name\": {\n                        \"first_name\": \"Alice\",\n                        \"last_name\": \"Jane\",\n                        \"formatted_name\": \"Alice Jane\"},\n                    \"birthday\":\"1994-12-12\",\n                    \"phones\": [{\"phone\": \"{recipient}\"}, {\"phone\": \"+91815678xxxx\"}],\n                    \"emails\":[{\"email\": \"[email protected]\"}],\n                    \"urls\":[{\"url\": \"https://d7networks.com\"}]\n                }]\n            },\n            \"recipients\": [{\n                \"recipient\": \"{recipient}\",\n                \"recipient_type\": \"individual\"\n            }]\n        }\n    ]\n}", null, "application/json");
 request.Content = content;
 var response = await client.SendAsync(request);
 response.EnsureSuccessStatusCode();
 Console.WriteLine(await response.Content.ReadAsStringAsync());