Categories

The categories you group your products, services, and events into.

API docs: Categories

List categories

GET/api/v1/categoriesAny catalog read

Returns all of your categories, sorted by name. A store has at most 25 categories, so this list is never paginated: has_more is always false. Deleted categories are never returned.

Request
curl "https://e2c.store/api/v1/categories" \
  -H "Authorization: Bearer $E2C_API_KEY"
Response
{
  "data": [
    { "code": "markets", "name": "Markets", "status": "active", "counts": { "products": 0, "services": 0, "events": 2 } },
    { "code": "tops", "name": "Tops", "status": "active", "counts": { "products": 14, "services": 0, "events": 0 } }
  ],
  "has_more": false,
  "next_cursor": null
}

counts is the number of non-deleted listings in the category, and only includes the types your key can read: a key with just products:read gets { "products": 14 }. To list a category's listings, pass its code as the category filter on Products, Services, or Events.

Retrieve a category

GET/api/v1/categories/{code}Any catalog read

Returns one category by its code. Category codes are unique within your store.

Request
curl "https://e2c.store/api/v1/categories/tops" \
  -H "Authorization: Bearer $E2C_API_KEY"
Response
{
  "data": { "code": "tops", "name": "Tops", "status": "active", "counts": { "products": 14, "services": 0, "events": 0 } }
}

Every product, service, and event also includes its category as { "code", "name" }, or null when it isn't in a category.

Create a category

POST/api/v1/categoriescategories:write

Adds a category. Only name is required. When you leave out code, one is made from the name, with a number added if it's taken. New categories are active unless you send "status": "inactive".

Body fields

FieldDescription
namestringUp to 25 characters, plain text. Unique within your store, and can't be "All".
codestringUp to 25 lowercase letters, numbers, and single hyphens, like summer-tops. Used in the category's URL.
statusstringactive shows the category on your storefront; inactive hides it.
Request
curl -X POST "https://e2c.store/api/v1/categories" \
  -H "Authorization: Bearer $E2C_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Summer Tops" }'
Response
{
  "data": { "code": "summer-tops", "name": "Summer Tops", "status": "active", "counts": { "products": 0 } }
}

Returns 201. A store has at most 25 categories; past that you get 409 limit_reached. A name or code that's already used returns 409 conflict. To put products in the category, set their category with Update a product.

Update a category

PATCH/api/v1/categories/{code}categories:write

Renames a category, changes its code, or shows or hides it. Only the fields you send change. Products in the category stay in it when its code changes.

Body fields

FieldDescription
namestringUp to 25 characters, plain text. Unique within your store, and can't be "All".
codestringUp to 25 lowercase letters, numbers, and single hyphens, like summer-tops. Used in the category's URL.
statusstringactive shows the category on your storefront; inactive hides it.
Request
curl -X PATCH "https://e2c.store/api/v1/categories/summer-tops" \
  -H "Authorization: Bearer $E2C_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "status": "inactive" }'
Response
{
  "data": { "code": "summer-tops", "name": "Summer Tops", "status": "inactive", "counts": { "products": 6 } }
}

counts in write responses follows the same rule as reads: it only includes listing types your key can read, so a key with only categories:write gets {}.