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.The Sublay user ID.
Comma-separated list of associations to populate.
Promise<User>
fetchUserByForeignId
Fetches a user profile by your application’s own user identifier. Optionally creates the user if not found.Your application’s user identifier.
When
true, creates the user with the provided profile fields if no match is found. Defaults to false.Display name — used only when creating a new user.
Username — used only when creating a new user.
Avatar URL — used only when creating a new user.
Bio text — used only when creating a new user.
Public metadata — used only when creating a new user.
Secure metadata (not exposed to the client) — used only when creating a new user.
Comma-separated list of associations to populate.
Promise<User>
fetchUserByUsername
Fetches a user profile by their username.The user’s unique username.
Comma-separated list of associations to populate.
Promise<User>
updateUser
Updates a user’s profile fields.The Sublay user ID to update.
New display name.
New username. Must be available.
New bio text.
New avatar URL.
Updated public metadata. Merged with existing metadata.
Updated secure metadata (not exposed in public responses). Merged with existing values.
ISO 8601 date string for the user’s birthdate.
Geographic location
{ latitude: number; longitude: number }.Promise<UserFull>
deleteUser
Permanently deletes a user and cascades cleanup across all of their related data — reactions, files, follows, connections, notifications, collections, reports, and mentions are removed, and their entities and comments are stripped of authored content. This mirrors the full-cascade delete performed from the dashboard.The Sublay user ID to delete.
Promise<void>
fetchUserSuggestions
Returns users whose name or username matches a partial query string. Useful for mention autocomplete on the server.Partial name or username to search for.
Promise<User[]>
checkUsernameAvailability
Checks whether a username is available for registration.The username to check.
Promise<{ available: boolean }>
fetchFollowersByUserId
Returns a paginated list of users following the specified user.The Sublay user ID.
Page number (1-indexed). Defaults to
1.Results per page. Defaults to
20.Promise<PaginatedResponse<User>>
fetchFollowersCountByUserId
Returns the total number of followers for a user.The Sublay user ID.
Promise<{ count: number }>
fetchFollowingByUserId
Returns a paginated list of users that the specified user is following.The Sublay user ID.
Page number (1-indexed). Defaults to
1.Results per page. Defaults to
20.Promise<PaginatedResponse<User>>
fetchFollowingCountByUserId
Returns the number of users the specified user is following.The Sublay user ID.
Promise<{ count: number }>
fetchConnectionsByUserId
Returns a paginated list of established mutual connections for a user.The Sublay user ID.
Page number (1-indexed). Defaults to
1.Results per page. Defaults to
20.Promise<PaginatedResponse<EstablishedConnection>>
fetchConnectionsCountByUserId
Returns the number of established connections for a user.The Sublay user ID.
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.The user being followed (the target).
The user performing the follow (the follower).
Promise<Follow>
deleteFollow
Makes one user unfollow another.The user being unfollowed (the target).
The user performing the unfollow (the follower).
Promise<void>
fetchFollowStatus
Checks whether the acting user follows the target user.The user whose follow relationship is being checked (the target).
The user whose perspective the status is from.
Promise<{ isFollowing: boolean; followId?: string }>
requestConnection
Sends a connection request from the acting user to the target user.The user the connection is requested with (the target).
The user sending the request (the requester).
Optional message to include with the request.
Promise<Connection>
fetchConnectionStatus
Returns the connection status between the acting user and the target user.The other user in the connection (the target).
The user whose perspective the status is from.
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.The other user in the connection (the target).
The user withdrawing, declining, or disconnecting.
Promise<RemoveConnectionByUserIdResponse>
