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

# File Upload API

> Upload PDF or text files to be processed and chunked for embedding search.

### Request

**Content-Type**: `multipart/form-data`

The POST request should be a multipart form request containing the file to be uploaded.

### Query Parameters

| Name           | Type    | Required | Description                                                       |
| -------------- | ------- | -------- | ----------------------------------------------------------------- |
| chunk\_size    | integer | No       | The chunk size (in tokens) applied when splitting the document    |
| chunk\_overlap | integer | No       | The chunk overlap (in tokens) applied when splitting the document |

### Authentication

Before making requests to the AI Tutor RAG API, you need to obtain your API key from your dashboard.

### Example Request

```javascript theme={null}
const formData = new FormData();
formData.append("file", files[0]); // Accepts PDF (.pdf) or text (.txt) files

const response = await fetch("https://rag-api-llm.up.railway.app/upload_file", {
  method: "POST",
  headers: {
    "authorization": apiKey,
  },
  body: formData,
});

```

Response

```javascript theme={null}
{
  "success": true,
  "message": "PDF file processed successfully",
  "file_id": "4db6b5d7-b199-4bfd-9914-6991cb4ba3b6",
  "file_name": "elon_musk.txt",
  "chunks": 2,
  "chunk_size": 1000,
  "chunk_overlap": 200
}

```

File Requirements
Requirement	Description
File Types	PDF (.pdf) or text (.txt) files only
Maximum Size	10MB

Download CSV

Error Responses

```javascript theme={null}
{
  "success": false,
  "error": {
    "message": "Invalid file type. Only PDF and TXT files are supported",
    "code": "invalid_file_type"
  }
}
```

```javascript theme={null}

{
  "success": false,
  "error": {
    "message": "File size exceeds maximum limit of 10MB",
    "code": "file_too_large"
  }
}

```

```javascript theme={null}



{
  "success": false,
  "error": {
    "message": "Invalid API key provided",
    "code": "unauthorized"
  }
}
```
