Skip to main content
The connections module acts on the logged-in user’s own mutual connections — bidirectional relationships, similar to “friends.” Use it to list established connections, inspect outgoing and incoming pending requests, and accept, decline, or remove connections.
To request a connection with someone, check the connection status against a specific user, or remove a connection by the other user’s ID, use the users module.

fetchConnections

Returns a paginated list of your established (mutual) connections.
const { data, pagination } = await sublay.connections.fetchConnections({
  page: 1,
  limit: 20,
});
page
number
Page number (1-indexed). Defaults to 1.
limit
number
Results per page. Defaults to 20.
ReturnsPromise<PaginatedResponse<EstablishedConnection>>, where EstablishedConnection is { id, connectedUser, connectedAt }.

fetchConnectionsCount

Returns the number of your established connections.
const { count } = await sublay.connections.fetchConnectionsCount();
ReturnsPromise<{ count: number }>

fetchSentPendingConnections

Returns a paginated list of your outgoing connection requests that are still pending.
const { data, pagination } =
  await sublay.connections.fetchSentPendingConnections({
    page: 1,
    limit: 20,
  });
page
number
Page number (1-indexed). Defaults to 1.
limit
number
Results per page. Defaults to 20.
ReturnsPromise<PaginatedResponse<PendingConnection>>, where PendingConnection is { id, message?, createdAt, user, type: "received" | "sent" }.

fetchReceivedPendingConnections

Returns a paginated list of incoming connection requests you have received.
const { data, pagination } =
  await sublay.connections.fetchReceivedPendingConnections({
    page: 1,
    limit: 20,
  });
page
number
Page number (1-indexed). Defaults to 1.
limit
number
Results per page. Defaults to 20.
ReturnsPromise<PaginatedResponse<PendingConnection>>

acceptConnection

Accepts a pending incoming connection request.
const result = await sublay.connections.acceptConnection({
  connectionId: "con_xyz789",
});
connectionId
string
required
The ID of the pending connection request to accept.
ReturnsPromise<{ id: string; status: string; createdAt?: string; respondedAt?: string }>

declineConnection

Declines a pending incoming connection request.
const result = await sublay.connections.declineConnection({
  connectionId: "con_xyz789",
});
connectionId
string
required
The ID of the pending connection request to decline.
ReturnsPromise<{ id: string; status: string; createdAt?: string; respondedAt?: string }>

removeConnection

Removes an established connection by its connection ID.
await sublay.connections.removeConnection({ connectionId: "con_xyz789" });
connectionId
string
required
The connection ID to remove.
ReturnsPromise<void>