# Linear

Linear is a modern issue tracking and project management platform for software teams. The Sling Linear connector extracts data from Linear's GraphQL API, supporting teams, users, issues, comments, projects, cycles, labels, workflow states, attachments, issue relations, and project milestones.

{% 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 are accepted:

**Secrets:**

* `api_key` **(required)** -> Your Linear Personal API Key

**Inputs (optional):**

* `anchor_date` -> Starting date for first sync of incremental endpoints (ISO 8601 format, e.g., `2024-01-01T00:00:00Z`). Defaults to 1 year ago.

### Getting Your Personal API Key

1. Log in to [Linear](https://linear.app)
2. Click your avatar (bottom-left corner)
3. Go to **Settings**
4. Navigate to **Security & access** in the left sidebar
5. Scroll to **Personal API keys**
6. Click **New API key**
7. Name the key (e.g., `sling-api`)
8. Select **Full access** for permissions
9. Select **All teams you have access to** for team access
10. Click **Create** and copy the key immediately (it won't be shown again)

{% hint style="warning" %}
**Important:** Personal API keys grant the same access as your user account. Use a service account with minimal permissions for production workloads.
{% endhint %}

### Using `sling conns`

{% code overflow="wrap" %}

```bash
sling conns set LINEAR type=api spec=linear secrets='{ api_key: lin_api_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx }'
```

{% 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 LINEAR='{ type: api, spec: linear, secrets: { api_key: "lin_api_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" } }'
```

{% 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:
  LINEAR:
    type: api
    spec: linear
    secrets:
      api_key: "lin_api_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
```

## Replication

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

```yaml
source: LINEAR
target: MY_POSTGRES

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

streams:
  # sync all endpoints
  '*':
```

**Incremental sync for issues, comments, projects, and attachments:**

```yaml
source: LINEAR
target: MY_POSTGRES

defaults:
  object: linear.{stream_name}

streams:
  teams:
    mode: full-refresh

  users:
    mode: full-refresh

  issues:
    mode: incremental
    primary_key: [id]
    update_key: updatedAt

  comments:
    mode: incremental
    primary_key: [id]
    update_key: updatedAt

  projects:
    mode: incremental
    primary_key: [id]
    update_key: updatedAt

  cycles:
    mode: full-refresh

  labels:
    mode: full-refresh

  workflow_states:
    mode: full-refresh

  attachments:
    mode: incremental
    primary_key: [id]
    update_key: updatedAt

  issue_relations:
    mode: full-refresh

  project_milestones:
    mode: full-refresh
```

## Endpoints

| Endpoint             | Description                                                           | Incremental |
| -------------------- | --------------------------------------------------------------------- | ----------- |
| `teams`              | All teams in the workspace                                            | No          |
| `users`              | All users in the workspace                                            | No          |
| `issues`             | All issues with full detail (state, assignee, project, cycle, labels) | Yes         |
| `comments`           | All issue comments                                                    | Yes         |
| `projects`           | All projects with lead and status                                     | Yes         |
| `cycles`             | All cycles (sprints) with progress tracking                           | No          |
| `labels`             | All issue labels                                                      | No          |
| `workflow_states`    | All workflow states (issue status definitions)                        | No          |
| `attachments`        | All issue attachments                                                 | Yes         |
| `issue_relations`    | All issue relations (blocks, related, duplicates)                     | No          |
| `project_milestones` | All project milestones                                                | No          |

To discover available endpoints:

```bash
sling conns discover LINEAR
```

## Incremental Sync

Four endpoints support incremental sync via the `updatedAt` timestamp:

**`issues`** — Fetches issues updated since the last sync:

* **First run:** Fetches all issues updated in the last year (or since `anchor_date` if provided)
* **Subsequent runs:** Only fetches issues modified after the last sync timestamp
* Includes archived issues for completeness

**`comments`** — Fetches comments updated since the last sync:

* **First run:** Fetches all comments from the last year (or since `anchor_date`)
* **Subsequent runs:** Only fetches new or modified comments

**`projects`** — Fetches projects updated since the last sync.

**`attachments`** — Fetches attachments updated since the last sync.

All other endpoints run in full-refresh mode since they contain relatively small datasets (teams, labels, workflow states, etc.) that benefit from complete refreshes.

## Rate Limiting

The Linear API enforces rate limits:

* **5,000 requests per hour** per user
* **250,000 complexity points per hour** per user

The connector automatically:

* Uses conservative rate limiting (5 requests/second with concurrency of 3)
* Retries with exponential backoff on 429 (rate limit) responses, up to 5 attempts

## Common Use Cases

### Sync All Linear Data

```yaml
source: LINEAR
target: MY_POSTGRES

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

streams:
  '*':
```

### Track Issues Incrementally

```yaml
source: LINEAR
target: MY_POSTGRES

defaults:
  object: linear.{stream_name}

streams:
  teams:
    mode: full-refresh
  users:
    mode: full-refresh
  workflow_states:
    mode: full-refresh
  issues:
    mode: incremental
    primary_key: [id]
    update_key: updatedAt
```

### Export Issues with Comments for Analysis

```yaml
source: LINEAR
target: MY_POSTGRES

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

streams:
  teams:
  users:
  issues:
  comments:
  labels:
  workflow_states:
```

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/linear.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.
