---
title: "Upload a file for a comment"
description: "A file for a comment you're writing (images, PDF, Word, Excel, PowerPoint, zip, text; up to 10 MB), as multipart file."
canonical_url: https://docs.markdrop.in/api/comments/upload-a-file-for-a-comment
last_updated: 2026-11-20
site: "Markdrop Docs"
index: https://docs.markdrop.in/llms.txt
---

# Upload a file for a comment

`POST https://api.markdrop.in/api/v1/documents/{slug}/comments/attachments`

A file for a comment you're writing (images, PDF, Word, Excel, PowerPoint, zip, text; up to 10 MB), as multipart `file`. Send its `id` in the comment's `attachments`. Anyone who can comment.

- **Authentication:** API token required: `Authorization: Bearer mdk_…`.
- **Rate limit:** 30 per minute per IP address.
- **Guide:** [Comments](https://docs.markdrop.in/collaboration/comments#images-and-files)

## Path parameters

- `slug` (string, required): The document's address: the part after `markdrop.in/`.

## Headers

- `X-Read-Password` (string): The password of a password-protected document.
- `X-Markdrop-Workspace` (string): A workspace's id: answer only if the document is in that workspace, else `404`. Workspace domains send it; you rarely need it.

## Request body

`multipart/form-data`, required.

- `file` (file, required)

## Responses

- `201`: Created.
- `401`: No token, or the token is revoked or mistyped.
- `415`: That kind of file can't go in a comment.
- `422`: The request didn't validate. `detail` lists each problem, with where it is (`loc`) and why (`msg`).
- `429`: Too many requests from your IP address. Wait the seconds in `Retry-After`.

## Examples

**curl**

```bash
curl -X POST https://api.markdrop.in/api/v1/documents/k3x9q2m/comments/attachments \
  -H "Authorization: Bearer $MARKDROP_TOKEN" \
  -F 'file=@logo.png'
```

**JavaScript**

```javascript
import { readFile } from "node:fs/promises";

const form = new FormData();
form.append("file", new Blob([await readFile("logo.png")]), "logo.png");

const res = await fetch("https://api.markdrop.in/api/v1/documents/k3x9q2m/comments/attachments", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MARKDROP_TOKEN}`,
  },
  body: form,
});
const data = await res.json();
```

**Python**

```python
import os

import requests

r = requests.post(
    "https://api.markdrop.in/api/v1/documents/k3x9q2m/comments/attachments",
    headers={"Authorization": f"Bearer {os.environ['MARKDROP_TOKEN']}"},
    files={"file": open("logo.png", "rb")},
)
r.raise_for_status()
print(r.json())
```
