> ## 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.

# Create Category

> Create a new product category in your workspace

## Authorization

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

## Request Body

<ParamField body="api_name" type="string" required>
  Unique API identifier (snake\_case). Can only contain lowercase letters,
  numbers and underscores. Cannot start or end with underscore.
</ParamField>

<ParamField body="name" type="string" required>
  Category name
</ParamField>

<ParamField body="description" type="string">
  Category description
</ParamField>

<ParamField body="is_active" type="boolean" default="true">
  Active status
</ParamField>

<ParamField body="parent_category_id" type="string">
  UUID of parent category for hierarchical organization
</ParamField>

## Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://qwoty.app/api/categories \
    -H "Authorization: Bearer qwoty_your_token" \
    -H "Content-Type: application/json" \
    -d '{
      "api_name": "electronics",
      "name": "Electronics",
      "description": "Electronic products and accessories",
      "is_active": true
    }'
  ```

  ```bash With Parent theme={null}
  curl -X POST https://qwoty.app/api/categories \
    -H "Authorization: Bearer qwoty_your_token" \
    -H "Content-Type: application/json" \
    -d '{
      "api_name": "smartphones",
      "name": "Smartphones",
      "description": "Mobile phones and accessories",
      "is_active": true,
      "parent_category_id": "550e8400-e29b-41d4-a716-446655440001"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://qwoty.app/api/categories', {
    method: 'POST',
    headers: {
      Authorization: 'Bearer qwoty_your_token',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      api_name: 'electronics',
      name: 'Electronics',
      description: 'Electronic products and accessories',
      is_active: true,
    }),
  })

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

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

  response = requests.post(
      'https://qwoty.app/api/categories',
      headers={
          'Authorization': 'Bearer qwoty_your_token',
          'Content-Type': 'application/json'
      },
      json={
          'api_name': 'electronics',
          'name': 'Electronics',
          'description': 'Electronic products and accessories',
          'is_active': True
      }
  )

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

## Response

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

<ResponseField name="data" type="object">
  Created category object

  <Expandable title="Category Object">
    <ResponseField name="id" type="string">
      Unique identifier (UUID)
    </ResponseField>

    <ResponseField name="workspace_id" type="string">
      Workspace ID (UUID)
    </ResponseField>

    <ResponseField name="name" type="string">
      Category name
    </ResponseField>

    <ResponseField name="api_name" type="string">
      API identifier
    </ResponseField>

    <ResponseField name="description" type="string">
      Category description
    </ResponseField>

    <ResponseField name="is_active" type="boolean">
      Active status
    </ResponseField>

    <ResponseField name="parent_category_id" type="string | null">
      ID of parent category (UUID)
    </ResponseField>

    <ResponseField name="created_at" type="string">
      Creation timestamp (ISO 8601)
    </ResponseField>

    <ResponseField name="updated_at" type="string">
      Last update timestamp (ISO 8601)
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseExample>
  ```json 201 Created theme={null}
  {
    "success": true,
    "data": {
      "id": "550e8400-e29b-41d4-a716-446655440001",
      "workspace_id": "660e8400-e29b-41d4-a716-446655440000",
      "name": "Electronics",
      "api_name": "electronics",
      "description": "Electronic products and accessories",
      "is_active": true,
      "parent_category_id": null,
      "created_at": "2026-01-15T10:00:00Z",
      "updated_at": "2026-01-15T10:00:00Z"
    }
  }
  ```
</ResponseExample>

## Error Responses

<ResponseExample>
  ```json 400 Validation Error theme={null}
  {
    "success": false,
    "error": "Validation error",
    "details": [
      "Field 'api_name' is required"
    ]
  }
  ```

  ```json 400 Invalid api_name theme={null}
  {
    "success": false,
    "error": "Validation error",
    "details": [
      "Field 'api_name' can only contain lowercase letters, numbers and underscores (cannot start or end with underscore)"
    ]
  }
  ```
</ResponseExample>
