---
title: Delete and restore a node
summary: Soft-delete a node so it disappears from listings, and restore it later; what cannot be deleted and when a restore fails.
order: 60
languages: [javascript, java, csharp, php]
terms: [node, version]
see-also: [how-to/models/list-the-tree, how-to/models/create-a-folder, explanation/nodes-versions-and-the-tree]
---

# Delete and restore a node

For clean-up in an integration. Deleting a [[term:node|node]] is a soft delete: the node and everything below it vanish from listings, queries and viewers, but nothing is removed from storage, and `UndeleteNode` brings the node back with all its [[term:version|versions]].

## Before you start

- A login with the `fs:write` scope and write rights on the node ([[page:how-to/auth/log-in-with-an-api-token]]).
- The node's UUID ([[page:how-to/models/list-the-tree]]).

## 1. Delete

```code-group {#delete} classic
```javascript
await client.fs.deleteNode(nodeUuid);
```
```java
client.fs.deleteNode(nodeUuid);
```
```csharp
client.Fs.DeleteNode(nodeUuid);
```
```

```sdk-example
operation: DeleteNode
body: |
  {
    "uuid": "<node uuid>"
  }
```

`deleteNode` is on [[js:@bimworks/jssdk/Fs|Fs]] and [[java:nl.bimbase.bimworks.client.apis.FileSystemApi|FileSystemApi]], `DeleteNode` on [[dotnet:BIM.works_SDK.Fs|Fs]], `FsApi::deleteNode` in [[page:reference/sdk/php]]; over HTTP [[openapi:DeleteNode]]:

```try-it
operation: DeleteNode
method: POST
path: /openapi/fs/DeleteNode
body: |
  {
    "uuid": "<node uuid>"
  }
```

Two nodes refuse: the root node of an account ([[error:CANNOT_DELETE_USER_FOLDER]]) and the root node of an API token ([[error:CANNOT_DELETE_API_TOKEN_FOLDER]]). Deleting a folder deletes its subtree with it. The Java and .NET SDKs also offer `deleteNodeIfExists(path)`, which does nothing for a path that does not exist, handy in test set-ups.

## 2. Restore

```code-group {#restore} classic
```javascript
await client.fs.undeleteNode(nodeUuid);
```
```java
client.fs.undeleteNode(nodeUuid);
```
```csharp
client.Fs.UndeleteNode(nodeUuid);
```
```

```sdk-example
operation: UndeleteNode
body: |
  {
    "uuid": "<node uuid>"
  }
```

`undeleteNode` is on [[js:@bimworks/jssdk/Fs|Fs]] and [[java:nl.bimbase.bimworks.client.apis.FileSystemApi|FileSystemApi]], `UndeleteNode` on [[dotnet:BIM.works_SDK.Fs|Fs]], `FsApi::undeleteNode` in [[page:reference/sdk/php]]; over HTTP [[openapi:UndeleteNode]] with the same `uuid` body. A restore fails with [[error:CANNOT_UNDELETE_NAME_CONFLICT]] when the parent meanwhile got another node with the same name; rename or delete that one first.

## 3. Know what stays

- A deleted node is invisible to API tokens and delegated tokens; an account with the super-admin role can list deleted nodes with `show_deleted_nodes` on [[openapi:ListNodes]], which is how you find a UUID you did not keep.
- Versions are not deleted by deleting the node; they come back with it. To drop a single version, use [[openapi:DeleteVersion]] (`deleteNodeVersion` in the SDKs): only the last version of a node can be deleted ([[error:CAN_ONLY_DELETE_LAST_VERSION]]).
- Delegated tokens that name the node keep naming it; they simply cannot read it while it is deleted ([[error:AuthorizationError.NO_READ_RIGHTS]]).

## Check

After the delete, `listNodes` of the parent no longer shows the node and `getNodeByUuid` fails with [[error:AuthorizationError.NO_READ_RIGHTS]]; after the restore, both work again and the node's `versions` are unchanged ([[page:how-to/models/list-the-tree]]).
