# Update Document

`PATCH /api/v1/knowledge/{id}/documents/{documentId}`

## Description
Rename a document or enable/disable it. Disabled documents stay in the knowledge base but are left out of search results.

## Parameters

- **id** (path) (required) — `string`: Knowledge base ID.

- **documentId** (path) (required) — `string`: Document ID.

## Request Body

```json
{
  "type": "object",
  "required": [
    "workspaceId"
  ],
  "properties": {
    "workspaceId": {
      "type": "string",
      "description": "The workspace ID."
    },
    "filename": {
      "type": "string",
      "minLength": 1,
      "description": "New display filename."
    },
    "enabled": {
      "type": "boolean",
      "description": "Whether the document is included in search."
    }
  }
}
```

## Responses

### 200 — Document updated.

```json
{
  "type": "object",
  "properties": {
    "success": {
      "type": "boolean",
      "description": "Indicates whether the request was successful."
    },
    "data": {
      "type": "object",
      "properties": {
        "document": {
          "type": "object",
          "description": "Detailed document information including processing and connector details.",
          "properties": {
            "id": {
              "type": "string",
              "description": "Unique document identifier."
            },
            "knowledgeBaseId": {
              "type": "string",
              "description": "Knowledge base this document belongs to."
            },
            "filename": {
              "type": "string",
              "description": "Original filename."
            },
            "fileSize": {
              "type": "integer",
              "description": "File size in bytes."
            },
            "mimeType": {
              "type": "string",
              "description": "MIME type of the file."
            },
            "processingStatus": {
              "type": "string",
              "enum": [
                "pending",
                "processing",
                "completed",
                "failed"
              ],
              "description": "Current processing status."
            },
            "processingError": {
              "type": "string",
              "nullable": true,
              "description": "Error message if processing failed."
            },
            "processingStartedAt": {
              "type": "string",
              "format": "date-time",
              "nullable": true,
              "description": "When processing started."
            },
            "processingCompletedAt": {
              "type": "string",
              "format": "date-time",
              "nullable": true,
              "description": "When processing completed."
            },
            "chunkCount": {
              "type": "integer",
              "description": "Number of chunks created."
            },
            "tokenCount": {
              "type": "integer",
              "description": "Total token count."
            },
            "characterCount": {
              "type": "integer",
              "description": "Total character count."
            },
            "enabled": {
              "type": "boolean",
              "description": "Whether the document is enabled for search."
            },
            "connectorId": {
              "type": "string",
              "nullable": true,
              "description": "Connector ID if sourced from an external connector."
            },
            "connectorType": {
              "type": "string",
              "nullable": true,
              "description": "Connector type (e.g. google-drive, notion)."
            },
            "sourceUrl": {
              "type": "string",
              "nullable": true,
              "description": "Original source URL for connector-sourced documents."
            },
            "createdAt": {
              "type": "string",
              "format": "date-time",
              "description": "ISO 8601 timestamp when the document was uploaded."
            }
          }
        }
      },
      "description": "Response payload."
    }
  }
}
```

### 400 — Invalid request parameters. Check the details array for specific validation errors.

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message describing the validation failure."
    },
    "details": {
      "type": "array",
      "description": "List of specific validation errors with field-level details.",
      "items": {
        "type": "object"
      }
    }
  }
}
```

### 401 — Invalid or missing API key. Ensure the X-API-Key header is set with a valid key.

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    }
  }
}
```

### 403 — Access denied. You do not have permission to access this resource. For audit log endpoints, this requires an Enterprise subscription and organization admin/owner role.

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    }
  }
}
```

### 404 — The requested resource was not found. Verify the ID is correct and belongs to your workspace.

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message."
    }
  }
}
```

### 429 — Rate limit exceeded. Wait for the duration specified in the Retry-After header before retrying.

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Human-readable error message with rate limit details."
    }
  }
}
```
