APIs & Integrations

scott_collen
Member

Contacts API - Merge/ Contact duplication

Hey!

We've just starting using the Contacts API and are putting a contact record into HubSpot when a new customer signs up.

Where the {New} Contact has the same email address as an existing contact record - the API doesn't appear to handle very well and we end up with two contact records - but with the identifying email address attached to the original not the {New} Contact. All contacts created by API should have an email address (as we collect in our db) but the record when pushed in doesn't display it.

My question: How can we merge these contacts via the API in a sensible way? Anyone came across or dealt with this situation before?

0 Upvotes
3 Replies 3
TWilliams2
Participant

Contacts API - Merge/ Contact duplication

@Derek_Gervais @scott_collen :  

OK I found out what was wrong and it was a big oversight on my part. I knew that HubSpot uses email addresses as unique key fields but I was so sure that I had provided an email  that I felt I did not need to check the code. Wrong! So, I updated the AWS ETL integration code making sure that the email was extracted from the csv file and then added to the python dictionry used to construct the pay oad for the HubSpot Contact API .  This problem is solved because HubSpot now sends the erorr code 409 message indicating that a duplicate record was attempting to be inserted. It now functions the same way as Postman does for these scenarios.

0 Upvotes
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Contacts API - Merge/ Contact duplication

Hi @scott_collen,

Contacts are unique by email in HubSpot; are the second duplicate contacts being created without an email? Or with a different email?

0 Upvotes
TWilliams2
Participant

Contacts API - Merge/ Contact duplication

@Derek_Gervais   I am having the same issue except I am using AWS Lambda python code to POST contact records to a client's HubSpot server using the Contact API:

  • I put the csv file containing the records with emails, into the AWS FTP location and it posts the contact successfully to HubSpot.
  • I load the same file onto the AWS FTP location and it creates a duplicate.
  • I create a raw JSON Body string in Postman of the same data from the csv file.
    • I submit the POST method for this record and I get a 409 Error Code indicating this: 
        "status""error",
          "message""Contact already exists. Existing ID: 131879551",
          "correlationId""5dd9efd8-21e2-4bb0-adc8-5b4556a3f538",
          "category""CONFLICT"
      }
       
      Q) Why doesn't hubspot send the same error response back in AWS? Here are the two duplicate contacts. The emails for both of these were: 
      Cara.Reasy@junkster.com
      Thanks

      << TOKEN RESPONSE >>

      {

          "id": "135312001",

          "properties": {

              "business_name": "Makinac Island Fudge Emporium",

              "createdate": "2021-12-21T18:01:41.245Z",

              "eog": "gas",

              "hs_all_contact_vids": "135312001",

              "hs_is_contact": "true",

              "hs_is_unworked": "true",

              "hs_marketable_until_renewal": "false",

              "hs_object_id": "135312001",

              "hs_pipeline": "contacts-lifecycle-pipeline",

              "lastmodifieddate": "2021-12-21T18:01:41.245Z",

              "proposal_date": "2021-12-09",

              "proposal_start_date": "2021-12-21",

              "smbapi": "yes",

              "srvc_address_1": "2628 Crest View Dr",

              "srvc_city_1": "Mackinac Island",

              "srvc_state_1": "MI",

              "srvc_zip_1": "49757",

              "term_1": "12",

              "term_2": "24",

              "term_3": "36",

              "udc_code_1": "AGL"

          },

          "createdAt": "2021-12-21T18:01:41.245Z",

          "updatedAt": "2021-12-21T18:01:41.245Z",

          "archived": false

      }

       

      << TOKEN RESPONSE >>

      {

          "id": "135313401",

          "properties": {

              "business_name": "Makinac Island Fudge Emporium",

              "createdate": "2021-12-21T18:01:41.245Z",

              "eog": "gas",

              "hs_all_contact_vids": "135312001",

              "hs_is_contact": "true",

              "hs_is_unworked": "true",

              "hs_marketable_until_renewal": "false",

              "hs_object_id": "135312001",

              "hs_pipeline": "contacts-lifecycle-pipeline",

              "lastmodifieddate": "2021-12-21T18:01:41.245Z",

              "proposal_date": "2021-12-09",

              "proposal_start_date": "2021-12-21",

              "smbapi": "yes",

              "srvc_address_1": "2628 Crest View Dr",

              "srvc_city_1": "Mackinac Island",

              "srvc_state_1": "MI",

              "srvc_zip_1": "49757",

              "term_1": "12",

              "term_2": "24",

              "term_3": "36",

              "udc_code_1": "AGL"

          },

          "createdAt": "2021-12-21T18:05:26.388Z",

          "updatedAt": "2021-12-21T18:05:26.388Z",

          "archived": false

      }

       


       @Derek_Gervais wrote:

      Hi @scott_collen,

      Contacts are unique by email in HubSpot; are the second duplicate contacts being created without an email? Or with a different email?


0 Upvotes