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:
Then in your API call, simply pass this property:
$data['properties'][] = ['property' => 'hubspot_owner_id', 'value' => 123456];
You can find out more about the hubspot_owner_id
property (which is internal to Hubspot, this is not a custom property) in Hubspot's documentation.
It will automatically assign the newly created (or updated) Hubspot contact to the related Owner (Hubspot User).