> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mirage.strukto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# OneNote

> Virtualize OneNote notebooks through Microsoft Graph.

![](https://mintcdn.com/struktoai/F9Lv_nTaj6By6crk/images/python-logo.svg?fit=max\&auto=format\&n=F9Lv_nTaj6By6crk\&q=85\&s=cf5b268d330f7db46ea5cf6083f309a1)

Node.js

Browser

![](https://mintcdn.com/struktoai/CsxMCKUyfoQQJYHB/images/cloudflare-logo.svg?fit=max\&auto=format\&n=CsxMCKUyfoQQJYHB\&q=85\&s=23668457afa14abb3b0db0f5b9c0541a)

OneNote notebooks become a folder tree, read only: each notebook, section
group and section a folder, and each page the HTML OneNote renders for it.

## Setup

The mount needs a delegated Microsoft Graph access token with `Notes.Read`,
which reads the signed-in user's notebooks. OneNote's Graph API refuses
app-only tokens since March 31, 2025.

> [accordion] Quick token (Graph Explorer)
>
> The fastest way to try it. The token lasts about an hour.
>
> 1. Open [Graph Explorer](https://developer.microsoft.com/graph/graph-explorer)
>    and sign in.
> 2. Run `GET /me/onenote/notebooks` and consent to `Notes.Read` when asked.
> 3. Open the **Access token** tab and copy the token.

> [accordion] Device-code token (own app registration)
>
> A delegated token from an app registration. The first sign-in is
> interactive, so this is a development bootstrap, not an unattended
> credential.
>
> 1. In the [Microsoft Entra admin center](https://entra.microsoft.com), go
>    to **Entra ID** > **App registrations** > **New registration**.
>
> 2. Under **Authentication**, set **Allow public client flows** to **Yes**.
>
> 3. Under **API permissions** > **Microsoft Graph** > **Delegated
>    permissions**, add `Notes.Read`.
>
> 4. Request a device code with the **Application (client) ID** and the
>    **Directory (tenant) ID** from the registration's **Overview**, open
>    `https://microsoft.com/devicelogin` and enter the `user_code` it
>    prints. A registration that accepts accounts in any tenant can use
>    `common` for the tenant:
>
>    ```bash theme={null}
>    curl -s -X POST "https://login.microsoftonline.com/$TENANT_ID/oauth2/v2.0/devicecode" \
>      -d "client_id=$CLIENT_ID" \
>      -d "scope=Notes.Read offline_access"
>    ```
>
> 5. After signing in, exchange the `device_code` for tokens:
>
>    ```bash theme={null}
>    curl -s -X POST "https://login.microsoftonline.com/$TENANT_ID/oauth2/v2.0/token" \
>      -d "grant_type=urn:ietf:params:oauth:grant-type:device_code" \
>      -d "client_id=$CLIENT_ID" \
>      -d "device_code=$DEVICE_CODE"
>    ```
>
> Mirage does not refresh Microsoft tokens itself: a long-running program
> passes a callable as `access_token` that returns a fresh token.

```bash theme={null}
export MS_GRAPH_NOTES_TOKEN=eyJ0eXAi...
```

## Connect

> [tab] YAML
>
> ```yaml workspace.yaml theme={null}
> mounts:
>   /onenote:
>     vfs: onenote
>     mode: read
>     config:
>       access_token: ${MS_GRAPH_NOTES_TOKEN}
> ```
>
> ```bash theme={null}
> mirage workspace create workspace.yaml --id notes
> mirage shell -w notes -c 'ls /onenote'
> ```

> [tab] Python
>
> ```python theme={null}
> import os
>
> from mirage import MountMode, Workspace
> from mirage.vfs.onenote import OneNoteConfig, OneNoteVFS
>
> config = OneNoteConfig(access_token=os.environ["MS_GRAPH_NOTES_TOKEN"])
> ws = Workspace({"/onenote": OneNoteVFS(config)}, mode=MountMode.READ)
> result = await ws.shell("ls /onenote")
> print(await result.stdout_str())
> await ws.close()
> ```

> [tab] TypeScript
>
> ```typescript theme={null}
> import { MountMode, OneNoteVFS, Workspace } from '@struktoai/mirage-node'
>
> const ws = new Workspace(
>   {
>     '/onenote': new OneNoteVFS({
>       accessToken: process.env.MS_GRAPH_NOTES_TOKEN!,
>     }),
>   },
>   { mode: MountMode.READ },
> )
> const result = await ws.shell('ls /onenote')
> console.log(result.stdoutText)
> await ws.close()
> ```

## Layout

```text theme={null}
/onenote/
  Research Desk/
    Standards/
      Build_Conventions__0-9f6d26e0e2b14271!1-816F7725BFE7F3F8!1124.html
    Archive/
      Q4/
        Close/
          Close_checklist__0-4ab0a1c3d2e94f10!1-816F7725BFE7F3F8!1210.html
  Project Falcon/
    Open Items/
      Open_items__0-6c1e5d7b8a2f4c03!1-816F7725BFE7F3F8!1302.html
```

* A notebook, a section group and a section are each a folder named by its
  display name; section groups nest to any depth.
* A page file is the HTML OneNote answers for the page.
* The part after `__` is the page's Graph id.

## Sample runs

```bash theme={null}
$ ls /onenote
Project Falcon
Research Desk
```

```bash theme={null}
$ grep -rl 'checks row' /onenote
/onenote/Research Desk/Standards/Build_Conventions__0-9f6d26e0e2b14271!1-816F7725BFE7F3F8!1124.html
```

```bash theme={null}
$ grep -rh 'data-tag="to-do"' '/onenote/Project Falcon'
			<p data-tag="to-do">Confirm the revolver size with the lender</p>
```

The mount is read-only.

## SDK guides

> [card] [Python](https://docs.mirage.strukto.ai/python/vfs/onenote.md)
>
> Every config field, the layout and the VFS.md.

> [card] [TypeScript](https://docs.mirage.strukto.ai/typescript/vfs/onenote.md)
>
> Every config field, the layout and the VFS.md.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.