Skip to main content

Overview

The Categories API provides comprehensive category management for organizing products in your marketplace. It supports both global categories (available to all stores) and store-specific categories, creating a flexible hierarchical structure. Location: convex/shared/categories.ts

Create Store Category

Creates a new store-specific category under the store’s primary category.
name
string
required
Category name (1-100 characters)

Update Store Category

Updates a store-specific category name.
categoryId
Id<'categories'>
required
Category ID to update
name
string
required
Updated category name

Delete Store Category

Deletes a store-specific category.
categoryId
Id<'categories'>
required
Category ID to delete

Get Parent Categories

Retrieves all parent categories (categories with no parent).

Get Categories by Parent ID

Retrieves all child categories under a parent category.
parent
Id<'categories'>
required
Parent category ID

Get Global Categories

Retrieves all global categories (not store-specific).

Get Store Categories

Retrieves all categories for a specific store.
storeId
Id<'stores'>
required
Store ID

Get Available Categories for Store

Retrieves all categories available to a store (global + store-specific).
storeId
Id<'stores'>
required
Store ID

Category Hierarchy

Categories follow a hierarchical structure:

Error Handling

Status Code: 404
Status Code: 400
Status Code: 400

Best Practices

Hierarchical Organization

Use the parent-child relationship to create logical product organization that customers can navigate easily.

Naming Convention

Use clear, descriptive names that customers will understand. Avoid technical jargon or internal codes.

Global vs Store Categories

Use global categories for broad classifications and store categories for specific subcategories unique to your store.

Category Maintenance

Regularly review and optimize your category structure based on customer behavior and product performance.
Categories are automatically indexed for search functionality. Changes to category names are reflected in search results immediately.
Store-specific categories are automatically created under your store’s primary category, ensuring proper hierarchy and organization.