editContacts

Edits one or more Contacts in a List.

editContacts

Edits one or more Contacts in a List.

Top ↑

Syntax

array editContacts(
    string api_key,
    int list_id,
    array contacts,
  [ bool trigger_update_profile ] 
);

Parameters

api_key (string)

The key required to access the API. See Getting Started for more information.

list_id (int)

The ID of the List containing the Contacts to update.

contacts (array)

An array containing one or more associative arrays of new Contact details. The Contact details are indexed using each of the Field names in the List and must contain an id index with the Contact's ID. See the examples below.

trigger_update_profile (bool - optional)

Set to true to trigger any Update Profile Campaign Events or Autoresponders.

Return Value

Returns an associative array of boolean values indexed by Contact ID, indicating the Contacts that were successfully updated.

Examples

In List 1234567, editContacts() changes the state Field to Queensland in Contact 123 and changes the email Field to joe@example.com in Contact 456.

$list_id = 1234567;     // can be obtained using searchLists()

$contacts = array();    // array of contacts to update
$contacts[] = array(
    'id'    => 123,     // required
    'State' => 'Queensland'
);
$contacts[] = array(
    'id'    => 456,     // required
    'Email' => 'joe@example.com'
);

$api = new Api($url, 'YOURAPIKEY');
$edited_contacts = $api->invokeMethod('editContacts', $list_id, $contacts);

// loop over result
foreach ($edited_contacts as $contact_id => $success) {
    if ($success) {
        print "Contact ". $contact_id ." updated successfully\n";
    }
}
{
    "id": 1,
    "method": "editContacts",
    "params": [
        "YOURAPIKEY",
        1234567,
        [
            {
                "id": 123,
                "State": "Queensland"
            },
            {
                "id": 456,
                "Email": "joe@example.com"
            }
        ]
    ]
}
{
    "id": 1,
    "result": {
        "123": true,
        "456": true
    },
    "error": null
}

Remarks

The API does not check the mandatory value of List Fields when adding or editing Contacts.

Error Codes

This method may return the following error codes in addition to the standard error codes:

Code Error Description
303 Unable to Load List list_id is not a valid List
380 Invalid contact array specified contacts must be an array containing one or more associative arrays of contact details
370 No real contacts found when editing a contact Each array in contacts must have an id value specifying the Id for the Contact
320 Failed to Update any Contacts Typically returned if the Contact id is not valid or the email address and mobile number are not valid

See Also