contact owner options are empty in API response

Hello,

I want to fetch available contact owner options for creating new contact using API.

I have tried this code

const res = await hubspotClient.crm.properties.coreApi.getByName('contacts','hubspot_owner_id')

And receiving empty options field.

Property {
 updatedAt: 2023-01-10T23:43:41.247Z,
 createdAt: 2020-06-30T15:57:36.383Z,
 name: 'hubspot_owner_id',
 label: 'Contact owner',
 type: 'enumeration',
 fieldType: 'select',
 description: 'The owner of a contact. This can be any HubSpot user or Salesforce integration user, and can be set manually or via Workflows.',
 groupName: 'sales_properties',
 options: [],
 referencedObjectType: 'OWNER',
 displayOrder: 6,
 calculated: false,
 externalOptions: true,
 hasUniqueValue: false,
 hidden: false,
 hubspotDefined: true,
 modificationMetadata: PropertyModificationMetadata {
 archivable: true,
 readOnlyDefinition: true,
 readOnlyValue: false
 },
 formField: false
}

Is there any way to fetch available user list for assigning Contact Owner?

Hi @kishanprmr :waving_hand:

You’ll need to make a call to HubSpot’s CRM Owners API. For example:

GET https://api.hubapi.com/crm/v3/owners

Example response:

{
 "results": [
 {
 "id": "12345",
 "email": "example@test.com.au",
 "firstName": "Example",
 "lastName": "Test",
 "userId": 54321,
 "createdAt": "2023-11-23T08:37:43.738Z",
 "updatedAt": "2023-11-23T08:37:43.738Z",
 "archived": false
 },
 {
 "id": "67890",
 "email": "test@example.com.au",
 "firstName": "Test",
 "lastName": "Example",
 "userId": 09876,
 "createdAt": "2023-11-23T08:40:18.760Z",
 "updatedAt": "2023-11-23T08:40:18.760Z",
 "archived": false
 }
 ]
}

This endpoint responds with a list of HubSpot “Owners” (effectively “Users” of the relevant HubSpot Portal). Use the relevant “id” to set ownership of HubSpot records (e.g. Contact Owner, Deal Owner etc.).

I hope this proves useful. Please let me know if you have any follow-up questions.