0

Create text item

by
Published Oct 17, 2025

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

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