POST /wp-json/content-api/v1/product-category/
Creates a new product product category.
Content API Version: 1.0.3
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 |
---|---|---|---|
name | string | The name of the product category to create | Yes |
taxonomy | string | Taxonomy name (defaults to product_cat ) |
No |
description | string | The description of the product category | No |
slug | string | The slug of the product category | No |
parent | integer | The ID of the parent product category (set to 0 for no parent) | No |
yoast | object | Yoast SEO meta fields (title, description, premium social data) | No |
Example Request
POST /wp-json/content-api/v1/product-category/
Content-Type: application/json
{
"name": "New Product Category",
"taxonomy": "product_cat",
"description": "Description for New Product Category",
"slug": "new-product-category",
"parent": 0,
"yoast": {
"title": "New Product Category Title",
"description": "New Product Category Description",
"premium": {
"social_appearance": {
"title": "New Product Category Social Title",
"description": "New Product Category Social Description",
"image": "https://example.com/wp-content/uploads/new-product-category-social.jpg"
},
"x": {
"title": "New Product Category X Title",
"description": "New Product Category X Description",
"image": "https://example.com/wp-content/uploads/new-product-category-x.jpg"
}
}
}
}
Example Response
{
"success": true,
"product_category_id": 3,
"message": "Product category created successfully."
}
Possible Errors
Code | Message | Description | HTTP Status |
---|---|---|---|
missing_name | Product category name is required. | No product category name was provided in the request. | 400 |
invalid_parent | The specified parent product category does not exist. | The provided parent ID does not correspond to an existing product category. | 400 |
term_creation_failed | [Error message from WordPress] | An error occurred while creating the product category term. | 500 |
not_authorized | Not Authorized | The provided Bearer token is invalid or does not match the configured token. | 401 |