---
title: "Upload a file"
method: POST
path: "/v1/files"
tags: ["Files"]
---

# Upload a file

`POST /v1/files`

## Request

- Base URL: `https://api.capacity.com` (the document declares no server; this is the origin it was published from)
- URL: `https://api.capacity.com/v1/files`
- Auth: one of:
  - API key in header `x-capacity-id`
  - HTTP bearer

Upload a new file.

## Request body

- object
  - `file_data` string: base64-encoded string of binary file data to upload. Required if no file object is provided
  - `file_url` string: URL to file to be uploaded
  - `filename` string: desired file name for the upload. Must include a file extension. Required if no file object is provided.
  - `folder_id` string: ID of the folder that the file will be created in. Leaving it out indicates the file should be in the root folder of the default knowledge base.
  - `is_public` boolean: Whether the file is public
  - `replace_duplicate` boolean: Whether to replace the existing file if there is one with the same name under the same folder
  - `tag_ids` string[]: IDs of global tags to associate with file
  - `tag_names` string[]: Names of global tags to associate with file

## Response `201`

The created file

- object
  - `body` object: Json body data in the request
  - `parameters` object: Query parameters in the request
  - `result` FileSchema
    - `created_at` string: Datetime when the file was created
    - `id` string: ID of the file
    - `folder_id` string: ID of the folder that the file is in. Null indicates the file is in the root folder of its knowledge base.
    - `is_public` boolean: Whether the file is public
    - `md5sum` string: MD5 checksum for the file
    - `name` string: Name of the file
    - `tag_ids` string[]: IDs of global tags applied to file
    - `tag_names` string[]: Names of global tags applied to file

## Other responses

- `400`: The request contains malformed data or violates data integrity
- `422`: The request was well-formed but was unable to be followed due to semantic errors. This is usually due to the request data failing to pass validations.

---

[API](https://skmtc.dev/capacity/apis/capacity-api-docs.md) - [All operations](https://skmtc.dev/capacity/apis/capacity-api-docs/llms.txt) - [OpenAPI document](https://skmtc.dev/capacity/apis/capacity-api-docs/revisions/74c85bb61004?raw)
