---
title: Create a nodes token
summary: Issue a short-lived token for a set of nodes, including the versions they will get later, and use it in the browser.
order: 50
languages: [javascript, java, csharp, php]
terms: [nodes-token, auth-token, scope, node, version]
see-also: [how-to/auth/create-a-versions-token, how-to/auth/create-a-recursive-node-token, how-to/auth/refresh-an-expired-token, explanation/tokens-and-delegation]
notion: https://www.notion.so/bimbase/Auth-Tokens-ba73574cf219406898ee0159b58bd187
---

# Create a nodes token

For a backend whose users follow a model rather than one upload of it. A [[term:nodes-token|nodes token]] names a set of [[term:node|nodes]] and grants every [[term:version|version]] of them, the ones that exist now and the ones uploaded while the token is valid. It does not recurse into folders; for that, use a [[term:recursive-node-token|recursive-node token]]. When you want to pin exact versions, use a [[term:versions-token|versions token]].

## Before you start

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

## 1. Choose the lifetime

`expires_seconds` is required and the token cannot be revoked; keep it short and refresh from the backend ([[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.createNodesToken(
	[nodeUuid1, nodeUuid2], 30 * 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 java.util.Set;
import java.util.UUID;
import com.fasterxml.jackson.databind.node.ObjectNode;
import nl.bimbase.bimworks.client.Scope;

ObjectNode auth = client.tokens.createNodesToken(Set.of(nodeUuid1, nodeUuid2), Duration.ofMinutes(30),
		EnumSet.of(Scope.FS_READ, Scope.GEOMETRY_READ, Scope.QUERY_RUN), null, false);
```
```csharp
ISet<Guid> nodes = Collections.CreateHashSet(nodeUuid1, nodeUuid2);
ISet<Scope> scopes = new HashSet<Scope> { Scope.FS_READ, Scope.GEOMETRY_READ, Scope.QUERY_RUN };
CreateNodesTokenResponse response = client.Tokens.CreateNodesToken(
    new CreateNodesTokenRequest(nodes, scopes, TimeSpan.FromMinutes(30)));
AuthToken auth = response.GetAuth();
string forBrowser = auth.GetJson().GetRawText();
```
```

```sdk-example
operation: CreateNodesToken
body: |
  {
    "node_uuids": ["<node uuid>", "<node uuid>"],
    "expires_seconds": 1800,
    "scopes": ["fs:read", "geometry:read", "query:run"]
  }
```

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

```try-it
operation: CreateNodesToken
method: POST
path: /openapi/auth/CreateNodesToken
body: |
  {
    "node_uuids": ["<node uuid>", "<node uuid>"],
    "expires_seconds": 1800,
    "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 `node_uuids` instead of `version_uuids`. Every node is checked for read rights; one node you may not read fails the whole call with [[error:AuthorizationError.NO_READ_RIGHTS]].

## 3. Use it in the browser

Create the page's client with `createClientWithAuth(auth)` exactly as for a versions token ([[page:how-to/auth/create-a-versions-token#use]]). The page resolves a node to its current version with `fs.getNodeByUuid(nodeUuid).last_version_uuid` ([[js:@bimworks/jssdk/Fs|Fs]]) and loads or queries that.

## Check

With the browser client, `fs.getNodeByUuid` on one of the nodes answers, and a query on its `last_version_uuid` returns objects. Upload a new version of the node from the backend; the same token now resolves to the new `last_version_uuid`. A node outside the set fails with [[error:AuthorizationError.NO_READ_RIGHTS]].
