0

Create mind map node

by
Published Oct 17, 2025

Adds a mind map node to a board.

Script miro Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Miro = {
3
  token: string;
4
};
5
/**
6
 * Create mind map node
7
 * Adds a mind map node to a board.
8
 */
9
export async function main(
10
  auth: Miro,
11
  board_id: string,
12
  body: {
13
    data: { nodeView: { data?: { type: string; content?: string } } };
14
    position?: { x?: number; y?: number };
15
    geometry?: { width?: number };
16
    parent?: { id?: string };
17
  },
18
) {
19
  const url = new URL(
20
    `https://api.miro.com//v2-experimental/boards/${board_id}/mindmap_nodes`,
21
  );
22

23
  const response = await fetch(url, {
24
    method: "POST",
25
    headers: {
26
      "Content-Type": "application/json",
27
      Authorization: "Bearer " + auth.token,
28
    },
29
    body: JSON.stringify(body),
30
  });
31
  if (!response.ok) {
32
    const text = await response.text();
33
    throw new Error(`${response.status} ${text}`);
34
  }
35
  return await response.json();
36
}
37