» Category POST API Documentation

Posting specific categories

Endpoints:   POST /admin/categories

Purpose

The POST /admin/categories API is used to create a new product category in the system. This endpoint allows administrators to define key category attributes such as name, availability, parent category relationships, product associations, SEO configurations, and metadata. It supports features like scheduled availability, customer-based access restrictions, password protection, and analytics integration. By enabling structured category creation, this API helps businesses organize their product catalogs effectively and enhance customer navigation.

Path Parameters

No path parameters for this endpoint.

Query Parameters 

This endpoint does not have any query parameters.

Use Case

Administrators use POST /admin/categories to add new product categories tailored to specific marketing campaigns, customer groups, or seasonal promotions. This endpoint enables them to define category visibility, restrict access to selected customers, and apply password protection for exclusive sales. Additionally, businesses can configure SEO settings, analytics tracking, and custom metadata to enhance search engine performance and user engagement. By providing structured category management, this API supports efficient inventory organization and product discoverability.

Request Body

{
    "name": "CATEGORY_NAME",
    "sku": "CATEGORY_SKU",
    "title": "CATEGORY_TITLE",
    "heading": "CATEGORY_HEADING",
    "available": CATEGORY_AVAILABLE,
    "category_available": CATEGORY_AVAILABLE_STATUS,
    "parent_category": {
        "id": PARENT_CATEGORY_ID,
        "name": "PARENT_CATEGORY_NAME"
    },
    "product_page": {
        "id": PRODUCT_PAGE_ID
    },
    "category_layout": {
        "id": CATEGORY_LAYOUT_ID
    },
    "product_layout": {
        "id": PRODUCT_LAYOUT_ID
    },
    "availability": {
        "on_date_range": AVAILABILITY_ON_DATE_RANGE,
        "from_date": "AVAILABILITY_FROM_DATE",
        "to_date": "AVAILABILITY_TO_DATE"
    },
    "availability_details": {
        "available_for": "AVAILABLE_FOR",
        "selected_customers": [
            SELECTED_CUSTOMER_ID
        ],
        "restrict_selected_customers": RESTRICT_SELECTED_CUSTOMERS
    },
    "protection_details": {
        "code_protected": CODE_PROTECTED,
        "code_to_protect": "CODE_TO_PROTECT"
    },
    "images": {
        "url": "IMAGE_URL",
        "base_url": "IMAGE_BASE_URL",
        "thumb_url": "IMAGE_THUMB_URL",
        "background_image": IMAGE_BACKGROUND_URL
    },
    "summary": "CATEGORY_SUMMARY",
    "description": "CATEGORY_DESCRIPTION",
    "products": [
        {
            "id": PRODUCT_ID
        }
    ],
    "tax_profile": "TAX_PROFILE_ID",
    "shipping_profile": "SHIPPING_PROFILE_ID",
    "product_sorting": "PRODUCT_SORTING",
    "disable_tracking": DISABLE_TRACKING,
    "loyalty_points": LOYALTY_POINTS,
    "seo_configurations": {
        "url": "SEO_URL",
        "overwrite_seo_settings": OVERWRITE_SEO_SETTINGS,
        "seo_title": "SEO_TITLE",
        "seo_description": "SEO_DESCRIPTION",
        "search_engine_indexing": SEARCH_ENGINE_INDEXING,
        "canonical_url": {
            "enable": CANONICAL_URL_ENABLE,
            "url": [
                "CANONICAL_URL_1",
                "CANONICAL_URL_2"
            ]
        }
    },
    "additional_meta_info": {
        "enable": ADDITIONAL_META_INFO_ENABLE,
        "meta_info": [
            {
                "tag_name": "META_TAG_NAME",
                "tag_content": "META_TAG_CONTENT"
            },
            {
                "name": "META_NAME",
                "value": "META_VALUE"
            }
        ]
    },
    "analytics": {
        "default_product_listing_configurations": DEFAULT_PRODUCT_LISTING_CONFIG,
        "third_party_analytics": {
            "enable": THIRD_PARTY_ANALYTICS_ENABLE,
            "platform": "ANALYTICS_PLATFORM",
            "enable_google_analytics": ENABLE_GOOGLE_ANALYTICS,
            "google_analysis": "GOOGLE_ANALYSIS",
            "google_ads_conversion_id": "GOOGLE_ADS_CONVERSION_ID",
            "google_ads_conversion_label": "GOOGLE_ADS_CONVERSION_LABEL",
            "debug_mode": DEBUG_MODE,
            "facebook_pixel_id": "FACEBOOK_PIXEL_ID",
            "track_event": {
                "enable": TRACK_EVENT_ENABLE,
                "events": {
                    "add_to_cart": ADD_TO_CART,
                    "view_item": VIEW_ITEM,
                    "view_item_list": VIEW_ITEM_LIST,
                    "begin_checkout": BEGIN_CHECKOUT,
                    "purchase": PURCHASE,
                    "remove_from_cart": REMOVE_FROM_CART,
                    "view_cart": VIEW_CART,
                    "add_payment_info": ADD_PAYMENT_INFO,
                    "add_shipping_info": ADD_SHIPPING_INFO,
                    "add_to_wish_list": ADD_TO_WISH_LIST
                }
            }
        },
        "seo_custom_code": {
            "enable": SEO_CUSTOM_CODE_ENABLE,
            "custom_code_in_header": "CUSTOM_CODE_HEADER",
            "custom_code_in_footer": "CUSTOM_CODE_FOOTER"
        },
        "custom_fields_for_order": [
            CUSTOM_FIELD_ID_1,
            CUSTOM_FIELD_ID_2
        ]
    }
}

Response

The API returns a newly created category object containing essential details such as category name, SKU, availability status, associated products, parent category relationships, SEO metadata, and access control settings. The response ensures administrators can verify the successful creation of a category and make further modifications if needed. Key attributes such as product sorting, tax and shipping profiles, and analytics configurations are also included, allowing for seamless integration into the broader e-commerce ecosystem.

POST
https://wcapi.mywebcommander.com/api/v4/admin/categories/
Try It Out
{
    "category": {
        "id": CATEGORY_ID,
        "name": "CATEGORY_NAME",
        "sku": "CATEGORY_SKU",
        "title": "CATEGORY_TITLE",
        "heading": "CATEGORY_HEADING",
        "url": "CATEGORY_URL",
        "available": CATEGORY_AVAILABLE,
        "visible": CATEGORY_VISIBLE,
        "parent_category": {
            "id": PARENT_CATEGORY_ID,
            "name": "PARENT_CATEGORY_NAME",
            "is_in_trash": PARENT_CATEGORY_IS_IN_TRASH,
            "is_parent_in_trash": PARENT_CATEGORY_IS_PARENT_IN_TRASH,
            "is_disposable": PARENT_CATEGORY_IS_DISPOSABLE
        },
        "layout": {},
        "product_page": {
            "id": PRODUCT_PAGE_ID,
            "name": "PRODUCT_PAGE_NAME"
        },
        "product_layout": {
            "id": PRODUCT_LAYOUT_ID,
            "name": "PRODUCT_LAYOUT_NAME"
        },
        "available_on_date_range": AVAILABLE_ON_DATE_RANGE,
        "available_from_date": "AVAILABLE_FROM_DATE",
        "available_to_date": "AVAILABLE_TO_DATE",
        "available_for": "AVAILABLE_FOR",
        "selected_categories": [],
        "password_protected": PASSWORD_PROTECTED,
        "password": "PASSWORD",
        "image_url": IMAGE_URL,
        "background_image_url": IMAGE_BACKGROUND_URL,
        "summary": "CATEGORY_SUMMARY",
        "description": "CATEGORY_DESCRIPTION",
        "products": [
            {
                "id": PRODUCT_ID,
                "name": "PRODUCT_NAME"
            }
        ],
        "shipping_profile": {},
        "tax_profile": {},
        "disable_tracking": DISABLE_TRACKING,
        "seo_configs": [],
        "transaction_no": TRANSACTION_NO,
        "is_disposable": IS_DISPOSABLE,
        "is_in_trash": IS_IN_TRASH,
        "is_parent_in_trash": IS_PARENT_IN_TRASH,
        "created_by": {},
        "created_on": "CREATED_ON_TIMESTAMP",
        "updated_on": "UPDATED_ON_TIMESTAMP"
    }
}