users module reads and updates user profiles and lets the logged-in user act on the social graph of an arbitrary target user, addressed by userId.
In the follow and connection helpers below, userId is always the target — the user being followed, the other party in a connection, or the user whose followers you’re reading. The actor is always the logged-in token holder. To act on your own graph (your own followers, the users you follow, your own connections and pending requests), use the follows and connections modules instead.
fetchUserById
Fetches a user by their internal Sublay user ID.Promise<User>
fetchUserByForeignId
Fetches a user by your application’s own user identifier.Promise<User>
fetchUserByUsername
Fetches a user by their username.Promise<User>
fetchUserSuggestions
Returns users whose name or username matches a partial query string. Useful for mention autocomplete.Promise<User[]>
checkUsernameAvailability
Checks whether a username is available.Promise<{ available: boolean }>
updateUser
Updates a user’s profile, optionally uploading a new avatar and/or banner image. A user token may only update its own profile.Updated secure metadata (
Record<string, any>). No API response returns it, to this user or anyone else; your backend receives it in webhooks. The user can write it themselves, so don’t store anything your app needs to trust here.When
avatarFile or bannerFile is supplied the request is sent as
multipart/form-data carrying the browser File/Blob. The image options
(an ImageOptions object whose mode selects a processing strategy) are sent
alongside the file.Promise<AuthUser>
fetchFollowersByUserId
Returns a paginated list of users following the target user.Optional search term. Filters the list to users whose username or name contains this text (case-insensitive). When omitted, no filtering is applied.
Restricts which field
query matches against — username or name. When omitted, query matches either field.Promise<PaginatedResponse<FollowListItem>>
fetchFollowersCountByUserId
Returns the total number of followers for the target user.Promise<{ count: number }>
fetchFollowingByUserId
Returns a paginated list of users that the target user is following.Optional search term. Filters the list to users whose username or name contains this text (case-insensitive). When omitted, no filtering is applied.
Restricts which field
query matches against — username or name. When omitted, query matches either field.Promise<PaginatedResponse<FollowListItem>>
fetchFollowingCountByUserId
Returns the number of users the target user is following.Promise<{ count: number }>
fetchConnectionsByUserId
Returns a paginated list of the target user’s established connections.Optional search term. Filters the list to connections whose connected user’s username or name contains this text (case-insensitive). When omitted, no filtering is applied.
Restricts which field
query matches against — username or name. When omitted, query matches either field.Promise<PaginatedResponse<EstablishedConnection>>
fetchConnectionsCountByUserId
Returns the number of established connections for the target user.Promise<{ count: number }>
createFollow
The logged-in user follows the target user.Promise<Follow>
deleteFollow
The logged-in user unfollows the target user.This unfollows by the target’s
userId. To delete one of your own follow
relationships by its record ID, use
follows.deleteFollow, which takes a followId.Promise<void>
fetchFollowStatus
Returns whether the logged-in user follows the target user.Promise<{ isFollowing: boolean; followId?: string; followedAt?: string }>
requestConnection
Sends a connection request from the logged-in user to the target user.Promise<ConnectionRequestResponse> — the created/pending connection.
fetchConnectionStatus
Returns the connection status between the logged-in user and the target user.Promise<ConnectionStatusResponse>
removeConnectionByUserId
Removes the connection with the target user — withdrawing a sent request, declining a received one, or disconnecting an established connection, depending on the current state.Promise<RemoveConnectionByUserIdResponse>
Blocking
User-to-user blocking is part of the trust & safety moderation bundle. These functions require that bundle; a project without it returns403 database/tables-not-available. The blocker is the token holder — there is no actingUserId.
Blocking severs interaction between two users across every Sublay surface and is non-disclosing — the blocked user is never notified. See Moderation — Blocking for the full enforcement behavior.
createBlock
Blocks a user. On a new block, existing follows and connections between the pair are torn down (both directions). Idempotent — re-blocking succeeds. Self-block is rejected server-side.Promise<BlockResponse> — { id, blockerId, blockedId, createdAt }.
deleteBlock
Unblocks a user. Idempotent; restores nothing.Promise<void>
fetchBlockStatus
Checks whether the token holder blocks the target user. Outbound-only — it never reveals whether the target has blocked the token holder.Promise<BlockStatusResponse> — { blocked: boolean; blockId?: string; createdAt?: string }.
fetchBlockedUsers
Returns a paginated list of the users the token holder has blocked (their outbound blocks), each row carrying a public profile summary. This block list is private to the blocker.Promise<PaginatedResponse<BlockedUserListItem>>, where each BlockedUserListItem is { id, blockedUser, createdAt }.
