# Product categories

## Create product category

GET `/stores/{store_id}/categories`

This endpoint lets you create a new product category.

**Headers**

| Header          | Type   | Description   |
| --------------- | ------ | ------------- |
| `Authorization` | string | Bearer token. |

**Body request**

```json
{
    "name": "Black Covers", // String | Required | Category name (max 100 characters, trimmed) | Example: "Black Covers", "Electronics", "Clothing"
    "parentCategory": "692592d8f67aff7e9fe0baf0", // String (ObjectId) | Optional | MongoDB ObjectId of parent category (must exist in same store) | Example: "692592d8f67aff7e9fe0baf0", null for top-level categories
    "sortOrder": 2, // Number | Optional | Display order (default: 0, lower numbers appear first) | Example: 0, 1, 2, 10, -1
    "metaTitle": "Black Covers", // String | Optional | SEO meta title for the category page | Example: "Black Covers", "Best Black iPhone Cases"
    "metaDescription": "Black Covers for Iphone 11" // String | Optional | SEO meta description for the category page | Example: "Black Covers for iPhone 11", "Shop premium black phone cases"
}
```

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "success": true,
    "message": "Category created successfully",
    "category": {
        "name": "Black Covers",
        "slug": "black-covers",
        "sortOrder": 2,
        "userStore": "692565f432118c6197abf2ec",
        "creator": "692560a0f3b17397ede28cae",
        "parentCategory": {
            "_id": "692592d8f67aff7e9fe0baf0",
            "name": "Covers",
            "slug": "covers"
        },
        "metaTitle": "Black Covers",
        "metaDescription": "Black Covers for Iphone 11",
        "_id": "692886e78a13ca447bd83a8f",
        "createdAt": "2025-11-27T17:14:15.712Z",
        "updatedAt": "2025-11-27T17:14:15.712Z",
        "__v": 0
    }
}
```

{% endtab %}
{% endtabs %}

## Update product category

PUT `/stores/{store_id}/categories/{category_id}`

This endpoint lets you update a product category.

**Headers**

| Header          | Type   | Description   |
| --------------- | ------ | ------------- |
| `Authorization` | string | Bearer token. |

**Body request**

```json
{
    "name": "Black Covers updated",
    "parentCategory": "692592d8f67aff7e9fe0baf0",
    "sortOrder": 2,
    "metaTitle": "Black Covers",
    "metaDescription": "Black Covers for Iphone 11"
}
```

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "success": true,
    "message": "Category updated successfully",
    "category": {
        "_id": "692886e78a13ca447bd83a8f",
        "name": "Black Covers",
        "slug": "black-covers",
        "sortOrder": 2,
        "userStore": "692565f432118c6197abf2ec",
        "creator": "692560a0f3b17397ede28cae",
        "parentCategory": {
            "_id": "692592d8f67aff7e9fe0baf0",
            "name": "Covers",
            "slug": "covers"
        },
        "metaTitle": "Black Covers",
        "metaDescription": "Black Covers for Iphone 11",
        "createdAt": "2025-11-27T17:14:15.712Z",
        "updatedAt": "2025-11-27T17:14:15.712Z",
        "__v": 0
    }
}
```

{% endtab %}
{% endtabs %}

## Get all product categories

GET `/stores/{store_id}/categories`

This endpoint lets you get all product categories for a store.

**Headers**

| Header          | Type   | Description   |
| --------------- | ------ | ------------- |
| `Authorization` | string | Bearer token. |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "success": true,
    "categories": [
        {
            "_id": "692886e78a13ca447bd83a8f",
            "name": "Black Covers",
            "slug": "black-covers",
            "sortOrder": 2,
            "userStore": "692565f432118c6197abf2ec",
            "creator": "692560a0f3b17397ede28cae",
            "parentCategory": {
                "_id": "692592d8f67aff7e9fe0baf0",
                "name": "Covers",
                "slug": "covers"
            },
            "metaTitle": "Black Covers",
            "metaDescription": "Black Covers for Iphone 11",
            "createdAt": "2025-11-27T17:14:15.712Z",
            "updatedAt": "2025-11-27T17:14:15.712Z",
            "__v": 0
        },
        {
            "_id": "692592d8f67aff7e9fe0baf0",
            "name": "Covers",
            "slug": "covers",
            "sortOrder": 2,
            "userStore": "692565f432118c6197abf2ec",
            "creator": "692560a0f3b17397ede28cae",
            "parentCategory": null,
            "metaTitle": "Shop Smartphones ",
            "metaDescription": "Browse our collection of latest smartphones from top brands.",
            "createdAt": "2025-11-25T11:28:24.314Z",
            "updatedAt": "2025-11-25T12:13:16.701Z",
            "__v": 0
        }
    ],
    "pagination": {
        "currentPage": 1,
        "totalPages": 1,
        "totalCategories": 2,
        "limit": 50
    }
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.searchagora.com/store-builder/product-categories.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
