Skip to main content

Update Product Dimensions

Update an existing product dimensions record with new measurements or dimension unit.

Endpoint

PUT /api/v1/product-dimensions/{id}

Path Parameters

id
integer
required
The unique identifier of the product dimensions record to update

Request Body

productId
integer
required
ID of the product to associate dimensions with
lengthCm
number
required
Length of the product in centimeters
widthCm
number
required
Width of the product in centimeters
heightCm
number
required
Height of the product in centimeters
dimensionUnit
string
required
Unit of measurement for dimensions (e.g., “cm”, “inches”)

Response

id
integer
Unique identifier for the product dimensions
productId
integer
ID of the associated product
lengthCm
number
Length of the product in centimeters
widthCm
number
Width of the product in centimeters
heightCm
number
Height of the product in centimeters
dimensionUnit
string
Unit of measurement for dimensions
createdAt
string
Timestamp when the record was originally created

Status Codes

200
OK
Product dimensions successfully updated
400
Bad Request
Invalid request body or validation error
404
Not Found
Product dimensions not found

Example Request

curl -X PUT https://api.example.com/api/v1/product-dimensions/1 \
  -H "Content-Type: application/json" \
  -d '{
    "productId": 101,
    "lengthCm": 210.0,
    "widthCm": 95.0,
    "heightCm": 90.0,
    "dimensionUnit": "cm"
  }'

Example Response

{
  "id": 1,
  "productId": 101,
  "lengthCm": 210.0,
  "widthCm": 95.0,
  "heightCm": 90.0,
  "dimensionUnit": "cm",
  "createdAt": "2024-01-15T10:30:00"
}

Validation Rules

  • productId must be a valid integer and reference an existing product
  • lengthCm, widthCm, and heightCm must be positive numbers
  • dimensionUnit must be a non-empty string
  • All required fields must be provided

Error Responses

Not Found:
{
  "status": 404,
  "error": "Not Found",
  "message": "Product dimensions not found with id: 1"
}
Validation Error:
{
  "status": 400,
  "error": "Bad Request",
  "message": "Validation failed",
  "errors": [
    {
      "field": "widthCm",
      "message": "must be greater than 0"
    }
  ]
}

Build docs developers (and LLMs) love