Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ricpalomino/spring-boot/llms.txt

Use this file to discover all available pages before exploring further.

The create endpoint adds a new product to the in-memory store. You must supply a name and a price in the JSON request body. On success, the API returns HTTP 201 with the created product, including its auto-assigned numeric ID. If the request body fails validation, the API returns HTTP 400 without creating anything.
Product IDs are assigned automatically, starting at 1 and incrementing by 1 for each new product. You cannot set or predict the ID in advance — always read the id from the response after creation.

Request body

name
string
required
The product name. Must be between 3 and 100 characters and cannot be blank.
price
number
required
The product price. Must be greater than 0 (minimum value: 1).

Request

curl --request POST \
  --url http://localhost:8080/api/v1/products \
  --header "Content-Type: application/json" \
  --data '{
    "name": "Mechanical Keyboard",
    "price": 149.99
  }'

Response fields

responseCode
string
HTTP status code as a string (e.g., "201", "400").
responseMessage
string
Human-readable message describing the result.
data
object | null
The newly created product object, or null on validation failure.

Created response — 201

{
  "responseCode": "201",
  "responseMessage": "Producto creado correctamente",
  "data": {
    "id": 4,
    "name": "Mechanical Keyboard",
    "price": 149.99
  }
}

Validation error response — 400

Returned when name is blank or too short/long, or when price is less than 1. The data field contains a map of failing field names to their constraint violation messages.
{
  "responseCode": "400",
  "responseMessage": "Error de validación",
  "data": {
    "name": "El nombre del producto debe tener entre 3 y 100 caracteres",
    "price": "El precio del producto debe ser mayor a 0"
  }
}

Build docs developers (and LLMs) love