Skip to main content

Assign Category to Product

POST 

/api/categories/assign-category-to-product

Assign a category to a product and optionally set it as the primary category. Uses updateOrCreate so re-posting changes is_primary.

Authentication: Requires Bearer token.

Request body fields:

  • category_id (required) — must be a leaf category
  • product_id (required) — must exist in products table
  • is_primary (optional, boolean) — if true, unsets primary from all other categories for this product

Returns 201 on creation, 200 on update.

Request

Responses

Successful response