Skip to main content

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

FieldTypeRequiredDescription
typeStringYes"user:friendship"
idStringYesUnique event ID.
timeLongYesEvent generation time (Unix ms).
dataArrayYesArray containing one friendship event object. See Data fields.

Data fields

FieldTypeRequiredDescription
operationTypeNumberYesEvent type. See Operation types.
userIdStringYesThe user ID of the party who initiated the action.
toUserIdStringYesThe user ID of the other party.
timeLongYesTime the action was performed (Unix ms).
osStringYesPlatform where the action originated. One of: Android, iOS, Websocket, Server.
extraStringNoAdditional data attached to the request. Typically present when operationType is 1 (friend request).

Operation types

ValueMeaning
1Friend request sentuserId sent a friend request to toUserId.
2Friend request acceptedtoUserId accepted the request from userId.
3Friend request rejectedtoUserId rejected the request from userId.
4Friend removeduserId removed toUserId from their friend list.
5Server-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\"}"
}
]
}