---
title: "Create Library Document"
method: POST
path: "/library/documents"
tags: ["Documents"]
---

# Create Library Document

`POST /library/documents`

## Request

- Base URL: `https://be.graph8.com/api/v1`
- URL: `https://be.graph8.com/api/v1/library/documents`
- Auth: HTTP bearer

Create a TEXT document from a string.

The counterpart to `/documents/upload`: no file, no extraction, the
`content` you send is the content stored. Use it for material you already
have as text.

## Headers

- `Authorization` string, nullable
- `X-Target-Org-Id` string, nullable

## Request body

- LibraryDocumentCreateRequest: Create a TEXT document in the Library. Mirrors `campaign_builder.routers.library.CreateDocumentRequest`. For a file, use `POST /library/documents/upload` instead - this path stores the `content` string verbatim and runs no extraction.
  - `folder_path` string, required: Where it lands, e.g. `Library/Case Studies`. The folder must already exist.
  - `file_name` string, required: Stored file name.
  - `display_name` string, required: How the document is listed.
  - `content` string, required: The document text. Stored verbatim.
  - `source` string: Where the text came from; `manual` or `copilot` are what the app writes. NOT validated by the app, so any value is accepted and stored as given.
  - `copilot_session_id` string, nullable: The Copilot session that produced it, when `source` is `copilot`.
  - `context_type` 'global' | 'campaign' | 'account': Whose library this belongs to.
  - `campaign_id` string, nullable: REQUIRED when `context_type` is `campaign`.
  - `account_id` string, nullable: REQUIRED when `context_type` is `account`.

## Response `201`

Successful Response

- ApiResponseDocumentPayload
  - `data` DocumentPayload, required: An open envelope for one document, folder or questionnaire. Open on purpose: a Library document carries extraction metadata, a questionnaire carries per-provider processing detail, and a generated deal document carries `structured_data` and `highlights` whose shape is the generator's rather than this contract's. Pinning those would silently drop whatever the app learned to return that this file had not caught up on.
  - `pagination` PaginationMeta
    - `page` integer, required: Current page number (1-indexed)
    - `limit` integer, required: Items per page
    - `total` integer, required: Total number of items
    - `has_next` boolean, required: Whether there are more pages
    - `next_cursor` string, nullable: Opaque cursor for the next page; null when there are no more items. Pass it back as the `cursor` query param to fetch the following page without computing page numbers.
    - `total_available` integer, nullable: Search endpoints only: how many records really match, when known. Can be larger than `total`, which is capped at the 10,000 results that can be paged. For company search this is a distinct-company estimate. Null when unknown; absent outside search.
    - `total_is_lower_bound` boolean, nullable: Search endpoints only: true when more records match than `total` shows (the result set is larger than the 10,000 results that can be paged). Absent outside search.
    - `notes` string[], nullable: Search endpoints only: plain-language notes about the result, e.g. that more records match than can be paged, or that a reversed `between` range was put in order.

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/graph8/apis/graph8-developer-api.md) · [All operations](https://skmtc.dev/graph8/apis/graph8-developer-api/llms.txt) · [OpenAPI document](https://skmtc.dev/graph8/apis/graph8-developer-api/revisions/89fc11143b70?raw)
