> ## Documentation Index
> Fetch the complete documentation index at: https://sure-917046f5-mintlify-docs-update-1787374966296.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create category



## OpenAPI

````yaml /openapi.yaml post /api/v1/categories
openapi: 3.0.3
info:
  title: Sure API
  version: v1
  description: OpenAPI documentation generated from executable request specs.
servers:
  - url: https://app.sure.am
    description: Production
  - url: http://localhost:3000
    description: Local development
security: []
paths:
  /api/v1/categories:
    post:
      tags:
        - Categories
      summary: Create category
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CategoryCreateRequest'
        required: true
      responses:
        '201':
          description: subcategory created with parent
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CategoryDetail'
        '400':
          description: bad request - missing category payload
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: unauthorized - missing api key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: forbidden - api key missing read_write scope
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: validation error - duplicate name
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - apiKeyAuth: []
components:
  schemas:
    CategoryCreateRequest:
      type: object
      required:
        - category
      properties:
        category:
          type: object
          required:
            - name
          properties:
            name:
              type: string
              description: Category name (required, unique within family)
            color:
              type: string
              description: >-
                Hex color code (e.g. #22c55e). Defaults to #6172F3 if omitted;
                subcategories inherit parent color.
            icon:
              type: string
              description: >-
                Lucide icon name (e.g. "coffee"). Auto-suggested from the name
                when omitted.
            parent_id:
              type: string
              format: uuid
              nullable: true
              description: >-
                Parent category ID. Must belong to the same family. Categories
                support up to 2 levels of nesting.
    CategoryDetail:
      type: object
      required:
        - id
        - name
        - color
        - icon
        - subcategories_count
        - created_at
        - updated_at
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        color:
          type: string
        icon:
          type: string
        parent:
          $ref: '#/components/schemas/CategoryParent'
          nullable: true
        subcategories_count:
          type: integer
          minimum: 0
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
        message:
          type: string
          nullable: true
        details:
          oneOf:
            - type: array
              items:
                type: string
            - type: object
          nullable: true
        errors:
          type: array
          items:
            type: string
          nullable: true
          description: >-
            Validation error messages (alternative to details used by trades,
            valuations, etc.)
    CategoryParent:
      type: object
      required:
        - id
        - name
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      name: X-Api-Key
      in: header
      description: API key for authentication. Generate one from your account settings.

````