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

# Update a category's position and parent

Updates the sort position and parent relationship of a snippet category. This endpoint allows you to reorder categories within their parent or move them to a different parent category. The position is 0-based, and all sibling categories are automatically reordered to maintain a consistent sequence.


## OpenAPI

````yaml https://api.getfernand.com/openapi.json patch /snippets/categories/{id}/position
openapi: 3.0.3
info:
  title: Fernand API Documentation
  version: '3.0'
  description: This is the documentation for the [Fernand](https://getfernand.com) API.
  termsOfService: https://getfernand.com/terms
  contact:
    name: Fernand Support
    url: https://getfernand.com
    email: support@getfernand.com
  x-logo:
    url: https://app.getfernand.com/images/favicon/icon_128.png
servers:
  - url: https://api.getfernand.com
    description: ''
    x-last-modified: 1764750693905
security:
  - apiKeyHeader: []
externalDocs:
  description: You can access our documentation online by visiting https://api.fernand.help
  url: https://api.fernand.help
paths:
  /snippets/categories/{id}/position:
    patch:
      tags:
        - Snippet Categories
      summary: Update a category's position and parent
      description: >-
        Updates the sort position and parent relationship of a snippet category.
        This endpoint allows you to reorder categories within their parent or
        move them to a different parent category. The position is 0-based, and
        all sibling categories are automatically reordered to maintain a
        consistent sequence.
      operationId: updateSnippetCategoryPosition
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: ID of the category to reposition.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                parent_id:
                  type: integer
                  nullable: true
                  description: >-
                    ID of the new parent category (optional, null for
                    root-level).
                  example: 3
                position:
                  type: integer
                  description: New position within the parent (0-based index, required).
                  example: 2
              required:
                - position
      responses:
        '200':
          description: Category position updated successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SnippetCategory'
        '400':
          description: Invalid input or parent category not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        '404':
          description: Category not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
components:
  schemas:
    SnippetCategory:
      type: object
      properties:
        id:
          type: integer
          format: int32
          description: Unique identifier for the snippet category
          example: 5
        name:
          type: string
          maxLength: 250
          description: Name of the category
          example: Customer Support
        parent_id:
          type: integer
          format: int32
          nullable: true
          description: ID of the parent category (null for root-level categories)
          example: 2
        sort:
          type: integer
          format: int32
          description: Sort order within the parent category (1-based)
          example: 1
      required:
        - id
        - name
        - sort
      x-computed-hash: 1b4d16a9a35a9d103ccbdaccc7316600d08ef27b337e5623ad58f40ccc9f763b
      x-last-modified: 1769075324
  securitySchemes:
    apiKeyHeader:
      type: apiKey
      description: >-
        Authenticate your account by including your secret key in API requests.

        You can manage your API keys in the
        [Dashboard](https://app.getfernand.com/).


        Authentication to the API is performed by using the HTTP Header
        X-API-Key.
      name: X-API-Key
      in: header
      x-last-modified: 1764750344730

````