---
title: "Create document"
method: POST
path: "/api/businesses/{business_id}/library/files"
tags: ["library"]
---

# Create document

`POST /api/businesses/{business_id}/library/files`

## Request

- Base URL: `https://api.mymarky.ai`
- URL: `https://api.mymarky.ai/api/businesses/{business_id}/library/files`
- Auth: HTTP bearer

Create a markdown/text DOCUMENT in a business's library.

This is the create endpoint for the same documents that `list_files`,
`get_file`, `update_file`, and `delete_file` operate on (the
`create_library_file` name is kept for backwards compatibility). It does NOT
upload an image or video — for binary media use `upload_media`.

Documents are stored as resources and can be used as context for post
generation. Use this to push blog posts, notes, or any written content.

Send an `Idempotency-Key` header to make a retry safe (a resend with the same
key returns the original file instead of creating a duplicate).

Errors:
    400 invalid_request: The file could not be created (e.g. bad path or content).
    400 invalid_value: The business_id is not a valid UUID.
    401 authentication_required: API key or token is missing, invalid, or revoked.
    403 permission_denied: Your plan does not include API access, or this business is not in your org.
    404 resource_not_found: No business with that ID exists.
    422 IDEMPOTENCY_KEY_CONFLICT: The Idempotency-Key was reused with a different body.
    429 rate_limit_exceeded: You sent too many requests this minute.

## Path parameters

- `business_id` string, required: A UUID identifier.

## Headers

- `Idempotency-Key` string, nullable: Optional. Send a unique value (e.g. a UUID) to make this create request safe to retry. A repeat with the same key returns the original response instead of creating a duplicate. Cached for 24h, scoped to your org. Reusing a key with a different body returns 422.
- `Marky-Version` '2026-04-08' | '2026-07-17' | '2026-08-02' | '2026-08-04' | '2026-08-06'

## Request body

- FileCreateRequest
  - `path` string, required: File path (e.g. '/documents/my-notes')
  - `content` string, required: File content (markdown)

## Response `201`

Successful Response

- FileCreateResponse
  - `id` string, required: Created file ID
  - `path` string, required: Full file path
  - `name` string, required: File name (the last path segment), matching list/get responses

## Other responses

- `400`: Bad request — the input was malformed or otherwise invalid.
- `401`: Authentication failed — the API key is missing or invalid.
- `403`: Forbidden — the key is valid but may not access this resource.
- `404`: Not found — no resource matches the id in the path.
- `409`: Conflict — a resource like this already exists.
- `422`: Validation error — one or more fields failed validation.
- `429`: Rate limited — retry after the window resets (see Retry-After).
- `500`: Server error — something failed on our side; retry or quote X-Request-Id.

---

[API](https://skmtc.dev/mymarky/apis/marky-public-api.md) · [All operations](https://skmtc.dev/mymarky/apis/marky-public-api/llms.txt) · [OpenAPI document](https://skmtc.dev/mymarky/apis/marky-public-api/revisions/25aeacae455c?raw)
