Issue checking if email already exists

JoscelynW
Campaign Contributor
0 Votes

I'm integrating the Constant Contact API V3 and I'm able to add new contacts and update existing ones. I need to however, determine if they already exist so I can either add new or update the existing contact. At first I thought I could use the /contacts/sign_up_form endpoint, but the syntax is slightly different between the /contacts and /contacts/sign_up_form. Hence why I need to determine beforehand to either update, or add new so I can use a different set of JSON data.

 

When I execute the following, all I get returned is a 1 no matter if they exist or not.

    // check if email already exists
    $encodedEmail = urlencode($ccEmail);
    $url = 'https://api.cc.email/v3/contacts?status=all&email='.$encodedEmail.'&include_count=false';
    $ch = curl_init();
    $header = array();
    $header[] = 'Accept: application/json';
    $header[] = 'Authorization: Bearer '.$accessToken;
    $header[] = 'Content-Type: application/json';
    $header[] = 'Cache-Control: no-cache';
    $header[] = 'Postman-Token: '.$APIkey;
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    $response = curl_exec($ch);
    curl_close($ch);

According to the documentation, I should get either an empty array if they do NOT exist and an object with user data if they DO exist. See: https://v3.developer.constantcontact.com/api_guide/contacts_create.html

 

Not sure what I'm missing here. I'm refreshing the access token on every call, so I know it's not that, otherwise I would probably get an unauthorized error.

 

Can anybody shed light on this?

1 REPLY 1
Courtney_E
Employee
0 Votes

Thank you for reaching out to Constant Contact API Developer Support. My team is here to assist outside software developers with questions about building into Constant Contact's API.

 

The POST /contacts/sign_up_form endpoint is the one you would want to use to add a new contact to an account or update an existing contact based on their email address. 

 

If the email address you provide already belongs to an existing contact, POST /contacts/sign_up_form updates that contact instead of returning a 409 Conflict error. This allows you to add contacts to an account without having to make a separate API call to check if the email address already exists for a contact in the user account.

https://v3.developer.constantcontact.com/api_guide/contacts_create_or_update.html


Regards,

Courtney E.
Tier II API Support Engineer

Did I answer your question?
If so, please mark my post as an "Accepted Solution" by clicking the Accept as Solution button in the bottom right hand corner of this post.
Resources
Developer Portal

View API documentation, code samples, get your API key.

Visit Page

Announcements

API Updates

Join our list to be notified of new features and updates to our V3 API.

Sign Up