---
title: "Upload a file"
method: POST
path: "/upload-file/{chatbotId}"
tags: ["File Operations"]
---

# Upload a file

`POST /upload-file/{chatbotId}`

## Request

- Base URL: `https://api.chat-data.com/api/v2`
- URL: `https://api.chat-data.com/api/v2/upload-file/{chatbotId}`
- Auth: HTTP bearer

Upload a file to be used with a chatbot, for example as a `files` attachment in `/chat` or `/live-chat`. The file is stored in the chatbot's folder under its original name. If a file with that name already exists, it is not replaced: nothing is uploaded and the existing file's URL is returned. Uploads count toward the workspace's file storage limit.

## Path parameters

- `chatbotId` string, required

## Response `200`

Successful response.

- object
  - `status` 'success', required
  - `url` string, required: The URL where the uploaded file can be accessed, with a read-only SAS token.

## Other responses

- `400`: No `file` was sent, or the workspace has reached its file storage limit.
- `401`: Authentication failed: the `Authorization` header is missing or not in the `Bearer <key>` format, the API key does not exist, its workspace is unavailable or has no owner, or the workspace's plan does not include API access. `message` says which.
- `403`: The API key cannot access the requested chatbot. A chatbot-scoped key used with another chatbot's ID gets `Access denied to this chatbot`. A workspace key gets `Chatbot <id> was not found in this API key's workspace. It may have been deleted or moved to another workspace.` when the chatbot does not exist or belongs to another workspace.
- `429`: The workspace sent more than 600 API requests in the last minute. Wait the number of seconds given in the `Retry-After` header (and in `message`) before retrying.
- `500`: The file could not be stored; the body also identifies the file. A file sent under a field other than `file` also gets a 500, whose body is not JSON.

---

[API](https://skmtc.dev/chat-data/apis/chat-data-api-schema-guide.md) · [All operations](https://skmtc.dev/chat-data/apis/chat-data-api-schema-guide/llms.txt) · [OpenAPI document](https://skmtc.dev/chat-data/apis/chat-data-api-schema-guide/revisions/72871007f7f0?raw)
