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

# Upload a File

> Use this endpoint to upload a file to the DeepRails API


Files used for the file search feature in Defend must be uploaded to DeepRails here before being added to workflows. The request body must include the `file` to upload as binary content formatted as a form-data.<br /><br />When you upload a file, you'll receive a file ID. Use this ID to add the file to a workflow for evaluation. Additionally, you'll receive a file path corresponding to the s3 bucket where the file is stored.


## OpenAPI

````yaml /api-reference/openapi.yaml post /files/upload
openapi: 3.0.0
info:
  title: DeepRails API
  description: >
    DeepRails is a powerful developer tool with a comprehensive set of adaptive
    & accurate guardrails to protect against LLM hallucinations - deploy our
    Monitor and Defend APIs in less than 15 minutes for the best out-of-the-box
    guardrails available.
  version: v3.0
  contact:
    name: DeepRails Support
    email: support@deeprails.ai
servers:
  - url: https://api.deeprails.com
    description: Production server
security:
  - BearerAuth: []
paths:
  /files/upload:
    post:
      tags:
        - Files
      summary: Upload a File
      description: |
        Use this endpoint to upload a file to the DeepRails API
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                files:
                  type: array
                  items:
                    type: string
                  description: The contents of the files to upload.
              required:
                - files
      responses:
        '200':
          description: File uploaded successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FileResponse'
        '400':
          description: Invalid request
        '401':
          description: Unauthorized
        '422':
          description: Validation error
      security:
        - BearerAuth: []
      x-codeSamples:
        - lang: python
          label: Upload a File
          source: |
            from deeprails import DeepRails
            DEEPRAILS_API_KEY = "YOUR_API_KEY"
            client = DeepRails(
              api_key=DEEPRAILS_API_KEY,
            )
            file_response = client.files.upload(
              file=open("example.pdf", "rb")
            )
            print(file_response)
components:
  schemas:
    FileResponse:
      type: object
      properties:
        file_name:
          type: string
          description: Name of the file.
          example: example.pdf
        file_id:
          type: string
          description: A unique file ID.
          example: file_xxxxxxxxxxxx
        file_size:
          type: integer
          description: The size of the file in bytes.
          example: 1024
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````