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

# Delete Category

> Soft delete a product category

## Authorization

<ParamField header="Authorization" type="string" required>
  Bearer token for authentication. Format: `Bearer qwoty_your_token`
</ParamField>

## Path Parameters

<ParamField path="id" type="string" required>
  Category UUID
</ParamField>

## Behavior

This endpoint performs a **soft delete** by setting the `deleted_at` timestamp on the category. The category will no longer appear in standard API queries but is not permanently removed from the database.

<Warning>
  Deletion is **blocked** if the category is referenced by active discounts. In
  that case, you will receive a `409 Conflict` error. You must first remove or
  update the discount references before deleting the category.
</Warning>

## Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X DELETE https://qwoty.app/api/categories/550e8400-e29b-41d4-a716-446655440001 \
    -H "Authorization: Bearer qwoty_your_token"
  ```

  ```javascript JavaScript theme={null}
  const categoryId = '550e8400-e29b-41d4-a716-446655440001'

  const response = await fetch(`https://qwoty.app/api/categories/${categoryId}`, {
    method: 'DELETE',
    headers: {
      Authorization: 'Bearer qwoty_your_token',
    },
  })

  const data = await response.json()
  ```

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

  category_id = '550e8400-e29b-41d4-a716-446655440001'

  response = requests.delete(
      f'https://qwoty.app/api/categories/{category_id}',
      headers={
          'Authorization': 'Bearer qwoty_your_token'
      }
  )

  data = response.json()
  ```
</CodeGroup>

## Response

<ResponseField name="success" type="boolean">
  Indicates whether the request was successful
</ResponseField>

<ResponseField name="data" type="object">
  Deletion confirmation

  <Expandable title="Deletion Object">
    <ResponseField name="id" type="string">
      UUID of the deleted category
    </ResponseField>

    <ResponseField name="deleted" type="boolean">
      Always `true` when deletion succeeds
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseExample>
  ```json 200 Success theme={null}
  {
    "success": true,
    "data": {
      "id": "550e8400-e29b-41d4-a716-446655440001",
      "deleted": true
    }
  }
  ```
</ResponseExample>

## Error Responses

<ResponseExample>
  ```json 404 Not Found theme={null}
  {
    "success": false,
    "error": "Category not found"
  }
  ```

  ```json 409 Conflict - Referenced by Discounts theme={null}
  {
    "success": false,
    "error": "CATEGORY_REFERENCED_IN_DISCOUNT"
  }
  ```
</ResponseExample>

## Cascade Effects

When a category is deleted:

* Products linked to this category through `category_ids` retain the reference (soft delete doesn't cascade)
* Child categories (with `parent_category_id` pointing to this category) are **not** automatically deleted
* Price percentage rules scoped to this category remain intact

<Tip>
  To permanently remove all traces of a category, you should first: 1. Remove
  the category from all products (`category_ids` field) 2. Update or delete all
  discounts referencing this category 3. Reassign or delete child categories 4.
  Then delete the category
</Tip>
