Skip to content

Membership levels

Membership levels let you create different tiers among a feed's audience, and control which activities are available to which users. This gives users the option to post content that only premium members can see.

This page details how you can set up membership levels.

Create membership levels

Use server-side SDKs to create membership levels. You can define unified membership levels for your application, or scope them (for example, to specific users) using custom data.

import uuid

# Create Premium membership level
premium_request = {
    "id": str(uuid.uuid4()),
    "name": "Premium",
    "description": "Weekly QA with me",
    "custom": {
        "creator_id": creator.id
    },
    "priority": 100,
    "tags": ["premium"]
}
premium_response = self.client.feeds.create_membership_level(**premium_request)

# Create Inner Circle membership level
inner_circle_request = {
    "id": str(uuid.uuid4()),
    "name": "Inner Circle",
    "description": "You can see new videos a week earlier, and weekly QA with me",
    "custom": {
        "creator_id": creator.id
    },
    "priority": 200,
    "tags": ["premium", "inner-circle"]
}
inner_circle_response = self.client.feeds.create_membership_level(**inner_circle_request)

Overview of the membership level model

MembershipLevelResponse

NameTypeDescriptionConstraints
created_atnumberWhen the membership level was createdRequired
customobjectCustom data for the membership level-
descriptionstringDescription of the membership level-
idstringUnique identifier for the membership levelRequired
namestringDisplay name for the membership levelRequired
priorityintegerPriority levelRequired
tagsstring[]Activity tags this membership level gives access toRequired
updated_atnumberWhen the membership level was last updatedRequired

Assign membership level to users

To assign a membership level to a user, you need to add them as a feed member, and set their membership level.

Info:

Users still have to follow the feed to see posts in their timelines. Membership levels are only used for authorization purposes.

Node.js
await serverClient.feeds.updateFeedMembers({
  feed_group_id: creatorFeed.group,
  feed_id: creatorFeed.id,
  operation: "upsert",
  members: [
    {
      user_id: premiumFan.id,
      membership_level: premiumMembershipLevel.id,
      role: "feed_member_viewer",
    },
  ],
});

Create a premium activity

client.feeds.add_activity(
    feeds=["user:1"],
    type="post",
    text="Premium content",
    visibility="tag",
    visibility_tag="premium",
    user_id="<user id>"
)
# Premium users can see full activity, others a preview

Users who don't have access to the post will only see a preview:

  • No attachments are shown
  • The activity text is truncated (first 20 characters are shown, for example: "Behind the scenes of...")

The activity.preview flag is true if a user received only a preview of the activity, not the full content.

Query membership levels

Node.js
await serverClient.feeds.queryMembershipLevels({
  filter: {
    custom: {
      $contains: {
        creator_id: creator.id,
      },
    },
  },
  sort: [{ field: "priority", direction: -1 }],
});

Filter options

name type description supported operations example
id string or list of strings The ID of the membership level $in, $eq { id: { $in: [ 'abc', 'xyz' ] } }
name string or list of strings The name of the membership level $in, $eq { name: { $in: [ 'abc', 'xyz' ] } }
description string or list of strings The description of the membership level $in, $eq { description: { $in: [ 'abc', 'xyz' ] } }
priority number The priority of the membership level $eq, $gt, $lt, $gte, $lte { priority: { $gte: 100 } }
tags list of strings Tags the membership level grants access to $eq, $in, $contains { tags: { $in: [ 'premium', 'inner-circle' ] } }
custom object Custom data of the membership level $contains, $path_exists { custom: { $contains: {creator_id: '123' } } }
created_at string, must be formatted as an RFC3339 timestamp The time the membership level was created $eq, $gt, $lt, $gte, $lte { created_at: { $gte: '2023-12-04T09:30:20.45Z' } }
updated_at string, must be formatted as an RFC3339 timestamp The time the membership level was last updated $eq, $gt, $lt, $gte, $lte { updated_at: { $gte: '2023-12-04T09:30:20.45Z' } }

Sort options

Fields:

  • priority
  • created_at
  • updated_at

Direction: 1 or -1

Update membership levels

Node.js
await serverClient.feeds.updateMembershipLevel({
  id: premiumMembershipLevel.id,
  name: "Premium",
  description: "Weekly QA with me",
  custom: {
    creator_id: creator.id,
  },
  priority: 100,
  tags: ["premium"],
});

Delete membership level

Node.js
await serverClient.feeds.deleteMembershipLevel({
  id: premiumMembershipLevel.id,
});