Skip to main content

Overview

Try the API

Test Figma REST API endpoints from your terminal with these ready-to-use examples.

This page provides copy-paste examples for every major API endpoint group. Replace the placeholder values, run the command, and inspect the response.

Before You Start

1

Get a personal access token

Go to Figma Account Settings and create a personal access token. Select the file_content:read scope at minimum.

export FIGMA_TOKEN="figd_your_token_here"
2

Find your file key

Open any Figma file in your browser. The file key is the string between /design/ (or /file/) and the file name in the URL.

https://www.figma.com/design/ABC123xyz/My-File
                              ^^^^^^^^^^^
                              This is the file key
export FILE_KEY="ABC123xyz"

All examples below assume you have exported FIGMA_TOKEN and FILE_KEY as environment variables. If you prefer, replace $FIGMA_TOKEN and $FILE_KEY inline.


Verify Authentication

Start by confirming your token works. This endpoint requires no parameters.

curl -s -H "X-Figma-Token: $FIGMA_TOKEN" \
  "https://api.figma.com/v1/me" | python3 -m json.tool

Expected response:

{
  "id": "12345",
  "handle": "your-username",
  "email": "you@example.com",
  "img_url": "https://s3-alpha.figma.com/img/..."
}

Files

Get a file tree

Retrieve the document structure. Use depth=1 to get only page-level data and keep the response small.

curl -s -H "X-Figma-Token: $FIGMA_TOKEN" \
  "https://api.figma.com/v1/files/$FILE_KEY?depth=1" | python3 -m json.tool

Get specific nodes

Fetch only the nodes you need by passing comma-separated node IDs. This is much faster than downloading the full file.

curl -s -H "X-Figma-Token: $FIGMA_TOKEN" \
  "https://api.figma.com/v1/files/$FILE_KEY/nodes?ids=1:2,3:4" | python3 -m json.tool

Images

Export nodes as images

Render specific nodes as PNG, SVG, JPG, or PDF. You need node IDs — get them from the file tree response above.

curl -s -H "X-Figma-Token: $FIGMA_TOKEN" \
  "https://api.figma.com/v1/images/$FILE_KEY?ids=1:2&format=png&scale=2" | python3 -m json.tool

Get all image fills

List download URLs for every image used as a fill in the file.

curl -s -H "X-Figma-Token: $FIGMA_TOKEN" \
  "https://api.figma.com/v1/files/$FILE_KEY/images" | python3 -m json.tool

Image export URLs are temporary and expire after 14 days. Download and store them if you need persistent access.


Comments

List comments on a file

curl -s -H "X-Figma-Token: $FIGMA_TOKEN" \
  "https://api.figma.com/v1/files/$FILE_KEY/comments" | python3 -m json.tool

Post a comment

curl -X POST "https://api.figma.com/v1/files/$FILE_KEY/comments" \
  -H "X-Figma-Token: $FIGMA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Spacing looks off here -- can we use the 8px grid?"
  }'

Delete a comment

curl -X DELETE -H "X-Figma-Token: $FIGMA_TOKEN" \
  "https://api.figma.com/v1/files/$FILE_KEY/comments/COMMENT_ID"

Components and Styles

List components

curl -s -H "X-Figma-Token: $FIGMA_TOKEN" \
  "https://api.figma.com/v1/files/$FILE_KEY/components" | python3 -m json.tool

List styles

curl -s -H "X-Figma-Token: $FIGMA_TOKEN" \
  "https://api.figma.com/v1/files/$FILE_KEY/styles" | python3 -m json.tool

Variables

Get local variables

curl -s -H "X-Figma-Token: $FIGMA_TOKEN" \
  "https://api.figma.com/v1/files/$FILE_KEY/variables/local" | python3 -m json.tool

Create a variable

curl -X POST "https://api.figma.com/v1/files/$FILE_KEY/variables" \
  -H "X-Figma-Token: $FIGMA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "variableCollections": [{
      "action": "CREATE",
      "id": "temp_collection_1",
      "name": "Spacing",
      "initialModeId": "temp_mode_1"
    }],
    "variableModes": [{
      "action": "CREATE",
      "id": "temp_mode_1",
      "name": "Default",
      "variableCollectionId": "temp_collection_1"
    }],
    "variables": [{
      "action": "CREATE",
      "id": "temp_var_1",
      "name": "spacing/sm",
      "variableCollectionId": "temp_collection_1",
      "resolvedType": "FLOAT",
      "initialModeValue": 8
    }]
  }'

Webhooks

Create a webhook

curl -X POST "https://api.figma.com/v2/webhooks" \
  -H "X-Figma-Token: $FIGMA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "event_type": "FILE_UPDATE",
    "team_id": "YOUR_TEAM_ID",
    "endpoint": "https://your-server.com/webhooks/figma",
    "passcode": "your-secret-passcode"
  }'

List webhooks for a team

curl -s -H "X-Figma-Token: $FIGMA_TOKEN" \
  "https://api.figma.com/v2/webhooks/YOUR_TEAM_ID" | python3 -m json.tool

Delete a webhook

curl -X DELETE -H "X-Figma-Token: $FIGMA_TOKEN" \
  "https://api.figma.com/v2/webhooks/WEBHOOK_ID"

Troubleshooting

SymptomLikely causeFix
403 ForbiddenInvalid or expired tokenGenerate a new token in Figma settings
403 Forbidden on specific endpointToken missing a required scopeRegenerate the token with the correct scopes
404 Not FoundWrong file key or node IDDouble-check the value from your Figma URL
429 Too Many RequestsRate limit exceededWait for the Retry-After duration, then retry
Empty images objectNode IDs do not exist in the fileVerify node IDs using the Get File endpoint first

Pipe curl output through python3 -m json.tool or jq to pretty-print JSON responses in your terminal. This makes it much easier to read deeply nested file trees.