Create swap request for a book.

POST /api/v1/swap-requests

Create swap request for a book.

application/json

Body Required

  • senderId string

    The ID of the sender of swap request.

  • receiverId string

    The ID of the receiver of swap request.

  • bookIdToSwapWith string

    The ID of the book a user want to swap with.

  • swapType string

    Swap condition type of the book.

  • swapOffer object
    Hide swapOffer attributes Show swapOffer attributes object
    • offeredBookId string

      The ID of the book offered for swap request.

    • offeredGenreId string

      The ID of the genre offered for swap request.

  • askForGiveaway boolean

    Ask to give away the book.

  • note string

    Add personal note to request.

Responses

  • 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 */*

    Not Found

    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
  • 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
  • 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 */*

    Swap request sent.

    Hide response attributes Show response attributes object
    • id string
    • senderId string
    • receiverId string
    • bookToSwapWith object
      Hide bookToSwapWith attributes Show bookToSwapWith attributes object
      • id string
      • title string
      • author string
      • genres array[string]
      • language string
      • description string
      • condition string
      • coverPhotoUrls array[string]
      • owner object
        Hide owner attributes Show owner attributes object
        • id string
        • name string
      • swapCondition object
        Hide swapCondition attributes Show swapCondition attributes object
        • swapType string
        • giveAway boolean
        • openForOffers boolean
        • swappableGenres array[object]
          Hide swappableGenres attributes Show swappableGenres attributes object
          • id string
          • name string
        • swappableBooks array[object]
          Hide swappableBooks attributes Show swappableBooks attributes object
          • id string
          • title string
          • author string
          • coverPhotoUrl string
    • swapType string
    • swapOffer object
      Hide swapOffer attributes Show swapOffer attributes object
      • offeredBook object
        Hide offeredBook attributes Show offeredBook attributes object
        • id string
        • title string
        • author string
        • coverPhotoUrl string
      • offeredGenre object
        Hide offeredGenre attributes Show offeredGenre attributes object
        • id string
        • name string
    • askForGiveaway boolean
    • swapStatus string
    • note string
    • requestedAt string(date-time)
    • updatedAt string(date-time)
POST /api/v1/swap-requests
curl \
 --request POST 'http://localhost:8080/api/v1/swap-requests' \
 --header "Content-Type: application/json" \
 --data '{"senderId":123456,"receiverId":123456,"bookIdToSwapWith":123456,"swapType":"ByBooks/ByGenres/GiveAway/OpenForOffers","swapOffer":{"offeredBookId":123456,"offeredGenreId":123456},"askForGiveaway":true,"note":"I want this book, how can I get it?"}'
Request examples
{
  "senderId": 123456,
  "receiverId": 123456,
  "bookIdToSwapWith": 123456,
  "swapType": "ByBooks/ByGenres/GiveAway/OpenForOffers",
  "swapOffer": {
    "offeredBookId": 123456,
    "offeredGenreId": 123456
  },
  "askForGiveaway": true,
  "note": "I want this book, how can I get it?"
}
Response examples (401)
{
  "error": {
    "code": "string",
    "message": "string",
    "target": "string",
    "details": [
      {
        "code": "string",
        "message": "string",
        "target": "string"
      }
    ]
  }
}
Response examples (404)
{
  "error": {
    "code": "string",
    "message": "string",
    "target": "string",
    "details": [
      {
        "code": "string",
        "message": "string",
        "target": "string"
      }
    ]
  }
}
Response examples (500)
{
  "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",
  "senderId": "string",
  "receiverId": "string",
  "bookToSwapWith": {
    "id": "string",
    "title": "string",
    "author": "string",
    "genres": [
      "string"
    ],
    "language": "string",
    "description": "string",
    "condition": "string",
    "coverPhotoUrls": [
      "string"
    ],
    "owner": {
      "id": "string",
      "name": "string"
    },
    "swapCondition": {
      "swapType": "string",
      "giveAway": true,
      "openForOffers": true,
      "swappableGenres": [
        {
          "id": "string",
          "name": "string"
        }
      ],
      "swappableBooks": [
        {
          "id": "string",
          "title": "string",
          "author": "string",
          "coverPhotoUrl": "string"
        }
      ]
    }
  },
  "swapType": "string",
  "swapOffer": {
    "offeredBook": {
      "id": "string",
      "title": "string",
      "author": "string",
      "coverPhotoUrl": "string"
    },
    "offeredGenre": {
      "id": "string",
      "name": "string"
    }
  },
  "askForGiveaway": true,
  "swapStatus": "string",
  "note": "string",
  "requestedAt": "2025-05-04T09:42:00Z",
  "updatedAt": "2025-05-04T09:42:00Z"
}