0

Update shape item

by
Published Oct 17, 2025

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

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