APIs & Integrations

thecoolcoder
Member

How to use API to insert email address as empty

I’m trying to insert contact’s with no email address. The API docs say that either firstname and lastname is required when email is not in such a case. I am using Zapier to do the insert. One of the two items below are my question:

  • Do I have to not include the email property entirely in my JSON and exclude it in the call to get it to work?

  • Because submitting the email property as empty is not working.

  • Or is it something else? Does a portal have to be configured in the beginning to require or not require email addresses.

0 Upvotes
3 Replies 3
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

How to use API to insert email address as empty

Hi @thecoolcoder,

I appreciate the feedback. Could you click the ‘Submit feedback’ button on the document you’re referring to? I’d be happy to take a look at the relevant documentation.

0 Upvotes
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

How to use API to insert email address as empty

Hi @thecoolcoder,

Submitting the email field as an empty string will return an error; to create a contact without an email, just leave the email field out of the request body entirely. I was able to successfully create a contact without an email using the following endpoint:

https://api.hubapi.com/contacts/v1/contact/?hapikey=demo

with the following JSON body:

{
  "properties": [
    {
      "property": "firstname",
      "value": "Test contact"
    },
    {
      "property": "lastname",
      "value": "without email"
    }
  ]
}
0 Upvotes
thecoolcoder
Member

How to use API to insert email address as empty

Very grateful for this confirmation of my suspicion. The documentation should be clearer on the API docs since it is so pivotal.