Send a chat message

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

Send a new message in the chat for a specific swap request with book swap context. User must be sender or receiver. Supports text message, images, or both.

Path parameters

  • id string Required

    Swap request ID

Query parameters

  • userId string Required

    User ID

  • request object Required
    Hide request attributes Show request attributes object
    • message string

      The message content to send

      Minimum length is 0, maximum length is 1000.

    • images array[string(binary)]

      Images to attach to the message (optional)

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 send messages in this chat

  • 400

    Invalid message content or images

  • 201 */*

    Message sent 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
POST /api/v1/swap-requests/{id}/chat
curl \
 --request POST 'http://localhost:8080/api/v1/swap-requests/{id}/chat?userId=string&request=%7B%7D'
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 (201)
{
  "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
  }
}