figma-api
Figma API
Overview
The Figma REST API (base URL https://api.figma.com) exposes every file as a tree of nodes in JSON, renders nodes to PNG, JPG, SVG or PDF, lists published components and styles, and manages comments and webhooks. This skill covers the read-oriented workflows used for developer handoff: fetch a file, extract styles into tokens, export assets, and react to changes. The machine-readable contract is the OpenAPI spec in the figma/rest-api-spec repository.
Instructions
Authentication. Send the token in the X-Figma-Token header. Create a personal access token in Figma under Settings, Security, "Generate new token"; you choose an expiration and scopes, and the value is shown once. Scopes needed here: file_content:read (file JSON and image rendering), library_content:read (published components and styles), webhooks:write and webhooks:read. The older files:read scope still works but is deprecated and broad. For organization automation such as CI use a plan access token (Organization and Enterprise plans); for apps acting on behalf of other users use an OAuth app, which sends an Authorization: Bearer header carrying the OAuth access token. Keep the token in an environment variable, never in code or in the repository.
export FIGMA_TOKEN="figd_..." # personal access token, scopes above
export FIGMA_WEBHOOK_PASSCODE="$(openssl rand -hex 16)"
File key and node ids. The key is the part of the file URL after /design/ (or /file/): https://www.figma.com/design/hP3kQw8mZxT2nVbR4cYdLs/Icons?node-id=12-34 (key hP3kQw8mZxT2nVbR4cYdLs). In the URL a node id is written 12-34; the API wants 12:34.
Endpoints used here: