Learn more about creating custom events using HubSpot’s API.
POST
request to events/v3/event-definitions
. In the request body, include definitions for your event schema, including its label, name, CRM object associations, and custom properties.
The request body below provides a basic example of an event definition:
customMatchingId
in your POST
request. Within this field, define a primaryObjectRule
object with two fields: the unique object property that you’ve set up beforehand as the targetObjectPropertyName
, and one of the properties you defined in the propertyDefinitions
from your event definition.
For example, the following request body specifies a customMatchingId
that matches on a CRM object property name of "unique_object_property"
and the event property name of "string_property"
:
Parameter | Type | Description |
---|---|---|
label | String | The event’s human readable label, which will display in HubSpot (up to 100 characters). Long labels may be cut off in certain parts of HubSpot’s UI. |
name | String | The unique, internal name of the event, which you’ll use to reference the event through the API. If no value is provided, HubSpot will automatically generate one based on the label.
|
description | String | The event’s description, which will display in HubSpot. |
primaryObject | String | The type of CRM object that event data will be associated with. Event completions will appear on the CRM records of that object type. Can be one of: "CONTACT" (default), "COMPANY" , "DEAL" , "TICKET" , "<CUSTOM_OBJECT_NAME>" . This cannot be changed after the event definition is created. |
propertyDefinitions | Array | In addition to the HubSpot default event properties, you can include this array to define custom event properties (up to 50). For each property object, include the following fields:
|
customMatchingId | Object | As an alternative to including the target object’s objectId in the event completion data, this optional field defines a rule to automatically link event completions to records of the specified CRM object type. This is done by matching the value of a property in the event data with the value of a unique property on the target object. This object must include a nested primaryObjectRule object, which in turn must include two fields:
|
includeDefaultProperties | Boolean | An optional field that specifies whether the event should include the set of default event properties. If no value is provided, this field will automatically be set to true . |
bool
: a property that receives a boolean value. Values must be represented as true
or false
.date
: a property that receives a date representing a specific day, month, and year. Values must be represented in UTC time and can be formatted as ISO 8601 strings or EPOCH-timestamps in milliseconds (i.e. midnight UTC).datetime
: A property that receives epoch millisecond or ISO8601 values representing a timestamp.enumeration
: A property with predefined options. When creating this property type, include an options
array to set the available values.number
: a property that receives numeric values with up to one decimal.string
: a property that receives plain text strings. If the property name contains the words url
, referrer
, or link
, the property value can be up to 1024 characters. Otherwise, property values can be up to 256 characters.hs_asset_description
hs_asset_type
hs_browser
hs_campaign_id
hs_city
hs_country
hs_device_name
hs_device_type
hs_element_class
hs_element_id
hs_element_text
hs_language
hs_link_href
hs_operating_system
hs_operating_version
hs_page_content_type
hs_page_id
hs_page_title
hs_page_url
hs_parent_module_id
hs_referrer
hs_region
hs_screen_height
hs_screen_width
hs_touchpoint_source
hs_tracking_name
hs_user_agent
hs_utm_campaign
hs_utm_content
hs_utm_medium
hs_utm_source
hs_utm_term
POST
request to events/v3/event-definitions/{eventName}/property
. In the request body, include the definition for your property.
PATCH
request to events/v3/event-definitions/{eventName}/property
. The only fields that can be updated on a property are the label
, description
, and options
for enumeration properties.
DELETE
endpoint to delete the property and recreate it with the correct type.DELETE
request to events/v3/event-definitions/{eventName}/property/{propertyName}
.
When a property is deleted, it will no longer be available for use in future event completions. Past completions will still have the property values.
PATCH
request to events/v3/event-definitions/{eventName}
.
The only event definition fields that can be updated are label
and description
.
DELETE
request to events/v3/event-definitions/{eventName}
.
Deleting a custom event will remove it from any other HubSpot tools that are referencing it, such as workflows and reports.
eventName
’s cannot be used again, so exercise caution when deleting an event.GET
request to events/v3/event-definitions/{eventName}
.
To search event definitions by specific criteria, make a GET
request to events/v3/event-definitions
. You can supply the following query parameters to refine your search:
searchString
: searches for events that contain the specified characters in the name
field. Searching is not fuzzy, but is instead a naive contains search.after
: a hashed string provided in paged responses for viewing the next page of search results.limit
: the maximum number of results to return.includeProperties
: a boolean value that specifies whether to include event properties in the returned results.