[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-entities\u002Ffiles\u002Fcopyto":3,"docs-tabs-entities\u002Ffiles\u002Fcopyto":6},{"content":4,"lastmod":5},"## Copy file\n\n`POST \u002Fv1\u002Ffiles\u002F:id\u002Fcopyto`\n\nCreates a copy of the file in the specified folder. The original stays in place; the copy gets a new identifier.\n\n## Parameters\n\n| Parameter | In | Type | Required | Description |\n|----------|---|-----|:-----:|---------|\n| `id` | path | number | yes | ID of the file to copy. Get it via `GET \u002Fv1\u002Ffiles` |\n\n## Request fields (body)\n\n| Field | Type | Required | Description |\n|------|-----|:-----:|---------|\n| `targetFolderId` | number | yes | Destination folder ID. Get it via `GET \u002Fv1\u002Ffolders` |\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X POST \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"targetFolderId\": 649}' \\\n  https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Ffiles\u002F9250\u002Fcopyto\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X POST \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"targetFolderId\": 649}' \\\n  https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Ffiles\u002F9250\u002Fcopyto\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch(\n  'https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Ffiles\u002F9250\u002Fcopyto',\n  {\n    method: 'POST',\n    headers: {\n      'X-Api-Key': 'YOUR_API_KEY',\n      'Content-Type': 'application\u002Fjson',\n    },\n    body: JSON.stringify({ targetFolderId: 649 }),\n  }\n)\nconst body = await res.json()\nif (!body.success) {\n  console.error(body.error.code, body.error.message)\n} else {\n  console.log('Copy created, ID:', body.data.id)\n}\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch(\n  'https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Ffiles\u002F9250\u002Fcopyto',\n  {\n    method: 'POST',\n    headers: {\n      'X-Api-Key': 'YOUR_APP_KEY',\n      'Authorization': 'Bearer USER_SESSION_TOKEN',\n      'Content-Type': 'application\u002Fjson',\n    },\n    body: JSON.stringify({ targetFolderId: 649 }),\n  }\n)\nconst body = await res.json()\n```\n\n## Response fields\n\nReturns the created copy.\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | `true` on a successful copy |\n| `data` | object | A file object. Full list of fields — [File fields](\u002Fdocs\u002Fentities\u002Ffiles\u002Ffields) |\n| `data.id` | number | ID of the created copy (differs from the original ID) |\n| `data.name` | string | File name |\n| `data.code` | string \\| null | System file code |\n| `data.storageId` | number | Storage ID |\n| `data.type` | string | Object type — always `\"file\"` |\n| `data.folderId` | number | Destination folder ID |\n| `data.deletedType` | number | Deletion type: `0` — not deleted |\n| `data.globalContentVersion` | number | Global content version |\n| `data.fileId` | number | Internal identifier of the file content |\n| `data.size` | number | Size in bytes |\n| `data.createdBy` | number | ID of the user who created the copy |\n| `data.updatedBy` | number | ID of the user who updated the copy |\n| `data.deletedBy` | number \\| null | ID of the user who deleted it. Always `null` for a new copy |\n| `data.createdAt` | string (ISO 8601) | Copy creation date |\n| `data.updatedAt` | string (ISO 8601) | Copy update date |\n| `data.deletedAt` | string \\| null | Deletion date. Always `null` for a new copy |\n| `data.downloadUrl` | string | Vibecode API address that downloads the file, `GET \u002Fv1\u002Ffiles\u002F:id\u002Fdownload`. Send the `X-Api-Key` header when you follow it |\n| `data.detailUrl` | string | URL of the file card in Bitrix24 |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"id\": 9253,\n    \"name\": \"doc-copy-test.txt\",\n    \"code\": null,\n    \"storageId\": 1,\n    \"type\": \"file\",\n    \"folderId\": 649,\n    \"deletedType\": 0,\n    \"globalContentVersion\": 1,\n    \"fileId\": 34869,\n    \"size\": 4,\n    \"createdBy\": 1,\n    \"updatedBy\": 1,\n    \"deletedBy\": null,\n    \"createdAt\": \"2026-05-06T09:35:13.000Z\",\n    \"updatedAt\": \"2026-05-06T09:35:13.000Z\",\n    \"deletedAt\": null,\n    \"downloadUrl\": \"https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Ffiles\u002F9253\u002Fdownload\",\n    \"detailUrl\": \"https:\u002F\u002F...\"\n  }\n}\n```\n\n## Error response example\n\n400 — `targetFolderId` not provided:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"MISSING_PARAMS\",\n    \"message\": \"targetFolderId is required.\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `MISSING_PARAMS` | Required `targetFolderId` parameter not provided |\n| 400 | `INVALID_PARAMS` | `targetFolderId` is not a positive integer |\n| 400 | `INVALID_ID` | The `id` in the path is not a positive integer |\n| 400 | `OPERATION_FAILED` | Bitrix24 returned an empty result — the copy was not performed |\n| 401 | `TOKEN_MISSING` | No authorization tokens found for the portal |\n| 403 | `SCOPE_DENIED` | The API key lacks the `disk` scope |\n| 422 | `BITRIX_ERROR` | A file with the same name already exists in the destination folder |\n\nFull list of common API errors — [Error codes](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n- **The copy gets a new ID.** The original stays in its source folder unchanged. The copy's identifier (the `data.id` field) differs from the original's — use `data.id` in all subsequent requests for the copy.\n- **Copying works between storages.** Unlike the move operation (`POST \u002Fv1\u002Ffiles\u002F:id\u002Fmoveto`), copying is allowed even when the source file and the destination folder belong to different storages.\n- **Name conflict.** If a file with the same name already exists in the destination folder, the operation fails with a `422` error. Rename the original or choose a different folder.\n\n## See also\n\n- [Move file](.\u002Fmoveto.md)\n- [Upload file](.\u002Fupload.md)\n- [List files](.\u002Flist.md)\n- [List folders](\u002Fdocs\u002Fentities\u002Ffolders)\n","2026-10-29",{},1794739375984]