# Reprocess Document

`POST /api/v1/knowledge/{id}/documents/{documentId}/reprocess`

## Description
Retry processing for a document whose processing failed. Existing chunks are cleared and processing restarts in the background; poll Get Document for the new status. Only documents with `processingStatus: "failed"` can be reprocessed.

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

## Responses

### 202 — Processing restarted.

```json
{
  "type": "object",
  "properties": {
    "success": {
      "type": "boolean",
      "description": "Indicates whether the request was successful."
    },
    "data": {
      "type": "object",
      "properties": {
        "documentId": {
          "type": "string"
        },
        "processingStatus": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      },
      "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."
    }
  }
}
```

### 409 — The document is not in the `failed` state.

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