PATCH /wp-json/content-api/v1/product/brands/
Updates product brands for a specific product.
Content API Version: 1.0.1
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
Replace
with the token you configured.
Parameters
Name | Type | Description | Required |
---|---|---|---|
product_id | integer | Product ID | Yes |
brands | array | Array of brand names, slugs, or IDs | Yes |
taxonomy | string | Taxonomy name (defaults to product_brand ) |
No |
append | boolean | If true, appends brands; if false, replaces existing brands (defaults to true) | No |
create_brand | boolean | If true, creates new brands if they don’t exist (defaults to false) | No |
Example Request
{
"product_id": 123,
"brands": ["Brand A", "Brand B"],
"taxonomy": "product_brand",
"append": false,
"create_brand": true
}
Example Response
{
"success": true,
"message": "Product brands updated successfully",
"data": [1, 2]
}
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 |
invalid_product_id | Valid Product ID is required | The provided product_id is missing or not a valid number. |
400 |
invalid_brands | Brands must be a non-empty array | The brands parameter is not an array or is empty. |
400 |
product_not_found | Product not found | The provided product_id does not correspond to a valid product. |
404 |
no_valid_terms | No valid brand terms found or created | No valid brand terms were found or created based on the provided brands. | 400 |
update_failed | Failed to update product brands | An error occurred while updating the product brands. | 500 |