# Figma

Figma is a collaborative design platform for building user interfaces, prototypes, and design systems. The Sling Figma connector extracts data from the Figma REST API, supporting users, team projects, files, comments, versions, components, and styles.

{% hint style="success" %}
**CLI Pro Required**: APIs require a [CLI Pro token](https://docs.slingdata.io/sling-cli/cli-pro) or [Platform Plan](https://docs.slingdata.io/sling-platform/platform).
{% endhint %}

## Setup

The following credentials and inputs are accepted:

**Secrets:**

* `personal_access_token` **(required)** -> Your Figma Personal Access Token

**Inputs:**

* `team_id` **(required)** -> The Figma team ID to extract data from. Find it in the URL when viewing your team page: `figma.com/files/team/<team_id>`
* `anchor_date` (optional) -> The starting date for historical data extraction (default: 1 year ago). Format: `YYYY-MM-DDTHH:MM:SSZ`

### Getting Your Personal Access Token

1. Log in to [Figma](https://www.figma.com/)
2. Go to **Settings** (click your profile icon → Settings)
3. Navigate to the **Security** tab
4. Scroll down to **Personal access tokens**
5. Click **Generate new token**
6. Give your token a descriptive name (e.g., "Sling Integration")
7. Select the following scopes:
   * **File content**: Read-only
   * **File metadata**: Read-only
   * **Comments**: Read-only (or Read and write if creating comments)
   * **Team library**: Read-only
8. Click **Generate token** and copy the token (it starts with `figd_`)

### Finding Your Team ID

1. Log in to Figma and navigate to your team page
2. Look at the URL: `https://www.figma.com/files/team/<team_id>/...`
3. The numeric value after `/team/` is your team ID

### Using `sling conns`

Here are examples of setting a connection named `FIGMA`. We must provide the `type=api` property:

{% code overflow="wrap" %}

```bash
sling conns set FIGMA type=api spec=figma \
  secrets='{ personal_access_token: figd_xxxxxxxxxxxx }' \
  inputs='{ team_id: "123456789" }'
```

{% endcode %}

### Environment Variable

See [here](https://docs.slingdata.io/sling-cli/environment#dot-env-file-.env.sling) to learn more about the `.env.sling` file.

{% code overflow="wrap" %}

```bash
export FIGMA='{ type: api, spec: figma, secrets: { personal_access_token: "figd_xxxxxxxxxxxx" }, inputs: { team_id: "123456789" } }'
```

{% endcode %}

### Sling Env File YAML

See [here](https://docs.slingdata.io/sling-cli/environment#sling-env-file-env.yaml) to learn more about the sling `env.yaml` file.

```yaml
connections:
  FIGMA:
    type: api
    spec: figma
    secrets:
      personal_access_token: "figd_xxxxxxxxxxxx"
    inputs:
      team_id: "123456789"
```

**With anchor date for historical data:**

```yaml
connections:
  FIGMA:
    type: api
    spec: figma
    secrets:
      personal_access_token: "figd_xxxxxxxxxxxx"
    inputs:
      team_id: "123456789"
      anchor_date: "2024-01-01T00:00:00Z"
```

## Replication

Here's an example replication configuration to sync Figma data to a PostgreSQL database:

```yaml
source: FIGMA
target: MY_POSTGRES

defaults:
  mode: full-refresh
  object: figma.{stream_name}

streams:
  # User info
  me:

  # Team structure
  team_projects:
  project_files:
  file_metadata:

  # Incremental data
  file_comments:
    mode: incremental
    primary_key: [id]
    update_key: created_at
  file_versions:
    mode: incremental
    primary_key: [id]
    update_key: created_at

  # Design system
  team_components:
  team_styles:
```

**Sync all endpoints with incremental where supported:**

```yaml
source: FIGMA
target: MY_POSTGRES

defaults:
  mode: full-refresh
  object: figma.{stream_name}

streams:
  '*':
```

## Endpoints

| Endpoint          | Description                                               | Incremental |
| ----------------- | --------------------------------------------------------- | ----------- |
| `me`              | Current authenticated user information                    | No          |
| `team_projects`   | All projects within the team                              | No          |
| `project_files`   | All files within each project                             | No          |
| `file_metadata`   | File metadata (name, last modified, version, editor type) | No          |
| `file_comments`   | Comments on each file, with incremental sync              | Yes         |
| `file_versions`   | Version history for each file                             | Yes         |
| `team_components` | Published components in the team library                  | No          |
| `team_styles`     | Published styles in the team library                      | No          |

To discover available endpoints:

```bash
sling conns discover FIGMA
```

## Rate Limiting

The Figma API uses a tiered rate limiting system with a leaky bucket algorithm:

* Rate limits vary by endpoint tier (Tier 1, 2, 3)
* The API returns `429 Too Many Requests` when limits are exceeded

The connector automatically:

* Uses conservative rate limiting (5 requests/second)
* Limits concurrency to 3 parallel requests
* Retries with exponential backoff on 429 (rate limit) responses up to 10 times
* Stops on 401 (authentication failed) responses
* Stops on 403 (forbidden) responses

## Common Use Cases

### Design Activity Tracking

```yaml
source: FIGMA
target: MY_POSTGRES

defaults:
  object: design_tracking.{stream_name}

streams:
  file_comments:
    mode: incremental
    primary_key: [id]
    update_key: created_at
  file_versions:
    mode: incremental
    primary_key: [id]
    update_key: created_at
  file_metadata:
    mode: full-refresh
```

### Design System Inventory

```yaml
source: FIGMA
target: MY_POSTGRES

defaults:
  mode: full-refresh
  object: design_system.{stream_name}

streams:
  team_components:
  team_styles:
  project_files:
```

If you are facing issues connecting, please reach out to us at <support@slingdata.io>, on [discord](https://discord.gg/q5xtaSNDvp) or open a Github Issue [here](https://github.com/slingdata-io/sling-cli/issues).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.slingdata.io/connections/api-connections/figma.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
