For AI agents: markdown of this page — /docs-content-en/entities/files/copyto.md documentation index — /llms.txt

Copy file

POST /v1/files/:id/copyto

Creates a copy of the file in the specified folder. The original stays in place; the copy gets a new identifier.

Parameters

Parameter In Type Required Description
Parameterid Inpath Typenumber Requiredyes DescriptionID of the file to copy. Get it via GET /v1/files

Request fields (body)

Field Type Required Description
FieldtargetFolderId Typenumber Requiredyes DescriptionDestination folder ID. Get it via GET /v1/folders

Examples

curl — personal key

Terminal
curl -X POST \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"targetFolderId": 649}' \
  https://vibecode.bitrix24.com/v1/files/9250/copyto

curl — OAuth application

Terminal
curl -X POST \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"targetFolderId": 649}' \
  https://vibecode.bitrix24.com/v1/files/9250/copyto

JavaScript — personal key

javascript
const res = await fetch(
  'https://vibecode.bitrix24.com/v1/files/9250/copyto',
  {
    method: 'POST',
    headers: {
      'X-Api-Key': 'YOUR_API_KEY',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ targetFolderId: 649 }),
  }
)
const body = await res.json()
if (!body.success) {
  console.error(body.error.code, body.error.message)
} else {
  console.log('Copy created, ID:', body.data.id)
}

JavaScript — OAuth application

javascript
const res = await fetch(
  'https://vibecode.bitrix24.com/v1/files/9250/copyto',
  {
    method: 'POST',
    headers: {
      'X-Api-Key': 'YOUR_APP_KEY',
      'Authorization': 'Bearer USER_SESSION_TOKEN',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ targetFolderId: 649 }),
  }
)
const body = await res.json()

Response fields

Returns the created copy.

Field Type Description
Fieldsuccess Typeboolean Descriptiontrue on a successful copy
Fielddata Typeobject DescriptionA file object. Full list of fields — File fields
Fielddata.id Typenumber DescriptionID of the created copy (differs from the original ID)
Fielddata.name Typestring DescriptionFile name
Fielddata.code Typestring | null DescriptionSystem file code
Fielddata.storageId Typenumber DescriptionStorage ID
Fielddata.type Typestring DescriptionObject type — always "file"
Fielddata.folderId Typenumber DescriptionDestination folder ID
Fielddata.deletedType Typenumber DescriptionDeletion type: 0 — not deleted
Fielddata.globalContentVersion Typenumber DescriptionGlobal content version
Fielddata.fileId Typenumber DescriptionInternal identifier of the file content
Fielddata.size Typenumber DescriptionSize in bytes
Fielddata.createdBy Typenumber DescriptionID of the user who created the copy
Fielddata.updatedBy Typenumber DescriptionID of the user who updated the copy
Fielddata.deletedBy Typenumber | null DescriptionID of the user who deleted it. Always null for a new copy
Fielddata.createdAt Typestring (ISO 8601) DescriptionCopy creation date
Fielddata.updatedAt Typestring (ISO 8601) DescriptionCopy update date
Fielddata.deletedAt Typestring | null DescriptionDeletion date. Always null for a new copy
Fielddata.downloadUrl Typestring DescriptionVibecode API address that downloads the file, GET /v1/files/:id/download. Send the X-Api-Key header when you follow it
Fielddata.detailUrl Typestring DescriptionURL of the file card in Bitrix24

Response example

JSON
{
  "success": true,
  "data": {
    "id": 9253,
    "name": "doc-copy-test.txt",
    "code": null,
    "storageId": 1,
    "type": "file",
    "folderId": 649,
    "deletedType": 0,
    "globalContentVersion": 1,
    "fileId": 34869,
    "size": 4,
    "createdBy": 1,
    "updatedBy": 1,
    "deletedBy": null,
    "createdAt": "2026-05-06T09:35:13.000Z",
    "updatedAt": "2026-05-06T09:35:13.000Z",
    "deletedAt": null,
    "downloadUrl": "https://vibecode.bitrix24.com/v1/files/9253/download",
    "detailUrl": "https://..."
  }
}

Error response example

400 — targetFolderId not provided:

JSON
{
  "success": false,
  "error": {
    "code": "MISSING_PARAMS",
    "message": "targetFolderId is required."
  }
}

Errors

HTTP Code Description
HTTP400 CodeMISSING_PARAMS DescriptionRequired targetFolderId parameter not provided
HTTP400 CodeINVALID_PARAMS DescriptiontargetFolderId is not a positive integer
HTTP400 CodeINVALID_ID DescriptionThe id in the path is not a positive integer
HTTP400 CodeOPERATION_FAILED DescriptionBitrix24 returned an empty result — the copy was not performed
HTTP401 CodeTOKEN_MISSING DescriptionNo authorization tokens found for the portal
HTTP403 CodeSCOPE_DENIED DescriptionThe API key lacks the disk scope
HTTP422 CodeBITRIX_ERROR DescriptionA file with the same name already exists in the destination folder

Full list of common API errors — Error codes.

Known specifics

  • 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.
  • Copying works between storages. Unlike the move operation (POST /v1/files/:id/moveto), copying is allowed even when the source file and the destination folder belong to different storages.
  • 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.

See also