Get chat messages for a swap request

GET /api/v1/swap-requests/{id}/chat

Retrieve all chat messages for a specific swap request with book swap context. User must be sender or receiver. Automatically marks messages as read.

Path parameters

  • id string Required

    Swap request ID

Query parameters

  • userId string Required

    User ID

Responses

  • 500 */*

    Internal Server Error

    Hide response attribute Show response attribute object
    • error object
      Hide error attributes Show error attributes object
      • code string
      • message string
      • target string
      • details array[object]
        Hide details attributes Show details attributes object
        • code string
        • message string
        • target string
  • 401 */*

    Unauthorized

    Hide response attribute Show response attribute object
    • error object
      Hide error attributes Show error attributes object
      • code string
      • message string
      • target string
      • details array[object]
        Hide details attributes Show details attributes object
        • code string
        • message string
        • target string
  • 404

    Swap request not found

  • 403

    Access denied - user not authorized to view this chat

  • 400 */*

    Bad Request

    Hide response attribute Show response attribute object
    • error object
      Hide error attributes Show error attributes object
      • code string
      • message string
      • target string
      • details array[object]
        Hide details attributes Show details attributes object
        • code string
        • message string
        • target string
  • 200 */*

    Chat messages retrieved successfully

    Hide response attributes Show response attributes object
    • id string
    • swapRequestId string
    • sender object
      Hide sender attributes Show sender attributes object
      • id string
      • name string
    • message string
    • imageUrls array[string]
    • sentAt string(date-time)
    • readByReceiver boolean
    • ownMessage boolean
    • swapContext object
      Hide swapContext attributes Show swapContext attributes object
      • requestedBook object
        Hide requestedBook attributes Show requestedBook attributes object
        • id string
        • title string
        • author string
        • condition string
        • coverPhotoUrl string
      • offeredBook object
        Hide offeredBook attributes Show offeredBook attributes object
        • id string
        • title string
        • author string
        • condition string
        • coverPhotoUrl string
      • offeredGenreName string
      • swapType string
      • swapStatus string
      • askForGiveaway boolean
GET /api/v1/swap-requests/{id}/chat
curl \
 --request GET 'http://localhost:8080/api/v1/swap-requests/{id}/chat?userId=string'
Response examples (500)
{
  "error": {
    "code": "string",
    "message": "string",
    "target": "string",
    "details": [
      {
        "code": "string",
        "message": "string",
        "target": "string"
      }
    ]
  }
}
Response examples (401)
{
  "error": {
    "code": "string",
    "message": "string",
    "target": "string",
    "details": [
      {
        "code": "string",
        "message": "string",
        "target": "string"
      }
    ]
  }
}
Response examples (400)
{
  "error": {
    "code": "string",
    "message": "string",
    "target": "string",
    "details": [
      {
        "code": "string",
        "message": "string",
        "target": "string"
      }
    ]
  }
}
Response examples (200)
[
  {
    "id": "string",
    "swapRequestId": "string",
    "sender": {
      "id": "string",
      "name": "string"
    },
    "message": "string",
    "imageUrls": [
      "string"
    ],
    "sentAt": "2025-05-04T09:42:00Z",
    "readByReceiver": true,
    "ownMessage": true,
    "swapContext": {
      "requestedBook": {
        "id": "string",
        "title": "string",
        "author": "string",
        "condition": "string",
        "coverPhotoUrl": "string"
      },
      "offeredBook": {
        "id": "string",
        "title": "string",
        "author": "string",
        "condition": "string",
        "coverPhotoUrl": "string"
      },
      "offeredGenreName": "string",
      "swapType": "string",
      "swapStatus": "string",
      "askForGiveaway": true
    }
  }
]