Skip to main content

Create a contact in your directory

This endpoint will let you create a contact in your 2Chat account and WhatsApp account, when specified.

Contact fields

Each contact must have at least a first name and some contact details like a phone number or an email address.

FieldDescription
first_nameFirst name
last_nameLast name
profile_pic_urlA publicly accessible URL
channel_uuidWhen provided, the contact will also be created on your WhatsApp account
contact_detailsA list of contact details
tip

The channel_uuid parameter must a WhatsApp channel. When provided, the contact will be created on your 2Chat account and also on the WhatsApp account associated to this channel. If the contact exists on your WhatsApp account, it will be updated.

You can obtain a list of UUIDs using the list numbers endpoint.

Contact details

Each person in your contact directory can have many associated details, like a phone number or a physical address. You can specify which information type you are creating by selecting the right type for each value following the instructions on the table below:

TypeDescriptionExample values
EEmail addressmyemail@example.com
APhysical addressFlower St. 123
PHPhone number+12121112222
WAPHPhone number that has a WhatsApp account+12121112222
caution

When specifying a phone number, always use its international format.

Invocation

curl --location --request POST 'https://api.p.2chat.io/open/contacts' \
--header 'Content-Type: application/json' \
--header 'X-User-API-Key: your_api_key_here' \
--data '{
"first_name": "2Chat",
"last_name": "Support",
"channel_uuid": "WPN66037eca-9ad1-4c96-9eff-526a90a48c77",
"contact_detail": [
{ "type": "PH", "value": "+17137157533" },
{ "type": "WAPH", "value": "+17137157533" },
{ "type": "E", "value": "support@2chat.co" }
]
}'

Response

The API will response with the new contact it created if the invocation succeeded.

{
"success": true,
"contact": {
"uuid": "CON2226e836-36dc-4103-b2a2-6307749cf390",
"first_name": "2Chat",
"last_name": "Support",
"channel_uuid": "WPN66037eca-9ad1-4c96-9eff-526a90a48c77",
"profile_pic_url": null,
"details": [
{
"id": 1331,
"value": "+17137157533",
"type": "PH",
"created_at": 1695230471,
"updated_at": 0
},
{
"id": 1332,
"value": "+17137157533",
"type": "WAPH",
"created_at": 1695230471,
"updated_at": 0
},
{
"id": 1333,
"value": "support@2chat.co",
"type": "E",
"created_at": 1695230471,
"updated_at": 0
}
]
}
}