APIs & Integrations

PTSergio
Member

How do you set secondary email addresses on Contacts?

Morning

 

I am working on an integration, and part of the flow is that users on our system can change their email address. When this happens I need to be able to locate the Contact record on HubSpot, update their email address and move their old email into the hs_additional_emails field.

 

The docs say you can simply update this property (a comma separated list) and you are good to go.

 

But when I try this the API tells me this is a computed property and is READONLY. So - what do I do?

 

I have seen reference to beta and legacy endpoints for working with secondary email addresses but can't actually find a concrete answer. Also using a totally separate endpoint makes my code more complex. Why not gives devs both options?

 

Thanks,

Sergio

 

0 Upvotes
2 Replies 2
Jaycee_Lewis
Community Manager
Community Manager

How do you set secondary email addresses on Contacts?

Hey, @PTSergio 👋 I'm working with my resources on this. Here's the update (so far):

  • the documentation around the v3 endpoint is incorrect and will be updated
  • you'll need to use the v1 endpoint listed here. Because it is a legacy endpoint, it has limitations that our v3 endpoints don't. Namely, that you'll need to send multiple requests if you have to add more than one secondary email address. And you cannot create a Contact and set the secondary email address in a single call. You'll have to make separate requests to accomplish this — one to create the contact + add values to your specified properties and a second request to the secondary email endpoint

I filed the doc update request just now. I'm out for vacation starting tomorrow but will update this post if I get any additional updates from my internal resources. 

 

Thank you very much for taking the time to make this post and flag this issue. It's likely caused others a few unnecessary headaches. 

 

Talk soon(ish) 😊 — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

How do you set secondary email addresses on Contacts?

Hey, @PTSergio  👋 I am going to flag this to my internal resources and try to get us confirmation. Here's my example, which returns a `400` response. I agree with you, this conflicts with what the documentation states. 

POST https://api.hubapi.com/crm/v3/objects/contacts
{
    "properties": {
        "company": "Wagstaff School",
        "email": "misslabonz@bobsburgers.com",
        "firstname": "Miss LaBonz",
        "hs_additional_emails": "labonz@bobsburgers.com"
        
    }
}

Response

{
    "status": "error",
    "message": "Property values were not valid: [{\"isValid\":false,\"message\":\"\\\"hs_additional_emails\\\" is a calculated property; its value cannot be set.\",\"error\":\"READ_ONLY_VALUE\",\"name\":\"hs_additional_emails\",\"localizedErrorMessage\":\"\\\"hs_additional_emails\\\" is a calculated property; its value cannot be set.\",\"propertyValue\":\"labonz@bobsburgers.com\",\"portalId\":22245342}]",
    "correlationId": "2f951629-106e-43ee-980e-7a15681c4033",
    "category": "VALIDATION_ERROR"
}

Thanks! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot