0

Create connector

by
Published Oct 17, 2025

Adds a connector 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 connector
7
 * Adds a connector 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
    startItem: {
14
      id?: string;
15
      position?: { x?: string; y?: string };
16
      snapTo?: "auto" | "top" | "right" | "bottom" | "left";
17
    };
18
    endItem: {
19
      id?: string;
20
      position?: { x?: string; y?: string };
21
      snapTo?: "auto" | "top" | "right" | "bottom" | "left";
22
    };
23
    shape?: "straight" | "elbowed" | "curved";
24
    captions?: {
25
      content: string;
26
      position?: string;
27
      textAlignVertical?: "top" | "bottom" | "middle";
28
    }[];
29
    style?: {
30
      color?: string;
31
      endStrokeCap?:
32
        | "none"
33
        | "stealth"
34
        | "rounded_stealth"
35
        | "diamond"
36
        | "filled_diamond"
37
        | "oval"
38
        | "filled_oval"
39
        | "arrow"
40
        | "triangle"
41
        | "filled_triangle"
42
        | "erd_one"
43
        | "erd_many"
44
        | "erd_only_one"
45
        | "erd_zero_or_one"
46
        | "erd_one_or_many"
47
        | "erd_zero_or_many"
48
        | "unknown";
49
      fontSize?: string;
50
      startStrokeCap?:
51
        | "none"
52
        | "stealth"
53
        | "rounded_stealth"
54
        | "diamond"
55
        | "filled_diamond"
56
        | "oval"
57
        | "filled_oval"
58
        | "arrow"
59
        | "triangle"
60
        | "filled_triangle"
61
        | "erd_one"
62
        | "erd_many"
63
        | "erd_only_one"
64
        | "erd_zero_or_one"
65
        | "erd_one_or_many"
66
        | "erd_zero_or_many"
67
        | "unknown";
68
      strokeColor?: string;
69
      strokeStyle?: "normal" | "dotted" | "dashed";
70
      strokeWidth?: string;
71
      textOrientation?: "horizontal" | "aligned";
72
    };
73
  },
74
) {
75
  const url = new URL(`https://api.miro.com//v2/boards/${board_id}/connectors`);
76

77
  const response = await fetch(url, {
78
    method: "POST",
79
    headers: {
80
      "Content-Type": "application/json",
81
      Authorization: "Bearer " + auth.token,
82
    },
83
    body: JSON.stringify(body),
84
  });
85
  if (!response.ok) {
86
    const text = await response.text();
87
    throw new Error(`${response.status} ${text}`);
88
  }
89
  return await response.json();
90
}
91