Skip to main content
Request Connection
Sends a connection request from the authenticated user to the specified user. An optional message can be included. A notification is sent to the receiving user. When a connection between the two users already exists:
  • Your own request is still pending, or you are already connected: 200 with the existing connection row. The stored message is kept (a new message is ignored) and no second notification is sent.
  • The other user already sent you a request: 409 connection/request-received, with their request in the body as connection, so your app can offer to accept it.
  • A declined request exists between you (either of you declined the other): 409 connection/request-declined. A new request is refused while it exists.
When the two users send each other a request through this endpoint at the same time, one request is created: one call gets 201, the other 409 connection/request-received.
Requires the connections bundle. A project without the connections bundle returns 403 database/tables-not-available. See Bundles.

Path Parameters

string
required
The Sublay user ID (UUID) of the user to send a connection request to.

Body Parameters

string
Optional message to include with the connection request.
string
Service key only, and required with one: the user this request acts as, who sends the connection request. A user token always acts as its own user and must not send it (400 connection/acting-user-not-allowed).

Response

Returns HTTP 201 with the created connection row, or HTTP 200 with the existing row when your request is already pending or the two of you are already connected. The body is the same in both cases:
string
ID of the connection record. Pass it to Remove Connection to withdraw the request.
object
Public profile of the user the request was sent to (the user in the path). Sensitive fields (email, hash, secureMetadata, etc.) are excluded.
string
"sent" when the authenticated user sent the request, "received" when the other user did. Always "sent" on a 201; an existing accepted connection the other user started answers "received".
string | null
The note sent with the request, or null.
string
"pending" for a request not yet answered (always, on a 201), "accepted" for an existing connection.
string
ISO timestamp of when the request was sent.
string | null
When the request was accepted, or null while it is pending.

Error Responses

A service key sent no actingUserId.
A user token sent actingUserId, even naming its own user. Only a service key names the user it acts as; a user token always acts as its own user.
A service key named an actingUserId that isn’t a user in this project:
Otherwise, the user to connect with doesn’t exist, or one of the two users has blocked the other. Both get the same answer:
The other user already sent you a connection request. connection is that request, as a connection row seen from your side (type: "received"); accept it with Accept Connection.

See Also