0

Create shape item

by
Published Oct 17, 2025

Adds a flowchart shape 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 shape item
7
 * Adds a flowchart shape 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?: string };
14
    style?: {
15
      borderColor?: string;
16
      borderOpacity?: string;
17
      borderStyle?: "normal" | "dotted" | "dashed";
18
      borderWidth?: string;
19
      color?: string;
20
      fillColor?: string;
21
      fillOpacity?: string;
22
      fontFamily?:
23
        | "arial"
24
        | "abril_fatface"
25
        | "bangers"
26
        | "eb_garamond"
27
        | "georgia"
28
        | "graduate"
29
        | "gravitas_one"
30
        | "fredoka_one"
31
        | "nixie_one"
32
        | "open_sans"
33
        | "permanent_marker"
34
        | "pt_sans"
35
        | "pt_sans_narrow"
36
        | "pt_serif"
37
        | "rammetto_one"
38
        | "roboto"
39
        | "roboto_condensed"
40
        | "roboto_slab"
41
        | "caveat"
42
        | "times_new_roman"
43
        | "titan_one"
44
        | "lemon_tuesday"
45
        | "roboto_mono"
46
        | "noto_sans"
47
        | "plex_sans"
48
        | "plex_serif"
49
        | "plex_mono"
50
        | "spoof"
51
        | "tiempos_text"
52
        | "formular";
53
      fontSize?: string;
54
      textAlign?: "left" | "right" | "center" | "unknown";
55
      textAlignVertical?: "unknown" | "top" | "middle" | "bottom";
56
    };
57
    position?: { x?: number; y?: number };
58
    geometry?: { height?: number; rotation?: number; width?: number };
59
    parent?: { id?: string };
60
  },
61
) {
62
  const url = new URL(
63
    `https://api.miro.com//v2-experimental/boards/${board_id}/shapes`,
64
  );
65

66
  const response = await fetch(url, {
67
    method: "POST",
68
    headers: {
69
      "Content-Type": "application/json",
70
      Authorization: "Bearer " + auth.token,
71
    },
72
    body: JSON.stringify(body),
73
  });
74
  if (!response.ok) {
75
    const text = await response.text();
76
    throw new Error(`${response.status} ${text}`);
77
  }
78
  return await response.json();
79
}
80