0

Create card item

by
Published Oct 17, 2025

Adds a card item to a boardRequired 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 card item
7
 * Adds a card item to a boardRequired scope boards:write Rate limiting Level 2
8
 */
9
export async function main(
10
  auth: Miro,
11
  board_id: string,
12
  body: {
13
    data?: {
14
      assigneeId?: string;
15
      description?: string;
16
      dueDate?: string;
17
      title?: string;
18
    };
19
    style?: { cardTheme?: string };
20
    position?: { x?: number; y?: number };
21
    geometry?: { height?: number; rotation?: number; width?: number };
22
    parent?: { id?: string };
23
  },
24
) {
25
  const url = new URL(`https://api.miro.com//v2/boards/${board_id}/cards`);
26

27
  const response = await fetch(url, {
28
    method: "POST",
29
    headers: {
30
      "Content-Type": "application/json",
31
      Authorization: "Bearer " + auth.token,
32
    },
33
    body: JSON.stringify(body),
34
  });
35
  if (!response.ok) {
36
    const text = await response.text();
37
    throw new Error(`${response.status} ${text}`);
38
  }
39
  return await response.json();
40
}
41