Working with the GraphQL API
Linear's public API is built using GraphQL. It's the same API we use internally for developing our applications.
If you're new to GraphQL, Apollo has resources for beginners. The official documentation is another good starting point.

Endpoint

Linear's GraphQL endpoint is:
1
https://api.linear.app/graphql
Copied!
It supports introspection so you can query the whole schema.

Authentication

Right now we support personal API keys and OAuth2 authentication.

OAuth2

If you're building an application for others to use, we recommend you use OAuth2 authentication. Once you completed the authentication flow and acquired an access token, you can pass it in the Authorization header:
1
curl \
2
-X POST \
3
-H "Content-Type: application/json" \
4
-H "Authorization: Bearer <Replace this with your access token>" \
5
--data '{ "query": "{ issues { nodes { id title } } }" }' \
6
https://api.linear.app/graphql
Copied!

Personal API keys

For personal scripts API keys are the easiest way to access the API. They can be created in the API settings. To authenticate your requests, you need to pass the newly created key as an Authorization header:
1
curl \
2
-X POST \
3
-H "Content-Type: application/json" \
4
-H "Authorization: <Replace this with your API Key>" \
5
--data '{ "query": "{ issues { nodes { id title } } }" }' \
6
https://api.linear.app/graphql
Copied!

Linear SDK

The Linear SDK exposes the Linear GraphQL schema, and makes it easy to access models, or perform mutations. We recommend using it to interact with the GraphQL API. It is written in TypeScript, allowing all operations to be strongly typed.

Getting Started

We recommend using a GraphQL client to introspect and explore the schema if you are not using the Linear Client (SDK).

Insomnia is a free HTTP client that supports GraphQL. GraphQL Playground from Prisma is a dedicated GraphQL client that also has a desktop app.
Point the GraphQL client to the Linear production API endpoint:
1
https://api.linear.app/graphql
Copied!
Once you have your client installed, you can start making queries (read) and mutations (write) to the API.

Queries & Mutations

To get information about the authenticated user, you can use the viewer query:
1
query Me {
2
viewer {
3
id
4
name
5
email
6
}
7
}
Copied!
As issues (and most other objects) are team based, you first need to get the ID of the team you want to interact with:
1
query Teams {
2
teams {
3
nodes {
4
id
5
name
6
}
7
}
8
}
Copied!
Once you have found the correct team, you can get the issues for that team. Lets make a request with also some other issue metadata:
1
query Team {
2
team(id: "9cfb482a-81e3-4154-b5b9-2c805e70a02d") {
3
id
4
name
5
6
issues {
7
nodes {
8
id
9
title
10
description
11
assignee {
12
id
13
name
14
}
15
createdAt
16
archivedAt
17
}
18
}
19
}
20
}
Copied!
We can also get an issue by id:
1
query Issue {
2
issue(id: "BLA-123") {
3
id
4
title
5
description
6
}
7
}
Copied!
To get the full list of available queries and mutations, introspect the API schema using your favorite GraphQL client.

Creating & Editing Issues

To create a new issue, we'll need to create a mutation:
1
mutation IssueCreate {
2
issueCreate(
3
input: {
4
title: "New exception"
5
description: "More detailed error report in markdown"
6
teamId: "9cfb482a-81e3-4154-b5b9-2c805e70a02d"
7
}
8
) {
9
success
10
issue {
11
id
12
title
13
}
14
}
15
}
Copied!
This mutation will create a new issue and return its id and title if the call was successful (success: true).
If an issue is created without a specified stateId(the status field for the issue), the issue will be assigned to the team's first state in the Backlog workflow state category. If the "Triage" feature is turned on for the team, then the issue will be assigned to the Triage workflow state.
A common use case after creating an issue is updating the issue. To do this we can use the issueUpdate mutation, using the input field to include whatever it is we want to change. The id provided can be either be the uuid returned by the creation query, or the shorthand id like BLA-123 below.
1
mutation IssueUpdate {
2
issueUpdate(
3
id: "BLA-123",
4
input: {
5
title: "New Issue Title"
6
stateId: "NEW-STATE-ID",
7
}
8
) {
9
success
10
issue {
11
id
12
title
13
state {
14
id
15
name
16
}
17
}
18
}
19
}
Copied!

Accessing images

Linear hosts images and other assets uploaded into Linear behind authentication. Only authenticated users can view their assets. This also applies to the API and all images will require authentication to be displayed outside Linear's application. Regular API authentication (OAuth or API keys) is accepted for displaying images. If you're displaying images outside Linear's applications, you should download and self-host them in your application's environment.

Fetching updates

If you're working on building an application which display Linear data and you want the information to update (near) realtime, you have few options. To prevent excessive usage of our API, we recommend that you be mindful about your implementation.
Lets say you're displaying a big number of issues in your application and want to update them:
Do's:
  • Register a programmatic webhook and get updates for all issues for the team. When you detect changes, update the issue information. You can also automatically register webhooks for OAuth applications.
  • If you have to poll recent changes, order results by returning recently updated issue first. See Pagination section above how to implement this
  • Filter issues in your GraphQL request instead of fetching all issues and filtering in code.
Dont's:
  • Poll updates for each issue in the application. There should never be a reason to do this and your application might get rate limited. See above tactics to implement this better
If you have any questions, visit #api channel on our customer Slack.

Other Examples

Queries

There are many ways to fetch issues. One common use case is to get all the issues assigned to a user.
First let's find our user's id:
1
query {
2
users {
3
nodes {
4
name
5
id
6
}
7
}
8
}
Copied!
Now we can use the assignedIssues field on User:
1
query {
2
user(id: "USERID") {
3
id
4
name
5
assignedIssues {
6
nodes {
7
id
8
title
9
}
10
}
11
}
12
}
Copied!
We can do the same thing with workflowStates which represent status fields for teams:
1
query {
2
workflowStates {
3
nodes {
4
id
5
name
6
}
7
}
8
}
Copied!
1
query {
2
workflowState(id: "WORKFLOW_ID") {
3
issues {
4
nodes {
5
title
6
}
7
}
8
}
9
}
Copied!

Archived resources

Archived resources are hidden by default from the paginated responses. They can be included by passing optional includeArchived: true as a query parameter for pagination.

Support

If you run into problems or have questions or suggestions, you can join our customer Slack or send us a note ([email protected]). Both options are available through the user menu in the Linear application.