# List Documents

`GET /api/v1/knowledge/{id}/documents`

## Description
List documents in a knowledge base with pagination, filtering, and sorting.

## Parameters

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

- **workspaceId** (query) (required) — `string`: The unique identifier of the workspace.

- **limit** (query) — `integer`: Maximum number of documents to return (1-100, default 50).

- **offset** (query) — `integer`: Number of documents to skip (default 0). Deprecated: use cursor. When both are sent, cursor wins.

- **cursor** (query) — `string`: Pagination cursor returned in a previous response's nextCursor field.

- **search** (query) — `string`: Search documents by filename.

- **enabledFilter** (query) — `string`: Filter by enabled status.

- **sortBy** (query) — `string`: Field to sort by.

- **sortOrder** (query) — `string`: Sort direction.

## Responses

### 200 — List of documents.

```json
{
  "type": "object",
  "properties": {
    "success": {
      "type": "boolean",
      "description": "Whether the request was successful."
    },
    "data": {
      "type": "object",
      "properties": {
        "documents": {
          "type": "array",
          "items": {
            "type": "object",
            "description": "A document in a knowledge base.",
            "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."
              },
              "chunkCount": {
                "type": "integer",
                "description": "Number of chunks created from this document."
              },
              "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."
              },
              "createdAt": {
                "type": "string",
                "format": "date-time",
                "description": "ISO 8601 timestamp when the document was uploaded."
              }
            }
          },
          "description": "Array of document objects in the knowledge base."
        },
        "pagination": {
          "type": "object",
          "properties": {
            "total": {
              "type": "integer",
              "minimum": 0,
              "example": 0,
              "description": "Total number of documents matching the query before pagination. Returned as a JSON number, including 0 when no documents match."
            },
            "limit": {
              "type": "integer",
              "description": "Maximum number of documents returned per page."
            },
            "offset": {
              "type": "integer",
              "description": "Number of documents skipped from the beginning."
            },
            "hasMore": {
              "type": "boolean",
              "description": "Whether there are more documents beyond the current page."
            }
          },
          "description": "Pagination metadata for the document list."
        }
      },
      "description": "Response payload containing the documents and pagination info."
    },
    "nextCursor": {
      "type": "string",
      "nullable": true,
      "description": "Cursor for fetching the next page. null when there are no more results."
    },
    "limits": {
      "type": "object",
      "description": "Rate limit and usage information attached to the /api/v1 workflows, logs, and audit logs responses. The Execute Workflow and Get Job Status responses do not include it.",
      "properties": {
        "workflowExecutionRateLimit": {
          "type": "object",
          "description": "Current rate limit status for workflow executions.",
          "properties": {
            "sync": {
              "description": "Rate limit bucket for synchronous executions.",
              "$ref": "#/components/schemas/RateLimitBucket"
            },
            "async": {
              "description": "Rate limit bucket for asynchronous executions.",
              "$ref": "#/components/schemas/RateLimitBucket"
            }
          }
        },
        "usage": {
          "type": "object",
          "description": "Current billing period usage and plan limits.",
          "properties": {
            "currentPeriodCost": {
              "type": "number",
              "description": "Total spend in the current billing period in USD.",
              "example": 1.25
            },
            "limit": {
              "type": "number",
              "description": "Maximum allowed spend for the current billing period in USD.",
              "example": 50
            },
            "plan": {
              "type": "string",
              "description": "Your current subscription plan (e.g., free, pro, team).",
              "example": "pro"
            },
            "isExceeded": {
              "type": "boolean",
              "description": "Whether the usage limit has been exceeded. Executions may be blocked when true.",
              "example": false
            }
          }
        }
      }
    }
  }
}
```

### 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."
    }
  }
}
```
