---
title: Create a recursive-node token
summary: Issue a short-lived token for one folder and everything below it, and use it in the browser.
order: 60
languages: [javascript, java, csharp, php]
terms: [recursive-node-token, auth-token, scope, node]
see-also: [how-to/auth/create-a-versions-token, how-to/auth/create-a-nodes-token, how-to/auth/refresh-an-expired-token, explanation/tokens-and-delegation]
notion: https://www.notion.so/bimbase/Auth-Tokens-ba73574cf219406898ee0159b58bd187
---

# Create a recursive-node token

For a backend where each user's models live in one folder. A [[term:recursive-node-token|recursive-node token]] names a single [[term:node|node]] and grants that node, every node below it and every version of them, now and later. One token per user session, created at login, is enough; it never needs updating when models are added. Use it with care: a token on a folder high in the tree grants a lot.

## Before you start

- A backend logged in with an [[term:api-token|API token]] (or an account) that has read rights on the folder and the `tokens:issue` scope.
- The folder's UUID ([[page:how-to/models/list-the-tree]]).
- The [[term:scope|scopes]] the page needs (see [[page:how-to/auth/create-a-versions-token]]), never more than your own.

## 1. Choose the lifetime

`expires_seconds` is required and the token cannot be revoked; a recursive token in particular should not outlive the user's session ([[page:how-to/auth/refresh-an-expired-token]]).

## 2. Create the token in the backend

```code-group {#create} classic
```javascript
const result = await client.tokens.createRecursiveNodeToken(
	folderUuid, 60 * 60,
	null, false, false, ["fs:read", "geometry:read", "query:run"]);
const auth = result.auth;   // the JSON to send to the browser
```
```java
import java.time.Duration;
import java.util.EnumSet;
import com.fasterxml.jackson.databind.node.ObjectNode;
import nl.bimbase.bimworks.client.Scope;

ObjectNode auth = client.tokens.createRecursiveNodeToken(folderUuid, Duration.ofHours(1),
		EnumSet.of(Scope.FS_READ, Scope.GEOMETRY_READ, Scope.QUERY_RUN), null, false);
```
```csharp
ISet<Scope> scopes = new HashSet<Scope> { Scope.FS_READ, Scope.GEOMETRY_READ, Scope.QUERY_RUN };
CreateRecursiveNodeTokenResponse response = client.Tokens.CreateRecursiveNodeToken(
    new CreateRecursiveNodeTokenRequest(folderUuid, scopes, TimeSpan.FromHours(1)));
string forBrowser = response.GetAuth().GetJson().GetRawText();
```
```

```sdk-example
operation: CreateRecursiveNodeToken
body: |
  {
    "node_uuid": "<folder uuid>",
    "expires_seconds": 3600,
    "scopes": ["fs:read", "geometry:read", "query:run"]
  }
```

The methods: `createRecursiveNodeToken` on [[js:@bimworks/jssdk/Tokens|Tokens]] and [[java:nl.bimbase.bimworks.client.apis.TokensApi|TokensApi]], `CreateRecursiveNodeToken` on [[dotnet:BIM.works_SDK.Tokens|Tokens]], `AuthApi::createRecursiveNodeToken` in [[page:reference/sdk/php]]; over HTTP [[openapi:CreateRecursiveNodeToken]]:

```try-it
operation: CreateRecursiveNodeToken
method: POST
path: /openapi/auth/CreateRecursiveNodeToken
body: |
  {
    "node_uuid": "<folder uuid>",
    "expires_seconds": 3600,
    "scopes": ["fs:read", "geometry:read", "query:run"]
  }
```

The fields are those of [[page:how-to/auth/create-a-versions-token#create|the versions token]] with a single `node_uuid`.

## 3. Use it in the browser

Create the page's client with `createClientWithAuth(auth)` as for a versions token ([[page:how-to/auth/create-a-versions-token#use]]). The token's node is the client's root: `fs.getNodeByPath("/")` returns the folder, `fs.listNodes(uuid)` lists what is below it ([[js:@bimworks/jssdk/Fs|Fs]]), and paths are relative to the folder.

## Check

With the browser client, `fs.getNodeByPath("/")` returns the folder you named, and a model anywhere below it can be queried by its `last_version_uuid`. The folder's parent cannot be reached: `fs.getNodeByUuid(parentUuid)` fails with [[error:AuthorizationError.NO_READ_RIGHTS]].
