Overview
This request allows you to create a new contact. You’ll do this when you want to add a contact to one or more of your lists.
Requests to create duplicate contacts (as determined by the email address and the mobile number of the contact) will fail. This can be changed to update the current contact with the latest information by setting the on_duplicate property to ‘update’. Please note that the API will return a 201 Created HTTP response for updates.
The Method
API | Request | Method | Description |
---|---|---|---|
REST | POST | https://[Your URL]/api/2.0/contacts | |
XML-RPC | Call | contacts.CreateContact | Pass the correct data with this function. |
Your method must be structured as follows:
Parameters
Required Parameters
You must, at the very least, have either an email address or a mobile phone number when you create a new contact. You must also specify the lists the contact will belong to, and their subscription status.
Property | Type | Description | Default | Required | Read Only |
---|---|---|---|---|---|
list_id | array | An array of list IDs with the subscription status for the contact. For example: array(1 => ‘unconfirmed’, 2 => ‘subscribed’) will subscribe the contact to list with ID 2, and add the contact as an unconfirmed contact to list 1. | empty | yes | no |
string | empty | no | no | ||
mobile | string | Mobile | empty | no | no |
Optional Parameters
You may include any of these optional parameters when adding a contact:
Property | Type | Description | Default | Required | Read Only |
---|---|---|---|---|---|
country_id | integer | Country identifier | 1 | no | no |
city_id | integer | City identifier | 1 | no | no |
name | string | First Name | empty | no | no |
last name | string | Last Name | empty | no | no |
status | string | Status Possible values: on / off / suppressed | on | no | no |
preferred_email_format | string | Email format Possible values: html / text | HTML | no | no |
title | string | Title | empty | no | no |
company_position | string | Position | empty | no | no |
company_name | string | Company Name | empty | no | no |
department | string | Department | empty | no | no |
industry | string | Industry | empty | no | no |
address | string | Address | empty | no | no |
city | string | City | empty | no | no |
country | string | Country | empty | no | no |
state | string | Province / State | empty | no | no |
zip | string | Postal / ZIP code | empty | no | no |
telephone_office | string | Work Number | empty | no | no |
telephone_home | string | Home Number | empty | no | no |
telephone_fax | string | Fax Number | empty | no | no |
date_of_birth | integer | Date of birth (deprecated) | empty | no | no |
tags | string | JSON array containing tag names | empty | no | no |
birth_date | string | Date of birth | empty | no | no |
gender | string | Gender Possible variables: unknown / male / female | empty | no | no |
marital_status | string | Marital status Possible values: unknown / single / married | empty | no | no |
education_level | string | Education level | empty | no | no |
hash | string | hash_key | empty | no | no |
unique_id | string | Unique import identifier | empty | no | no |
id | integer | ID | empty | no | yes |
date_create | integer | Date created | empty | no | yes |
score | float | Contact score | 2 | no | yes |
rating | integer | Contact rating score | 2 | no | yes |
email_status | string | Email status Possible values: none / bouncing / bounced / always send | none | no | yes |
create_notifications | string | Create notification Possible values: yes / no | no | no | no |
email_bounce_hard_count | integer | Hard email bounces | 0 | no | yes |
email_bounce_soft_count | integer | Soft email bounces | 0 | no | yes |
block_bounce_count | integer | Consecutive block bounces | 0 | no | yes |
sms_bounce_hard_count | integer | Hard SMS bounces | 0 | no | yes |
sms_bounce_soft_count | integer | Soft SMS bounces | 0 | no | yes |
sms_bounce_consecutive_count | integer | Consecutive SMS bounces | 0 | no | yes |
complaints_count | integer | Complaints | 0 | no | yes |
forward_count | integer | Forwards | empty | no | yes |
invite_count | integer | Invites | empty | no | yes |
bounce_unidentified_count | integer | Unidentified bounces | 0 | no | yes |
autoresponder_count | integer | Autoresponders | 0 | no | yes |
email_message_ids | string | Email message identifiers | empty | no | yes |
sms_message_ids | string | SMS message identifiers | empty | no | yes |
email_message_count | integer | Email Messages | 0 | no | yes |
sms_message_count | integer | SMS Messages | 0 | no | yes |
message_reads_inferred | integer | Inferred reads | 0 | no | yes |
message_reads_unique | integer | Unique reads | 0 | no | yes |
message_link_clicks | integer | Link clicks | 0 | no | yes |
message_link_clicks_unique | integer | Unique link clicks | 0 | no | yes |
Responses
Type | Description |
---|---|
integer | The ID of the created contact. |
Code Samples
$json = ' { "name":"My first name", "lastname":"My lastname", "email":"[email protected]", "gender":"male", "date_of_birth":"371430000000", "mobile":"123456789", "on_duplicate":"update", "list_id":{"1234":"subscribed"}, "tags":["first tag name", "second tag name"] } '; $url = '(Your URL)/api/2.0/contacts'; $method = 'POST'; $cSession = curl_init(); $headers = array(); $auth = base64_encode($username . ':' . $apikey); $headers[] = 'Authorization: Basic ' . $auth; curl_setopt($cSession, CURLOPT_URL, $url); curl_setopt($cSession, CURLOPT_RETURNTRANSFER, true); curl_setopt($cSession, CURLOPT_HEADER, false); curl_setopt($cSession, CURLOPT_CUSTOMREQUEST, strtoupper($method)); curl_setopt($cSession, CURLOPT_POSTFIELDS, $json); $headers[] = 'Content-Type: application/json'; curl_setopt($cSession, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($cSession); curl_close($cSession);