APIs & Integrations

mohammedyousfi
Member

Get contact vid from UI creation

SOLVE

Hello,

I am using Hubspot integration for the first time. I want to get the vid of a newly created contact in the interface and I want to get his id in my code so I can use it. Still confused how to do it. i believe it could be done using Webhooks, but still don't know how.

 

Any help ?

0 Upvotes
1 Accepted solution
Willson
Solution
HubSpot Employee
HubSpot Employee

Get contact vid from UI creation

SOLVE

Hi @mohammedyousfi 

 

Based off the fact that you want the Phone Number when the contact is created, I'd suggest working with a Webhook trigger via a Workflow. When this is done, we POST all the API data associated with this contact to your Webhook URL. 

 

From there, you can build some code to extract the Phone Number and run a validation test on it. 

 

It's important to note that the Webhooks via a Workflow are an Enterprise feature, details can be seen here: https://knowledge.hubspot.com/workflows/how-do-i-use-webhooks-with-hubspot-workflows

 

If you're not using an Enterprise level account, you'll need to use Webhooks via a Developer App as outlined here: https://developers.hubspot.com/docs/methods/webhooks/webhooks-overview

 

Using the API though will lengthen the process as you'll have to use the Contact_ID to then fetch the Contact details via the Get a contact by ID endpoint, after they're created. This is essentially creating 2 calls needed to fetch the number before you can then run validation.

 

I hope this helps!

Product Manager @ HubSpot

View solution in original post

0 Upvotes
3 Replies 3
Willson
HubSpot Employee
HubSpot Employee

Get contact vid from UI creation

SOLVE

Hi @mohammedyousfi 

 

There is a couple of ways which could be used here to fetch this value. These are listed below:

  1. Get recently created contacts 
  2. Webhooks

For the Get recently created contacts this will fetch a paginated list of contacts, with a maximum of 100 contacts per page, as specified by the count parameter. An example of this request can be seen below:

Request:
GET https://api.hubapi.com/contacts/v1/lists/all/contacts/recent?hapikey=demo&count=2

Response:
{
  "contacts": [
    {
      "addedAt": 1487883490018,
      "vid": 3867924,
      "canonical-vid": 3867924,
      "merged-vids": [
        
      ],
      "portal-id": 62515,
      "is-contact": true,
      "profile-token": "AO_T-mNNdDAmseL6-AfHmGpVNcsWoGmRq5lYxsiuGiptaAi7Y1Zd80cyKBJi-FN43wn3516wRtror7cPl03c86LRbGzWf3qwMpivZ4vTNb3u-IjkeipNh-G4L4L346pWWZF_U4gowtKU",
      "profile-url": "https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mNNdDAmseL6-AfHmGpVNcsWoGmRq5lYxsiuGiptaAi7Y1Zd80cyKBJi-FN43wn3516wRtror7cPl03c86LRbGzWf3qwMpivZ4vTNb3u-IjkeipNh-G4L4L346pWWZF_U4gowtKU/",
      "properties": {
        "lastmodifieddate": {
          "value": "1487883506690"
        }
      },
      "form-submissions": [
        
      ],
      "identity-profiles": [
        {
          "vid": 3867924,
          "saved-at-timestamp": 1487883490018,
          "deleted-changed-timestamp": 0,
          "identities": [
            {
              "type": "LEAD_GUID",
              "value": "6f8016f7-c5c9-4fa9-a50c-e45cbf83ca63",
              "timestamp": 1487883490015
            }
          ]
        }
      ],
      "merge-audits": [
        
      ]
    }

 

For Webhooks, you can use either the Workflows tool to trigger a webhook URL each time a contact is created, else, you can create an App which can then use webhooks to subscribe to specific events such as the contact creation event:

contact.creation - To get notified if any contact is created in a customer's account.

 

For using the workflows, see this article for assistance with the configuration. For the use of webhooks via an App, check out the link to the documentation here.

 

I hope this helps!

Product Manager @ HubSpot
0 Upvotes
mohammedyousfi
Member

Get contact vid from UI creation

SOLVE

Thank you very much sir. the solution you provided was helpful and I could add something to what I have done. But, I am new this integration field and what I want to do is getting the phone numeber of the customer when it is created or updated in the UI so I can make the API call to my application to verify if it is valid or not. And I still do not know how to get the information from the UI and implement it in the code I want to use.

 

Thank you anyway.

0 Upvotes
Willson
Solution
HubSpot Employee
HubSpot Employee

Get contact vid from UI creation

SOLVE

Hi @mohammedyousfi 

 

Based off the fact that you want the Phone Number when the contact is created, I'd suggest working with a Webhook trigger via a Workflow. When this is done, we POST all the API data associated with this contact to your Webhook URL. 

 

From there, you can build some code to extract the Phone Number and run a validation test on it. 

 

It's important to note that the Webhooks via a Workflow are an Enterprise feature, details can be seen here: https://knowledge.hubspot.com/workflows/how-do-i-use-webhooks-with-hubspot-workflows

 

If you're not using an Enterprise level account, you'll need to use Webhooks via a Developer App as outlined here: https://developers.hubspot.com/docs/methods/webhooks/webhooks-overview

 

Using the API though will lengthen the process as you'll have to use the Contact_ID to then fetch the Contact details via the Get a contact by ID endpoint, after they're created. This is essentially creating 2 calls needed to fetch the number before you can then run validation.

 

I hope this helps!

Product Manager @ HubSpot
0 Upvotes