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

# Update Document Categories

> Update the categories assigned to a document.

This endpoint replaces all existing categories for a document with the new
list provided. Use this to organize and tag documents for easier retrieval.

**Args**:
    `id`: Document ID (path parameter)
    `req`: Request body containing the new list of categories

**Returns**:
    Object with document_id, old_categories, new_categories, and a confirmation message.

**Raises**:
    - `404`: If the document is not found or doesn't belong to the user

**Example**:
    **Request**:
    ```
        PUT /api/v3/documents/doc-xyz789/categories
        Headers: {"Authorization": "Bearer <api_key>"}
        Body:
        {
            "categories": ["financial", "2024-q1", "confidential"]
        }
    ```



## OpenAPI

````yaml https://api.nugen.in/openapi-public.json put /api/v3/documents/{id}/categories
openapi: 3.1.0
info:
  title: Nugen Intelligence API
  description: 'Nugen Intelligence : Powering Specialized Intelligence At Scale'
  version: 25.4.20
servers: []
security: []
paths:
  /api/v3/documents/{id}/categories:
    put:
      tags:
        - Documents
      summary: Update Document Categories
      description: >-
        Update the categories assigned to a document.


        This endpoint replaces all existing categories for a document with the
        new

        list provided. Use this to organize and tag documents for easier
        retrieval.


        **Args**:
            `id`: Document ID (path parameter)
            `req`: Request body containing the new list of categories

        **Returns**:
            Object with document_id, old_categories, new_categories, and a confirmation message.

        **Raises**:
            - `404`: If the document is not found or doesn't belong to the user

        **Example**:
            **Request**:
            ```
                PUT /api/v3/documents/doc-xyz789/categories
                Headers: {"Authorization": "Bearer <api_key>"}
                Body:
                {
                    "categories": ["financial", "2024-q1", "confidential"]
                }
            ```
      operationId: update_document_categories
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            title: Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateDocumentCategoriesRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpdateDocumentCategoriesResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    UpdateDocumentCategoriesRequest:
      properties:
        categories:
          items:
            type: string
          type: array
          title: Categories
          description: List of categories to be assigned to the document
          example:
            - customer_support
            - products
            - legal
      type: object
      required:
        - categories
      title: UpdateDocumentCategoriesRequest
    UpdateDocumentCategoriesResponse:
      properties:
        document_id:
          type: string
          title: Document Id
          description: ID of the updated document
          example: doc-abc123
        old_categories:
          items:
            type: string
          type: array
          title: Old Categories
          description: Categories before the update
          example:
            - customer_service
            - ML_book_new
        new_categories:
          items:
            type: string
          type: array
          title: New Categories
          description: Categories after the update
          example:
            - customer_support
            - products
            - legal
        message:
          type: string
          title: Message
          description: Human-readable confirmation message
      type: object
      required:
        - document_id
        - old_categories
        - new_categories
        - message
      title: UpdateDocumentCategoriesResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````