Marketing Events
A marketing event is a CRM object, similar to contacts and companies, that enables you to track and associate marketing events, such as a webinar, with other HubSpot CRM objects. Below, learn more about working with the marketing event API to integrate marketing events into an app.
Scope requirements
To make an API request to one of the marketing event endpoints, the following scopes are required:
crm.objects.marketing_events.read
: grants permission to retrieve marketing event and attendance data.crm.objects.marketing_events.write
: grants permission to create, delete, or make changes to marketing event information.
When authenticating calls made by your app, you can either use a private app access token or OAuth. Learn more about authentication methods. For the full list of endpoints available, click the Endpoints tab at the top of this article.
Event attendance endpoints
The event attendance state endpoints allow you to record a subscription state between a HubSpot contact and a marketing event. For example, you can use this endpoint to record that a HubSpot contact has registered for a marketing event.
There are two endpoints you can use to update a contact's attendance status. If you were previously using the /upsert
or /email-upsert
endpoints to update an attendee's status, you can instead use the endpoints listed below to maintain the same functionality while also populating the contact's attendance duration on the contact timeline:
- If you want to use the contact IDs of existing contacts:
- Make a
POST
request to/marketing/v3/marketing-events/attendance/{externalEventId}/{subscriberState}/create
. - In the request body, provide an
inputs
object that includes the following fields:interactionDateTime
: the date and time at which the contact subscribed to the event.vid
: the contact ID of an existing contact.
- Make a
- If you want to use the email address of one of the event's attendees:
- Make a
POST
request to/marketing/v3/marketing-events/attendance/{externalEventId}/{subscriberState}/email-create
. - In the request body, provide an
inputs
object that includes the following fields:interactionDateTime
: the date and time at which the contact subscribed to the event.email
: the email address of the attendee as the value of the email field within an inputs
- If the email address you include don't match the address of an existing contact, a new contact will be created.
- Make a
For both of the endpoints above, provide the following values for the corresponding path parameters:
externalEventId
: the ID of the marketing event.-
subscriberState
: an enumeration that matches the new attendance status of the contact:REGISTERED
: indicates that the HubSpot contact has registered for the event.ATTENDED
: indicates that the HubSpot contact has attended the event. If you're updating a contact's status to ATTENDED, you can also include thejoinedAt
andleftAt
timestamps as parameters in the request body, specified in the ISO8601 Instant format.CANCELLED
: indicates that the HubSpot contact, who had previously registered for the event, has cancelled their registration.
Once your event has completed, you can mark the event as complete and calculate attendance metrics (e.g., duration of attendance for all attendees) by making a POST
request to /marketing/v3/marketing-events/events/{externalEventId}/complete
. Note this action is irreversible, so you should only invoke this endpoint once all attendance state change events have already occurred.
Please note: these APIs are idempotent so long as the ID of the contact and the interactionDateTime
value in the event has not changed. This enables you to safely set subscriber state multiple times without HubSpot creating duplicate events in the marketing events properties.
Configure settings
There's some setup required to enable Marketing Events correctly for your app.
If you send HubSpot a subscriber state change (e.g a register or cancelled event), HubSpot will first check to see if a Marketing Event exists for the specified event ID. If it doesn't, HubSpot will call the configured endpoint for your app to retrieve the details of the marketing event, then create the event in HubSpot and then publish the subscriber state change.
This is provided for convenience; however, it's still recommended that you create the Marketing Events yourself via our CRUD methods and don't rely on this functionality to create your Marketing Events in HubSpot.
Step 1: Create an API in your app
In order to support this, HubSpot requires each app that uses Marketing Events to define an API to fetch information about a specific marketing event.
Requirements:
- Accepts:
externalAccountId
(QueryParam): the accountId of the customer in the external app.appId
(QueryParam): the id of the HubSpot application that is requesting the event details. This will be the id of your app.externalEventId
(PathParam): the id of the event in the external app that we want details about.
- Returns:
- Marketing Event details
HubSpot will also send a X-HubSpot-Signature-v3
header that you can use to verify that the request came from HubSpot. Read more about request signatures for additional details on the signature and how to validate it.
Step 2: Configure the API in MarketingEventExtension
Now that you've created the API in your app that will return a MarketingEventDetails
object, you will need to configure the URL paths to this API in MarketingEventExtension
, so HubSpot knows where to make requests to get the Event Details.
NOTE: Your configured path must:
- At least contain a
%s
character sequence, which we use to substitute in the id of the event (externalEventId
) as a path parameter - Be the full path to the API resource.
For example, if you configure an eventDetailsURL
of https://my.event.app/events/%s
, and you need to make a request to fetch details of an event with id 1234-event-XYZ
, for the HubSpot app with id app-101
and account with id ABC-account-789
, HubSpot will make a GET
request to:
https://my.event.app/events/1234-event-XYZ?appId=app-101&externalAccountId=ABC-account-789
You should return a JSON response with the following fields:
Field Name | Required | Type | Field Description |
---|---|---|---|
eventName | true | string | The name of the marketing event |
eventOrganizer | true | string | The name of the organizer of the marketing event. |
eventType | false | string | Describes what type of event this is. For example: WEBINAR , CONFERENCE , WORKSHOP |
startDateTime | false | string($date-time) | The start date and time of the marketing event. |
endDateTime | false | string($date-time) | The end date and time of the marketing event. |
eventDescription | false | string | The description of the marketing event. |
eventUrl | false | string | A URL in the external event application where the marketing event. |
eventCancelled | false | bool | Indicates if the marketing event has been cancelled. Defaults to false " |
Thank you for your feedback, it means a lot to us.