---
title: "Publish a document"
description: "Creates a Markdown document and returns its link."
canonical_url: https://docs.markdrop.in/api/documents/publish-a-document
last_updated: 2026-10-30
site: "Markdrop Docs"
index: https://docs.markdrop.in/llms.txt
---

# Publish a document

`POST https://api.markdrop.in/api/v1/documents`

Creates a Markdown document and returns its link. Works without an account: send a token to own it. Keep the `edit_secret` from a call without a token: it is the only way to change or delete that document later.

- **Authentication:** Token optional: send `Authorization: Bearer mdk_…` to act as your account.
- **Rate limit:** 10 per minute per IP address.
- **MCP tool:** `publish_document` ([tools](https://docs.markdrop.in/ai/tools))
- **Guide:** [Publish your first document](https://docs.markdrop.in/get-started/first-document)

## Request body

`application/json`, required.

- `title` (string): Shown on the page and in link previews. Up to 200 characters.
- `content` (string, required): The document's Markdown. 1–500,000 characters.
- `custom_slug` (string): Your own address: `markdrop.in/<custom_slug>`. Letters, digits, `-` and `_`. Taken or reserved addresses answer `409`. 3–50 characters. Matches `^[a-zA-Z0-9_-]+$`.
- `expires_in` ("never" | "1d" | "7d" | "30d" | "custom"): When the document is deleted. `custom` needs `custom_expires_at`. Default `"never"`.
- `custom_expires_at` (string (date-time)): The deletion time, when `expires_in` is `custom`. Must be in the future. ISO 8601, for example `2026-11-30T12:00:00Z`.
- `read_password` (string): Readers must enter this password before they see the content. 1–100 characters.
- `encrypted` (boolean): Set by clients that encrypt in the browser: `content` and `title` are already ciphertext. The server never sees the key. Default `false`.
- `access_level` ("private" | "link" | "workspace"): Who can open it: `link` (anyone with the link), `private` (only you and the people you share it with) or `workspace` (members of its workspace). Default `"link"`.
- `workspace` (string): File it in this workspace: the workspace's id. 1–64 characters.
- `folder` (string): An existing folder of `workspace`: its id or its path, like `guides/setup`. 1–400 characters.

## Responses

- `201`: Created. Returns the document with its `slug`, `url` and `edit_secret`.
  - `slug` (string)
  - `url` (string)
  - `folder_path` (array of string)
  - `title` (string | null): Shown on the page and in link previews.
  - `content` (string): The document's Markdown.
  - `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_owned` (boolean): Default `false`.
  - `is_owner` (boolean): Default `false`.
  - `id` (string | null)
  - `ref` (string | null)
  - `google_doc_url` (string | null)
  - `google_doc_stale` (boolean): Default `false`.
  - `vscode_synced` (boolean): Default `false`.
  - `encrypted` (boolean): Set by clients that encrypt in the browser: `content` and `title` are already ciphertext. The server never sees the key. Default `false`.
  - `kind` (string): Default `"markdown"`.
  - `mime` (string | null)
  - `renderer` (string | null)
  - `type_label` (string | null)
  - `size_bytes` (integer | null)
  - `original_filename` (string | null)
  - `artifact_url` (string | null)
  - `download_url` (string | null)
  - `poster_url` (string | null)
  - `media` (object | null)
  - `file_version` (integer | null)
  - `workspace_url` (string | null)
  - `access_level` (string): Who can open it: `link` (anyone with the link), `private` (only you and the people you share it with) or `workspace` (members of its workspace). Default `"link"`.
  - `workspace_id` (string | null)
  - `can` (object | null)
  - `read_ticket` (string | null)
  - `access_epoch` (integer): Default `0`.
  - `edit_secret` (string): Returned once. Send it as `X-Edit-Secret` to change or delete a document published without a token.
  - `workspace_error` (string | null)
- `409`: The custom address is taken, or reserved.
- `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 \
  -H "Authorization: Bearer $MARKDROP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
       "title": "Release notes",
       "content": "# Release notes\n\nPublished from the API.",
       "expires_in": "7d"
     }'
```

**JavaScript**

```javascript
const res = await fetch("https://api.markdrop.in/api/v1/documents", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MARKDROP_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "title": "Release notes",
    "content": "# Release notes\n\nPublished from the API.",
    "expires_in": "7d"
  }),
});
const data = await res.json();
```

**Python**

```python
import os

import requests

r = requests.post(
    "https://api.markdrop.in/api/v1/documents",
    headers={"Authorization": f"Bearer {os.environ['MARKDROP_TOKEN']}"},
    json={
        "title": "Release notes",
        "content": "# Release notes\n\nPublished from the API.",
        "expires_in": "7d",
    },
)
r.raise_for_status()
print(r.json())
```
