Skip to main content

Create a contact in your directory

This endpoint will let you create a contact into your 2Chat account.

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
contact_detailsA list of contact details

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 '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",
"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": null,
"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
}
]
}
}