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.

Required scope: products:write

Grant this scope to your token under Settings → Developer → Personal Access Tokens.

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.

Requires permission: categories.update

Request

Responses

Created

Response Headers
    Content-Type