> ## Documentation Index
> Fetch the complete documentation index at: https://replyke-feat-push-rich-payload-fields.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Request Connection

> Send a connection request to another user

Send a connection request to another user. Connections are bidirectional relationships that require mutual agreement between two users.

***

## Request

### Path Parameters

| Parameter | Type     | Required | Description                                  |
| --------- | -------- | -------- | -------------------------------------------- |
| `userId`  | `string` | Yes      | ID of the user to send connection request to |

### Headers

| Header          | Type     | Required | Description                      |
| --------------- | -------- | -------- | -------------------------------- |
| `Authorization` | `string` | Yes      | Bearer token for authentication. |

### Body Parameters

| Parameter | Type     | Required | Description                              |
| --------- | -------- | -------- | ---------------------------------------- |
| `message` | `string` | No       | Optional message with connection request |

#### Example Request

```http theme={null}
POST /users/user-uuid-123/connection
Authorization: Bearer <ACCESS_TOKEN>
Content-Type: application/json

{
  "message": "Hi! I'd like to connect with you."
}
```

***

## Response

### Success Response (201 Created)

```json theme={null}
{
  "id": "connection-uuid",
  "status": "pending",
  "createdAt": "2024-01-01T12:00:00.000Z"
}
```

### Error Responses

#### Invalid User ID (400 Bad Request)

```json theme={null}
{
  "error": "Invalid or missing userId",
  "code": "connection/invalid-receiver-id"
}
```

#### Self-Request Attempt (400 Bad Request)

```json theme={null}
{
  "error": "Cannot send request to self",
  "code": "connection/self-request"
}
```

#### User Not Found (404 Not Found)

```json theme={null}
{
  "error": "User doesn't exist",
  "code": "connection/user-not-found"
}
```

#### Connection Already Exists (409 Conflict)

Request already pending:

```json theme={null}
{
  "error": "Request already pending",
  "code": "connection/request-pending"
}
```

Already connected:

```json theme={null}
{
  "error": "Users already connected",
  "code": "connection/already-connected"
}
```

Previous request declined:

```json theme={null}
{
  "error": "Previous request declined, only receiver can re-initiate",
  "code": "connection/request-declined"
}
```

#### Server Error (500 Internal Server Error)

```json theme={null}
{
  "error": "Internal server error",
  "code": "connection/server-error"
}
```

***

## Notes

* Creates a connection request with "pending" status
* Receiver will be notified of the connection request
* Cannot send requests to yourself
* Only one active connection record between any two users
* If previous request was declined, only the original receiver can create a new request
* Rate limiting: 25 requests per 5 minutes
