> For the complete documentation index, see [llms.txt](https://docs.authgear.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.authgear.com/reference/apis/admin-api/using-global-node-ids.md).

# Using global node IDs

The node `id` is a globally unique identifier of an object. It is needed when you call the GraphQL query and mutation. In this section, we will go through how to generate the node ID for calling the Admin GraphQL API.

The node id is a [base64url](https://datatracker.ietf.org/doc/html/rfc4648#section-5) encoded string with the format of `<NODE_TYPE>:<ID>`. For example, in `User:97b1c929-842c-415c-a7df-6967efdda160` , the node is "User" while "97b1c929-842c-415c-a7df-6967efdda160" is the ID for a specific user.

## 1. Generate id for User node type

You can use your preferred programming language or tool to encode node IDs to base64url as shown below:

{% tabs %}
{% tab title="Go" %}

```go
package main

import (
	"encoding/base64"
	"fmt"
)

func main() {
	nodeID := base64.RawURLEncoding.EncodeToString([]byte("User:97b1c929-842c-415c-a7df-6967efdda160"))
	fmt.Println(nodeID)
}
```

{% endtab %}

{% tab title="Python" %}

```python
import base64

base64.urlsafe_b64encode(b'User:97b1c929-842c-415c-a7df-6967efdda160').replace(b'=', b'')
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
function base64url_encode($data) {
    return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}

$encoded_id = base64url_encode("User:97b1c929-842c-415c-a7df-6967efdda160");
echo $encoded_id;

```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const encoder = require('base64-url');

const encoded_id = encoder.encode("User:97b1c929-842c-415c-a7df-6967efdda160");
console.log(encoded_id);
```

{% endtab %}
{% endtabs %}

### Fetch the User object example

The query:

```graphql
query {
  node(id: "<BASE64URL_ENCODED_USER_NODE_ID>") {
    ... on User {
      id
      standardAttributes
    }
  }
}
```

## 2. Generate id for AuditLog node type

{% tabs %}
{% tab title="Go" %}

```go
package main

import (
	"encoding/base64"
	"fmt"
)

func main() {
	nodeID := base64.RawURLEncoding.EncodeToString([]byte("AuditLog:000000000004d2e7"))
	fmt.Println(nodeID)
}
```

{% endtab %}

{% tab title="Python" %}

```python
import base64

base64.urlsafe_b64encode(b'AuditLog:000000000004d2e7').replace(b'=', b'')
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
function base64url_encode($data) {
    return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}

$encoded_id = base64url_encode("AuditLog:000000000004d2e7");
echo $encoded_id;
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const encoder = require('base64-url');

const encoded_id = encoder.encode("AuditLog:000000000004d2e7");
console.log(encoded_id);
```

{% endtab %}
{% endtabs %}

### Fetch AuditLog object example

Query:

```graphql
{
  node(id: "<BASE64URL_ENCODED_AUDIT_LOG_NODE_ID>") {
    ... on AuditLog {
      id
      data
    }
  }
}
```

## 3. Generate id for Session node type

{% tabs %}
{% tab title="Go" %}

```go
package main

import (
	"encoding/base64"
	"fmt"
)

func main() {
	nodeID := base64.RawURLEncoding.EncodeToString([]byte("Session:8891767c-992c-4c09-bbae-9a8337ae661k"))
	fmt.Println(nodeID)
}
```

{% endtab %}

{% tab title="Python" %}

```python
import base64

base64.urlsafe_b64encode(b'Session:8891767c-992c-4c09-bbae-9a8337ae661k').replace(b'=', b'')
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
function base64url_encode($data) {
    return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}

$encoded_id = base64url_encode("Session:8891767c-992c-4c09-bbae-9a8337ae661k");
echo $encoded_id;
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const encoder = require('base64-url');

const encoded_id = encoder.encode("Session:8891767c-992c-4c09-bbae-9a8337ae661k");
console.log(encoded_id);
```

{% endtab %}
{% endtabs %}

### Fetch Session object example

Query:

```graphql
{
  node(id: "<BASE64URL_ENCODED_SESSION_NODE_ID>") {
    ... on Session {
      id
      displayName
      type
      createdAt
    }
  }
}
```

## 4. Generate id for Authenticator node type

{% tabs %}
{% tab title="Go" %}

```go
package main

import (
	"encoding/base64"
	"fmt"
)

func main() {
	nodeID := base64.RawURLEncoding.EncodeToString([]byte("Authenticator:95435c90-8501-4735-a8b6-412601605a25"))
	fmt.Println(nodeID)
}
```

{% endtab %}

{% tab title="Python" %}

```python
import base64

base64.urlsafe_b64encode(b'Authenticator:95435c90-8501-4735-a8b6-412601605a25').replace(b'=', b'')
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
function base64url_encode($data) {
    return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}

$encoded_id = base64url_encode("Authenticator:95435c90-8501-4735-a8b6-412601605a25");
echo $encoded_id;
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const encoder = require('base64-url');

const encoded_id = encoder.encode("Authenticator:95435c90-8501-4735-a8b6-412601605a25");
console.log(encoded_id);
```

{% endtab %}
{% endtabs %}

### Fetch Authenticator object example

Query:

```graphql
{
  node(id: "<BASE64URL_ENCODED_AUTHENTICATOR_NODE_ID>") {
    id
    ... on Authenticator {
      id
      kind
      createdAt
    }
  }
}
```

## 5. Generate id for Authorization node type

{% tabs %}
{% tab title="Go" %}

```go
package main

import (
	"encoding/base64"
	"fmt"
)

func main() {
	nodeID := base64.RawURLEncoding.EncodeToString([]byte("Authorization:12345a90-7801-41d5-c3b6-655501605b56"))
	fmt.Println(nodeID)
}
```

{% endtab %}

{% tab title="Python" %}

```python
import base64

base64.urlsafe_b64encode(b'Authorization:12345a90-7801-41d5-c3b6-655501605b56').replace(b'=', b'')
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
function base64url_encode($data) {
    return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}

$encoded_id = base64url_encode("Authorization:12345a90-7801-41d5-c3b6-655501605b56");
echo $encoded_id;
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const encoder = require('base64-url');

const encoded_id = encoder.encode("Authorization:12345a90-7801-41d5-c3b6-655501605b56");
console.log(encoded_id);
```

{% endtab %}
{% endtabs %}

### Fetch Authorization object example

Query:

```graphql
{
  node(id: "<BASE64URL_ENCODED_AUTHORIZATION_NODE_ID>") {
    id
    ... on Authorization {
      id
      clientID
      scopes
      createdAt
    }
  }
}
```

## 6. Generate id for Identity node type

{% tabs %}
{% tab title="Go" %}

```go
package main

import (
	"encoding/base64"
	"fmt"
)

func main() {
	nodeID := base64.RawURLEncoding.EncodeToString([]byte("Identity:12345a90-7801-41d5-c3b6-655501605b56"))
	fmt.Println(nodeID)
}
```

{% endtab %}

{% tab title="Python" %}

```python
import base64

base64.urlsafe_b64encode(b'Identity:12345a90-7801-41d5-c3b6-655501605b56').replace(b'=', b'')
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
function base64url_encode($data) {
    return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}

$encoded_id = base64url_encode("Identity:12345a90-7801-41d5-c3b6-655501605b56");
echo $encoded_id;
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const encoder = require('base64-url');

const encoded_id = encoder.encode("Identity:12345a90-7801-41d5-c3b6-655501605b56");
console.log(encoded_id);
```

{% endtab %}
{% endtabs %}

### Fetch Identity object example

Query:

```graphql
{
  node(id: "<BASE64URL_ENCODED_IDENTITY_NODE_ID>") {
    id
    ... on Identity {
      id
      claims
      type
    }
  }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.authgear.com/reference/apis/admin-api/using-global-node-ids.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
