0

Create sticky note item

by
Published Oct 17, 2025

Adds a sticky note item to a board.Required scope boards:write Rate limiting Level 2

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 sticky note item
7
 * Adds a sticky note item to a board.Required scope boards:write Rate limiting Level 2
8
 */
9
export async function main(
10
  auth: Miro,
11
  board_id: string,
12
  body: {
13
    data?: { content?: string; shape?: "square" | "rectangle" };
14
    style?: {
15
      fillColor?:
16
        | "gray"
17
        | "light_yellow"
18
        | "yellow"
19
        | "orange"
20
        | "light_green"
21
        | "green"
22
        | "dark_green"
23
        | "cyan"
24
        | "light_pink"
25
        | "pink"
26
        | "violet"
27
        | "red"
28
        | "light_blue"
29
        | "blue"
30
        | "dark_blue"
31
        | "black";
32
      textAlign?: "left" | "right" | "center";
33
      textAlignVertical?: "top" | "middle" | "bottom";
34
    };
35
    position?: { x?: number; y?: number };
36
    geometry?: { height?: number; width?: number };
37
    parent?: { id?: string };
38
  },
39
) {
40
  const url = new URL(
41
    `https://api.miro.com//v2/boards/${board_id}/sticky_notes`,
42
  );
43

44
  const response = await fetch(url, {
45
    method: "POST",
46
    headers: {
47
      "Content-Type": "application/json",
48
      Authorization: "Bearer " + auth.token,
49
    },
50
    body: JSON.stringify(body),
51
  });
52
  if (!response.ok) {
53
    const text = await response.text();
54
    throw new Error(`${response.status} ${text}`);
55
  }
56
  return await response.json();
57
}
58