Build powerful Linear integrations using the GraphQL API. Complete guide with authentication, queries, mutations, and best practices.
Use the Linear GraphQL API to build sophisticated integrations, automate workflows, and create custom applications.
Create a personal API key in Linear settings for authentication.
# Generate API key: # 1. Go to Linear Settings → API # 2. Create new personal API key # 3. Store securely in environment variables LINEAR_API_KEY=lin_api_xxxxxxxxxxxxxxxx
Configure a GraphQL client to interact with the Linear API.
// Using Apollo Client
import { ApolloClient, InMemoryCache, createHttpLink } from '@apollo/client';
import { setContext } from '@apollo/client/link/context';
const httpLink = createHttpLink({
uri: 'https://api.linear.app/graphql',
});
const authLink = setContext((_, { headers }) => ({
headers: {
...headers,
authorization: `Bearer ${process.env.LINEAR_API_KEY}`,
}
}));
const client = new ApolloClient({
link: authLink.concat(httpLink),
cache: new InMemoryCache(),
});Fetch issues, teams, and other data using GraphQL queries.
// Fetch issues query
const GET_ISSUES = gql`
query GetIssues($filter: IssueFilter) {
issues(filter: $filter) {
nodes {
id
title
description
state {
name
}
assignee {
name
email
}
createdAt
updatedAt
}
}
}
`;Use mutations to create, update, and manage Linear issues.
// Create issue mutation
const CREATE_ISSUE = gql`
mutation CreateIssue($input: IssueCreateInput!) {
issueCreate(input: $input) {
success
issue {
id
title
url
}
}
}
`;
// Usage
const { data } = await client.mutate({
mutation: CREATE_ISSUE,
variables: {
input: {
title: "New feature request",
description: "Detailed description",
teamId: "team_id_here",
priority: 2
}
}
});Implement proper pagination and respect API rate limits.
// Pagination example
const getAllIssues = async () => {
let allIssues = [];
let hasNextPage = true;
let cursor = null;
while (hasNextPage) {
const { data } = await client.query({
query: GET_ISSUES_PAGINATED,
variables: { after: cursor }
});
allIssues = allIssues.concat(data.issues.nodes);
hasNextPage = data.issues.pageInfo.hasNextPage;
cursor = data.issues.pageInfo.endCursor;
}
return allIssues;
};Verify your API key is correct, active, and included in the Authorization header with Bearer prefix.
Implement exponential backoff and reduce request frequency. Linear allows 60 requests per minute.
Use the Linear API explorer to test queries and ensure proper syntax and field availability.
Start with linear.gratis and connect your Linear API workflow. Free setup, no limits, ready in minutes.