getContactById

Returns details for a specific Contact.

getContactById

Returns details for a specific Contact.

Top ↑

Syntax

array getContactById(
    string api_key,
    int list_id,
    int contact_id,
  [ array returned_fields ] 
);

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 Contact to retrieve.

contact_id (int)

The ID of the Contact to retrieve.

returned_fields (array - optional)

An array containing the names of the Fields or system values to return. Default is all. Field names are case sensitive.

Return Value

Returns an array containing a single associative array of Contact details. See searchContacts for a description of the values returned.

Examples

The following code retrieves all data for Contact 234 in List 1234567.

$list_id = 1234567;
$contact_id = 234;

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

// result is an array with a single associative array of Contact details
print "Retrieved details for ". $contacts[0]['Email'] ."\n";
{
    "id": 1,
    "method": "getContactById",
    "params": [
        "YOURAPIKEY",
        1234567,
        234
    ]
}
{
    "id": 1,
    "result" : [
        {
            "id": 234
            "Email": "alice@example.com",
            "Mobile Phone": "",
            "creation_time": 1353892038,
            "webform_id": 0,
            "last_modified_time": 1353893054,
            "subscribed_via": "single_addition",
            "is_unsubscribed": false,
            "is_bounce_deactivated": false,
            "last_message_time": 0,
            "last_open_time": 0,
            "last_click_time": 0,
            "double_opt_in": 0,
            "double_opt_in_time": 0,
            "is_active": true
        }
    ],
    "error": null
}

Remarks

Use searchContacts to retrieve multiple Contacts at a time instead of calling getContactById in a loop.

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
304 Unable to Load Contact contact_id is not a valid Contact in the List

See Also