> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getaptly.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a knowledge document

> Creates a new knowledge document scoped to your company. Optionally associates the
document with a board (`aptletUuid`), a card (`aptletInstanceId`), or a parent
document (`parentId`).

HTML or Markdown content is accepted and stored internally as a structured document
format. Provide either `html` or `markdown`, not both.




## OpenAPI

````yaml /openapi.yaml post /api/knowledge/create
openapi: 3.0.3
info:
  title: Aptly API
  version: '1.0'
  description: >
    The Aptly API lets you read and write cards on any Aptly board from external
    systems.


    All requests require an API key passed as the `x-token` header.

    API keys are scoped to your company and work across all boards.
servers:
  - url: https://core-api.getaptly.com
    description: Production
security:
  - ApiKeyHeader: []
paths:
  /api/knowledge/create:
    post:
      tags:
        - Knowledge
      summary: Create a knowledge document
      description: >
        Creates a new knowledge document scoped to your company. Optionally
        associates the

        document with a board (`aptletUuid`), a card (`aptletInstanceId`), or a
        parent

        document (`parentId`).


        HTML or Markdown content is accepted and stored internally as a
        structured document

        format. Provide either `html` or `markdown`, not both.
      operationId: createKnowledgeDoc
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              not:
                required:
                  - html
                  - markdown
              properties:
                name:
                  type: string
                  description: Document title.
                html:
                  type: string
                  description: >-
                    Initial HTML content for the document body. Mutually
                    exclusive with `markdown`.
                markdown:
                  type: string
                  description: >-
                    Initial Markdown content for the document body. Mutually
                    exclusive with `html`.
                aptletUuid:
                  type: string
                  description: UUID of the board to associate this document with.
                aptletInstanceId:
                  type: string
                  description: >-
                    Card ID to link this document to. Creates a reference on the
                    card.
                parentId:
                  type: string
                  description: ID of a parent knowledge document (for nested pages).
                accessType:
                  type: string
                  enum:
                    - public
                    - private
                  description: Access level. Defaults to `public`.
            example:
              name: Lease Addendum Policy
              html: <p>This policy applies to all lease agreements...</p>
              accessType: private
      responses:
        '201':
          description: Document created.
          content:
            application/json:
              schema:
                type: object
                properties:
                  _id:
                    type: string
                    description: ID of the created document.
                  name:
                    type: string
        '400':
          description: Both `html` and `markdown` were provided (only one is allowed).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Invalid or missing API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: >-
            Card or parent document not found (when `aptletInstanceId` or
            `parentId` provided).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - ApiKeyHeader: []
        - DelegateToken: []
        - PartnerBearer: []
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
  securitySchemes:
    ApiKeyHeader:
      type: apiKey
      in: header
      name: x-token
    DelegateToken:
      type: apiKey
      in: header
      name: Authorization
      description: 'Delegate token issued by the platform. Format: `DelegateToken <token>`'
    PartnerBearer:
      type: http
      scheme: bearer
      description: 'Partner token. Format: `Authorization: Bearer <token>`'

````