Can't create property with fieldType 'html' via API

I’m unable to create a property with fieldType = html in the API.

The documentation here: Accounts Dashboard | HubSpot

Says that I should be able to (and indeed, I am able to do so manually through the application).

I found this post from a couple years ago that seems to have gone unresolved?: https://community.hubspot.com/t5/APIs-Integrations/Can-not-create-properties-with-FieldType-quot-html-quot-for/m-p/694448

Can someone help?

Thanks!

Hi @jonpos,

You’re having trouble creating a property with fieldType = html through the HubSpot API.
1. Sometimes, HubSpot’s API might not support certain features or field types that are available in the manual UI. This could be due to limitations or specific use cases that the API is designed to handle.
2. The documentation may not be fully updated or might not reflect the exact capabilities of the API. It’s worth checking if there are any API version updates or changes that might have affected this functionality.
3. A common workaround in such scenarios is to create the property manually through the HubSpot UI and then use the API to manage or update it. This might not be ideal, but it can serve as a temporary solution.

4. Since you’ve already encountered a similar unresolved issue in the community forum, I recommend contacting HubSpot support directly. They can provide more detailed guidance or escalate the issue if it’s a bug or limitation that needs to be addressed.
In the meantime, please make sure you’re using the latest API version and double-check the field type and options you’re trying to set via the API. Sometimes, minor adjustments in the payload structure can make a difference.

I hope it helps, let me know if you need to talk!

Khushboo Pokhriyal

Growth & Operations

GroRapid Labs

LinkedIn | 9315044754 | Email | Website

TLDR: set type=“string” and field_type=“html”

I think have a solution here, I just tested it on my own HS. First I read a rich text (html) property to see what the values were set to, then I tried to imitate those values in the call to create the property. I believe the import part is to set type=“string” and field_type=“html” but I’m not sure whether you’re allowed to have html be form properties or other things like that. So here is the full return from my api get call in case it’s helpful.

 'results': [{'archived': False,
 'archived_at': None,
 'calculated': False,
 'calculation_formula': None,
 'created_at': datetime.datetime(2024, 4, 26, 13, 55, 25, 153000, tzinfo=tzutc()),
 'created_user_id': 'XXXXXXXXXX',
 'description': '',
 'display_order': -1,
 'external_options': False,
 'field_type': 'html',
 'form_field': False,
 'group_name': 'deal_properties',
 'has_unique_value': False,
 'hidden': False,
 'hubspot_defined': None,
 'label': 'XXXXXXXXXXX',
 'modification_metadata': {'archivable': True,
 'read_only_definition': False,
 'read_only_options': None,
 'read_only_value': False},
 'name': 'XXXXXXXXXXXXX',
 'options': [],
 'referenced_object_type': None,
 'show_currency_symbol': False,
 'type': 'string',
 'updated_at': datetime.datetime(2024, 4, 26, 13, 55, 25, 153000, tzinfo=tzutc()),
 'updated_user_id': 'XXXXXXXXXXXXX'}]

Here’s the code I used to make the property (assuming you have a HubSpot client already activated with a Hapi Key

property_create = PropertyCreate(hidden=False, display_order=2, description="Test test test", label="TestContactProperty", type="string", form_field=False, group_name="contactinformation", name="testtesttesttest", has_unique_value=False, field_type="html")
try:
 api_response = client.crm.properties.core_api.create(object_type="contact", property_create=property_create)
 pprint(api_response)
except ApiException as e:
 print("Exception when calling core_api->create: %s\n" % e)

Thanks! I think the issue might be that I’m using v2 instead of v3 of the API. I didn’t realize this until just now when debugging, the library we’re using is using v2 :(. Trying to do another test now to see if that solves it.

thanks so much for your help thus far!

That’s probably it. my original call was to a contact property and then I retested on a deal property, so they should both work. Alternatively it could be your hubspot subscription types, but either of those should probably show up in the error messages.

OK, i finally confirmed it -- this is an issue with v2 vs v3 of the API. V3, the call works fine. Unfortunately for me, I’ve built everything on v2, ha.

Thanks for your help, really appreciate it. The error message doesn’t say that its a v2 vs v3 thing, which would have been nice. Anyway, we’re all set now, so thanks for your help -- would not have figured this out without chatting with you!

Interesting -- I actually already am setting the type to ‘string’, but I wonder if i’m missing something else? What other attributes did you set with the create call? I am setting:

name

label

description

groupName

type = “string”

fieldType = “html”

and that’s it… so maybe something else you are including is satisfying the validation check, and i’m getting an erroneous message?

Also, I’m creating this on a contact vs a Deal in your example. I don’t know why that would matter…but maybe?

I just tested mine with deals and it’s working. What error message are you getting back when you make the call? One thing that happened for me when trying to switch to deal was that I had trouble getting the right group name. What are you using for groupName? I believe it has to be the internal value, and I’m not finding an easy way to check the internal value of a group name except by making an API call to an existing property with that group name). Alternatively, maybe you have to explicitly exclude it from forms or something.

Are you able to create this on a contact? I haven’t tried deal, I need this on a contact. I just tried to explicitly set

“formField” = false

per your thought and

“showCurrencySymbol” = false

because thats what it was on a manually created rich text field, but neither of those changes made it work…