AddProduct

POST /products

Create a product

application/json

Body

  • publisherId string Required

    Minimum length is 1.

  • image string(uri) Required

    Minimum length is 1.

  • title string Required

    Minimum length is 5, maximum length is 200.

  • size string
  • price number(double) Required

    Minimum value is 0.

  • description string Required

    Minimum length is 2, maximum length is 500.

  • type string Required

    Values are insect or plant.

  • category string
  • subcategory string

Responses

  • 201 application/json

    Created

    Hide response attributes Show response attributes object
    • _id string Required
    • publisherId object Required

      User schema

      Hide publisherId attributes Show publisherId attributes object
      • _id string Required

        Unique identifier for the given user.

      • firstName string Required

        Minimum length is 2, maximum length is 30.

      • email string(email) Required
      • username string Required

        Unique identifier for the given user.

      • password string(password) Required
      • lastName string Required

        Minimum length is 2, maximum length is 30.

      • dateOfBirth string(date-time) Required
      • emailVerified boolean

        Set to true if the user's email has been verified.

      • createDate string(date)

        The date that the user was created.

      • location string
      • image string
    • images array[string(uri)]
    • title string Required
    • size string
    • price number Required
    • type string Required

      Values are plant or insect.

    • description string

      Maximum length is 500.

    • publishedDate string(date)
    • sold boolean
    • category object
      Hide category attributes Show category attributes object
      • type string Required

        Values are plant or insect.

      • category string Required

        Minimum length is 2, maximum length is 20.

      • subcategory string

        Minimum length is 2, maximum length is 20.

  • 400

    Bad Request

  • 401

    Unauthorized

  • 500

    Internal Server Error

POST /products
curl \
 --request POST 'https://garden-to-yours.herokuapp.com/products' \
 --header "Authorization: Bearer $ACCESS_TOKEN" \
 --header "Content-Type: application/json" \
 --data '{"type":"plant","image":"http://example.com","price":20,"title":"La planta que come","description":"Es una planta carnivora","publisherId":"5345345fdsfg"}'
Request example
{
  "type": "plant",
  "image": "http://example.com",
  "price": 20,
  "title": "La planta que come",
  "description": "Es una planta carnivora",
  "publisherId": "5345345fdsfg"
}
Response examples (201)
{
  "_id": "string",
  "publisherId": {
    "_id": "string",
    "firstName": "string",
    "email": "hello@example.com",
    "username": "string",
    "password": "string",
    "lastName": "string",
    "dateOfBirth": "2000-08-24T00:00:00.000Z",
    "emailVerified": true,
    "createDate": "2025-05-04",
    "location": "string",
    "image": "string"
  },
  "images": [
    "https://example.com"
  ],
  "title": "string",
  "size": "string",
  "price": 42.0,
  "type": "plant",
  "description": "string",
  "publishedDate": "2025-05-04",
  "sold": true,
  "category": {
    "type": "plant",
    "category": "string",
    "subcategory": "string"
  }
}