Skip to main content

Create Product Dimensions

Create a new product dimensions record with length, width, height, and measurement unit information.

Endpoint

POST /api/v1/product-dimensions

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 newly created 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 created

Status Codes

201
Created
Product dimensions successfully created
400
Bad Request
Invalid request body or validation error

Example Request

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

Example Response

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

Response Headers

The response includes a Location header with the URI of the created resource:
Location: /api/v1/product-dimensions/1

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 Response

{
  "status": 400,
  "error": "Bad Request",
  "message": "Validation failed",
  "errors": [
    {
      "field": "lengthCm",
      "message": "must be greater than 0"
    }
  ]
}

Build docs developers (and LLMs) love