# Update Doc

`PATCH /api/v1/docs/{fileId}`

## Description
Rename a doc, move it to another folder, or both. Pass `folderId: null` to move the doc to the workspace top level. Provide at least one of `name` or `folderId`.

## Parameters

- **fileId** (path) (required) — `string`: The doc ID.

## Request Body

```json
{
  "type": "object",
  "required": [
    "workspaceId"
  ],
  "properties": {
    "workspaceId": {
      "type": "string",
      "description": "The workspace ID."
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "description": "New doc name."
    },
    "folderId": {
      "type": [
        "string",
        "null"
      ],
      "description": "Target folder ID, or `null` for the top level."
    }
  }
}
```

## Responses

### 200 — Doc updated.

```json
{
  "type": "object",
  "properties": {
    "success": {
      "type": "boolean",
      "description": "Indicates whether the request was successful."
    },
    "data": {
      "type": "object",
      "properties": {
        "doc": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "description": "Unique file identifier.",
              "example": "wf_1709571234_abc1234"
            },
            "name": {
              "type": "string",
              "description": "Original filename.",
              "example": "data.csv"
            },
            "size": {
              "type": "integer",
              "description": "File size in bytes.",
              "example": 1024
            },
            "type": {
              "type": "string",
              "description": "MIME type of the file.",
              "example": "text/csv"
            },
            "key": {
              "type": "string",
              "description": "Storage key for the file.",
              "example": "workspace/abc-123/1709571234-xyz-data.csv"
            },
            "uploadedBy": {
              "type": "string",
              "description": "User ID of the uploader."
            },
            "uploadedAt": {
              "type": "string",
              "format": "date-time",
              "description": "ISO 8601 timestamp of when the file was uploaded."
            },
            "folderId": {
              "type": [
                "string",
                "null"
              ],
              "description": "Parent folder id, or null when the doc lives at the workspace top level."
            }
          }
        }
      },
      "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 — A doc with that name already exists in the target location (`code: "duplicate_name"`).

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