Skip to main content
The connections module reads and manages a user’s mutual connections (bidirectional relationships, similar to “friends”). Use it to list established connections, inspect pending requests, and accept, decline, or remove connections.
Every function acts on behalf of a named user. Pass that user’s Sublay ID as userId — your service key performs the operation as that user.
To send a connection request, check a connection’s status, or remove a connection by the other user’s ID, use the nested routes on the users module (requestConnection, fetchConnectionStatus, removeConnectionByUserId), which take an actingUserId.

fetchConnections

Fetches a paginated list of a user’s established (mutual) connections.
string
required
The Sublay user ID whose connections to fetch.
number
Page number (1-indexed). Defaults to 1.
number
Results per page. Defaults to 20.
ReturnsPromise<PaginatedResponse<EstablishedConnection>>

fetchConnectionsCount

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

fetchSentPendingConnections

Returns a paginated list of connection requests the user has sent that are still pending.
string
required
The Sublay user ID whose sent requests to fetch.
number
Page number (1-indexed). Defaults to 1.
number
Results per page. Defaults to 20.
ReturnsPromise<PaginatedResponse<PendingConnection>>

fetchReceivedPendingConnections

Returns a paginated list of pending connection requests the user has received.
string
required
The Sublay user ID whose received requests to fetch.
number
Page number (1-indexed). Defaults to 1.
number
Results per page. Defaults to 20.
ReturnsPromise<PaginatedResponse<PendingConnection>>

acceptConnection

Accepts a pending connection request received by the user.
string
required
The ID of the pending connection request to accept.
string
required
The Sublay user ID accepting the request (the recipient).
ReturnsPromise<ConnectionActionResponse>{ id, status, createdAt?, respondedAt? }

declineConnection

Declines a pending connection request received by the user.
string
required
The ID of the pending connection request to decline.
string
required
The Sublay user ID declining the request (the recipient).
ReturnsPromise<ConnectionActionResponse>{ id, status, createdAt?, respondedAt? }

removeConnection

Removes an established connection (or withdraws a pending request) by its connection ID.
string
required
The connection ID to remove.
string
required
The Sublay user ID on whose behalf the connection is removed.
ReturnsPromise<void>