Skip to main content

Enriched Sessions API

Overview​

Returns a page of sessions, streams or downloads, each with who the viewer is and what authorized them:

  • user_ident -- the viewer's ID with your identity provider: the sub of the JWT they logged in with. Omitted if the viewer never logged in through your identity provider, for example one signed in with an Eluvio account.
  • authorized_by -- the NFTs the viewer held when the session started (view_start) that the content's access rules admit, however the viewer got them: bought, rented, subscribed, transferred or gifted. An NFT held then counts even if it was revoked or transferred later. An empty list means the viewer played without one, for example as a tenant admin, unless authorized_by_error is set: then the session could not be checked.
  • For each NFT: when and how this viewer got it, its marketplace sku, the customer_id of the purchase that issued it, and, if the tenant has a title catalog listing the content played, billing -- the title catalog offer it was sold under, with its affiliate_id. The title catalog must be configured for your tenant.

A subscription covers many titles, and each title has its own offer, so it has no single billing ID. Each session gets the billing_id of the title watched.


Endpoints​

OperationEndpoint
StreamingPOST /:tid/sessions_enriched
DownloadsPOST /:tid/download_sessions_enriched

Authentication: tenant admin bearer token.


Request​

The same query parameters and request body as Sessions, with these differences and notes:

ParameterDescription
limitDefault and maximum 200
offsetMust not be negative
search_indexiq__ ID of a title catalog search index to use instead of the tenant's configured one
srtStreams only: true for SRT (live) sessions

JSON only; no CSV.


Paging Through History​

  • Request one time window at a time with start_ts/end_ts (for example, a day), and use offset only within a window. Large offsets get slower.
  • Send one request at a time per tenant. A request made while another is running gets HTTP 429 with a Retry-After header: wait that many seconds and retry. Sessions and download sessions are limited separately.
  • Which NFTs a viewer held when a session started never changes, but billing, title_iq and the access rules come from the title catalog and the content as they are now. A session's result can change when either is updated, for example once a title is added to the catalog, so fetch a range again after such a change.

Response​

Success (HTTP 200)​

Each record has the session fields, or for downloads the download session fields, plus:

FieldDescription
event_typestream, or download for download sessions
user_identThe viewer's ID with your identity provider (the login JWT's sub), if any
authorized_byThe NFTs that authorized the session; see below. Empty if none
title_iqTitle catalog title of the content played, if the catalog lists it
authorized_by_errorSet if this session could not be checked (for example, an invalid object_id)

The response also has paging and, if a title catalog was used, its search_index.

authorized_by entries​

FieldDescription
contract_addrNFT contract address
token_idToken ID
acquired_atWhen this viewer got it, unix seconds
acquired_bymint (issued to this viewer) or transfer (received from someone else)
skuMarketplace item that mints it, when one can be identified
billingTitle catalog offers it was sold under, for the content played; see below. Omitted if none
customer_idcustomer_id of the purchase that issued it, if it has one; see below

billing entries​

FieldDescription
billing_idThe offer's billing ID
offer_typeEST, TVOD or SVOD
access_tierSubscription tier, for SVOD
affiliate_idThe offer's affiliate, for example META
regionOffer region, for example US
variantOffer variant, for example hd-3d-sdr

The offer is the one for the variant played whose licensing window covers the date the NFT was first issued (for SVOD, the session start). Where no offer matches a condition, that condition is dropped.

customer_id is the one sent with the purchase, for example in Create Entitlement. It belongs to the purchase, so an NFT the viewer received by transfer or as a gift shows the original buyer's customer_id; acquired_by tells the two apart.

Example Response​

{
"sessions": [
{
"event_type": "stream",
"uuid": "<session-id>",
"auth_addr": "0xabc123...",
"object_id": "iq__...",
"title": "Example Title",
"view_start": 1796102181,
"watched_secs": 1320,
"user_ident": "<idp-user-id>",
"title_iq": "iq__...",
"authorized_by": [
{
"contract_addr": "0xdef456...",
"token_id": "3957",
"acquired_at": 1796102163,
"acquired_by": "mint",
"sku": "<svod-sku>",
"customer_id": "<customer-id>",
"billing": [
{
"billing_id": "<billing-id>",
"offer_type": "SVOD",
"access_tier": "premium",
"affiliate_id": "META",
"region": "US",
"variant": "hd-3d-sdr"
}
]
}
]
}
],
"paging": { "offset": 0, "limit": 200, "total": 1, "start_ts": 1796000000, "end_ts": 1796103000 },
"search_index": "iq__..."
}

Errors​

StatusMeaning
400Invalid parameter or body, for example a negative offset
401Missing or invalid token, or the user is not a tenant admin
403The user is a content admin, not a tenant admin
429Another request of this kind for this tenant is running; wait Retry-After seconds
502The authorization lookup failed; retry later

If You Use the Entitlements API​

If you create entitlements with the Entitlements API, each authorized_by entry's contract_addr and token_id match an entitlement's minted[] in List Entitlements, listed by the session's auth_addr. That gives each session the rest of the entitlement's metadata: any fields you set on Create Entitlement.


Curl Example​

curl -X POST "https://appsvc.svc.eluv.io/casa/main/<tenantId>/sessions_enriched?start_ts=1796000000&end_ts=1796086400&limit=200" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{}'

For download sessions, use download_sessions_enriched in the same way.