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

# Reorder Template Sections

> Reorder and renumber template sections. After applying the new positions, all section names are automatically renumbered to reflect the hierarchy (e.g., '1.', '1.1', '2.').



## OpenAPI

````yaml /api-reference/openapi-v1.json put /api/v1/templates/{template_id}/sections/reorder
openapi: 3.0.0
info:
  title: Artos API
  description: API for document generation, template management, and document organization
  version: 1.0.0
  contact:
    name: Artos Support
    email: internal@artosai.com
servers:
  - url: https://api.artosai.com
    description: Production server
  - url: http://localhost:8000
    description: Local development server
security:
  - bearerAuth: []
paths:
  /api/v1/templates/{template_id}/sections/reorder:
    put:
      tags:
        - Templates
      summary: Reorder Template Sections
      description: >-
        Reorder and renumber template sections. After applying the new
        positions, all section names are automatically renumbered to reflect the
        hierarchy (e.g., '1.', '1.1', '2.').
      operationId: reorderTemplateSections
      parameters:
        - name: template_id
          in: path
          required: true
          description: UUID of template
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReorderSectionsRequest'
            example:
              sections:
                - section_id: sec-uuid-001
                  order_index: 0
                  level: 1
                - section_id: sec-uuid-003
                  order_index: 1
                  level: 1
                - section_id: sec-uuid-002
                  order_index: 2
                  level: 1
      responses:
        '200':
          description: Sections reordered successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReorderSectionsResponse'
        '400':
          description: Authentication errors
        '403':
          description: Unauthorized access
        '404':
          description: Template not found
        '500':
          description: Database operation failures
components:
  schemas:
    ReorderSectionsRequest:
      type: object
      properties:
        sections:
          type: array
          items:
            type: object
            properties:
              section_id:
                type: string
              order_index:
                type: integer
              level:
                type: integer
            required:
              - section_id
              - order_index
              - level
          description: List of {section_id, order_index, level} defining the new order
      required:
        - sections
    ReorderSectionsResponse:
      type: object
      properties:
        template_id:
          type: string
        sections:
          type: array
          items:
            $ref: '#/components/schemas/SectionSummary'
          description: All sections in their new order with updated names
        message:
          type: string
          description: Success message
      required:
        - template_id
        - sections
        - message
    SectionSummary:
      type: object
      properties:
        section_id:
          type: string
        section_name:
          type: string
        order_index:
          type: integer
        level:
          type: integer
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Bearer token authentication. Token provides organization-scoped access.

````