0

Update dev resources

by
Published Apr 8, 2025

Bulk update dev resources across multiple files. Ids for dev resources that are successfully updated will show up in the `links_updated` array in the response. If there are any dev resources that cannot be updated, you may still get a 200 response. These resources will show up in the `errors` array.

Script figma Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Figma = {
3
  token: string;
4
};
5
/**
6
 * Update dev resources
7
 * Bulk update dev resources across multiple files.
8

9
Ids for dev resources that are successfully updated will show up in the `links_updated` array in the response.
10

11
If there are any dev resources that cannot be updated, you may still get a 200 response. These resources will show up in the `errors` array.
12
 */
13
export async function main(
14
  auth: Figma,
15
  body: { dev_resources: { id: string; name?: string; url?: string }[] },
16
) {
17
  const url = new URL(`https://api.figma.com/v1/dev_resources`);
18

19
  const response = await fetch(url, {
20
    method: "PUT",
21
    headers: {
22
      "Content-Type": "application/json",
23
      Authorization: "Bearer " + auth.token,
24
    },
25
    body: JSON.stringify(body),
26
  });
27
  if (!response.ok) {
28
    const text = await response.text();
29
    throw new Error(`${response.status} ${text}`);
30
  }
31
  return await response.json();
32
}
33