REST API V3 / Contact / Create
URI
POST /wp-json/gh/v3/contacts
Method
This endpoint supports the POST
method
Request
You can pass any relevant contact arguments to the contacts endpoint plus additional metadata.
PARAM | TYPE | REQUIRED | EXAMPLE |
email |
string | Yes | admin@example.com |
first_name |
string | no | John |
last_name |
string | no | Doe |
user_id |
int | no | 1 |
owner_id |
int | no | 1 |
optin_status |
int | no | 1 |
meta |
array | no | { "custom" : "data" } |
tags |
array | no | [ "tag 1", "tag 2", 123, 456 ] |
Tags
You can pass the tags
parameter, any given tags will be added to the contact. You can pass the name of the tag or the ID of the tag you want to add.
Metadata
You can provide additional metadata in an array of associative keys to values with the meta parameter.
Below are some reserved meta keys which you can use to map data to fields in the contact record.
PARAM | TYPE | REQUIRED | EXAMPLE |
primary_phone |
string | no | 555-555-5555 |
primary_phone_extension |
string | no | 1234 |
street_address_1 |
string | no | 1222 Mariners |
street_address_2 |
string | no | Unit D |
city |
string | no | Blenheim |
postal_zip |
string | no | N0P 1A0 |
country |
string | no | CA |
Adding any non-reserved key-value pairs will also be added to the metadata and will appear in the custom meta section of the contact record.
Example
Here is a full example JSON request which will create a new contact record.
{ "email": "email@example.com", "first_name": "Jhon", "last_name": "Doe", "user_id": "1", "owner_id": "1", "optin_status": "1", "meta": { "primary_phone": "1234567890", "primary_phone_extension": "5623", "street_address_1": "1222 Mariners Rd.", "street_address_2": "Unit D", "city": "Blenheim", "postal_zip": "N0P 1A0", "region": "Ontario", "country": "CA", "lead_source": "", "source_page": "", "custom_meta": "this is meta" }, "tags" : [ "tag 1", "tag 2" ] }
Response
If the contact was created you will receive a 200 OK response with the full profile of the contact record. An example response is below.
{ "contact": { "data": { "email": "email@example.com", "first_name": "Jhon", "last_name": "Doe", "user_id": "1", "owner_id": "1", "optin_status": "1", "date_created": "2020-06-17 11:59:22", "date_optin_status_changed": "2020-06-17 11:59:22", "ID": "5123", "age": false }, "meta": { "primary_phone": "1234567890", "primary_phone_extension": "5623", "street_address_1": "1222 Mariners Rd", "street_address_2": "Unit D", "city": "Blenheim", "postal_zip": "N0P 1A0", "region": "Ontario", "country": "CA", "lead_source": "", "source_page": "", "custom_meta": "this is meta", "birthday": "" }, "tags": [ 17, 16, 9, 2 ], "files": [] }, "status": "success", "message": "Contact added successfully." }