Zum Hauptinhalt springen
POST
/
media-bridge
/
v1
/
events
/
attention-span
Create an attention span event
curl --request POST \
  --url https://api.hubapi.com/media-bridge/v1/events/attention-span \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "mediaType": "AUDIO",
  "occurredTimestamp": 123,
  "rawDataMap": {},
  "sessionId": "<string>",
  "_hsenc": "<string>",
  "contactId": 123,
  "contactUtk": "<string>",
  "externalId": "<string>",
  "externalPlayContext": "EMAIL",
  "mediaBridgeId": 123,
  "mediaName": "<string>",
  "mediaUrl": "<string>",
  "pageId": 123,
  "pageName": "<string>",
  "pageUrl": "<string>",
  "rawDataString": "<string>"
}
'
{
  "contactId": 123,
  "mediaBridgeId": 123,
  "mediaBridgeObjectCoordinates": "<string>",
  "mediaBridgeObjectTypeId": "<string>",
  "mediaName": "<string>",
  "mediaType": "AUDIO",
  "occurredTimestamp": 123,
  "percentRange": "<string>",
  "portalId": 123,
  "providerId": 123,
  "sessionId": "<string>",
  "totalPercentPlayed": 123,
  "externalPlayContext": "EMAIL",
  "mediaUrl": "<string>",
  "pageId": 123,
  "pageName": "<string>",
  "pageObjectCoordinates": "<string>",
  "pageUrl": "<string>",
  "rawData": "<string>",
  "totalSecondsPlayed": 123
}

Supported products

Autorisierungen

Authorization
string
header
erforderlich

The access token received from the authorization server in the OAuth 2.0 flow.

Body

application/json
mediaType
enum<string>
erforderlich
Verfügbare Optionen:
AUDIO,
DOCUMENT,
IMAGE,
OTHER,
VIDEO
occurredTimestamp
integer<int64>
erforderlich
rawDataMap
object
erforderlich
sessionId
string
erforderlich
_hsenc
string
contactId
integer<int64>
contactUtk
string
derivedValues
object
externalId
string
externalPlayContext
enum<string>
Verfügbare Optionen:
EMAIL,
EXTERNAL_PAGE
mediaBridgeId
integer<int64>
mediaName
string
mediaUrl
string
pageId
integer<int64>
pageName
string
pageUrl
string
rawDataString
string

Antwort

successful operation

contactId
integer<int64>
erforderlich

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.

mediaBridgeId
integer<int64>
erforderlich
mediaBridgeObjectCoordinates
string
erforderlich
mediaBridgeObjectTypeId
string
erforderlich
mediaName
string
erforderlich
mediaType
enum<string>
erforderlich
Verfügbare Optionen:
AUDIO,
DOCUMENT,
IMAGE,
OTHER,
VIDEO
occurredTimestamp
integer<int64>
erforderlich

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

percentRange
string
erforderlich
portalId
integer<int32>
erforderlich

The ID of the HubSpot account.

providerId
integer<int32>
erforderlich
sessionId
string
erforderlich
totalPercentPlayed
number
erforderlich

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).

externalPlayContext
enum<string>
Verfügbare Optionen:
EMAIL,
EXTERNAL_PAGE
mediaUrl
string
pageId
integer<int64>

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

pageName
string

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

pageObjectCoordinates
string
pageUrl
string

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

rawData
string

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;”.

totalSecondsPlayed
integer<int32>

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.

Last modified on April 9, 2026