> ## 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.

# Remove Connection By User Id

> Remove a connection with another user

This endpoint handles multiple connection removal scenarios based on the current connection status:

* **Decline**: If the specified user sent you a pending request, decline it
* **Withdraw**: If you sent a pending request to the specified user, withdraw it
* **Disconnect**: If you're connected with the specified user, remove the connection

***

## Request

### Path Parameters

| Parameter | Type     | Required | Description                                        |
| --------- | -------- | -------- | -------------------------------------------------- |
| `userId`  | `string` | Yes      | ID of the user to decline/withdraw/disconnect with |

### Headers

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

### Body Parameters

*None*

#### Example Request

```http theme={null}
DELETE /users/user-uuid-123/connection
Authorization: Bearer <ACCESS_TOKEN>
```

***

## Response

### Success Responses

#### Decline (200 OK)

When other user sent you a pending request:

```json theme={null}
{
  "id": "connection-uuid",
  "status": "declined",
  "respondedAt": "2024-01-01T12:05:00.000Z"
}
```

#### Withdraw (200 OK)

When you sent them a pending request:

```json theme={null}
{
  "message": "Connection request withdrawn successfully.",
  "action": "withdraw"
}
```

#### Disconnect (200 OK)

When you're connected:

```json theme={null}
{
  "message": "Connection removed successfully.",
  "action": "disconnect"
}
```

### Error Responses

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

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

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

```json theme={null}
{
  "error": "Cannot disconnect from yourself",
  "code": "connection/self-request"
}
```

#### No Connection Found (404 Not Found)

```json theme={null}
{
  "error": "No connection found between these users that can be removed",
  "code": "connection/not-found"
}
```

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

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

***

## Notes

* Smart endpoint that automatically handles the correct action based on connection status
* **Decline**: Updates connection status to "declined" and sets respondedAt timestamp
* **Withdraw**: Deletes the connection record (allows fresh request later)
* **Disconnect**: Deletes the connection record (allows fresh request later)
* Cannot disconnect from yourself
* Returns different response formats based on the action taken
* Rate limiting: 50 requests per 5 minutes
