--- title: "Replace file" slug: "rag-replace-file" updated: 2026-09-17T09:35:51Z published: 2026-09-17T09:35:51Z canonical: "api.ncloud-docs.com/rag-replace-file" --- > ## Documentation Index > Fetch the complete documentation index at: https://api.ncloud-docs.com/llms.txt > Use this file to discover all available pages before exploring further. # Replace file Available in VPC Replace a previously uploaded file with a new one. ## Request This section describes the request format. The method and URI are as follows: | Method | URI | | --- | --- | | PUT | /api/v1/svc/{serviceId}/file/{fileId} | ### Request headers For information about the headers common to all RAG APIs, see [RAG request headers](/docs/en/rag-overview#%EC%9A%94%EC%B2%AD%ED%97%A4%EB%8D%94). ### Request path parameters You can use the following path parameters with your request: | Field | Type | Required | Description | | --- | --- | --- | --- | | `serviceId` | String | Required | Service's unique identifier | | `fileId` | String | Required | File's unique identifier | ### Request query parameters You can use the following query parameters with your request: | Field | Type | Required | Description | | --- | --- | --- | --- | | `background` | Boolean | Optional | Whether to process text extraction in the background - `true` \| `false` (default) - `true`: Uploading a file returns an immediate response, while text extraction is asynchronous in the background. - `false`: Response is returned after text extraction is complete (synchronous processing). | ### Request body You can include the following data in the body of your request: | Field | Type | Required | Description | | --- | --- | --- | --- | | `file` | File | Required | File to upload (up to 1) - Supported formats - Image: JPG, PNG, TIFF - Document: PDF, PPTX, DOCX, HWP, HWPX, TXT - Data file: MD, JSON, XML - File size: Up to 100 MB | | `document` | Document | Optional | Document containing metadata for the file to be uploaded - Pass an object of the same format as Add/Replace document as a JSON string. - document.body is replaced with the string extracted from the file. - See [Request body](/docs/en/rag-add-doc#%EC%9A%94%EC%B2%AD%EB%B0%94%EB%94%94). | ### Request example The request example is as follows: ``` curl --location --request PUT 'https://kr-pub-gateway.rag.naverncp.com/api/v1/svc/{serviceId}/file/12345?background=true' \ --header 'Authorization: Bearer {apiKey}' \ --header 'Content-Type: multipart/form-data' \ --form 'file=@"filePath"' \ --form 'document={"id":"string","orgid":"string","title":"string","file_name":"string","body":"","url":"string","created_at":"2025-07-25T06:43:53.863Z","extra":{"additionalProp1":{}}}' ``` ## Response This section describes the response format. ### Response body The response body includes the following data: | Field | Type | Required | Description | | --- | --- | --- | --- | | `status` | Object | - | API processing result | | `status.code` | Integer | - | [API response status code](/docs/en/rag-overview#%EC%9D%91%EB%8B%B5%EC%83%81%ED%83%9C%EC%BD%94%EB%93%9C) | | `status.message` | String | - | [API response status message](/docs/en/rag-overview#%EC%9D%91%EB%8B%B5%EC%83%81%ED%83%9C%EC%BD%94%EB%93%9C) | | `result` | Object | - | File processing result | | `result.inserted` | Array | - | Created file ID (always `null`) | | `result.deleted` | Array | - | Deleted file ID (always `null`) | | `result.updated` | Array | - | Edited file ID | ### Response status codes For information about the HTTP status codes common to all RAG APIs, see [RAG response status codes](/docs/en/rag-overview#%EC%9D%91%EB%8B%B5%EC%83%81%ED%83%9C%EC%BD%94%EB%93%9C). ### Response example The response example is as follows: ``` { "status": { "code": 200, "message": "" }, "result": { "inserted": null, "deleted": null, "updated": [ "12345" ] } } ```