REST API V3 / Contact / Update

URL

PUT|PATCH /wp-json/gh/v3/contacts

Method

This endpoint supports PUT or PATCH

Request

To update a contact record you must pass these arguments.

PARAM TYPE REQUIRED EXAMPLE
id_or_email string|int Yes admin@example.com|1234
by_user_id bool no false
contact array Yes { args... }

id_or_email allows you to specify the contact you wish to update.

by_user_id if you are referencing the contact based on the user ID and not the contact ID.

contact the arguments you wish to update the contact with.

Contact

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 ]
meta_delete array no [ "meta_key"... ]
tags_remove 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.

You can also pass tags_remove any tags in this parameter will be removed from the contact.

Meta

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 Rd.
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.

You can optionally pass the meta_delete attribute which will delete any metadata with the given keys.

Example

Here is a full example JSON request which will update an existing contact record.

{
    "id_or_email" : "email@example.com",
    "by_user_id" : false,
    "contact" : {
        "first_name": "John",
        "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 updated 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": "John",
            "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 updated successfully."
}
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us