# Add Files (Pdf, Doc etc.)

**API Endpoint**

The following endpoint/URL should be used in order to access this API:

```
https://app.stammer.ai/en/chatbot/api/your_chabot_uuid/datafile/upload/with-training/
```

***

**Request Headers**

The API must have the following request headers:

```
Content-Type: application/json
Authorization: Token <Your-API-Token>
```

***

<figure><img src="https://1359281993-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkLIQnOFYHkQtdWxUzzFE%2Fuploads%2FAZBCCGAjk9q0t36ATpDQ%2FScreenshot%202025-03-21%20at%201.35.57%E2%80%AFPM.jpg?alt=media&#x26;token=2d4b82b6-0dcc-4556-99a2-2a92450b890a" alt=""><figcaption></figcaption></figure>

**Request Example**\
Here's an example of the request:

```python
import requests
import os

# Define the API endpoint
url = "https://app.stammer.ai/en/chatbot/api/your_chabot_uuid/datafile/upload/with-training/"

# Set up authentication and headers
headers = {
    'Authorization': 'Token <YOUR-API-TOKEN>',
    'Accept': 'application/json'
}


# Files to upload with their properties
files_to_upload = [

    {
        "file_path": "path/to/ex1.pdf",
        "content_type": "application/pdf"
    }

]

# Example of uploading multiple files
# Note: The API expects files to be sent as 'files[]'
upload_files = []
for file_info in files_to_upload:
    upload_files.append(
        ('files[]', 
         (os.path.basename(file_info['file_path']), 
          open(file_info['file_path'], 'rb'), 
          file_info['content_type']))
    )

# Upload the files
response = requests.post(url, headers=headers, files=upload_files)



# Process the response
if response.status_code in (200, 201, 202):
    result = response.json()
    print("Response data:", result)

else:
    try:
        error_data = response.json()
        error_message = error_data.get('message') or error_data.get('error', 'Unknown error')
        print(f"Error: {error_message}")
    except ValueError:
        print(f"Error: Status code {response.status_code}")
        print(f"Response content: {response.text}")

```

Learn More - <https://app.stammer.ai/en/api-docs/chatbot/file/>
