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.fetchConnections
Fetches a paginated list of a user’s accepted connections.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.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.
Restricts which field
query matches against — username or name. When omitted, query matches either field.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.Promise<{ count: number }>
fetchSentPendingConnections
Returns a paginated list of connection requests the user has sent that are still pending.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.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.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.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.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.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).Promise<void>. It resolves with no value once the connection is removed (the server answers 204 No Content).
