Skip to main content
The 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.
string
required
The Sublay user ID.
string
Comma-separated list of associations to populate.
string
Opts the returned user into a spaceReputation number. Accepts a space <uuid> or "none" (the project-general bucket) only — "context" is rejected (400), since a bare user lookup has no space context. The empty string and the legacy general / null aliases are also rejected. See Reputation.
boolean
Only honored alongside an explicit space <uuid>. When true, spaceReputation is the subtree sum — the named space plus all of its descendants.
ReturnsPromise<User>

fetchUserByForeignId

Fetches a user profile by your application’s own user identifier. Optionally creates the user if not found.
string
required
Your application’s user identifier.
boolean
When true, creates the user with the provided profile fields if no match is found. Defaults to false.
string
Display name — used only when creating a new user.
string
Username — used only when creating a new user.
string
Avatar URL — used only when creating a new user.
string
Bio text — used only when creating a new user.
object
Public metadata — used only when creating a new user.
object
Secure metadata (not exposed to the client) — used only when creating a new user.
string
Comma-separated list of associations to populate.
string
Opts the returned user into a spaceReputation number. Accepts a space <uuid> or "none" (the project-general bucket) only — "context" is rejected (400), since a bare user lookup has no space context. The empty string and the legacy general / null aliases are also rejected. See Reputation.
boolean
Only honored alongside an explicit space <uuid>. When true, spaceReputation is the subtree sum — the named space plus all of its descendants.
ReturnsPromise<User>

fetchUserByUsername

Fetches a user profile by their username.
string
required
The user’s unique username.
string
Comma-separated list of associations to populate.
string
Opts the returned user into a spaceReputation number. Accepts a space <uuid> or "none" (the project-general bucket) only — "context" is rejected (400), since a bare user lookup has no space context. The empty string and the legacy general / null aliases are also rejected. See Reputation.
boolean
Only honored alongside an explicit space <uuid>. When true, spaceReputation is the subtree sum — the named space plus all of its descendants.
ReturnsPromise<User>

updateUser

Updates a user’s profile fields.
string
required
The Sublay user ID to update.
string
New display name.
string
New username. Must be available.
string
New bio text.
string
New avatar URL.
object
Updated public metadata. Merged with existing metadata.
object
Updated secure metadata (not exposed in public responses). Merged with existing values.
string
ISO 8601 date string for the user’s birthdate.
object
Geographic location { latitude: number; longitude: number }.
ReturnsPromise<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.
This is a hard, irreversible delete — the user and their related data cannot be recovered.
string
required
The Sublay user ID to delete.
ReturnsPromise<void>

fetchUserSuggestions

Returns users whose name or username matches a partial query string. Useful for mention autocomplete on the server.
string
required
Partial name or username to search for.
string
Opts each returned user into a spaceReputation number. Accepts a space <uuid> or "none" (the project-general bucket) only — "context" is rejected (400), since this lookup has no space context. The empty string and the legacy general / null aliases are also rejected. See Reputation.
boolean
Only honored alongside an explicit space <uuid>. When true, spaceReputation is the subtree sum — the named space plus all of its descendants.
ReturnsPromise<User[]>

checkUsernameAvailability

Checks whether a username is available for registration.
string
required
The username to check.
ReturnsPromise<{ available: boolean }>

fetchFollowersByUserId

Returns a paginated list of users following the specified user.
string
required
The Sublay user ID.
number
Page number (1-indexed). Defaults to 1.
number
Results per page. Defaults to 20.
string
Opts each returned follower into a spaceReputation number. Accepts a space <uuid> or "none" (the project-general bucket) only — "context" is rejected (400), since this list has no space context. The empty string and the legacy general / null aliases are also rejected. See Reputation.
boolean
Only honored alongside an explicit space <uuid>. When true, spaceReputation is the subtree sum — the named space plus all of its descendants.
ReturnsPromise<PaginatedResponse<User>>

fetchFollowersCountByUserId

Returns the total number of followers for a user.
string
required
The Sublay user ID.
ReturnsPromise<{ count: number }>

fetchFollowingByUserId

Returns a paginated list of users that the specified user is following.
string
required
The Sublay user ID.
number
Page number (1-indexed). Defaults to 1.
number
Results per page. Defaults to 20.
string
Opts each returned user into a spaceReputation number. Accepts a space <uuid> or "none" (the project-general bucket) only — "context" is rejected (400), since this list has no space context. The empty string and the legacy general / null aliases are also rejected. See Reputation.
boolean
Only honored alongside an explicit space <uuid>. When true, spaceReputation is the subtree sum — the named space plus all of its descendants.
ReturnsPromise<PaginatedResponse<User>>

fetchFollowingCountByUserId

Returns the number of users the specified user is following.
string
required
The Sublay user ID.
ReturnsPromise<{ count: number }>

fetchConnectionsByUserId

Returns a paginated list of established mutual connections for a user.
string
required
The Sublay user ID.
number
Page number (1-indexed). Defaults to 1.
number
Results per page. Defaults to 20.
string
Opts each returned connection’s user into a spaceReputation number. Accepts a space <uuid> or "none" (the project-general bucket) only — "context" is rejected (400), since this list has no space context. The empty string and the legacy general / null aliases are also rejected. See Reputation.
boolean
Only honored alongside an explicit space <uuid>. When true, spaceReputation is the subtree sum — the named space plus all of its descendants.
ReturnsPromise<PaginatedResponse<EstablishedConnection>>

fetchConnectionsCountByUserId

Returns the number of established connections for a user.
string
required
The Sublay user ID.
ReturnsPromise<{ 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.
string
required
The user being followed (the target).
string
required
The user performing the follow (the follower).
ReturnsPromise<Follow>

deleteFollow

Makes one user unfollow another.
string
required
The user being unfollowed (the target).
string
required
The user performing the unfollow (the follower).
ReturnsPromise<void>

fetchFollowStatus

Checks whether the acting user follows the target user.
string
required
The user whose follow relationship is being checked (the target).
string
required
The user whose perspective the status is from.
ReturnsPromise<{ isFollowing: boolean; followId?: string }>

requestConnection

Sends a connection request from the acting user to the target user.
string
required
The user the connection is requested with (the target).
string
required
The user sending the request (the requester).
string
Optional message to include with the request.
ReturnsPromise<Connection>

fetchConnectionStatus

Returns the connection status between the acting user and the target user.
string
required
The other user in the connection (the target).
string
required
The user whose perspective the status is from.
ReturnsPromise<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.
string
required
The other user in the connection (the target).
string
required
The user withdrawing, declining, or disconnecting.
ReturnsPromise<RemoveConnectionByUserIdResponse>