> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ya.works/llms.txt
> Use this file to discover all available pages before exploring further.

# Categories and Catalogs

> Query catalogs and manage categories before creating products

# Categories and Catalogs

Categories and catalogs are prerequisite entities for creating products. This guide covers how to query and manage them.

## Catalogs

Catalogs are created automatically when the merchant is registered. The API only allows querying them to get the `catalog_id`.

### List Catalogs

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://api.ya.onl/v1/catalogs" \
    -H "X-API-Key: yv_live_v1_your_api_key"
  ```

  ```python Python theme={null}
  import httpx

  response = httpx.get(
      "https://api.ya.onl/v1/catalogs",
      headers={"X-API-Key": "yv_live_v1_your_api_key"},
  )
  catalogs = response.json()
  catalog_id = catalogs["data"][0]["id"]
  print(f"Catalog ID: {catalog_id}")
  ```

  ```javascript Node.js theme={null}
  const response = await fetch("https://api.ya.onl/v1/catalogs", {
    headers: { "X-API-Key": "yv_live_v1_your_api_key" },
  });
  const catalogs = await response.json();
  const catalogId = catalogs.data[0].id;
  console.log(`Catalog ID: ${catalogId}`);
  ```
</CodeGroup>

<Warning>
  Every merchant has a catalog created automatically. Use the `id` from the first result as `catalog_id` when creating products and categories.
</Warning>

## Categories

Categories are global labels that you can assign to multiple products. They are managed independently.

### Create Category

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.ya.onl/v1/categories" \
    -H "X-API-Key: yv_live_v1_your_api_key" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Ropa",
      "catalog_id": 1
    }'
  ```

  ```python Python theme={null}
  import httpx

  response = httpx.post(
      "https://api.ya.onl/v1/categories",
      headers={"X-API-Key": "yv_live_v1_your_api_key"},
      json={"name": "Ropa", "catalog_id": 1},
  )
  category = response.json()
  print(f"Category ID: {category['id']}")
  ```

  ```javascript Node.js theme={null}
  const response = await fetch("https://api.ya.onl/v1/categories", {
    method: "POST",
    headers: {
      "X-API-Key": "yv_live_v1_your_api_key",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ name: "Ropa", catalog_id: 1 }),
  });
  const category = await response.json();
  console.log(`Category ID: ${category.id}`);
  ```
</CodeGroup>

### List Categories

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://api.ya.onl/v1/categories?page=1&limit=20" \
    -H "X-API-Key: yv_live_v1_your_api_key"
  ```

  ```python Python theme={null}
  import httpx

  response = httpx.get(
      "https://api.ya.onl/v1/categories",
      params={"page": 1, "limit": 20},
      headers={"X-API-Key": "yv_live_v1_your_api_key"},
  )
  print(response.json())
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    "https://api.ya.onl/v1/categories?page=1&limit=20",
    {
      headers: { "X-API-Key": "yv_live_v1_your_api_key" },
    }
  );
  const data = await response.json();
  console.log(data);
  ```
</CodeGroup>

### Update Category

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PATCH "https://api.ya.onl/v1/categories/1" \
    -H "X-API-Key: yv_live_v1_your_api_key" \
    -H "Content-Type: application/json" \
    -d '{"name": "Ropa y Accesorios"}'
  ```

  ```python Python theme={null}
  import httpx

  response = httpx.patch(
      "https://api.ya.onl/v1/categories/1",
      headers={"X-API-Key": "yv_live_v1_your_api_key"},
      json={"name": "Ropa y Accesorios"},
  )
  print(response.json())
  ```

  ```javascript Node.js theme={null}
  const response = await fetch("https://api.ya.onl/v1/categories/1", {
    method: "PATCH",
    headers: {
      "X-API-Key": "yv_live_v1_your_api_key",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ name: "Ropa y Accesorios" }),
  });
  const data = await response.json();
  console.log(data);
  ```
</CodeGroup>

### Delete Category

<CodeGroup>
  ```bash cURL theme={null}
  curl -X DELETE "https://api.ya.onl/v1/categories/1" \
    -H "X-API-Key: yv_live_v1_your_api_key"
  ```

  ```python Python theme={null}
  import httpx

  response = httpx.delete(
      "https://api.ya.onl/v1/categories/1",
      headers={"X-API-Key": "yv_live_v1_your_api_key"},
  )
  print(response.status_code)  # 204
  ```

  ```javascript Node.js theme={null}
  const response = await fetch("https://api.ya.onl/v1/categories/1", {
    method: "DELETE",
    headers: { "X-API-Key": "yv_live_v1_your_api_key" },
  });
  console.log(response.status); // 204
  ```
</CodeGroup>

<Warning>
  Deleting a category automatically unlinks it from all products that had it assigned. This action cannot be undone.
</Warning>

## Next Step

Once you have your `catalog_id` and the categories created, you can start [managing products](/en/products/manage-products).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.