Supported products
Supported products
Requires one of the following products or higher.
Scope requirements
Scope requirements
Define a custom event
To create a custom event schema (i.e. define a new custom event), make aPOST 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.
You can include the following fields in your request body:
| Parameter | Type | Description |
|---|---|---|
label Required | String | The event’s human readable label, which will display in HubSpot. The label can be up to 100 characters, but 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. The name can be up to 50 characters, must start with a letter, and can only contain lowercase letters, numbers, and underscores. If no value is provided, HubSpot will automatically generate one based on the label. Once defined, the name cannot be changed. |
description | String | Text to describe the event, displayed in the HubSpot UI. |
propertyDefinitions | Array | Include this array to define up to 50 custom event properties. For each property, include the required fields to create an event property. |
primaryObject | String | The object with which to associate event data. Event occurrences will appear on records of that object. Can be one of: "CONTACT" (default), "COMPANY", "DEAL", "TICKET", or "<CUSTOM_OBJECT_NAME>". This cannot be changed after the event definition is created. |
customMatchingId | Object | Sets a rule that automatically associates event occurrences with records of the specified object by matching the value of a property in the event data with the value of a unique property on the target object. Includes a nested primaryObjectRule object with the following required fields:
|
includeDefaultProperties | Boolean | Specifies whether the event should include the default event properties. The default value is true, so only include this field to set the value as false. When false, the default event properties are not added to the event schema, which means you can only use your defined custom properties for event occurrences. |
Set up a custom matching ID
To automatically link event occurrences to records of a specified object (e.g., automatically link event occurrences with companies), include thecustomMatchingId object in your definition request. In this object, define a primaryObjectRule object with the following fields: the unique object property that you’ve set up beforehand as the targetObjectPropertyName, and one of the properties from your event definition as the eventPropertyName.
For example, the following request body specifies a customMatchingId that matches a company property "unique_object_property" and the event property "string_property".
objectId each time you send an event occurrence, instead using the customMatchingId event property as the matching ID to identify the record. Learn more about sending custom event occurrences linked to records.
Manage properties in event definitions
Event properties are used to store information on individual custom event occurrences. These properties should be used when appropriate for sending event occurrences, but they are not required for an event occurrence to be valid. For each event definition, HubSpot provides a default set of properties, but you can also create custom properties for an event. Below, learn about HubSpot’s default event properties, how to define new properties for existing events, and how to update existing custom event properties.HubSpot’s default event properties
Expand the section below to view the default event properties. These properties are included for each event, unless you’ve set theincludeDefaultProperties field as false when defining your custom event.
The following tables show the valid option values for enumeration event properties. Use the option’s internal name when setting a value for the property via API.
Define new properties
You can create up to 50 custom properties per custom event.- To create custom properties when defining a new custom event, include the
propertyDefinitionsarray in your definition request body. - To create a new property for an existing custom event, make a
POSTrequest toevents/v3/event-definitions/{eventName}/property.
| Field | Description |
|---|---|
label Required | The property’s human-readable name. The label can be up to 50 characters, but long labels may be cut off in certain parts of the HubSpot UI. |
name | The property’s unique internal name, which you’ll use when sending event data through the API. The name can be up to 50 characters, must start with a letter, and can only contain lowercase letters, numbers, and underscores. If no value is provided, HubSpot will automatically generate one based on the label. Once defined, the name cannot be changed. |
type Required | The type of property. Learn more about supported property types and formatting requirements for each. |
description | Text to describe the property, displayed in the HubSpot UI. |
| Type | Description | Stored field type |
|---|---|---|
bool | Receives a boolean value. Values must be represented as true or false. | Radio select (radio) |
date | 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 UNIX-formatted timestamps at midnight in milliseconds. | Date picker (date) |
datetime | Receives a UNIX timestamp in milliseconds or ISO8601 strings representing a timestamp. | Date picker (date) |
enumeration | Receives values from predefined options. When creating this property type, include an options array to set the available values. You must provide at least one option. | Dropdown select (select) |
number | Receives numeric values with up to one decimal. | Number (number) |
string | Receives plain text strings. If the property name contains the words url, referrer, or link, the property value can be up to 1,024 characters. Otherwise, property values can be up to 256 characters. | Single-line text (text) |
Update existing custom properties
To update an existing property on a custom event, make aPATCH 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 a property
To delete an existing property on a custom event, make aDELETE 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 occurrences, but past occurrences will still have the property values.
Update an event’s label or description
To update an existing custom event schema, make aPATCH request to events/v3/event-definitions/{eventName}. You can only update the custom event’s values for label and description.
Delete an event definition
To delete a custom event schema, make aDELETE 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.
Get existing event definitions
To fetch a single event definition, make aGET 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 use the following query parameters to refine your search.
| Parameter | Description |
|---|---|
searchString | Searches for events that contain the specified characters in the name field. |
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. |