Created
October 25, 2021 18:09
-
-
Save jaredshaunsmith/6f2d2b2b53573aba735f060c1280129a to your computer and use it in GitHub Desktop.
Figma api webhooks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get all registered Figma webhooks | |
const listWebHooks = async () => { | |
const response = await axios({ | |
url: `https://api.figma.com/v2/teams/${FIGMA_TEAM_ID}/webhooks`, | |
method: 'get', | |
headers: { | |
'X-Figma-Token': YOUR_FIGMA_PERSONAL_ACCESS_TOKEN, | |
} | |
}) | |
return response.data.webhooks | |
} | |
// delete a specific Figma webhook | |
const deleteWebhook = async (hookId) => { | |
await axios({ | |
url: `https://api.figma.com/v2/webhooks/${hookId}`, | |
method: 'delete', | |
headers: { | |
'X-Figma-Token': YOUR_FIGMA_PERSONAL_ACCESS_TOKEN, | |
} | |
}) | |
} | |
// create a Figma webhook | |
const createFigmaWebhook = async ({ | |
// https://www.figma.com/developers/api#webhooks-v2-events | |
event_type: 'FILE_VERSION_UPDATE' | |
}) => { | |
const response = await axios({ | |
url: 'https://api.figma.com/v2/webhooks', | |
method: 'post', | |
headers: { | |
'X-Figma-Token': YOUR_FIGMA_PERSONAL_ACCESS_TOKEN, | |
}, | |
data: { | |
event_type, | |
team_id: FIGMA_TEAM_ID, | |
passcode: A_SECRET_HANDSHAKE_PASSCODE_YOU_MADE_UP, | |
endpoint: THE_URL_THE_WEBHOOK_SHOULD_CALL | |
}, | |
}) | |
return response | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment