User friendship
The user:friendship event fires when a friendship relationship between two users changes. This includes friend requests, acceptances, rejections, removals, and server-initiated additions.
For the complete webhook setup and signature verification guide, see Webhooks overview.
Event type
user:friendship
Payload
Envelope
| Field | Type | Required | Description |
|---|---|---|---|
type | String | Yes | "user:friendship" |
id | String | Yes | Unique event ID. |
time | Long | Yes | Event generation time (Unix ms). |
data | Array | Yes | Array containing one friendship event object. See Data fields. |
Data fields
| Field | Type | Required | Description |
|---|---|---|---|
operationType | Number | Yes | Event type. See Operation types. |
userId | String | Yes | The user ID of the party who initiated the action. |
toUserId | String | Yes | The user ID of the other party. |
time | Long | Yes | Time the action was performed (Unix ms). |
os | String | Yes | Platform where the action originated. One of: Android, iOS, Websocket, Server. |
extra | String | No | Additional data attached to the request. Typically present when operationType is 1 (friend request). |
Operation types
| Value | Meaning |
|---|---|
1 | Friend request sent — userId sent a friend request to toUserId. |
2 | Friend request accepted — toUserId accepted the request from userId. |
3 | Friend request rejected — toUserId rejected the request from userId. |
4 | Friend removed — userId removed toUserId from their friend list. |
5 | Server-initiated add — The friendship was created directly via the server API, bypassing the request/accept flow. |
Example
JSON
{
"type": "user:friendship",
"id": "550e8400-e29b-41d4-a716-446655440004",
"time": 1730192400000,
"data": [
{
"operationType": 2,
"userId": "user_001",
"toUserId": "user_002",
"time": 1730192400000,
"os": "iOS",
"extra": "{\"greeting\":\"Hi\"}"
}
]
}