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

# Delete file(s) by key(s)

> Deletes one or more files by key from the authenticated organization. Validates API key using WorkOS, extracts organization ID, verifies each file key starts with the organization UUID and belongs to the organization, then deletes from S3 storage and database. Each file key must start with a valid UUID that matches the organization ID. The file key can contain slashes (e.g., 'org-id/path/to/file.png').



## OpenAPI

````yaml api-reference/openapi.json delete /v1/files
openapi: 3.0.0
info:
  title: FileJar Core API
  version: 1.0.0
  description: >-
    API documentation for FileJar Core API - File upload and organization
    management
servers:
  - url: http://localhost:8787
    description: Local development server
  - url: https://core-api.filejar.dev
    description: Production server
security: []
tags:
  - name: Health
    description: Health check endpoints
  - name: Upload
    description: File upload endpoints
  - name: Files
    description: File retrieval and management endpoints
paths:
  /v1/files:
    delete:
      tags:
        - Files
      summary: Delete file(s) by key(s)
      description: >-
        Deletes one or more files by key from the authenticated organization.
        Validates API key using WorkOS, extracts organization ID, verifies each
        file key starts with the organization UUID and belongs to the
        organization, then deletes from S3 storage and database. Each file key
        must start with a valid UUID that matches the organization ID. The file
        key can contain slashes (e.g., 'org-id/path/to/file.png').
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                keys:
                  type: array
                  description: >-
                    Array of file keys/paths in storage. Each key must start
                    with a UUID that matches the organization ID.
                  items:
                    type: string
                    description: >-
                      File key/path in storage (must start with organization
                      UUID)
                    example: 9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example.png
                  minItems: 1
              required:
                - keys
            example:
              keys:
                - 9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example.png
                - 9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example2.jpg
      responses:
        '200':
          description: Delete operation completed (may include partial success)
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                    description: Indicates if the request was processed
                  results:
                    type: array
                    description: >-
                      Array of results for each key. Each item may be a success
                      object or an error object.
                    items:
                      oneOf:
                        - type: object
                          description: Successful deletion
                          properties:
                            key:
                              type: string
                              description: File key that was deleted
                              example: >-
                                9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example.png
                            deleted:
                              type: object
                              properties:
                                id:
                                  type: string
                                  format: uuid
                                  description: Unique identifier of the deleted upload
                                  example: 223e4567-e89b-12d3-a456-426614174001
                                key:
                                  type: string
                                  description: File key/path that was deleted
                                  example: >-
                                    9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example.png
                                file_name:
                                  type: string
                                  description: Original file name
                                  example: example.png
                              required:
                                - id
                                - key
                                - file_name
                          required:
                            - key
                            - deleted
                        - type: object
                          description: Error for a specific key
                          properties:
                            key:
                              type: string
                              description: File key that failed
                              example: >-
                                9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example.png
                            error:
                              type: string
                              description: >-
                                Error message (e.g., 'File not found' or
                                'Internal server error')
                              example: File not found
                          required:
                            - key
                            - error
                  summary:
                    type: object
                    description: Summary of the deletion operation
                    properties:
                      total:
                        type: integer
                        description: Total number of keys processed
                        example: 2
                      deleted:
                        type: integer
                        description: Number of files successfully deleted
                        example: 1
                      errors:
                        type: integer
                        description: Number of files that failed to delete
                        example: 1
                    required:
                      - total
                      - deleted
                      - errors
                required:
                  - success
                  - results
                  - summary
                example:
                  success: true
                  results:
                    - key: >-
                        9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example.png
                      deleted:
                        id: 223e4567-e89b-12d3-a456-426614174001
                        key: >-
                          9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example.png
                        file_name: example.png
                    - key: >-
                        9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4/test/out/example2.jpg
                      error: File not found
                  summary:
                    total: 2
                    deleted: 1
                    errors: 1
        '400':
          description: Bad request - Validation error or keys do not match organization ID
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Validation failed
                    description: >-
                      Either 'Validation failed' or 'File keys must start with
                      the organization ID'
                  fields:
                    type: object
                    description: Field-specific validation errors (if validation failed)
                  invalid_keys:
                    type: array
                    description: >-
                      Keys that do not match the organization ID (if keys
                      mismatch)
                    items:
                      type: string
                  expected_org_id:
                    type: string
                    format: uuid
                    description: Expected organization ID (if keys mismatch)
                    example: 9bbe5ff7-dd84-4af7-a27b-8b6c59855cf4
        '401':
          description: >-
            Unauthorized - Invalid or missing API key, or organization ID not
            found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: API key required
                    description: >-
                      Either 'API key required', 'Invalid API key', or
                      'Organization ID not found'
        '404':
          description: Organization or file not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: File not found
                    description: Either 'Organization not found' or 'File not found'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Internal server error
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: WorkOS API key for authentication

````