Skip to main content

Subscriptions API

Overview​

Returns a tenant's subscriptions -- one record per subscriber per subscription, from any source: Eluvio-hosted (Stripe) checkout or the Entitlements API -- with each one's status, paid-through date and the NFT it holds.

Three calls:

OperationEndpoint
List subscriptionsPOST /authd/tnt/:tid/subscriptions
One subscription, with paymentsGET /authd/tnt/:tid/subscriptions/:id
Values of one field, countedPOST /authd/tnt/:tid/subscriptions/attr/:field

All take a tenant admin bearer token, under the same base URL as the other Analytics APIs: https://appsvc.svc.eluv.io/casa/main.


List Subscriptions​

POST

https://appsvc.svc.eluv.io/casa/main/authd/tnt/:tid/subscriptions

Query Parameters​

NameTypeRequiredDescription
start_tsintegerNoStart of the range of creation times, unix seconds. Default: 1 week ago
end_tsintegerNoEnd of the range, unix seconds. Default: now
limitintegerNoMax results to return (paging)
offsetintegerNoResult offset (paging)

The time range selects subscriptions by when they were created.

Request Body (optional)​

{
"filters": { "status": ["active"], "sku": ["<svod-sku>"] },
"exclude_filters": { "country": ["CA"] },
"search": { "text": "example.com", "fields": ["email"] },
"order_by": "paid_to desc"
}
FieldDescription
filtersRestrict results: OR within a field, AND across fields
exclude_filtersLeave out matching results, in the same form
searchCase-insensitive substring text, matched in any of fields
order_byA field, optionally followed by asc or desc. Default: newest created first

Fields for filters, exclude_filters and search: status, period, description, currency, email, user_addr, token_addr, token_id, sub_id, stripe_sub, stripe_cus, sku, country, discount_code, name, or attr.<key> for any other attributes key. order_by also takes created, updated, start_time, end_time, paid_to, canceled_at and last_payment.

CSV​

Send Accept: text/csv to get CSV. Without limit, CSV returns every matching row.

Response​

{
"subscriptions": [
{
"id": "<uuid>",
"sub_id": "3pp:<tenantId>:pi_sub_1234",
"user_addr": "0xabc123...",
"token_addr": "0xdef456...",
"token_id": "3957",
"description": "Example monthly subscription",
"status": "active",
"period": "month",
"email": "user@example.com",
"attributes": { "sku": ["<svod-sku>"], "country": ["US"], "customer_id": ["cus_1234"] },
"start_time": 1796102158,
"paid_to": 1798694157,
"last_payment": 1796102158,
"created": 1796102158,
"updated": 1796102164
}
],
"period": { "start_ts": 1795497358, "end_ts": 1796102358 },
"paging": { "offset": 0, "limit": 50, "total": 1 }
}
FieldDescription
idSubscription record ID, for One Subscription
sub_idSubscription ID: for the Entitlements API, the trans_id from Create Entitlement
user_addrSubscriber's wallet address
token_addr, token_idThe NFT the subscription holds
statusactive, canceled, expired or refunded
periodBilling period: month, year or season, when known
attributesDetails such as sku, country and customer_id
metadataYour own metadata, as sent on Create Entitlement
start_time, paid_to, end_time, canceled_at, last_paymentUnix seconds; omitted when not set
token_removedWhen the NFT was revoked, unix seconds, if it has been
user_ident, user_name, user_extrasFrom the user's login, masked when the user has not agreed to share their email; not masked for users of your own identity provider

One Subscription, with Payments​

GET

https://appsvc.svc.eluv.io/casa/main/authd/tnt/:tid/subscriptions/:id

:id is the id field of a list entry. Returns the subscription, its payments (purchases: the initial purchase, renewals, refunds and credits, each with its kind), and all the subscriber's primary purchases in the tenant (user_purchases). Returns HTTP 404 if there is no such subscription.


Values of One Field​

POST

https://appsvc.svc.eluv.io/casa/main/authd/tnt/:tid/subscriptions/attr/:field

Returns the distinct values of one field, with the number of matching subscriptions for each, most common first -- for example status or sku, to build filter choices. Takes the same query parameters and request body as the list.


Curl Example​

curl -X POST "https://appsvc.svc.eluv.io/casa/main/authd/tnt/<tenantId>/subscriptions?start_ts=1793000000&limit=50" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{"filters": {"status": ["active"]}}'