users module provides server-side access to user profiles, social graph data (follows and connections), and username availability. All operations use your project API key and do not require a user access token.
fetchUserById
Fetches a user profile by their internal Sublay user ID.Promise<User>
fetchUserByForeignId
Fetches a user profile by your application’s own user identifier. Optionally creates the user if not found.When
true, creates the user with the provided profile fields if no match is found. Defaults to false.Secure metadata, used only when creating a new user. No API response returns it to any user. Users can also write their own, so don’t treat it as trusted.
Promise<User>
fetchUserByUsername
Fetches a user profile by their username.Promise<User>
updateUser
Updates a user’s profile fields.Updated secure metadata. No API response returns it to any user. Users can also write their own, so don’t treat it as trusted. Merged with existing values.
Promise<UserFull>
deleteUser
Permanently deletes a user and cascades cleanup across all of their related data — reactions, files, follows, connections, notifications, collections and reports are removed, and their drafts are deleted with everything attached to them. Their published entities and comments stay, with no author and stripped of everything they wrote, metadata included (and an entity’s keywords and location); their comments are marked deleted. Their chat messages stay in their conversations as deleted, the same as if the user had deleted each one: content, GIF, mentions and metadata cleared anduserDeletedAt set. Mentions of the user in other entities, comments and chat messages keep their text, but their id and foreignId become null. This mirrors the full-cascade delete performed from the dashboard.
Promise<void>
fetchUserSuggestions
Returns users whose name or username matches a partial query string. Useful for mention autocomplete on the server.Promise<User[]>
checkUsernameAvailability
Checks whether a username is available for registration.Promise<{ available: boolean }>
fetchFollowersByUserId
Returns a paginated list of users following the specified 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<User>>
fetchFollowersCountByUserId
Returns the total number of followers for a user.Promise<{ count: number }>
fetchFollowingByUserId
Returns a paginated list of users that the specified 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<User>>
fetchFollowingCountByUserId
Returns the number of users the specified user is following.Promise<{ count: number }>
fetchConnectionsByUserId
Returns a paginated list of established mutual connections for a user.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 a user.Promise<{ count: number }>
Acting on a user’s follows and connections
The functions above are read-only queries about a target user. The functions below perform an action on behalf of one user toward another. Because a service key isn’t tied to a single user, these routes take both:userId— the target of the action (the user being followed, connected with, etc.), taken from the request path.actingUserId— the actor performing it (the follower, the requester, the user whose perspective a status is from).
Listing and managing the acting user’s own follow/connection graph by record ID
lives on the dedicated
follows and
connections modules.createFollow
Makes one user follow another.Promise<Follow>
deleteFollow
Makes one user unfollow another.Promise<void>
fetchFollowStatus
Checks whether the acting user follows the target user.Promise<{ isFollowing: boolean; followId?: string }>
requestConnection
Sends a connection request from the acting user to the target user.Promise<ConnectionRequestResponse> — the created/pending connection.
fetchConnectionStatus
Returns the connection status between the acting user and the target user.Promise<ConnectionStatusResponse> — a discriminated union on status: "none", "pending" (with type and connectionId), "connected", or "declined".
removeConnectionByUserId
Removes the connection between the acting user and the target user — withdrawing a sent request, declining a received one, or disconnecting an established connection, depending on the current state.Promise<RemoveConnectionByUserIdResponse>
Acting on a user’s blocks
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. Each acts on behalf of one user (the blocker) — pass that user’s ID as 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 one user on behalf of another. On a new block, existing follows and connections between the pair are torn down (both directions) in one transaction. Idempotent — re-blocking succeeds. Self-block is rejected.Promise<Block> — { id, blockerId, blockedId, createdAt }.
deleteBlock
Removes a block on behalf of the blocker. Idempotent; restores nothing.Promise<void>
fetchBlockStatus
Checks whether the acting user blocks the target user. Outbound-only — it never reveals whether the target has blocked the acting user.Promise<{ blocked: boolean; blockId?: string; createdAt?: string }>
fetchBlockedUsers
Returns a paginated list of the users the acting user has blocked (their outbound blocks), each row carrying a public profile summary. This block list is private to the blocker.Promise<PaginatedResponse<BlockedUser>>, where each BlockedUser is { id, blockedUser, createdAt }.
