# Upload Doc

`POST /api/v1/docs`

## Description
Upload a doc to a workspace. Send the doc as multipart/form-data with a `file` field and a `workspaceId` field, plus an optional `folderId`. Maximum doc size is 100MB. Duplicate doc names within a workspace are not allowed.

## Request Body

## Responses

### 200 — Doc uploaded successfully.

```json
{
  "type": "object",
  "properties": {
    "success": {
      "type": "boolean",
      "description": "Whether the upload completed successfully."
    },
    "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."
            }
          }
        },
        "message": {
          "type": "string",
          "description": "Human-readable confirmation message."
        }
      },
      "description": "Response payload containing the uploaded doc metadata."
    }
  }
}
```

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

### 409 — A doc with the same name already exists in this workspace.

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Error message indicating a doc with the same name already exists in this workspace."
    }
  }
}
```

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