PATCH /wp-json/content-api/v1/product/categories/
Updates categories assigned to a specific product by adding new categories while preserving existing ones.
Authentication
This endpoint requires a Bearer token in the Authorization
header. To authenticate:
- Go to Content API > Settings in your WordPress admin panel.
- Set a secure token in the “Token” field and save it.
- Include the token in your request header as follows:
Authorization: Bearer <your-token-here>
Replace <your-token-here>
with the token you configured.
Parameters
Name | Type | Description | Required |
---|---|---|---|
product_id | integer | Product ID | Yes (or SKU) |
sku | string | Product SKU | Yes (or product_id) |
categories | array | Array of category IDs to assign | Yes |
Example Request
{
"product_id": 123,
"categories": [15, 16]
}
Example Response
{
"success": true,
"product_id": 123,
"assigned_category_ids": [15, 16]
}
Possible Errors
Code | Message | Description | HTTP Status |
---|---|---|---|
not_authorized | Not Authorized | The provided Bearer token is invalid or does not match the configured token. | 401 |
missing_identifier | Product ID or SKU is required | Neither product_id nor sku was provided. |
400 |
product_id_invalid | Product ID is invalid | The provided product_id is not a valid number. |
400 |
sku_invalid | SKU is invalid | The provided sku contains invalid characters. |
400 |
conflicting_identifiers | Both Product ID and SKU are provided. Please provide only one. | Both product_id and sku were provided. |
400 |
product_not_found | Product not found | The specified product does not exist. | 404 |
invalid_input | Categories empty | The categories array is empty. |
400 |
category_not_found | Category ID [id] does not exist | One or more provided category IDs do not exist. | 404 |