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

# Add/Remove Queries In/From Folder

> Moves queries into or out of a folder. Queries in queryIdsAdded are moved to the folder's path, queries in queryIdsRemoved are moved to root ("/").

<span style={{display: "flex", gap: "10px", flexDirection: "row", alignItems: "center"}}>
  <img src="https://cdn.peaka.com/badges/partner-api-key-badge.png" />

  <img src="https://cdn.peaka.com/badges/project-api-key-badge.png" />
</span>


## OpenAPI

````yaml put /data/projects/{projectId}/queries/folders/{folderId}
openapi: 3.0.1
info:
  title: Peaka Gateway API
  description: Peaka Gateway API Documentation
  version: '1.0'
servers:
  - url: https://partner.peaka.studio/api/v1
    description: Default Server URL (US Zone)
  - url: https://partner.eu.peaka.studio/api/v1
    description: EU Zone
security:
  - bearerAuth: []
paths:
  /data/projects/{projectId}/queries/folders/{folderId}:
    put:
      tags:
        - Data -- Query Folders
      summary: Add/Remove Queries In/From Folder
      description: >-
        Moves queries into or out of a folder. Queries in queryIdsAdded are
        moved to the folder's path, queries in queryIdsRemoved are moved to root
        ("/").
      operationId: addOrRemoveQueryFromFolder
      parameters:
        - name: projectId
          in: path
          description: ID of the Project
          required: true
          schema:
            type: string
          example: mtKDhe1U
        - name: folderId
          in: path
          description: ID of the Query Folder
          required: true
          schema:
            type: string
          example: 550e8400-e29b-41d4-a716-446655440000
      requestBody:
        description: Query add/remove request
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/QueryFolderUpdateRequest'
            example:
              queryIdsAdded:
                - '709922802836177297'
              queryIdsRemoved:
                - '709891320440684892'
        required: true
      responses:
        '200':
          description: Queries moved successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QueryFolderWithContentsResponse'
        '404':
          description: Folder not found
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/QueryFolderWithContentsResponse'
components:
  schemas:
    QueryFolderUpdateRequest:
      type: object
      properties:
        queryIdsAdded:
          type: array
          items:
            type: string
        queryIdsRemoved:
          type: array
          items:
            type: string
      description: |-
        Request body for updating a query folder (adding/removing query IDs).

         <p>Both lists are initialised to empty {@link ArrayList ArrayList}s so the serialised
         JSON always contains <code>&quot;queryIdsAdded&quot;: [...]</code> and
         <code>&quot;queryIdsRemoved&quot;: [...]</code>.  The search service requires both fields
         to be present (non-null) and rejects <code>null</code> with a validation error.
    QueryFolderWithContentsResponse:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier of the folder (UUID)
        name:
          type: string
          description: Display name of the folder
        path:
          type: string
          description: Full path of the folder in the hierarchy
        parentId:
          type: string
          description: ID of the parent folder, null if root-level
        createdAt:
          type: string
          description: Timestamp when the folder was created (ISO 8601)
        folders:
          type: array
          description: Direct child folders
          items:
            $ref: '#/components/schemas/QueryFolderItem'
        queries:
          type: array
          description: Queries contained in this folder
          items:
            $ref: '#/components/schemas/Query'
      description: A folder with its direct child folders and queries
    QueryFolderItem:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier of the folder (UUID)
          example: 550e8400-e29b-41d4-a716-446655440000
        name:
          type: string
          description: Display name of the folder
          example: Monthly Reports
        path:
          type: string
          description: Full path of the folder in the hierarchy
          example: /reports/monthly
        parentId:
          type: string
          description: ID of the parent folder, null if root-level
          example: 550e8400-e29b-41d4-a716-446655440001
        createdAt:
          type: string
          description: Timestamp when the folder was created (ISO 8601)
          example: '2025-01-15T10:30:00Z'
      description: Represents a query folder
    Query:
      type: object
      properties:
        id:
          type: string
          description: The ID of the query.
        displayName:
          type: string
          description: The display name of the query.
        name:
          type: string
          description: >-
            The name of the query used in SQL, e.g. SELECT * FROM
            "peaka"."query"."<name>".
        inputQuery:
          type: string
          description: The SQL query.
        inputQueryRefId:
          type: string
          description: >-
            The reference id of the input query. For a MATERIALIZED query, the
            id of the original query it materializes.
          nullable: true
        queryType:
          type: string
          description: The type of the query.
          enum:
            - PLAIN
            - MATERIALIZED
        schedule:
          $ref: '#/components/schemas/MaterializedQuerySchedule'
        path:
          type: string
          description: >-
            The folder path of the query (e.g. "/analytics/dashboards"). Null if
            not in any folder.
          nullable: true
        folderId:
          type: string
          description: >-
            The ID of the folder containing this query. Null if not in any
            folder.
          nullable: true
      description: A saved query belonging to a project.
    MaterializedQuerySchedule:
      type: object
      properties:
        type:
          type: string
          description: Type of schedule.
          enum:
            - interval
            - cron
            - none
        cronExpression:
          type: string
          description: Cron expression. Set only when the schedule type is 'cron'.
          nullable: true
        repeatDuration:
          type: string
          description: ISO-8601 duration. Set only when the schedule type is 'interval'.
          nullable: true
        timezone:
          type: string
          description: >-
            IANA timezone used to evaluate the cron expression. Set only when
            the schedule type is 'cron'.
          nullable: true
      description: >-
        Schedule configuration of a materialized query. Provide EITHER an
        interval schedule (`type=interval` with `repeatDuration`) OR a cron
        schedule (`type=cron` with `cronExpression` and optional `timezone`).
        Use `type=none` for no schedule. The fields that do not apply to the
        chosen type are omitted.
      nullable: true
      example:
        type: cron
        cronExpression: 0 0 * * *
        timezone: UTC
  securitySchemes:
    bearerAuth:
      type: http
      description: >-
        Use the Authorization header with the value 'Bearer <apiKey>' to
        authenticate. Partner API Keys have full access; Project API Keys are
        limited to their project scope. Learn more:
        https://docs.peaka.com/api-reference/authentication
      scheme: bearer
      bearerFormat: Api Key

````