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

# Create or Update Knowledge Item

Creates a new knowledge item or updates an existing one at the given path. Requires `knowledge:write` permission on the key's role.

When updating an existing item, a version snapshot is created automatically for audit and rollback purposes.

<ParamField path="path" type="string" required>
  The item path, e.g. `docs/api/overview.md`. Must be lowercase, use hyphens/underscores, and end with a file extension.
</ParamField>

<ParamField body="content" type="string" required>
  The content to store.
</ParamField>

**Path constraints:**

* Max 255 characters
* Lowercase alphanumeric, hyphens, underscores, slashes, and dots
* Must end with a file extension (e.g. `.md`, `.json`)
* Max 5 directory levels

<ResponseExample>
  ```json 200 theme={null}
  {
    "success": true,
    "data": {
      "item": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "organizationId": "org_2abc123",
        "path": "docs/api/overview.md",
        "content": "# API Overview\n\nUpdated content.",
        "itemType": "text",
        "fileKey": null,
        "fileName": null,
        "contentType": null,
        "fileSize": null,
        "requiredReadPermission": "inherit",
        "requiredWritePermission": "inherit",
        "createdAt": "2026-01-15T10:30:00.000Z",
        "updatedAt": "2026-05-24T14:00:00.000Z"
      }
    }
  }
  ```

  ```json 403 theme={null}
  {
    "success": false,
    "error": "Forbidden — requires knowledge:write permission"
  }
  ```

  ```json 409 theme={null}
  {
    "success": false,
    "error": "A deleted item exists at this path — restore it first or use a different path"
  }
  ```
</ResponseExample>

<ResponseField name="success" type="boolean" required>
  Always `true` for successful responses.
</ResponseField>

<ResponseField name="data" type="object" required>
  <Expandable title="data">
    <ResponseField name="item" type="KnowledgeItem" required>
      The created or updated knowledge item.

      <Expandable title="KnowledgeItem">
        <ResponseField name="id" type="string" required>UUID of the item.</ResponseField>
        <ResponseField name="path" type="string" required>File-like path.</ResponseField>
        <ResponseField name="content" type="string" required>Item content.</ResponseField>
        <ResponseField name="itemType" type="string" required>Either `text` or `file`.</ResponseField>
        <ResponseField name="createdAt" type="string" required>ISO 8601 timestamp.</ResponseField>
        <ResponseField name="updatedAt" type="string" required>ISO 8601 timestamp.</ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>
