What is it?
You can now create property validation rules via public API.
Why does it matter?
This update makes it easier for admins and developers to ensure that data flowing into HubSpot is consistent and accurate.
How does it work?
To create or update a specific validation rule for a property:
- Make a PUT request to crm/v3/property-validations/{objectTypeId}/{propertyName}/rule-type/{ruleType} with the rule configuration in the request body.
- This will replace any existing rule of the same type or add a new rule if one doesn't exist. The request body should include ruleArguments (an array of strings) and optionally shouldApplyNormalization (a boolean indicating whether to normalize input before validation).
- Example: To set an ALPHANUMERIC rule that allows only numeric characters for an Order ID deal property:
- Make a PUT request to crm/v3/property-validations/0-3/order_id/rule-type/ALPHANUMERIC with the following request body:
{
"ruleArguments": [
"NUMERIC_ONLY"
],
"shouldApplyNormalization": false
}
This will create or update the ALPHANUMERIC rule for the order_id property while preserving any other existing validation rules.
To view a specific validation rule for a property:
- Make a GET request to crm/v3/property-validations/{objectTypeId}/{propertyName}/rule-type/{ruleType}.
- This returns the configuration for a single rule type if it exists for the property. The response includes the ruleType, ruleArguments, and an optional shouldApplyNormalization field that indicates whether input values should be normalized before validation.
- Example: To view the MIN_LENGTH rule for an Order ID deal property:
- Make a GET request to crm/v3/property-validations/0-3/order_id/rule-type/MIN_LENGTH.
- In the response, the rule requires the property to have at least one character.
{
"ruleType": "MIN_LENGTH",
"ruleArguments": [
"1"
],
"shouldApplyNormalization": false
}
Who gets it?
All hubs and tiers