0

Get Current User

by
Published today

Get the bot user the token belongs to, with its workspace.

Script notion Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 3 hours ago
1
//native
2

3
/**
4
 * Get Current User
5
 * Get the bot user the token belongs to: its name, owner and workspace name and ID.
6
 */
7
export async function main(auth: RT.Notion) {
8
  const response = await fetch(`https://api.notion.com/v1/users/me`, {
9
    headers: {
10
      Authorization: `Bearer ${auth.token}`,
11
      Accept: "application/json",
12
      "Notion-Version": "2026-03-11",
13
    },
14
  })
15

16
  if (!response.ok) {
17
    throw new Error(`${response.status} ${await response.text()}`)
18
  }
19

20
  return await response.json()
21
}
22