Перейти к основному содержимому

GET /api/v1/p2p/sessions

Retrieve all active P2P order chat sessions for the authenticated user. Returns a list of orders that have active chats, along with the last message and unread message count for each session.

Authentication

Required. The request must include a valid Bearer token in the Authorization header.

Request

No parameters required.

Example

curl -X GET https://example.com/api/v1/p2p/sessions \
-H "Authorization: Bearer <token>"

Response

200 OK

Returns an object with sessions array. Each session is a P2POrderWithLastMessage object (P2P order fields plus last_message, author_id, and counterpart).

{
"sessions": [
{
"id": 101,
"ad_id": 42,
"buyer_id": 15,
"seller_id": 7,
"usdt_amount": 500000,
"fiat_amount": 500000,
"fiat_currency": "RUB",
"exchange_rate": 100,
"payment_method": "sber",
"status": "pending",
"frozen_balance": 500000,
"operator_called": false,
"created_at": "2026-04-04T12:00:00Z",
"updated_at": "2026-04-04T12:12:00Z",
"author_id": 7,
"last_message": {
"id": 3,
"order_id": 101,
"user_id": 15,
"sender_type": "user",
"message": "Payment sent, please check your account.",
"created_at": "2026-04-04T12:12:00Z"
},
"counterpart": {
"id": 7,
"name": "Petr",
"nickname": "petr42",
"avatar_url": "https://cdn.example.com/avatars/7.png"
}
}
]
}

Error Responses

StatusCodeDescription
401UNAUTHORIZEDMissing or invalid authentication token.