Last modified by user

I am working on an intergation with the API and need to identify who update the record (Contact and Companies) last. There does not seem to be a proprety to get access to this informaiton. How can this be achieved? Thank you!

Hey @RChair,

There is a hidden field (not surfaced in the UI) called “Updated by user ID”. It can be programmtically accessed via the API using it’s internal name “hs_updated_by_user_id”. The field is described as “the user that last updated this object. This value is automatically set by HubSpot and may not be modified.”

"name": "hs_updated_by_user_id",
"label": "Updated by user ID",
"type": "number",
"fieldType": "number",
"description": "The user that last updated this object. This value is automatically set by HubSpot and may not be modified.",
"groupName": "contactinformation",
"options": [],
"displayOrder": -1,
"calculated": false,
"externalOptions": false,
"hasUniqueValue": false,
"hidden": true,
"hubspotDefined": true

The field itself stores the user ID of the HubSpot user who last updated the record. You’d need to make an additional request to the Owners API to pull specific information like users first name, last name and email address. See below requests as an example:

1) Get the user ID of user who last updated company record

GET https://api.hubapi.com/crm/v3/objects/company/8109465573?properties=hs_updated_by_user_id
RESPONSE
{
 "id": "8109465573",
 "properties": {
 "createdate": "2023-07-20T13:25:52.999Z",
 "hs_lastmodifieddate": "2023-08-21T03:30:57.721Z",
 "hs_object_id": "8109465573",
 "hs_updated_by_user_id": "4592290"
 },
 "createdAt": "2023-07-20T13:25:52.999Z",
 "updatedAt": "2023-08-21T03:30:57.721Z",
 "archived": false
}

2) Get the details of the user using their user ID

GET https://api.hubapi.com/crm/v3/owners/4592290?idProperty=userid
RESPONSE
{
 "id": "1147024111",
 "email": "jackcoldrick-demo@gmail.com",
 "firstName": "Jack",
 "lastName": "Coldrick",
 "userId": 4592290,
 "createdAt": "2023-07-17T14:35:51.734Z",
 "updatedAt": "2023-08-24T08:03:13.263Z",
 "archived": false
}

I hope this helps! :+1:

We are using a bearer token for the integration and the hs_updated_by_user_id is not being populated by Hubspot

Ok, thank you for the additional clarity @RChair.

Based on that the only viable option you have is to send over the user data (from your system) and populate custom properties within HubSpot against Contact and Company records as from HubSpots perspective all it see’s is an API request being authenticated with a valid bearer token. It has no knowledge of the user(s) behind those requests.

Ultimately what it comes down to is that if the change is happening from the HubSpot CRM by a logged in user using “hs_updated_by_user_id” will suffice. Otherwise, if the change is happening external to the HubSpot CRM it is expected that the “hs_updated_by_user_id” property will not populate, or update and you will need to send this metadata with your request and store in custom properties.

I have tried setting a new field through the API that the API last modified the record however the hs_updated_by_user_id property does not get set to null after an update by the API. Any suggestions or workflows for this. Maybe something looking at the source of the change for the last modified date that can be seen from the UI. Thank you