APIs & Integrations

Bill_Reynolds
Member

How to locate recordId for Properties via API

SOLVE

I'm trying to PATCH (Update) a Property

 

I went here first: https://developers.hubspot.com/beta-docs/guides/api/crm/properties

 for guidance.

 

Then I pulled down a list of properties:

GET https://api.hubapi.com/crm/v3/properties/deal

 

The list is accurate, and all the data about each property is there, but not any 'id' value. In order to update (PATCH) a property I need 'recordId', but cannot find this is the parameters listed for any property.

 

THANK YOU for any pointers.

 

From docs: "crm/v3/objects/{objectType}/{recordId}"

 

"options": [
{
"label": "Label 1",
"value": "Value 1",

"description": "",
"displayOrder": 0,
"hidden": false
},
{
"label": "Label 2",
"value": "Value 2",
"description": "",
"displayOrder": 1,
"hidden": false
}
]

 

 

0 Upvotes
1 Accepted solution
zach_threadint
Solution
Guide

How to locate recordId for Properties via API

SOLVE

Hi @Bill_Reynolds 👋

 

Assuming your existing Deal property "d_tools_project" already is type "enumeration" and fieldType "select", all you'll need to supply in the update property API call are the valid value options. Here's the relevant HubSpot API documentation. For example:

 

PATCH https://api.hubapi.com/crm/v3/properties/:OBJECT_TYPE/:PROPERTY_NAME

 

e.g. PATCH 

https://api.hubapi.com/crm/v3/properties/deal/d_tools_project 

 

Example Request JSON body

 

{
    "options": [
        {
            "label": "Option A",
            "value": "A",
            "hidden": false, // optional
            "description": "Choice number one", // optional
            "displayOrder": 1 // optional
        },
        {
            "label": "Option B",
            "value": "B",
            "hidden": false, // optional
            "description": "Choice number two", // optional
            "displayOrder": 2 // optional
        }
    ]
}

 

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

All the best,

Zach

--

Zach Klein
HubSpot Integrations & App Developer
Meanjin / Brisbane, Australia



Say g'day


If my post helped answer your query, please consider marking it as a solution.


View solution in original post

0 Upvotes
7 Replies 7
Bill_Reynolds
Member

How to locate recordId for Properties via API

SOLVE

Thank you @zach_threadint @SteveHTM and @Jaycee_Lewis for all your contributions - as a newbie to HubSpot I very much appreciate the hand-holding and benefit of all your knowledge. Best regards to everyone!

SteveHTM
Guide | Partner
Guide | Partner

How to locate recordId for Properties via API

SOLVE

@Bill_Reynolds - I think I am seeing a misunderstanding behind the details here. An record - like a Contact or Deal - does have a record id value (the internal name of this property on a Deal is actually 'hs_object_id'

 

The property itself is uniquely referenced by a combination of this record id value and the internal name of the property itself. There is no ID value for the property.

 

So, by a quick scan of the API JSON you provided in the initial query, you are trying to patch a property with the internal name of 'd_tools_project' The parameters provided look consistent to me.

 

If you want to update the definition of a property on this object (the available dropdown choices for example) then you have all you need to construct a property update using the object type:

https://api.hubapi.com/crm/v3/properties/{objectType}

But bear in mind the update will need to contain the old values AND the new ones - you can't just add to the list in a single API operation.

 

If you are looking to set a value on an existing deal record for example, then the patch operation will need  the deal ID.

https://api.hubapi.com/crm/v3/objects/deals/{dealId}

 

Hope this helps!

 

Steve

Steve Christian

HTM Solutions

https://info.htmsolutions.biz/meetings/stevec2

mobilePhone
+1 6195183009
emailAddress
stevec@htmsolutions.biz
website
www.htmsolutions.biz
address
San Diego, CA
Create Your Own Free Signature
Bill_Reynolds
Member

How to locate recordId for Properties via API

SOLVE

Hi Steve, thanks for the response!

I'm still stuck, and hoping these snippets help me get better clarity...

 

I tried using a POST to https://api.hubapi.com/crm/v3/properties/deal with a body of, in an attempt to create a property list, as a test, using the existing name of the property I'm hoping to update.

 

Here was the body of the request sent:

{
  "groupName": "dealinformation",
  "name": "d_tools_project",
  "label": "D-Tools Project",
  "type": "enumeration",
  "fieldType": "select"
}

...and here is the response...

{
    "status": "error",
    "message": "A property named 'd_tools_project' already exists.",
    "correlationId": "134cb914-748f-426a-b130-4c3612cd53fd",
    "context": {
        "name": [
            "d_tools_project"
        ]
    },
    "category": "OBJECT_ALREADY_EXISTS",
    "subCategory": "Properties.PROPERTY_WITH_NAME_EXISTS"
}

...which tells me I'm in the ballpark, and the error is correct - the property does already exist.

What I'm lacking now is the syntax for updating/patching this propery. 

 

Can you offer me more advice on how to update or replace this property?

0 Upvotes
zach_threadint
Solution
Guide

How to locate recordId for Properties via API

SOLVE

Hi @Bill_Reynolds 👋

 

Assuming your existing Deal property "d_tools_project" already is type "enumeration" and fieldType "select", all you'll need to supply in the update property API call are the valid value options. Here's the relevant HubSpot API documentation. For example:

 

PATCH https://api.hubapi.com/crm/v3/properties/:OBJECT_TYPE/:PROPERTY_NAME

 

e.g. PATCH 

https://api.hubapi.com/crm/v3/properties/deal/d_tools_project 

 

Example Request JSON body

 

{
    "options": [
        {
            "label": "Option A",
            "value": "A",
            "hidden": false, // optional
            "description": "Choice number one", // optional
            "displayOrder": 1 // optional
        },
        {
            "label": "Option B",
            "value": "B",
            "hidden": false, // optional
            "description": "Choice number two", // optional
            "displayOrder": 2 // optional
        }
    ]
}

 

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

All the best,

Zach

--

Zach Klein
HubSpot Integrations & App Developer
Meanjin / Brisbane, Australia



Say g'day


If my post helped answer your query, please consider marking it as a solution.


0 Upvotes
SteveHTM
Guide | Partner
Guide | Partner

How to locate recordId for Properties via API

SOLVE

@Bill_Reynolds - seems like you are close. If you use the property update API (PATCH) the property name goes into the API URL:

https://api.hubapi.com/crm/v3/properties/{objectType}/{propertyName}

 

The parameters are likely to be something like:

{
  "groupName": "dealinformation",
  "options": [
    {
      "label": "Option A",
      "value": "A",
      "hidden": false,
      "description": "Choice number one",
      "displayOrder": 1
    },
    {
      "label": "Option B",
      "value": "B",
      "hidden": false,
      "description": "Choice number two",
      "displayOrder": 2
    }
  ],
  "label": "D-Tools Project",
  "type": "enumeration",
  "fieldType": "select"
}

 

Happy hunting!

 

Steve

Steve Christian

HTM Solutions

https://info.htmsolutions.biz/meetings/stevec2

mobilePhone
+1 6195183009
emailAddress
stevec@htmsolutions.biz
website
www.htmsolutions.biz
address
San Diego, CA
Create Your Own Free Signature
0 Upvotes
Bill_Reynolds
Member

How to locate recordId for Properties via API

SOLVE

Hi Jaycee, thanks for the info! What I'm really trying to do is access a 'Property' which is a "fieldType": "select", to populate a listbox from an outside system. The property is defined as a 'Deal Property', and I can see it via the API, I just can't find a 'recordId' to update it. 

 

When I query it, "https://api.hubapi.com/crm/v3/properties/deal/my_property_name"

I get back the property object, but it doesn't have a 'recordId' to update it via. Which makes me think I'm going about this all wrong...???

 

BTW Here is the object returned from the query, if it sheds more light on things. This is the list I want to update programmatically via the API 🙂

 

 

{
    "updatedAt": "2024-10-31T18:11:58.521Z",
    "createdAt": "2024-10-29T23:43:29.774Z",
    "name": "d_tools_project",
    "label": "D-Tools Project",
    "type": "enumeration",
    "fieldType": "select",
    "description": "Bill R. is working on this.",
    "groupName": "dealinformation",
    "options": [
        {
            "label": "This is where the thing will go",
            "value": "This is where the thing will go",
            "description": "",
            "displayOrder": 0,
            "hidden": false
        },
        {
            "label": "Label 2",
            "value": "Label 2",
            "description": "",
            "displayOrder": 1,
            "hidden": false
        }
    ],
    "createdUserId": "10857906",
    "updatedUserId": "70179506",
    "displayOrder": -1,
    "calculated": false,
    "externalOptions": false,
    "archived": false,
    "hasUniqueValue": false,
    "hidden": false,
    "modificationMetadata": {
        "archivable": true,
        "readOnlyDefinition": false,
        "readOnlyValue": false
    },
    "formField": true,
    "dataSensitivity": "non_sensitive"
}

 

 

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

How to locate recordId for Properties via API

SOLVE

Hey, @Bill_Reynolds 👋 Here are two ways you can get your Deal IDs so you can update records:

  • Make a request to the Deals endpoint to get back all records for the deals object
    GET https://api.hubapi.com/crm/v3/objects/deals
  • If you need a more targeted approach, I'd recommend the Search API. You can filter your results as well as specify what properties you want retuned in the response — Filters and Properties

Have fun testing! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes