//native
type Figma = {
token: string;
};
/**
* Update a webhook
* Update a webhook by ID.
*/
export async function main(
auth: Figma,
webhook_id: string,
body: {
event_type:
| "PING"
| "FILE_UPDATE"
| "FILE_VERSION_UPDATE"
| "FILE_DELETE"
| "LIBRARY_PUBLISH"
| "FILE_COMMENT";
endpoint: string;
passcode: string;
status?: "ACTIVE" | "PAUSED";
description?: string;
},
) {
const url = new URL(`https://api.figma.com/v2/webhooks/${webhook_id}`);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago