Skip to main content
The connections module reads and manages a user’s mutual connections (bidirectional relationships, similar to “friends”). Use it to list accepted 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 actingUserId, the user your service key acts as.
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).

fetchConnections

Fetches a paginated list of a user’s accepted connections.
string
required
The user the service key acts as, whose connections to fetch.
number
Page number (1-indexed). Defaults to 1.
number
Results per page: a whole number from 1 to 100. Defaults to 20. A larger value is rejected with 400 connection/invalid-query, never lowered to 100.
string
Optional search term. Filters the list to connections whose other user’s username or name contains this text (case-insensitive). When omitted, no filtering is applied.
string
Restricts which field query matches against — username or name. When omitted, query matches either field.
Returns — Promise<PaginatedResponse<AcceptedConnectionRow>>, where AcceptedConnectionRow is { id, user, status: "accepted", createdAt, respondedAt } and user is the other user in the connection.

fetchConnectionsCount

Returns the number of accepted connections for a user.
string
required
The user the service key acts as.
Returns — Promise<{ count: number }>

fetchSentPendingConnections

Returns a paginated list of connection requests the user has sent that are still pending.
string
required
The user the service key acts as, whose sent requests to fetch.
number
Page number (1-indexed). Defaults to 1.
number
Results per page: a whole number from 1 to 100. Defaults to 20. A larger value is rejected with 400 connection/invalid-query, never lowered to 100.
Returns — Promise<PaginatedResponse<ConnectionRow>>, where ConnectionRow is { id, user, type, message, status, createdAt, respondedAt }. Here user is the user the request was sent to, type is "sent", status is "pending" and respondedAt is null.

fetchReceivedPendingConnections

Returns a paginated list of pending connection requests the user has received.
string
required
The user the service key acts as, whose received requests to fetch.
number
Page number (1-indexed). Defaults to 1.
number
Results per page: a whole number from 1 to 100. Defaults to 20. A larger value is rejected with 400 connection/invalid-query, never lowered to 100.
Returns — Promise<PaginatedResponse<ConnectionRow>>. Here user is the user who sent the request, type is "received", status is "pending" and respondedAt is null.

acceptConnection

Accepts a pending connection request received by the user.
string
required
The ID of the pending connection request to accept.
string
required
The user the service key acts as: the recipient accepting the request.
Returns — Promise<ConnectionRow>: the accepted connection from the acting user’s side (user is the requester, type is "received", status is "accepted"). See ConnectionRow.

declineConnection

Declines a pending connection request received by the user.
string
required
The ID of the pending connection request to decline.
string
required
The user the service key acts as: the recipient declining the request.
Returns — Promise<ConnectionRow>: the declined connection from the acting user’s side (user is the requester, type is "received", status is "declined"). See ConnectionRow.

removeConnection

Removes a connection by its connection ID: withdraws a pending request the user sent, or disconnects an accepted connection (either user can).
string
required
The connection ID to remove.
string
required
The user the service key acts as, on whose behalf the connection is removed.
Returns — Promise<void>. It resolves with no value once the connection is removed (the server answers 204 No Content).