Skip to main content
This page documents all HTTP endpoints exposed by the Markdown-OS server. Use these endpoints to interact with the editor programmatically from your client applications.

Base URL

When running locally:
When running in a cloud VM:
The server auto-increments the port if 8000 is occupied. Check the CLI output for the actual URL.

Editor Interface

GET /

Serves the main editor web application HTML page. Response: HTML document with the editor interface Example:

GET /favicon.ico

Redirects to the SVG favicon at /static/favicon.svg. Response: 302 redirect

Mode Information

GET /api/mode

Returns the current server mode (“file” or “folder”). Response:
string
required
Either “file” (single file editing) or “folder” (directory workspace)
Example:
Sample Response:

File Tree

GET /api/file-tree

Returns the markdown file tree structure for folder mode.
This endpoint is only available when the server is running in folder mode. Returns a 400 error in file mode.
Response:
object
Nested structure representing the directory tree with folders and markdown files
Example:
Sample Response:

Content Management

GET /api/content

Retrieve markdown content and metadata for a file. Query Parameters:
string
Relative file path (required in folder mode, ignored in file mode)
Response:
string
required
Raw markdown content of the file
object
required
File metadata including size, timestamps, and path information
integer
File size in bytes
string
Last modified timestamp (ISO 8601 format)
string
Relative path from workspace root (folder mode only)
Example:
Sample Response:
Error Responses:
  • 400: Missing file parameter in folder mode or invalid file path
  • 404: File not found
  • 500: File read error

POST /api/save

Save markdown content to disk with atomic file replacement. Request Body:
string
required
Markdown content to save
string
Relative file path (required in folder mode, ignored in file mode)
Response:
string
required
Always “saved” on success
object
required
Updated file metadata after save
integer
New file size in bytes
string
Updated timestamp (ISO 8601 format)
string
Relative path from workspace root (folder mode only)
Example:
Sample Response:
Error Responses:
  • 400: Missing file parameter in folder mode or invalid file path
  • 404: File not found (folder mode)
  • 500: File write error
Saving triggers a file watcher event, but the server ignores events from its own writes for 500ms to prevent infinite loops.

Image Management

POST /api/images

Upload an image to the workspace images directory. Request: multipart/form-data with file upload
file
required
Image file to upload
Supported Formats:
  • .png
  • .jpg, .jpeg
  • .gif
  • .webp
  • .svg
  • .bmp
  • .ico
Constraints:
  • Maximum file size: 10 MB
  • File must not be empty
  • Extension must be in the allowed list
Response:
string
required
Relative path to use in markdown (e.g., images/screenshot-20260228-103000-123456.png)
string
required
Generated unique filename with timestamp
Example:
Sample Response:
Error Responses:
  • 400: Unsupported format, empty file, or file too large
Filenames are sanitized and timestamped to prevent collisions. The original filename is preserved in the stem (e.g., screenshot.png becomes screenshot-20260228-103000-123456.png).

GET /images/{filename}

Serve an uploaded image from the workspace images directory. Path Parameters:
string
required
Image filename (can include subdirectories)
Response: Image file with appropriate content type Example:
Error Responses:
  • 400: Invalid path (contains .. or starts with /)
  • 404: Image not found
Security:
Path traversal attempts are blocked. The server validates that resolved paths stay within the images directory.

Static Assets

GET /static/{path}

Serves static frontend assets (JavaScript, CSS, fonts, icons). Example:
Static files are served from the markdown_os/static/ directory in the package.