---
title: 'Files and directories'
url: 'https://docs.geens.com/geens-partners/geens-sdk/browser-sdk/files-and-directories'
markdown: 'https://docs.geens.com/geens-partners/geens-sdk/browser-sdk/files-and-directories.md'
date: '2026-12-03'
description: 'The following examples assume a logged-in session. The options argument is required even when empty. For shared links, supply url_token and password together. external_access_token, when needed, also requires that pair. createDirectory and createFile additionally accept external_access_token_for_p…'
---

# Files and directories

[](#)# Files and directories

The following examples assume a logged-in session. The `options` argument is required even when empty. For shared links, supply `url_token` and `password`together. `external_access_token`, when needed, also requires that pair. `createDirectory` and `createFile` additionally accept `external_access_token_for_parent_item` for access to their parent.

## Create a directory

Pass `null` for the root directory. The privacy flag defaults to `false` if you pass `undefined`; pass it explicitly before the options and callbacks.

```javascript
sdk.createDirectory(null, 'Documents', false, {}, onSuccess, onError);
```

## Create a file

Accepts a browser `File` or an `ArrayBuffer`. For a `File`, pass `null` for the metadata fields to derive them from the file. With an `ArrayBuffer`, supply a title, extension, and MIME type. The privacy flag is required.

```javascript
const file = new File(['Hello'], 'greeting.txt', { type: 'text/plain' });
sdk.createFile(null, null, null, null, file, false, {}, onSuccess, onError);
```

With an `ArrayBuffer`:

```javascript
const buffer = new TextEncoder().encode('Hello').buffer;
sdk.createFile(null, 'greeting', 'txt', 'text/plain', buffer, false, {}, onSuccess, onError);
```

## Get item metadata

`getItem` accepts an array of item IDs and returns decrypted metadata through the success callback:

```javascript
sdk.getItem([123, 456], {}, onSuccess, onError);
```

## List items

Supply the parent directory ID, or `-1` for the root. `type` can be `''`, `'personal'`, `'company'`, `'shared_for_me'`, or `'shared_by_me'`.

```javascript
sdk.listAllItems(-1, { type: 'personal' }, onSuccess, onError);
```

Get all active items with `false`, or request deleted items with `true`:

```javascript
sdk.getAllItems(false, onSuccess, onError);
```

Get descendants of one or more items:

```javascript
sdk.getItemsDescendants([123], {}, onSuccess, onError);
```

## Update metadata and note content

Pass `null` for the title or description you want to leave unchanged. Supplying `null` for both performs no update.

```javascript
sdk.updateItem(123, 'New title', null, {}, onSuccess, onError);
sdk.editNote(123, 'Updated note content', {}, onSuccess, onError);
```

`editNote` creates updated content for a text file; its callback receives version data from the API.

## File versions

Upload a new version using a file of the same type:

```javascript
const versionFile = new File(['Updated'], 'greeting.txt', { type: 'text/plain' });
sdk.createItemVersion(123, versionFile, {}, onSuccess, onError);
```

Delete a version by passing the item and version IDs in the expected object:

```javascript
sdk.deleteItemVersion({ id: 123, version: { id: 456 } }, {}, onSuccess, onError);
```

## Copy and move items

Pass the destination directory ID first and the item IDs second. Use `-1` for the root destination. Passing `null` with an options object currently reports `parent_id_is_missing`.

```javascript
sdk.copyItems(789, [123], {}, onSuccess, onError);
sdk.moveItems(789, [123], {}, onSuccess, onError);
```

For shared links, these methods accept `external_access_token` as an array of strings, rather than the single string used by most other file methods.

## Download files

Pass item descriptors with `itemId`; include `versionId` to select a version. The success callback receives an array of Blobs for the application to save or use. This method does not create a browser download link for you.

```javascript
sdk.downloadItem([{ itemId: 123 }], {}, onSuccess, onError);
sdk.downloadItem([{ itemId: 123, versionId: 456 }], {}, onSuccess, onError);
```

## Delete items

```javascript
sdk.permanentlyDeleteItems([123], {}, onSuccess, onError);
```

Despite its name, `permanentlyDeleteItems` currently sends a **soft-delete**request. Do not rely on it for permanent erasure. There is no public SDK method for hard deletion or restoring deleted items in this release.

---

## Navigation

- Parent: [Browser SDK](https://docs.geens.com/geens-partners/geens-sdk/browser-sdk.md)
- Previous: [Authentication](https://docs.geens.com/geens-partners/geens-sdk/browser-sdk/authentication.md)
- Next: [Sharing and users](https://docs.geens.com/geens-partners/geens-sdk/browser-sdk/sharing-and-users.md)
