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.fetchConnections
Fetches a paginated list of a user’s established (mutual) 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>>
fetchConnectionsCount
Returns the number of established connections for a user.Promise<{ count: number }>
fetchSentPendingConnections
Returns a paginated list of connection requests the user has sent that are still pending.Promise<PaginatedResponse<PendingConnection>>
fetchReceivedPendingConnections
Returns a paginated list of pending connection requests the user has received.Promise<PaginatedResponse<PendingConnection>>
acceptConnection
Accepts a pending connection request received by the user.Promise<ConnectionActionResponse> — { id, status, createdAt?, respondedAt? }
declineConnection
Declines a pending connection request received by the user.Promise<ConnectionActionResponse> — { id, status, createdAt?, respondedAt? }
removeConnection
Removes an established connection (or withdraws a pending request) by its connection ID.Promise<void>
