CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-linear--sdk

The Linear Client SDK for interacting with the Linear GraphQL API

Overview
Eval results
Files

team-user-management.mddocs/

Team & User Management

Team and user operations for managing workspace members, teams, permissions, and organizational structure within Linear.

Capabilities

Team Queries

Query individual teams or collections with filtering and pagination support.

/**
 * Get a single team by ID
 * @param id - The team ID
 * @returns Promise resolving to the team
 */
team(id: string): LinearFetch<Team>;

/**
 * Get a paginated list of teams with optional filtering
 * @param variables - Query parameters including filters and pagination
 * @returns Promise resolving to a connection of teams
 */
teams(variables?: TeamsQueryVariables): LinearFetch<TeamConnection>;

interface TeamsQueryVariables extends LinearConnectionVariables {
  /** Filter conditions for teams */
  filter?: TeamFilter;
  /** Sort order for teams */
  orderBy?: PaginationOrderBy;
  /** Include archived teams */
  includeArchived?: boolean;
}

interface TeamFilter {
  /** Filter by team name */
  name?: StringFilter;
  /** Filter by team key */
  key?: StringFilter;
  /** Filter by team description */
  description?: NullableStringFilter;
  /** Combine filters with AND logic */
  and?: TeamFilter[];
  /** Combine filters with OR logic */
  or?: TeamFilter[];
}

Usage Examples:

import { LinearClient } from "@linear/sdk";

const client = new LinearClient({ apiKey: "your-api-key" });

// Get a single team
const team = await client.team("team-id");
console.log(team.name, team.key);

// Get all active teams
const teams = await client.teams({
  filter: {
    key: { neq: "archived" }
  }
});

// Find team by key
const engineeringTeam = await client.teams({
  filter: {
    key: { eq: "ENG" }
  }
});

Team Mutations

Create, update, and manage teams with comprehensive configuration options.

/**
 * Create a new team
 * @param input - Team creation data
 * @returns Promise resolving to the creation result
 */
createTeam(input: TeamCreateInput): LinearFetch<TeamPayload>;

/**
 * Update an existing team
 * @param id - The team ID to update
 * @param input - Team update data
 * @returns Promise resolving to the update result
 */
updateTeam(id: string, input: TeamUpdateInput): LinearFetch<TeamPayload>;

/**
 * Archive a team
 * @param id - The team ID to archive
 * @returns Promise resolving to the archive result
 */
archiveTeam(id: string): LinearFetch<ArchivePayload>;

interface TeamCreateInput {
  /** Team name */
  name: string;
  /** Team key (unique identifier) */
  key: string;
  /** Team description */
  description?: string;
  /** Team icon */
  icon?: string;
  /** Team color */
  color?: string;
  /** Timezone for the team */
  timezone?: string;
  /** Whether the team is private */
  private?: boolean;
  /** Issue estimation type */
  issueEstimationType?: IssueEstimationType;
  /** Issue estimation scale */
  issueEstimationExtended?: boolean;
  /** Issue estimation allow zero */
  issueEstimationAllowZero?: boolean;
  /** Issue auto-assignment on creation */
  issueOrderingNoPriorityFirst?: boolean;
  /** Default issue state for new issues */
  defaultIssueStateId?: string;
  /** Default template for issues */
  defaultTemplateForMembersId?: string;
  /** Default template for non-members */
  defaultTemplateForNonMembersId?: string;
  /** Triage state ID */
  triageStateId?: string;
  /** Whether to automatically archive completed issues */
  autoArchivePeriod?: number;
}

interface TeamUpdateInput {
  /** Update team name */
  name?: string;
  /** Update team key */
  key?: string;
  /** Update team description */
  description?: string;
  /** Update team icon */
  icon?: string;
  /** Update team color */
  color?: string;
  /** Update timezone */
  timezone?: string;
  /** Update privacy setting */
  private?: boolean;
  /** Update estimation settings */
  issueEstimationType?: IssueEstimationType;
  issueEstimationExtended?: boolean;
  issueEstimationAllowZero?: boolean;
  /** Update default state */
  defaultIssueStateId?: string;
  /** Update auto-archive period */
  autoArchivePeriod?: number;
}

enum IssueEstimationType {
  NotUsed = "notUsed",
  Exponential = "exponential",
  Fibonacci = "fibonacci",
  Linear = "linear",
  TShirt = "tShirt"
}

Usage Examples:

// Create a new engineering team
const newTeam = await client.createTeam({
  name: "Backend Engineering",
  key: "BE",
  description: "Backend services and infrastructure team",
  color: "#3b82f6",
  issueEstimationType: IssueEstimationType.Fibonacci,
  issueEstimationExtended: true
});

// Update team settings
const updatedTeam = await client.updateTeam("team-id", {
  description: "Updated team description",
  autoArchivePeriod: 30 // days
});

User Queries

Query workspace users and members with filtering and pagination.

/**
 * Get a single user by ID
 * @param id - The user ID
 * @returns Promise resolving to the user
 */
user(id: string): LinearFetch<User>;

/**
 * Get a paginated list of users with optional filtering
 * @param variables - Query parameters including filters and pagination
 * @returns Promise resolving to a connection of users
 */
users(variables?: UsersQueryVariables): LinearFetch<UserConnection>;

/**
 * Get the current authenticated user
 * @returns Promise resolving to the viewer user
 */
viewer: LinearFetch<User>;

interface UsersQueryVariables extends LinearConnectionVariables {
  /** Filter conditions for users */
  filter?: UserFilter;
  /** Sort order for users */
  orderBy?: PaginationOrderBy;
  /** Include deactivated users */
  includeDisabled?: boolean;
}

interface UserFilter {
  /** Filter by display name */
  displayName?: StringFilter;
  /** Filter by email */
  email?: StringFilter;
  /** Filter by name */
  name?: StringFilter;
  /** Filter by active status */
  active?: BooleanFilter;
  /** Filter by admin status */
  admin?: BooleanFilter;
  /** Combine filters with AND logic */
  and?: UserFilter[];
  /** Combine filters with OR logic */
  or?: UserFilter[];
}

Usage Examples:

// Get current user
const currentUser = await client.viewer;
console.log(currentUser.email);

// Get all active users
const activeUsers = await client.users({
  filter: {
    active: { eq: true }
  }
});

// Find user by email
const userByEmail = await client.users({
  filter: {
    email: { eq: "john@company.com" }
  }
});

Team Memberships

Manage team memberships and user permissions.

/**
 * Get team memberships with filtering
 * @param variables - Query parameters
 * @returns Promise resolving to a connection of team memberships
 */
teamMemberships(variables?: TeamMembershipsQueryVariables): LinearFetch<TeamMembershipConnection>;

/**
 * Create a team membership
 * @param input - Team membership creation data
 * @returns Promise resolving to the creation result
 */
createTeamMembership(input: TeamMembershipCreateInput): LinearFetch<TeamMembershipPayload>;

/**
 * Update a team membership
 * @param id - The membership ID to update
 * @param input - Membership update data
 * @returns Promise resolving to the update result
 */
updateTeamMembership(id: string, input: TeamMembershipUpdateInput): LinearFetch<TeamMembershipPayload>;

/**
 * Delete a team membership
 * @param id - The membership ID to delete
 * @returns Promise resolving to the deletion result
 */
deleteTeamMembership(id: string): LinearFetch<DeletePayload>;

interface TeamMembershipCreateInput {
  /** Team ID */
  teamId: string;
  /** User ID */
  userId: string;
  /** Whether user is owner of the team */
  owner?: boolean;
  /** Sort order within team */
  sortOrder?: number;
}

interface TeamMembershipUpdateInput {
  /** Update owner status */
  owner?: boolean;
  /** Update sort order */
  sortOrder?: number;
}

Organization Settings

Manage organization-wide settings and configurations.

/**
 * Get organization information
 * @returns Promise resolving to the organization
 */
organization: LinearFetch<Organization>;

/**
 * Update organization settings
 * @param input - Organization update data
 * @returns Promise resolving to the update result
 */
updateOrganization(input: UpdateOrganizationInput): LinearFetch<OrganizationPayload>;

interface UpdateOrganizationInput {
  /** Organization name */
  name?: string;
  /** Organization logo URL */
  logoUrl?: string;
  /** Organization URL slug */
  urlKey?: string;
  /** Allow members to create teams */
  allowMembersToCreateTeams?: boolean;
  /** Roadmap visibility */
  roadmapEnabled?: boolean;
  /** Git branch format */
  gitBranchFormat?: string;
  /** Git linkback messages enabled */
  gitLinkbackMessagesEnabled?: boolean;
  /** Git public linkback messages enabled */
  gitPublicLinkbackMessagesEnabled?: boolean;
}

Core Team & User Types

/** Team model representing a Linear team */
class Team extends Request {
  /** Unique team identifier */
  id: string;
  /** Team name */
  name: string;
  /** Team key (unique identifier) */
  key: string;
  /** Team description */
  description?: string;
  /** Team color */
  color: string;
  /** Team icon */
  icon?: string;
  /** Team timezone */
  timezone: string;
  /** Whether team is private */
  private: boolean;
  /** Issue estimation settings */
  issueEstimationType: IssueEstimationType;
  issueEstimationExtended: boolean;
  issueEstimationAllowZero: boolean;
  /** Auto-archive period in days */
  autoArchivePeriod: number;
  /** Default issue state */
  defaultIssueState?: WorkflowState;
  /** Triage workflow state */
  triageState?: WorkflowState;
  /** Team members */
  members: UserConnection;
  /** Team memberships with roles */
  memberships: TeamMembershipConnection;
  /** Team issues */
  issues: IssueConnection;
  /** Team projects */
  projects: ProjectConnection;
  /** Team cycles */
  cycles: CycleConnection;
  /** Team workflow states */
  states: WorkflowStateConnection;
  /** Team labels */
  labels: IssueLabelConnection;
  /** Creation timestamp */
  createdAt: DateTime;
  /** Last update timestamp */
  updatedAt: DateTime;
  /** Archive timestamp */
  archivedAt?: DateTime;
}

/** User model representing a workspace user */
class User extends Request {
  /** Unique user identifier */
  id: string;
  /** User display name */
  displayName: string;
  /** User email address */
  email: string;
  /** User name/handle */
  name: string;
  /** User avatar URL */
  avatarUrl?: string;
  /** User timezone */
  timezone?: string;
  /** Whether user is active */
  active: boolean;
  /** Whether user is admin */
  admin: boolean;
  /** Whether user is guest */
  guest: boolean;
  /** User creation timestamp */
  createdAt: DateTime;
  /** Last update timestamp */
  updatedAt: DateTime;
  /** Last seen timestamp */
  lastSeenAt?: DateTime;
  /** User's teams */
  teams: TeamConnection;
  /** User's team memberships */
  teamMemberships: TeamMembershipConnection;
  /** Issues assigned to user */
  assignedIssues: IssueConnection;
  /** Issues created by user */
  createdIssues: IssueConnection;
}

/** Team membership model */
class TeamMembership extends Request {
  /** Unique membership identifier */
  id: string;
  /** Associated team */
  team: Team;
  /** Associated user */
  user: User;
  /** Whether user is team owner */
  owner: boolean;
  /** Sort order within team */
  sortOrder: number;
  /** Creation timestamp */
  createdAt: DateTime;
  /** Last update timestamp */
  updatedAt: DateTime;
}

/** Organization model */
class Organization extends Request {
  /** Unique organization identifier */
  id: string;
  /** Organization name */
  name: string;
  /** Organization logo URL */
  logoUrl?: string;
  /** Organization URL key */
  urlKey: string;
  /** Whether members can create teams */
  allowMembersToCreateTeams: boolean;
  /** Whether roadmap is enabled */
  roadmapEnabled: boolean;
  /** Git branch format */
  gitBranchFormat?: string;
  /** Git linkback settings */
  gitLinkbackMessagesEnabled: boolean;
  gitPublicLinkbackMessagesEnabled: boolean;
  /** Creation timestamp */
  createdAt: DateTime;
  /** Last update timestamp */
  updatedAt: DateTime;
}

/** Response payload for team mutations */
interface TeamPayload {
  /** The mutated team */
  team?: Team;
  /** Whether the mutation was successful */
  success: boolean;
  /** Last sync ID */
  lastSyncId: number;
}

/** Paginated connection of teams */
class TeamConnection extends Connection<Team> {
  /** Teams in this page */
  nodes: Team[];
  /** Pagination information */
  pageInfo: PageInfo;
}

/** Paginated connection of users */
class UserConnection extends Connection<User> {
  /** Users in this page */
  nodes: User[];
  /** Pagination information */
  pageInfo: PageInfo;
}

Install with Tessl CLI

npx tessl i tessl/npm-linear--sdk

docs

comments-attachments.md

core-client.md

error-handling.md

index.md

issue-management.md

pagination-connections.md

project-management.md

team-user-management.md

webhook-processing.md

workflow-cycle-management.md

tile.json