Skip to main content

Overview

The User Management modules (sdk.self and sdk.user) handle user profiles, interactions, and settings. The self module manages your own profile, while the user module handles operations with other users.

Self Module

sdk.self - Current user profile, notifications, settings

User Module

sdk.user - Other users, profiles, search, interactions

Self Module (sdk.self)

Get Current User Profile

Retrieve the authenticated user’s profile information.
const { data: profile, error } = await sdk.self.getMe({
  authentication: { connectionId: "conn_123" }
})

console.log(`${profile.name} (@${profile.username})`)
console.log(`Subscribers: ${profile.subscribersCount}`)
console.log(`Posts: ${profile.postsCount}`)
authentication
AuthenticationOptions
required
Either { connectionId: string } or { session: object }
Returns: User profile with ID, username, name, email, bio, subscriber/post counts, verification status, and avatar/cover URLs.

Update Profile

Update the authenticated user’s profile information.
const { data: result, error } = await sdk.self.updateProfile({
  authentication: { session: userData },
  data: {
    name: "New Display Name",
    about: "Updated bio with new information! ✨"
  }
})
data.name
string
New display name for the user
data.about
string
New bio/about text

Get Notifications

Retrieve notifications for the authenticated user.
const { data: notifications, error } = await sdk.self.getNotifications({
  authentication: { connectionId: "conn_123" },
  params: {
    limit: 50,
    filter: "unread" // "all", "unread", "tips", "messages"
  }
})

console.log(`${notifications.list.length} notifications`)
params.limit
number
default:"20"
Maximum notifications to return (1-100)
params.filter
string
default:"all"
Filter by type: “all”, “unread”, “tips”, “messages”, “subscribers”

Mark Notifications as Read

Mark specific notifications as read.
const { data: result, error } = await sdk.self.markNotificationsRead({
  authentication: { session: userData },
  notificationIds: ["notif_123", "notif_456"]
})

User Module (sdk.user)

Get User by ID

Retrieve another user’s public profile information.
const { data: user, error } = await sdk.user.getById({
  authentication: { connectionId: "conn_123" },
  userId: 987654321
})

console.log(`${user.name} (@${user.username})`)
console.log(`Verified: ${user.isVerified}`)
console.log(`Posts: ${user.postsCount}`)
userId
number
required
OnlyFans user ID to retrieve
Returns: Public profile information including username, name, bio, post count, verification status, and avatar.

Search Users

Search for users by username or name.
const { data: results, error } = await sdk.user.search({
  authentication: { connectionId: "conn_123" },
  params: {
    query: "example",
    limit: 20
  }
})

console.log(`Found ${results.users.length} users`)
params.query
string
required
Search term (username or display name)
params.limit
number
default:"10"
Maximum results to return (1-50)

Subscribe to User

Subscribe to another user’s content.
const { data: subscription, error } = await sdk.user.subscribe({
  authentication: { session: userData },
  userId: 987654321,
  params: {
    paymentMethod: "card_123",
    promocode: "WELCOME10" // Optional
  }
})
params.paymentMethod
string
required
Payment method ID for subscription
params.promocode
string
Optional promotional code

Unsubscribe from User

Cancel subscription to a user.
const { data: result, error } = await sdk.user.unsubscribe({
  authentication: { session: userData },
  userId: 987654321
})

Check Subscription Status

Check if you’re subscribed to a user.
const { data: status, error } = await sdk.user.getSubscriptionStatus({
  authentication: { connectionId: "conn_123" },
  userId: 987654321
})

console.log(`Subscribed: ${status.isSubscribed}`)
if (status.isSubscribed) {
  console.log(`Expires: ${status.expiresAt}`)
}

Block/Unblock User

Block or unblock another user.
// Block user
const { data: blockResult, error } = await sdk.user.block({
  authentication: { session: userData },
  userId: 987654321
})

// Unblock user
const { data: unblockResult, error } = await sdk.user.unblock({
  authentication: { session: userData },
  userId: 987654321
})

Response Types

User Profile Object

interface UserProfile {
  id: string
  username: string
  name: string
  email?: string // Only for self
  about?: string
  subscribersCount: number
  postsCount: number
  isVerified: boolean
  avatar?: string
  cover?: string
  subscriptionPrice?: number // For other users
}

Notification Object

interface Notification {
  id: string
  type: "tip" | "message" | "subscriber" | "like" | "comment"
  title: string
  message: string
  createdAt: string
  isRead: boolean
  userId?: string
  username?: string
  amount?: number // For tips
}

Subscription Status Object

interface SubscriptionStatus {
  isSubscribed: boolean
  subscribedAt?: string
  expiresAt?: string
  isExpired: boolean
  renewalPrice?: number
  isFree: boolean
}

Error Handling

Common error scenarios for user operations:
const { data, error } = await sdk.user.subscribe(params)

if (error) {
  switch (error.type) {
    case "unauthorized":
      console.log("Please login to subscribe")
      break
    case "forbidden":
      console.log("Cannot subscribe to this user")
      break
    case "bad_request":
      if (error.details?.paymentMethod) {
        console.log("Invalid payment method")
      }
      break
    case "not_found":
      console.log("User not found")
      break
  }
}

Best Practices

Profile Updates

Update efficiently
  • Only send changed fields
  • Validate data client-side
  • Handle validation errors gracefully

User Interactions

Respect user privacy
  • Check subscription status before actions
  • Handle blocking/privacy settings
  • Cache user data appropriately
Privacy & Permissions: Always respect user privacy settings and subscription requirements. Some user information is only available to subscribers.