---
title: "Replace a file"
description: "Swaps the file behind a link for one uploaded with Get a single upload URL, keeping the link and its settings."
canonical_url: https://docs.markdrop.in/api/files/replace-a-file
last_updated: 2026-10-30
site: "Markdrop Docs"
index: https://docs.markdrop.in/llms.txt
---

# Replace a file

`PUT https://api.markdrop.in/api/v1/artifacts/{slug}/file`

Swaps the file behind a link for one uploaded with [Get a single upload URL](https://docs.markdrop.in/api/files/get-a-single-upload-url), keeping the link and its settings. The previous file is kept as a version.

- **Authentication:** API token required: `Authorization: Bearer mdk_…`.
- **Rate limit:** 20 per minute per IP address.
- **CLI:** `markdrop replace k3x9q2m deck-v2.pdf`
- **Guide:** [Replace and versions](https://docs.markdrop.in/files/replace-and-versions)

## Path parameters

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

## Request body

`application/json`, required.

- `blob_key` (string, required): 1–300 characters.
- `filename` (string): Up to 255 characters.

## Responses

- `200`: OK.
  - `slug` (string)
  - `url` (string)
  - `title` (string | null): Shown on the page and in link previews.
  - `kind` (string): Default `"artifact"`.
  - `mime` (string)
  - `renderer` (string)
  - `type_label` (string)
  - `size_bytes` (integer)
  - `original_filename` (string | null)
  - `artifact_url` (string)
  - `workspace_url` (string | null)
  - `download_url` (string)
  - `poster_url` (string | null)
  - `media` (object | null)
  - `created_at` (string (date-time)): ISO 8601, for example `2026-11-30T12:00:00Z`.
  - `updated_at` (string (date-time)): ISO 8601, for example `2026-11-30T12:00:00Z`.
  - `expires_at` (string (date-time) | null): ISO 8601, for example `2026-11-30T12:00:00Z`.
  - `views` (integer): Default `0`.
  - `is_password_protected` (boolean): Default `false`.
  - `is_owner` (boolean): Default `false`.
- `401`: No token, or the token is revoked or mistyped.
- `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`.
- `507`: The owner's storage is full.

## Examples

**curl**

```bash
curl -X PUT https://api.markdrop.in/api/v1/artifacts/k3x9q2m/file \
  -H "Authorization: Bearer $MARKDROP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"blob_key":"BLOB_KEY"}'
```

**JavaScript**

```javascript
const res = await fetch("https://api.markdrop.in/api/v1/artifacts/k3x9q2m/file", {
  method: "PUT",
  headers: {
    Authorization: `Bearer ${process.env.MARKDROP_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "blob_key": "BLOB_KEY"
  }),
});
const data = await res.json();
```

**Python**

```python
import os

import requests

r = requests.put(
    "https://api.markdrop.in/api/v1/artifacts/k3x9q2m/file",
    headers={"Authorization": f"Bearer {os.environ['MARKDROP_TOKEN']}"},
    json={"blob_key": "BLOB_KEY"},
)
r.raise_for_status()
print(r.json())
```

**CLI**

```bash
markdrop replace k3x9q2m deck-v2.pdf
```
