v14

latestOpenAPI 3.0.0raw.githubusercontent.com2026-05-279719892.3 MB
Advanced

Create an attention span event

Create an event containing the viewers attention span details for the media.

post/media-bridge/2026-03/events/attention-span

Request body

_hsencstring
contactIdinteger
contactUtkstring
externalIdstring
externalPlayContext'EMAIL' | 'EXTERNAL_PAGE'
mediaBridgeIdinteger
mediaNamestring
mediaType'AUDIO' | 'DOCUMENT' | 'IMAGE' | 'OTHER' | 'VIDEO' required
mediaUrlstring
occurredTimestampinteger required
pageIdinteger
pageNamestring
pageUrlstring
rawDataMapobject required
rawDataStringstring
sessionIdstring required

Response

successful operation

contactIdinteger required

The ID of the contact in HubSpot’s system that consumed the media. This can be fetched using HubSpot's Get contact by usertoken (utk) API. The API also supports supplying a usertoken, and will handle converting this into a contact ID automatically.

externalPlayContext'EMAIL' | 'EXTERNAL_PAGE'
mediaBridgeIdinteger required
mediaBridgeObjectCoordinatesstring required
mediaBridgeObjectTypeIdstring required
mediaNamestring required
mediaType'AUDIO' | 'DOCUMENT' | 'IMAGE' | 'OTHER' | 'VIDEO' required
mediaUrlstring
occurredTimestampinteger required

The timestamp at which this event occurred, in milliseconds since the epoch.

pageIdinteger

The ID of the page, if hosted on HubSpot. Required for HubSpot pages.

pageNamestring

The name of the page. Required if the page is not hosted on HubSpot.

pageObjectCoordinatesstring
pageUrlstring

The URL of the page that an event happened on. Required if the page is not hosted on HubSpot.

percentRangestring required
portalIdinteger required

The ID of the HubSpot account.

providerIdinteger required
rawDatastring

This is the raw data which provides the most granular data about spans of the media, and how many times each span was consumed by the user. For example, for a 10 second video where each second is a span, if a visitor watches the first 5 seconds of the video, then restarts the video and watches the first 2 seconds again, the resulting rawDataString would be “0=2;1=2;2=1;3=1;4=1;5=0;6=0;7=0;8=0;9=0;”.

sessionIdstring required
totalPercentPlayednumber required

The percent of the media that the user consumed. Providers may calculate this differently depending on how they consider repeated views of the same portion of media. For this reason, the API will not attempt to validate totalPercentWatched against the attention span information for the event. If it is missing, HubSpot will calculate this from the attention span map as follows: (number of spans with a value of 1 or more)/(Total number of spans).

totalSecondsPlayedinteger

The seconds that a user spent consuming the media. The media bridge calculates this as totalPercentPlayed*mediaDuration. If a provider would like this to be calculated differently, they can provide the pre-calculated value when they create the event.