简体   繁体   中英

How to assign an Owner using the Hubspot API?

I'm using the Hubspot API to create new contacts and would like to automatically set the owner when the contact is created. I know this is possible without using the API via Workflows, however I'd like to use the API for that.

Here's my code right now (which works, just missing the contact owner):

$data = [
    'properties' => [
                        ['property' => 'firstname', 'value' => $contact->first_name],
                        ['property' => 'lastname', 'value' => $contact->last_name],
                    ]
];

$body = json_encode($data);
$response = $client->request('POST', '/contacts/v1/contact/email/'.$user->email.'/profile',
                ['query' => ['hapikey' => $hubspot_key, 'body' => $body]);

I eventually found a way to achieve this:

  1. Go to your Hubspot instance, then Settings and Properties
  2. Search for " Contact Owner " and click on Edit
  3. In " Field type ", identify the Owner's ID value

Then in your API call, simply pass this property:

$data['properties'][] = ['property' => 'hubspot_owner_id', 'value' => 123456];

You can find out more about this hubspot_owner_id property (which is internal to Hubspot, this is not a custom property) in Hubspot's documentation .

It will automatically assign the new created (or updated) Hubspot contact to the related Owner (Hubspot User).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM