0

Update text item

by
Published Oct 17, 2025

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

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