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

# Delete multiple files

> Send either `file_ids` or `select_all` with the file list's filters in `filters` (the parameters of
`GET /files`) and optional `except_ids`.

With `file_ids` each file is checked and deleted on its own and the response reports a result per file: a
missing file fails with `RESOURCE_NOT_FOUND`, an erased patient with `CUSTOMER_ERASED`, another rep's lead
with `LEAD_NOT_ASSIGNED`, a gallery image the caller may not edit, or chat media whose message the caller
may not delete, with `FORBIDDEN`. Deleting chat media also marks its message deleted in the conversation.

With `select_all` the files are deleted in the background with the same checks: the response carries `queued`
and the number of files, and the caller gets an `inventory_bulk_operation` notification with how many were
deleted and how many were skipped, by error code. Files added after the request are left out.



## OpenAPI

````yaml post /v1/files/bulk-delete
openapi: 3.1.0
info:
  title: Flextell API
  version: 0.0.1
  description: >-
    Flextell REST API referansı. Kimlik doğrulama, scope ve istek kuralları için
    API sekmesindeki rehberlere bakın.
servers:
  - url: https://app.flextell.ai/api
    description: Üretim
security:
  - oauth2: []
  - bearer: []
paths:
  /v1/files/bulk-delete:
    post:
      tags:
        - File
      summary: Delete multiple files
      description: >-
        Send either `file_ids` or `select_all` with the file list's filters in
        `filters` (the parameters of

        `GET /files`) and optional `except_ids`.


        With `file_ids` each file is checked and deleted on its own and the
        response reports a result per file: a

        missing file fails with `RESOURCE_NOT_FOUND`, an erased patient with
        `CUSTOMER_ERASED`, another rep's lead

        with `LEAD_NOT_ASSIGNED`, a gallery image the caller may not edit, or
        chat media whose message the caller

        may not delete, with `FORBIDDEN`. Deleting chat media also marks its
        message deleted in the conversation.


        With `select_all` the files are deleted in the background with the same
        checks: the response carries `queued`

        and the number of files, and the caller gets an
        `inventory_bulk_operation` notification with how many were

        deleted and how many were skipped, by error code. Files added after the
        request are left out.
      operationId: file.bulkDestroy
      parameters:
        - name: X-Tenant
          in: header
          required: true
          description: >-
            Tenant identifier. Send the Tenant ID in the `X-Tenant` header to
            scope API requests to a specific tenant.
          schema:
            type: number
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FileBulkDestroyRequest'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    anyOf:
                      - type: object
                        properties:
                          success_count:
                            type: integer
                          failed_count:
                            type: integer
                          results:
                            type: array
                            items:
                              type: object
                              properties:
                                file_id:
                                  type: integer
                                success:
                                  type: boolean
                                error_code:
                                  type: string
                                message:
                                  type: string
                              required:
                                - file_id
                                - success
                        required:
                          - success_count
                          - failed_count
                          - results
                      - type: object
                        properties:
                          queued:
                            type: boolean
                          count:
                            type: integer
                        required:
                          - queued
                          - count
                required:
                  - success
                  - data
        '401':
          $ref: '#/components/responses/AuthenticationException'
        '403':
          $ref: '#/components/responses/AuthorizationException'
        '422':
          $ref: '#/components/responses/ValidationException'
components:
  schemas:
    FileBulkDestroyRequest:
      type: object
      description: >-
        The selection is either `file_ids` or `select_all` with the file list's
        filters in `filters`

        (the parameters of `GET /files`).
      properties:
        file_ids:
          type: array
          description: >-
            The identifiers of the selected records. Send either these or
            `select_all`.
          items:
            type: integer
            minimum: 1
          minItems: 1
          maxItems: 100
        select_all:
          type: boolean
          description: >-
            Select every record the list shows with the filters in `filters`.
            The action then runs in the background and the response only carries
            the number of records.
        filters:
          type:
            - object
            - 'null'
          description: >-
            With `select_all`, the filters the list shows, as an object: the
            query parameters of `GET /api/v1/files` with the same names and
            values, array parameters without the `[]`. Paging and sorting
            parameters are ignored.
          properties:
            search:
              type:
                - string
                - 'null'
              description: >-
                The search query. Matches the file name, description and MIME
                type, or the name of the record the

                file is attached to (patient, lead, user or tenant; for chat
                media, the patient who sent it).
              maxLength: 255
            type:
              anyOf:
                - $ref: '#/components/schemas/FileType'
                  description: Filter by file type.
                - type: 'null'
            fileable_type:
              type:
                - string
                - 'null'
              description: >-
                Filter by fileable type. `doctor` narrows `user` to members
                holding the doctor role in this tenant.
              enum:
                - customer
                - lead
                - user
                - doctor
                - tenant
                - chat_log
                - ai_report
                - treatment
                - treatment_group
                - quick_reply
                - null
            fileable_id:
              type:
                - integer
                - 'null'
              description: Filter by fileable id.
              minimum: 1
            customer_id:
              type:
                - integer
                - 'null'
              description: >-
                Filter by patient ID: the patient's own files plus the media the
                patient sent in their conversations

                (returned with fileable_type `chat_log`). Returns no files for a
                patient you cannot view.
            lead_id:
              type:
                - integer
                - 'null'
              description: >-
                Filter by lead ID: the lead's own files plus the media its
                patient sent in their conversations

                (returned with fileable_type `chat_log`). Returns no files for a
                lead you cannot view.
            source:
              anyOf:
                - $ref: '#/components/schemas/CreationType'
                  description: Filter by how the file was created (ai_generated, manuel).
                - type: 'null'
            recently_sent:
              type:
                - boolean
                - 'null'
              description: >-
                Only the files the current user sent into conversations, each
                content once with its `last_sent_at`, newest send first.
                `sort_by` and `sort_order` are ignored.
            favorite:
              type:
                - boolean
                - 'null'
              description: Only the files the current user starred.
            created_at_from:
              type:
                - string
                - 'null'
              format: date-time
              description: >-
                Filter records created at or after this date (inclusive,
                YYYY-MM-DD).
            created_at_to:
              type:
                - string
                - 'null'
              format: date-time
              description: >-
                Filter records created at or before this date (inclusive,
                YYYY-MM-DD).
        except_ids:
          type:
            - array
            - 'null'
          description: >-
            With `select_all`, the identifiers of the records to leave out, at
            most 1000.
          items:
            type: integer
            description: A record identifier to leave out.
            minimum: 1
          maxItems: 1000
      title: FileBulkDestroyRequest
    FileType:
      type: string
      enum:
        - form_image
        - audio
        - catalog
        - certificate
        - image
        - video
        - other
        - before_after
      title: FileType
    CreationType:
      type: string
      enum:
        - ai_generated
        - manuel
      title: CreationType
  responses:
    AuthenticationException:
      description: Unauthenticated
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Error overview.
            required:
              - message
    AuthorizationException:
      description: Authorization error
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Error overview.
            required:
              - message
    ValidationException:
      description: Validation error
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Errors overview.
              errors:
                type: object
                description: A detailed description of each field that failed validation.
                additionalProperties:
                  type: array
                  items:
                    type: string
            required:
              - message
              - errors
  securitySchemes:
    oauth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://app.flextell.ai/oauth/authorize
          tokenUrl: https://app.flextell.ai/oauth/token
          scopes:
            '*': all
    bearer:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.