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

# Create knowledge document

> Create a new knowledge document.

**Default filename**

When `filename` is omitted, the destination filename is still derived from `title`
via the existing slugifier (lowercase, hyphenated). That behavior is unchanged.

**Optional `filename` (request body)**

Pass `filename` in the JSON body to control the stored name while preserving casing.

- Accepts either a bare name (`MyNote`) or with the `.md` extension (`MyNote.md`); the
  stored file always ends in `.md`.
- Case is preserved verbatim — `MyNote` becomes `MyNote.md`, not `mynote.md`. This is the
  main reason to use this parameter.
- Spaces are normalized to hyphens: `My Note` → `My-Note.md`.
- Characters outside `[A-Za-z0-9._-]` are stripped: `hello!` → `hello.md`.
- Path components are stripped for safety: `foo/bar` → `bar.md`.
- If the sanitized result is empty (for example `!!!` or all-whitespace input), the API
  returns **400 Bad Request**.
- If a file with the resolved filename already exists, the API returns **409 Conflict**.

**Example**

```bash
curl -X POST https://api.coconut.dev/api/v1/knowledge \
  -H 'Content-Type: application/json' \
  -d '{"title":"Quick Note","content":"...","filename":"QuickNote"}'
```

Successful responses include the created document under `data`, with `filename` reflecting
the resolved value (for example `QuickNote.md`).




## OpenAPI

````yaml /api-reference/openapi.yaml post /api/v1/knowledge
openapi: 3.1.1
info:
  title: Coconut API
  description: |
    Comprehensive API for the Coconut development platform.

    Coconut is a development environment that provides AI-assisted coding,
    task management, skill orchestration, and integrated terminal sessions.
  version: 1.0.72
  contact:
    name: Coconut Team
  license:
    name: MIT
servers:
  - url: http://localhost:3001
    description: Development server
  - url: '{baseUrl}'
    description: Production server
    variables:
      baseUrl:
        default: http://localhost:3001
        description: Base URL for the API
security:
  - sessionCookie: []
  - bearerAuth: []
  - apiKey: []
tags:
  - name: Tasks
    description: Task management
  - name: Skills
    description: AI skill configuration and management (Agent Skills spec)
  - name: Resources
    description: File and media resource management
  - name: Knowledge
    description: Knowledge document management
  - name: Terminal
    description: Terminal session management
  - name: AI
    description: AI chat and completion endpoints
  - name: Chats
    description: Chat history management
  - name: Configuration
    description: Project and global configuration
  - name: MCP
    description: Model Context Protocol server management
  - name: Context
    description: Context documents for role, agents, team, and memory
  - name: Identity
    description: Identity and agent card management
  - name: User
    description: User information and settings
  - name: Jobs
    description: Scheduled job management
  - name: Git
    description: Git repository management
  - name: Slack
    description: Slack integration and notification management
  - name: Mail
    description: Email management and Resend webhook integration
  - name: Version
    description: API version information
paths:
  /api/v1/knowledge:
    post:
      tags:
        - Knowledge
      summary: Create knowledge document
      description: >
        Create a new knowledge document.


        **Default filename**


        When `filename` is omitted, the destination filename is still derived
        from `title`

        via the existing slugifier (lowercase, hyphenated). That behavior is
        unchanged.


        **Optional `filename` (request body)**


        Pass `filename` in the JSON body to control the stored name while
        preserving casing.


        - Accepts either a bare name (`MyNote`) or with the `.md` extension
        (`MyNote.md`); the
          stored file always ends in `.md`.
        - Case is preserved verbatim — `MyNote` becomes `MyNote.md`, not
        `mynote.md`. This is the
          main reason to use this parameter.
        - Spaces are normalized to hyphens: `My Note` → `My-Note.md`.

        - Characters outside `[A-Za-z0-9._-]` are stripped: `hello!` →
        `hello.md`.

        - Path components are stripped for safety: `foo/bar` → `bar.md`.

        - If the sanitized result is empty (for example `!!!` or all-whitespace
        input), the API
          returns **400 Bad Request**.
        - If a file with the resolved filename already exists, the API returns
        **409 Conflict**.


        **Example**


        ```bash

        curl -X POST https://api.coconut.dev/api/v1/knowledge \
          -H 'Content-Type: application/json' \
          -d '{"title":"Quick Note","content":"...","filename":"QuickNote"}'
        ```


        Successful responses include the created document under `data`, with
        `filename` reflecting

        the resolved value (for example `QuickNote.md`).
      operationId: createKnowledge
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - title
                - content
              properties:
                title:
                  type: string
                  description: Document title
                filename:
                  type: string
                  description: |
                    Optional custom filename (string).
                  example: QuickNote
                content:
                  type: string
                  description: Document content in Markdown
                tags:
                  type: array
                  items:
                    type: string
            examples:
              customFilename:
                summary: Custom filename (case preserved)
                value:
                  title: Quick Note
                  content: ...
                  filename: QuickNote
      responses:
        '201':
          description: Knowledge document created
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/SuccessResponse'
                  - type: object
                    properties:
                      data:
                        type: object
                        properties:
                          document:
                            $ref: '#/components/schemas/KnowledgeDocument'
              examples:
                customFilename:
                  summary: Created with custom filename
                  value:
                    success: true
                    data:
                      document:
                        filename: QuickNote.md
                        title: Quick Note
                        content: ...
        '400':
          $ref: '#/components/responses/BadRequest'
        '409':
          description: A document with the resolved filename already exists
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  schemas:
    SuccessResponse:
      type: object
      required:
        - success
      properties:
        success:
          type: boolean
          const: true
        data:
          type: object
    KnowledgeDocument:
      type: object
      required:
        - filename
        - title
      properties:
        filename:
          type: string
          description: Document filename
        title:
          type: string
          description: Document title
        content:
          type: string
          description: >-
            Document content — full markdown when full=true, otherwise a ~200
            char summary
        metadata:
          type: object
          properties:
            updated:
              type: string
              format: date-time
            category:
              type: string
            tags:
              type: array
              items:
                type: string
            sources:
              type: array
              items:
                type: string
            summary:
              type: string
        snippet:
          type: string
          description: Context around the search match (only present when q is provided)
        matchedIn:
          type: array
          items:
            type: string
          description: >-
            Fields that matched the search query (only present when q is
            provided)
        score:
          type: number
          description: >-
            Relevance score — lower is better, 0 = exact match (only present
            when q is provided)
    ErrorResponse:
      type: object
      required:
        - success
        - error
      properties:
        success:
          type: boolean
          const: false
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: Error code
            message:
              type: string
              description: Human-readable error message
  responses:
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InternalError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    sessionCookie:
      type: apiKey
      in: cookie
      name: nut-session
      description: Session cookie authentication
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key authentication

````