Skip to main content

Create Releated Product

Create a new related product.

HTTP Request

POST/api/products/:product_id/related

Path Parameters

ParameterTypeRequiredDescription
product_idintegerYesThe unique identifier of the product

Authorization

Authorization

  • Required: Yes
  • Permission: Staff or Admin
  • Authentication: Token-based (Authorization: Token <your_api_key>)

Request Body

FieldTypeRequiredDescription
productsArray[int]YesArray of related product IDs

Example Requests

1import requests
2response = requests.post('http://www.example.com/api/products/123/related', 
3  json={
4      'products': [456, 789, 101]
5  },
6  headers={'Authorization': 'Token <your_token>'}
7
8  print(response.json())
9)

Status Codes

CodeDescription
201Related products created successfully
400Bad Request - Invalid input data
401Unauthorized - Invalid or missing API key
403Forbidden - Access denied
404Not Found - Product not found
500Internal Server Error

Response Fields

FieldTypeDescription
idIntegerUnique ID of the related product entry
activeBooleanWhether the relation is active
image_dataObjectImage details (read-only)
orderIntegerDisplay order priority
codeStringProduct code/SKU
nameStringProduct name
slugStringURL-friendly product identifier
stock_typeStringStock management type
stockIntegerAvailable stock quantity
in_stockBooleanWhether the product is in stock (computed)
regular_priceDecimalOriginal price of the product
sale_priceDecimalSale price (if on sale)
discountDecimalDiscount amount (computed)
discount_percentDecimalDiscount percentage (computed)
priceDecimalFinal price after discount (computed)
price_notesStringAdditional pricing notes
excerptStringShort product description
comments_countIntegerNumber of comments (computed)
ratingDecimalAverage product rating (computed)
descriptionStringFull product description
created_atString (ISO 8601)Timestamp when the relation was created
updated_atString (ISO 8601)Timestamp when the relation was last updated
brand_dataObjectBrand details (id: int, name: string)
categories_dataArray[Object]List of categories the product belongs to (id: int, name: string)

Image Data Structure

FieldTypeDescription
idIntegerUnique ID of the image
typeStringFile type (e.g., image/jpeg)
nameStringOriginal file name
sizeIntegerFile size in bytes
human_readable_sizeStringHuman readable file size (e.g., 2.5 MB)
fStringURL to access the image file
widthIntegerImage width in pixels
heightIntegerImage height in pixels
modeStringColor mode (e.g., RGB, CMYK)

Brand Data Structure

FieldTypeDescription
idIntegerUnique ID of the brand
nameStringName of the brand

Categories Data Structure

FieldTypeDescription
idIntegerUnique ID of the category
nameStringName of the category