Is possible to retrive the additional_phone configured for an owner? Or add a custom field like “extension”.
Need to make a search for a phone number/contact and with the associated owner get the additional_phone or extension
I’m using Get at :
Is possible to retrive the additional_phone configured for an owner? Or add a custom field like “extension”.
Need to make a search for a phone number/contact and with the associated owner get the additional_phone or extension
I’m using Get at :
Hey @AVidal53 ! How’re you?
Here’s developer’s answer that I find:
Retrieving Additional Phone Information for an Owner
1. Retrieve Owners Data:
Use the endpoint `GET /owners/v2/owners` to get details about owners, including any additional phone information that may be configured.
Endpoint: `GET https://api.hubspot.com/owners/v2/owners\`
Example code snippet:
```python
import requests
# Define the API endpoint and your API key
url = “https://api.hubspot.com/owners/v2/owners”
api_key = “YOUR_API_KEY_HERE”
# Define headers with API key
headers = {
“Authorization”: f"Bearer {api_key}",
“Accept”: “application/json”
}
# Make the request to retrieve owners data
response = requests.get(url, headers=headers)
# Check if the request was successful
if response.status_code == 200:
owners_data = response.json().get(“owners”)
for owner in owners_data:
owner_id = owner.get(“ownerId”)
owner_email = owner.get(“email”)
additional_phone = owner.get(“phone”) # Assuming additional phone is stored in “phone” field
extension = owner.get(“extension”) # Example if you add a custom extension field
print(f"Owner ID: {owner_id}, Email: {owner_email}, Additional Phone: {additional_phone}, Extension: {extension}")
else:
# Request failed, print error message
print(“Error:”, response.status_code, response.text)
```
In this updated example:
- Replace `“YOUR_API_KEY_HERE”` with your actual HubSpot API key.
- The code retrieves owner data using the correct endpoint and accesses fields like `phone` for additional phone information.
- You can also add a custom field like `extension` and retrieve its value if it’s defined for owners in your HubSpot account.
Adding a Custom Field (e.g., Extension) for Owners
To add a custom field like “extension” for owners in HubSpot, you typically need to:
1. Create a Custom Property - details here
- Go to your HubSpot account and navigate to Settings > Properties > Owners.
- Create a new custom property of type “Single Line Text” or any other suitable type for your extension field.
2. Update Owner Data:
- You can update owner details via the HubSpot API using the endpoint `PUT /owners/v2/owners/{ownerId}`.
- Include the new custom property (e.g., `extension`) in the JSON payload to update or add it to an owner’s profile.
Example update code (assuming `owner_id` and `extension_value` are defined):
```python
# Define the API endpoint for updating an owner
update_url = f"https://api.hubspot.com/owners/v2/owners/{owner_id}"
# Define the payload with the custom property
update_payload = {
“properties”: {
“extension”: extension_value
}
}
# Make the request to update the owner
update_response = requests.put(update_url, headers=headers, json=update_payload)
# Check if the update request was successful
if update_response.status_code == 200:
print(“Owner updated successfully.”)
else:
print(“Error updating owner:”, update_response.status_code, update_response.text)
```
- Replace `owner_id` with the actual owner ID you want to update.
- Replace `extension_value` with the value you want to set for the extension field.
By following these updated steps based on the HubSpot Beta API documentation, you can effectively retrieve additional phone information for owners and add custom fields like “extension” using the HubSpot API. Adjust the code according to your specific requirements and your HubSpot account setup.
HubSpot developers guide here.
Can you tell me if it works?
cheers
tried with the new api version
https://api.hubapi.com/crm/v3/owners
get all the owners , but fields from User> Preferences like Job Title Main Phone or Additional Phone are not retrived
Had more succes with. https://api.hubapi.com/crm/v3/objects/users?properties=hs_job_title,hs_additional_phone
Adding a custom field to Users seems unavaliable the Ownner Object can’t get new properties (don’t appear on menu)
Can you tell me if it works?
import requests
# Define the API endpoint and your API key
url = “https://api.hubapi.com/crm/v3/objects/users”
api_key = “YOUR_API_KEY_HERE”
# Define the properties you want to retrieve
properties = “hs_job_title,hs_main_phone,hs_additional_phone”
# Define headers with API key
headers = {
“Authorization”: f"Bearer {api_key}",
“Accept”: “application/json”
}
# Define the query parameters
params = {
“properties”: properties
}
# Make the request to retrieve users data with specified properties
response = requests.get(url, headers=headers, params=params)
# Check if the request was successful
if response.status_code == 200:
users_data = response.json().get(“results”)
for user in users_data:
user_id = user.get(“id”)
job_title = user.get(“properties”, {}).get(“hs_job_title”, {}).get(“value”)
main_phone = user.get(“properties”, {}).get(“hs_main_phone”, {}).get(“value”)
additional_phone = user.get(“properties”, {}).get(“hs_additional_phone”, {}).get(“value”)
print(f"User ID: {user_id}, Job Title: {job_title}, Main Phone: {main_phone}, Additional Phone: {additional_phone}")
else:
# Request failed, print error message
print(“Error:”, response.status_code, response.text)
========================
Also, I think @danmoyle can help us as well.
@AVidal53 wrote:
Is possible to retrive the additional_phone configured for an owner? Or add a custom field like “extension”.
Need to make a search for a phone number/contact and with the associated owner get the additional_phone or extension
I’m using Get at :
https://api.hubapi.com/crm/v3/owners
Is not avaliable for me.
I can make a get at
https://api.hubapi.com/crm/v3/objects/users and get all the users, but would be better to make a search
but using https://api.hubapi.com/settings/v3/users/$email?idProperty=EMAIL
the response can’t get the addicionals properties