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

# Batch-apply folder policies for a connection

> Apply a batch of folder-policy changes in a single transaction.

The connect-flow picker persists a whole selection at once. Doing that as N
sequential ``POST``/``DELETE`` calls means N HTTP round-trips and up to N
re-syncs (each SKIP->non-SKIP transition dispatched its own). This endpoint
upserts/deletes every change in one request and fires **at most one** re-sync
at the end, then prunes descendant rows a newly-selected ancestor made
redundant. Returns the connection's full policy set after the changes.



## OpenAPI

````yaml https://app.stainlessapi.com/api/spec/documented/hyperspell.yaml put /connections/{connection_id}/folder-policies
openapi: 3.1.0
info:
  title: Hyperspell API
  summary: >-
    Hyperspell is the memory layer for AI apps and agents. Through the API, you
    can add memories, connect data sources to index them in real-time, and
    search memories with our natural language query engine.
  termsOfService: https://hyperspell.com/blog/tos
  contact:
    name: Hyperspell
    url: https://hyperspell.com/
    email: hello@hyperspell.com
  version: 0.32.1
servers:
  - url: https://api.hyperspell.com
    description: Production
security:
  - APIKey: []
    AsUser: []
paths:
  /connections/{connection_id}/folder-policies:
    put:
      tags:
        - Folder Policies
      summary: Batch-apply folder policies for a connection
      description: >-
        Apply a batch of folder-policy changes in a single transaction.


        The connect-flow picker persists a whole selection at once. Doing that
        as N

        sequential ``POST``/``DELETE`` calls means N HTTP round-trips and up to
        N

        re-syncs (each SKIP->non-SKIP transition dispatched its own). This
        endpoint

        upserts/deletes every change in one request and fires **at most one**
        re-sync

        at the end, then prunes descendant rows a newly-selected ancestor made

        redundant. Returns the connection's full policy set after the changes.
      operationId: >-
        batch_update_connection_policies_connections__connection_id__folder_policies_put
      parameters:
        - name: connection_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Connection Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BatchFolderPolicyRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FolderPolicyListResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKey: []
        - AsUser: []
components:
  schemas:
    BatchFolderPolicyRequest:
      properties:
        changes:
          items:
            $ref: '#/components/schemas/BatchFolderPolicyItem'
          type: array
          title: Changes
          description: Folder-policy changes to apply in a single transaction
      type: object
      required:
        - changes
      title: BatchFolderPolicyRequest
    FolderPolicyListResponse:
      properties:
        policies:
          items:
            $ref: '#/components/schemas/FolderPolicyResponse'
          type: array
          title: Policies
          description: List of folder policies
      type: object
      required:
        - policies
      title: FolderPolicyListResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    BatchFolderPolicyItem:
      properties:
        provider_folder_id:
          type: string
          title: Provider Folder Id
          description: Folder ID from the source provider
        folder_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Folder Name
          description: Display name of the folder
        folder_path:
          anyOf:
            - type: string
            - type: 'null'
          title: Folder Path
          description: Display path of the folder
        parent_folder_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Parent Folder Id
          description: Parent folder's provider ID for inheritance resolution
        sync_mode:
          anyOf:
            - $ref: '#/components/schemas/SyncMode'
            - type: 'null'
          description: Sync mode for this folder (required when action='set')
        action:
          type: string
          enum:
            - set
            - delete
          title: Action
          description: '''set'' upserts the policy; ''delete'' removes it'
          default: set
      type: object
      required:
        - provider_folder_id
      title: BatchFolderPolicyItem
      description: >-
        One folder-policy change in a batch save.


        ``action="set"`` upserts a policy for ``provider_folder_id`` with
        ``sync_mode``

        (``sync_mode`` is required for set); ``action="delete"`` removes the
        policy for

        that folder (identified by folder id, not row id — the picker doesn't
        need to

        carry policy row ids to un-check a folder).
    FolderPolicyResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
          description: Unique policy ID
        provider_folder_id:
          type: string
          title: Provider Folder Id
          description: Folder ID from the source provider
        folder_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Folder Name
          description: Display name of the folder
        folder_path:
          anyOf:
            - type: string
            - type: 'null'
          title: Folder Path
          description: Display path of the folder
        parent_folder_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Parent Folder Id
          description: Parent folder's provider ID
        sync_mode:
          $ref: '#/components/schemas/SyncMode'
          description: Sync mode for this folder
        connection_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Connection Id
          description: Connection ID (null for integration defaults)
      type: object
      required:
        - id
        - provider_folder_id
        - sync_mode
      title: FolderPolicyResponse
    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
    SyncMode:
      type: string
      enum:
        - sync
        - skip
        - manual
      title: SyncMode
  securitySchemes:
    APIKey:
      type: http
      description: >-
        API Key or JWT User Token. If using an API Key, set the X-As-User header
        to act as a specific user. A JWT User Token is always scoped to a
        specific user.
      scheme: bearer
      bearerFormat: Bearer <token>
    AsUser:
      type: apiKey
      description: >-
        Optionally set this header to act as a specific user when using an API
        Key, equivalent to first exchanging the API Key for a User Token
      in: header
      name: X-As-User

````