Getting started

If you have not yet set up Trigger.dev in your project, go to the quick start guide.

Installation

To get started with the Linear integration on Trigger.dev, you need to install the @trigger.dev/linear package. You can do this using npm, pnpm, or yarn:

npm install @trigger.dev/linear@latest

Authentication

To use the Linear API with Trigger.dev, you can either use OAuth or a Personal API Key.

OAuth

import { Linear } from "@trigger.dev/linear";

//this will use OAuth
const linear = new Linear({
  id: "linear",
});

Personal API Key

You can create a Personal API Key in your Linear API Settings.

import { Linear } from "@trigger.dev/linear";

//this will use the passed in API key (defined in your environment variables)
const linear = new Linear({
  id: "linear",
  apiKey: process.env["LINEAR_API_KEY"],
});

Usage

Include the Linear integration in your Trigger.dev job.

client.defineJob({
  id: "linear-new-issue-autoresponder",
  name: "Linear - New Issue Autoresponder",
  version: "0.1.0",
  integrations: {
    //use the linear integration
    linear,
  },
  //trigger on issue created events
  trigger: linear.onIssueCreated(),
  run: async (payload, io, ctx) => {
    //get new issue ID from the event payload
    const newIssueId = payload.data.id;

    //comment
    await io.linear.createComment("create-comment", {
      issueId: newIssueId,
      body: "Thank's for opening this issue!",
    });

    //react
    await io.linear.createReaction("create-reaction", {
      issueId: newIssueId,
      emoji: "+1",
    });

    //store and display in the job run
    return { payload, ctx };
  },
});

Serialization helper

Use the serializeLinearOutput helper instead of returning raw Linear SDK responses:

import { Linear, serializeLinearOutput } from "@trigger.dev/linear";
...
client.defineJob({
  id: "linear-sdk",
  name: "Linear SDK",
  version: "0.1.0",
  integrations: {
    linear,
  },
  trigger: eventTrigger({
    name: "linear.sdk",
  }),
  run: async (payload, io, ctx) => {
    //the official Linear SDK is exposed as `client`
    const issues = await io.linear.runTask("first-two", async (client) => {
      //these nodes contain values we can't serialize, e.g. functions
      const { nodes } = await client.issues({ first: 2 });
      //we remove them with this little helper
      return serializeLinearOutput(nodes);
    });
    return issues;
  },
});

Pagination

You can paginate responses two different ways:

  1. Iterating the same integration task with different params
  2. Using the getAll helper exposed on the integration (recommended!)

When ordering results, make sure to use the PaginationOrderBy enum.

import { Linear, PaginationOrderBy, serializeLinearOutput } from "@trigger.dev/linear";
...
client.defineJob({
  id: "linear-pagination",
  name: "Linear Pagination",
  version: "0.1.0",
  integrations: {
    linear,
  },
  trigger: eventTrigger({
    name: "linear.paginate",
  }),
  run: async (payload, io, ctx) => {
    //the same params will be used for all tasks
    const params = { first: 5, orderBy: PaginationOrderBy.UpdatedAt };

    //1. Linear integration - no pagination helper
    let edges = await io.linear.issues("get-issues", params);
    let noHelper = edges.nodes;

    for (let i = 0; edges.pageInfo.hasNextPage; i++) {
      edges = await io.linear.issues(`get-more-issues-${i}`, {
        ...params,
        after: edges.pageInfo.endCursor,
      });
      noHelper = noHelper.concat(edges.nodes);
    }

    //2. Linear integration - with the pagination helper
    const withHelper = await io.linear.getAll(io.linear.issues, "get-all", params);

    return {
      issueCounts: {
        withSdk: sdkIssues.length,
        noHelper: noHelper.length,
        withHelper: withHelper.length,
      },
    };
  },
});

Triggers

Attachments

Function NameDescription
onAttachmentWhen any action is performed on an attachment.
onAttachmentCreatedWhen an attachment is created.
onAttachmentRemovedWhen an attachment is removed.
onAttachmentUpdatedWhen an attachment is updated.

Comments

Function NameDescription
onCommentWhen any action is performed on an comment.
onCommentCreatedWhen an comment is created.
onCommentRemovedWhen an comment is removed.
onCommentUpdatedWhen an comment is updated.

Cycles

Function NameDescription
onCycleWhen any action is performed on an cycle.
onCycleCreatedWhen an cycle is created.
onCycleRemovedWhen an cycle is removed.
onCycleUpdatedWhen an cycle is updated.

Issues

Function NameDescription
onIssueWhen any action is performed on an issue.
onIssueCreatedWhen an issue is created.
onIssueRemovedWhen an issue is removed.
onIssueUpdatedWhen an issue is updated.

Issue Labels

Function NameDescription
onIssueLabelWhen any action is performed on an issue label.
onIssueLabelCreatedWhen an issue label is created.
onIssueLabelRemovedWhen an issue label is removed.
onIssueLabelUpdatedWhen an issue label is updated.

Issue SLAs

Function NameDescription
onIssueSLAWhen any action is performed on an issue SLA.
onIssueSLASetWhen an issue SLA is set.
onIssueSLABreachedWhen an issue SLA is breached.
onIssueSLAHighRiskWhen an issue SLA is high risk.

Projects

Function NameDescription
onProjectWhen any action is performed on an project.
onProjectCreatedWhen an project is created.
onProjectRemovedWhen an project is removed.
onProjectUpdatedWhen an project is updated.

Project Updates

Function NameDescription
onProjectUpdateWhen any action is performed on an project update.
onProjectUpdateCreatedWhen an project update is created.
onProjectUpdateRemovedWhen an project update is removed.
onProjectUpdateUpdatedWhen an project update is updated.

Reactions

Function NameDescription
onReactionWhen any action is performed on an reaction.
onReactionCreatedWhen an reaction is created.
onReactionRemovedWhen an reaction is removed.
onReactionUpdatedWhen an reaction is updated.

Tasks

Attachments

Function NameDescription
attachmentGets an attachment.
attachmentsGets multiple attachments.
createAttachmentCreates an attachment.
deleteAttachmentDeletes an attachment.
updateAttachmentUpdates an attachment.
Function NameDescription
attachmentLinkFrontLinks a Front conversation to an issue.
attachmentLinkIntercomLinks a Intercom conversation to an issue.
attachmentLinkJiraIssueLinks a Jira issue to an issue.
attachmentLinkSlackLinks a Slack message to an issue.
attachmentLinkURLLinks any URL to an issue.
attachmentLinkZendeskLinks a Zendesk ticket to an issue.

Comments

Function NameDescription
commentGets a comment.
commentsGets multiple comments.
createCommentCreates a comment.
deleteCommentDeletes a comment.
updateCommentUpdates a comment.

Cycles

Function NameDescription
archiveCycleArchives a cycle.
createCycleCreates a cycle.
updateCycleUpdates a cycle.

Documents

Function NameDescription
documentGets a document.
documentsGets multiple documents.
createDocumentCreates a document.
searchDocumentsSearches documents.

Favorites

Function NameDescription
favoriteGets a favorite.
favoritesGets multiple favorites.
createFavoriteCreates a favorite.

Issues

Function NameDescription
issueGets an issue.
issuesGets multiple issues.
archiveIssueArchives an issue.
createIssueCreates an issue.
deleteIssueDeletes an issue.
searchIssuesSearches issues.
updateIssueUpdates an issue.

Issue Labels

Function NameDescription
issueLabelGets an issue label.
issueLabelsGets multiple issue labels.
createIssueLabelCreates an issue label.
deleteIssueLabelDeletes an issue label.
updateIssueLabelUpdates an issue label.

Issue Relations

Function NameDescription
issueRelationGets an issue relation.
issueRelationsGets multiple issue relations.
createIssueRelationCreates an issue relation.

Notifications

Function NameDescription
notificationGets a notification.
notificationsGets multiple notifications.
archiveNotificationArchives a notification.
createNotificationSubscriptionCreates a notification subscription.

Organizations

Function NameDescription
organizationGets the viewer’s organization.
createOrganizationFromOnboardingCreates an organization.
createOrganizationInviteCreates an organization invite.

Projects

Function NameDescription
projectGets a project.
projectsGets multiple projects.
archiveProjectArchives a project.
createProjectCreates a project.
deleteProjectDeletes a project.
searchProjectsSearches projects.
updateProjectUpdates a project.
Function NameDescription
projectLinkGets a project link.
projectLinksGets multiple project links.
createProjectLinkCreates a project link.

Project Updates

Function NameDescription
projectUpdateGets a project update.
projectUpdatesGets multiple project updates.
createProjectUpdateCreates a project update.
deleteProjectUpdateDeletes a project update.
updateProjectUpdateUpdates a project update.

Reactions

Function NameDescription
createReactionCreates a reaction.
deleteReactionDeletes a reaction.

Roadmaps

Function NameDescription
archiveRoadmapArchives a roadmap.
createRoadmapCreates a roadmap.

Teams

Function NameDescription
teamGets a team.
teamsGets multiple teams.
createTeamCreates a team.

Team Memberships

Function NameDescription
teamMembershipGets a team membership.
teamMembershipsGets multiple team memberships.
createTeamMembershipCreates a team membership.

Templates

Function NameDescription
templateGets a template.
templatesGets multiple templates.

Users

Function NameDescription
userGets a user.
usersGets multiple users.
updateUserUpdates a user.

Webhooks

Function NameDescription
webhookGets a webhook.
webhooksGets multiple webhooks.
createWebhookCreates a webhook.
deleteWebhookDeletes a webhook.
updateWebhookUpdates a webhook.

Workflow States

Function NameDescription
workflowStateGets a workflow state.
workflowStatesGets multiple workflow states.
archiveWorkflowStateArchives a workflow state.
createWorkflowStateCreates a workflow state.

Misc

Function NameDescription
createProjectMilestoneCreates a project milestone.
issuePriorityValuesGets issue priority values and labels.
viewerGets the currently authenticated user.

Example jobs

Code examples

Check out pre-built jobs using Linear in our API section.