# Linear API

Every handle of the Linear fake: the `linear` fixture, the people and objects a test creates on it, and what they read and wait for. How to test a Linear app or agent, step by step, is in the [Linear guide](https://channelstack.dev/docs/platforms/linear).

Each call is shown in every SDK's language, with its required options (the table under it lists them all). Arguments go first; options are TypeScript's trailing object, Python's keyword arguments and Rust's builder setters. The variable names are the ones the calls return elsewhere on these pages, so `user` is a `LinearUser` handle.

Besides the errors listed with each method, most methods can fail with [`action_requires`](https://channelstack.dev/docs/reference/api/errors#action-requires), [`cross_workspace_credential`](https://channelstack.dev/docs/reference/api/errors#cross-workspace-credential), [`fake_actor_in_live_world`](https://channelstack.dev/docs/reference/api/errors#fake-actor-in-live-world), [`internal`](https://channelstack.dev/docs/reference/api/errors#internal), [`invalid_argument`](https://channelstack.dev/docs/reference/api/errors#invalid-argument), [`live_misconfigured`](https://channelstack.dev/docs/reference/api/errors#live-misconfigured), [`live_not_allowlisted`](https://channelstack.dev/docs/reference/api/errors#live-not-allowlisted), [`not_found`](https://channelstack.dev/docs/reference/api/errors#not-found), [`session_not_found`](https://channelstack.dev/docs/reference/api/errors#session-not-found), [`unauthorized`](https://channelstack.dev/docs/reference/api/errors#unauthorized), [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): a bad request, a closed session, or live mode refusing or misconfigured.

## LinearFixture

Returned by [`Session.linear()`](https://channelstack.dev/docs/reference/api/client#linear).

| Field    | Python / Rust | Type        |
| -------- | ------------- | ----------- |
| `app`    | `app`         | `LinearApp` |
| `apiUrl` | `api_url`     | `string`    |

### createUser()

Create a person in the workspace.

```ts title="TypeScript"
const user = await linear.createUser({ name: "…" });
```

```python title="Python"
user = await linear.create_user(name="…")
```

```rust title="Rust"
let user = linear.create_user().name("…").await?;
```

| Parameter     | Python / Rust  | Type      | Required |                                                                         |
| ------------- | -------------- | --------- | -------- | ----------------------------------------------------------------------- |
| `name`        | `name`         | `string`  | yes      | option                                                                  |
| `id`          | `id`           | `string`  | no       | option                                                                  |
| `displayName` | `display_name` | `string`  | no       | option                                                                  |
| `email`       | `email`        | `string`  | no       | option                                                                  |
| `admin`       | `admin`        | `boolean` | no       | option                                                                  |
| `guest`       | `guest`        | `boolean` | no       | option                                                                  |
| `token`       | `token`        | `string`  | no       | option; read from `CHANNELSTACK_LINEAR_USER_{name}_TOKEN` when left out |

**Returns** [`LinearUser`](https://channelstack.dev/docs/reference/api/linear#linearuser).

### users()

The people this session created.

```ts title="TypeScript"
const users = await linear.users();
```

```python title="Python"
users = await linear.users()
```

```rust title="Rust"
let users = linear.users().await?;
```

**Returns** [`LinearUsers`](https://channelstack.dev/docs/reference/api/linear#linearusers).

### createApp()

Make another OAuth app in the workspace, installed with `actor=app`: its own app user (mentionable and assignable), access token, client and webhook secret. Or return the one made with this name and settings. Its webhooks go to CHANNELSTACK_LINEAR_APP\_\<NAME>\_WEBHOOK_URL.

```ts title="TypeScript"
const app = await linear.createApp({ name: "…" });
```

```python title="Python"
app = await linear.create_app(name="…")
```

```rust title="Rust"
let app = linear.create_app().name("…").await?;
```

| Parameter | Type       | Required |        |
| --------- | ---------- | -------- | ------ |
| `name`    | `string`   | yes      | option |
| `events`  | `string[]` | no       | option |

**Returns** [`LinearApp`](https://channelstack.dev/docs/reference/api/linear#linearapp).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): Live, the Linear workspace has the built-in app only: another app needs a sandbox app of its own.

### apps()

The apps this session used: the built-in one first, then each it got from `createApp`, in the order it first did. Another session's are `not_found` here.

```ts title="TypeScript"
const apps = await linear.apps();
```

```python title="Python"
apps = await linear.apps()
```

```rust title="Rust"
let apps = linear.apps().await?;
```

**Returns** [`LinearApps`](https://channelstack.dev/docs/reference/api/linear#linearapps).

### teams()

The teams this session created.

```ts title="TypeScript"
const teams = await linear.teams();
```

```python title="Python"
teams = await linear.teams()
```

```rust title="Rust"
let teams = linear.teams().await?;
```

**Returns** [`LinearTeams`](https://channelstack.dev/docs/reference/api/linear#linearteams).

### createTeam()

Create a team: its members, workflow states and labels. Without a key one is made up, so parallel tests never share one.

```ts title="TypeScript"
const team = await linear.createTeam({ key: "…" });
```

```python title="Python"
team = await linear.create_team(key="…")
```

```rust title="Rust"
let team = linear.create_team().key("…").await?;
```

| Parameter | Type                                                                                                            | Required |        |
| --------- | --------------------------------------------------------------------------------------------------------------- | -------- | ------ |
| `key`     | `string`                                                                                                        | no       | option |
| `name`    | `string`                                                                                                        | no       | option |
| `members` | `LinearUser[]`                                                                                                  | no       | option |
| `states`  | `Array<{ name: string; type: "backlog" \| "unstarted" \| "started" \| "completed" \| "canceled" \| "triage" }>` | no       | option |
| `labels`  | `string[]`                                                                                                      | no       | option |

**Returns** [`LinearTeam`](https://channelstack.dev/docs/reference/api/linear#linearteam).

### issues()

The issues in this session's teams, read again from Linear live, oldest first.

```ts title="TypeScript"
const issues = await linear.issues();
```

```python title="Python"
issues = await linear.issues()
```

```rust title="Rust"
let issues = linear.issues().await?;
```

**Returns** [`LinearIssues`](https://channelstack.dev/docs/reference/api/linear#linearissues).

### deliveries()

Every webhook channelstack sent the agent for this session, with every attempt.

```ts title="TypeScript"
const deliveries = await linear.deliveries({ type: "…" });
```

```python title="Python"
deliveries = await linear.deliveries(type="…")
```

```rust title="Rust"
let deliveries = linear.deliveries().r#type("…").await?;
```

| Parameter  | Python / Rust     | Type          | Required |        |
| ---------- | ----------------- | ------------- | -------- | ------ |
| `type`     | `type` · `r#type` | `string`      | no       | option |
| `resource` | `resource`        | `LinearIssue` | no       | option |
| `app`      | `app`             | `LinearApp`   | no       | option |

**Returns** [`LinearDeliveries`](https://channelstack.dev/docs/reference/api/linear#lineardeliveries).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): Live, the platform delivers to the agent itself and channelstack isn't in the path (delivery chaos is fake-only).

### calls()

The GraphQL operations the agent sent about this session's issues and sessions, by root field (`agentActivityCreate`).

```ts title="TypeScript"
const apiCalls = await linear.calls({ operation: "…" });
```

```python title="Python"
api_calls = await linear.calls(operation="…")
```

```rust title="Rust"
let api_calls = linear.calls().operation("…").await?;
```

| Parameter   | Type             | Required |        |
| ----------- | ---------------- | -------- | ------ |
| `operation` | `string`         | no       | option |
| `error`     | `true \| string` | no       | option |

**Returns** [`LinearApiCalls`](https://channelstack.dev/docs/reference/api/linear#linearapicalls).

**Live:** needs proxy mode: Linear doesn't report the app's calls; proxy mode sees them. Proxy mode doesn't read the app's calls back live yet ([#24](https://github.com/christian-bromann/channelstack/issues/24)), so for now the call is refused with [`action_requires`](https://channelstack.dev/docs/reference/api/errors#action-requires) and the test is skipped.

### waitForCall()

Waits for the next API call from the agent after the last one this handle returned: it polls `calls()` and never sleeps longer than it must.

```ts title="TypeScript"
const apiCall = await linear.waitForCall({ operation: "…" });
```

```python title="Python"
api_call = await linear.wait_for_call(operation="…")
```

```rust title="Rust"
let api_call = linear.wait_for_call().operation("…").await?;
```

| Parameter   | Type             | Required |             |
| ----------- | ---------------- | -------- | ----------- |
| `operation` | `string`         | no       | filter      |
| `error`     | `true \| string` | no       | filter      |
| `timeout`   | `Duration`       | no       | default 10s |

**Returns** [`LinearApiCall`](https://channelstack.dev/docs/reference/api/linear#linearapicall). When the time is up, it fails with what it was waiting for.

## LinearApp

Returned by [`LinearFixture.createApp()`](https://channelstack.dev/docs/reference/api/linear#createapp), [`LinearIssue.delegatedTo()`](https://channelstack.dev/docs/reference/api/linear#delegatedto).

| Field           | Python / Rust    | Type     |
| --------------- | ---------------- | -------- |
| `id`            | `id`             | `string` |
| `name`          | `name`           | `string` |
| `kind`          | `kind`           | `"app"`  |
| `botUserId`     | `bot_user_id`    | `string` |
| `accessToken`   | `access_token`   | `string` |
| `webhookSecret` | `webhook_secret` | `string` |
| `clientId`      | `client_id`      | `string` |
| `clientSecret`  | `client_secret`  | `string` |

### comment()

An app a test made comments on an issue, as its own `commentCreate` would. Its mention of another app is refused (to confirm, B6).

```ts title="TypeScript"
const comment = await app.comment("…", { issue });
```

```python title="Python"
comment = await app.comment("…", issue=issue)
```

```rust title="Rust"
let comment = app.comment("…").issue(&issue).await?;
```

| Parameter | Type          | Required |            |
| --------- | ------------- | -------- | ---------- |
| `body`    | `string`      | yes      | positional |
| `issue`   | `LinearIssue` | yes      | option     |

**Returns** [`LinearComment`](https://channelstack.dev/docs/reference/api/linear#linearcomment).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): Live, the Linear workspace has the built-in app only: another app needs a sandbox app of its own.

### reply()

An app a test made replies in a comment's thread, as its own `commentCreate` with a `parentId` would.

```ts title="TypeScript"
const result = await app.reply("…", { comment });
```

```python title="Python"
result = await app.reply("…", comment=comment)
```

```rust title="Rust"
let result = app.reply("…").comment(&comment).await?;
```

| Parameter | Type            | Required |            |
| --------- | --------------- | -------- | ---------- |
| `body`    | `string`        | yes      | positional |
| `comment` | `LinearComment` | yes      | option     |

**Returns** [`LinearComment`](https://channelstack.dev/docs/reference/api/linear#linearcomment).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): Live, the Linear workspace has the built-in app only: another app needs a sandbox app of its own.

## LinearUser

Returned by [`LinearFixture.createUser()`](https://channelstack.dev/docs/reference/api/linear#createuser), [`LinearIssue.assignee()`](https://channelstack.dev/docs/reference/api/linear#assignee).

| Field         | Python / Rust  | Type                  |
| ------------- | -------------- | --------------------- |
| `id`          | `id`           | `string`              |
| `name`        | `name`         | `string`              |
| `kind`        | `kind`         | `"user"`              |
| `displayName` | `display_name` | `string`              |
| `email`       | `email`        | `string \| undefined` |
| `admin`       | `admin`        | `boolean`             |
| `guest`       | `guest`        | `boolean`             |

### createIssue()

Create an issue. Sends `Issue` (`create`); with `delegate`, it opens an agent session and sends `AgentSessionEvent` (`created`).

```ts title="TypeScript"
const result = await user.createIssue(issue, { team });
```

```python title="Python"
result = await user.create_issue(issue, team=team)
```

```rust title="Rust"
let result = user.create_issue(issue).team(&team).await?;
```

| Parameter | Type                                                                                                                                                               | Required |            |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------- | ---------- |
| `issue`   | `{ title: string; description?: string; priority?: number; state?: string; labels?: string[]; assignee?: LinearUser; delegate?: LinearApp; parent?: LinearIssue }` | yes      | positional |
| `team`    | `LinearTeam`                                                                                                                                                       | yes      | option     |

**Returns** [`LinearIssue`](https://channelstack.dev/docs/reference/api/linear#linearissue).

**Errors** [`forbidden`](https://channelstack.dev/docs/reference/api/errors#forbidden).

### editIssue()

Edit an issue's title, description or priority. Sends `Issue` (`update`).

```ts title="TypeScript"
const delivery = await user.editIssue(changes, { issue });
```

```python title="Python"
delivery = await user.edit_issue(changes, issue=issue)
```

```rust title="Rust"
let delivery = user.edit_issue(changes).issue(&issue).await?;
```

| Parameter | Type                                                          | Required |            |
| --------- | ------------------------------------------------------------- | -------- | ---------- |
| `changes` | `{ title?: string; description?: string; priority?: number }` | yes      | positional |
| `issue`   | `LinearIssue`                                                 | yes      | option     |

**Returns** [`LinearDelivery | undefined`](https://channelstack.dev/docs/reference/api/linear#lineardelivery).

**Errors** [`forbidden`](https://channelstack.dev/docs/reference/api/errors#forbidden).

### undelegate()

Take an issue back from the app. Sends `Issue` (`update`).

```ts title="TypeScript"
const delivery = await user.undelegate({ issue });
```

```python title="Python"
delivery = await user.undelegate(issue=issue)
```

```rust title="Rust"
let delivery = user.undelegate().issue(&issue).await?;
```

| Parameter | Type          | Required |        |
| --------- | ------------- | -------- | ------ |
| `issue`   | `LinearIssue` | yes      | option |

**Returns** [`LinearDelivery | undefined`](https://channelstack.dev/docs/reference/api/linear#lineardelivery).

**Errors** [`forbidden`](https://channelstack.dev/docs/reference/api/errors#forbidden).

### assign()

Assign an issue to a person, or (with no one) unassign it. Sends `Issue` (`update`).

```ts title="TypeScript"
const delivery = await user.assign({ issue });
```

```python title="Python"
delivery = await user.assign(issue=issue)
```

```rust title="Rust"
let delivery = user.assign().issue(&issue).await?;
```

| Parameter  | Type          | Required |            |
| ---------- | ------------- | -------- | ---------- |
| `assignee` | `LinearUser`  | no       | positional |
| `issue`    | `LinearIssue` | yes      | option     |

**Returns** [`LinearDelivery | undefined`](https://channelstack.dev/docs/reference/api/linear#lineardelivery).

**Errors** [`forbidden`](https://channelstack.dev/docs/reference/api/errors#forbidden).

### setState()

Move an issue to a workflow state, by name. Sends `Issue` (`update`).

```ts title="TypeScript"
const delivery = await user.setState("…", { issue });
```

```python title="Python"
delivery = await user.set_state("…", issue=issue)
```

```rust title="Rust"
let delivery = user.set_state("…").issue(&issue).await?;
```

| Parameter | Type          | Required |            |
| --------- | ------------- | -------- | ---------- |
| `state`   | `string`      | yes      | positional |
| `issue`   | `LinearIssue` | yes      | option     |

**Returns** [`LinearDelivery | undefined`](https://channelstack.dev/docs/reference/api/linear#lineardelivery).

**Errors** [`forbidden`](https://channelstack.dev/docs/reference/api/errors#forbidden).

### label()

Put labels on an issue, by name. Sends `Issue` (`update`).

```ts title="TypeScript"
const delivery = await user.label(labels, { issue });
```

```python title="Python"
delivery = await user.label(labels, issue=issue)
```

```rust title="Rust"
let delivery = user.label(labels).issue(&issue).await?;
```

| Parameter | Type                 | Required |            |
| --------- | -------------------- | -------- | ---------- |
| `labels`  | `string \| string[]` | yes      | positional |
| `issue`   | `LinearIssue`        | yes      | option     |

**Returns** [`LinearDelivery | undefined`](https://channelstack.dev/docs/reference/api/linear#lineardelivery).

**Errors** [`forbidden`](https://channelstack.dev/docs/reference/api/errors#forbidden).

### delegate()

Delegate an issue to an app. Opens that app's agent session and sends it `AgentSessionEvent` (`created`); an issue delegated to another app moves.

```ts title="TypeScript"
const agentSession = await user.delegate(app, { issue });
```

```python title="Python"
agent_session = await user.delegate(app, issue=issue)
```

```rust title="Rust"
let agent_session = user.delegate(&app).issue(&issue).await?;
```

| Parameter | Type          | Required |            |
| --------- | ------------- | -------- | ---------- |
| `app`     | `LinearApp`   | yes      | positional |
| `issue`   | `LinearIssue` | yes      | option     |

**Returns** [`LinearAgentSession`](https://channelstack.dev/docs/reference/api/linear#linearagentsession).

**Errors** [`forbidden`](https://channelstack.dev/docs/reference/api/errors#forbidden).

### comment()

Comment on an issue. A mention of the app opens an agent session and sends `AgentSessionEvent` (`created`).

```ts title="TypeScript"
const comment = await user.comment("…", { issue });
```

```python title="Python"
comment = await user.comment("…", issue=issue)
```

```rust title="Rust"
let comment = user.comment("…").issue(&issue).await?;
```

| Parameter | Type          | Required |            |
| --------- | ------------- | -------- | ---------- |
| `body`    | `string`      | yes      | positional |
| `issue`   | `LinearIssue` | yes      | option     |

**Returns** [`LinearComment`](https://channelstack.dev/docs/reference/api/linear#linearcomment).

**Errors** [`forbidden`](https://channelstack.dev/docs/reference/api/errors#forbidden).

### reply()

Reply in a comment's thread. In an agent session's thread, it prompts the session (`AgentSessionEvent` `prompted`).

```ts title="TypeScript"
const result = await user.reply("…", { comment });
```

```python title="Python"
result = await user.reply("…", comment=comment)
```

```rust title="Rust"
let result = user.reply("…").comment(&comment).await?;
```

| Parameter | Type            | Required |            |
| --------- | --------------- | -------- | ---------- |
| `body`    | `string`        | yes      | positional |
| `comment` | `LinearComment` | yes      | option     |

**Returns** [`LinearComment`](https://channelstack.dev/docs/reference/api/linear#linearcomment).

**Errors** [`forbidden`](https://channelstack.dev/docs/reference/api/errors#forbidden).

### edit()

Edit a comment. Sends `Comment` (`update`).

```ts title="TypeScript"
const delivery = await user.edit("…", { comment });
```

```python title="Python"
delivery = await user.edit("…", comment=comment)
```

```rust title="Rust"
let delivery = user.edit("…").comment(&comment).await?;
```

| Parameter | Type            | Required |            |
| --------- | --------------- | -------- | ---------- |
| `body`    | `string`        | yes      | positional |
| `comment` | `LinearComment` | yes      | option     |

**Returns** [`LinearDelivery | undefined`](https://channelstack.dev/docs/reference/api/linear#lineardelivery).

**Errors** [`forbidden`](https://channelstack.dev/docs/reference/api/errors#forbidden).

### delete()

Delete a comment. Sends `Comment` (`remove`).

```ts title="TypeScript"
const delivery = await user.delete({ comment });
```

```python title="Python"
delivery = await user.delete(comment=comment)
```

```rust title="Rust"
let delivery = user.delete().comment(&comment).await?;
```

| Parameter | Type            | Required |        |
| --------- | --------------- | -------- | ------ |
| `comment` | `LinearComment` | yes      | option |

**Returns** [`LinearDelivery | undefined`](https://channelstack.dev/docs/reference/api/linear#lineardelivery).

**Errors** [`forbidden`](https://channelstack.dev/docs/reference/api/errors#forbidden).

### react()

React to a comment with an emoji. Linear sends no webhook for it.

```ts title="TypeScript"
await user.react("…", { comment });
```

```python title="Python"
await user.react("…", comment=comment)
```

```rust title="Rust"
user.react("…").comment(&comment).await?;
```

| Parameter | Type            | Required |            |
| --------- | --------------- | -------- | ---------- |
| `emoji`   | `string`        | yes      | positional |
| `comment` | `LinearComment` | yes      | option     |

**Returns** nothing.

**Errors** [`forbidden`](https://channelstack.dev/docs/reference/api/errors#forbidden).

### prompt()

Send a follow-up in an agent session. Sends `AgentSessionEvent` (`prompted`).

```ts title="TypeScript"
const delivery = await user.prompt("…", { session });
```

```python title="Python"
delivery = await user.prompt("…", session=session)
```

```rust title="Rust"
let delivery = user.prompt("…").session(&session).await?;
```

| Parameter | Type                 | Required |            |
| --------- | -------------------- | -------- | ---------- |
| `body`    | `string`             | yes      | positional |
| `session` | `LinearAgentSession` | yes      | option     |

**Returns** [`LinearDelivery | undefined`](https://channelstack.dev/docs/reference/api/linear#lineardelivery).

**Errors** [`forbidden`](https://channelstack.dev/docs/reference/api/errors#forbidden).

### answer()

Answer a question the agent asked (an `elicitation` activity). Sends `AgentSessionEvent` (`prompted`).

```ts title="TypeScript"
const delivery = await user.answer("…", { elicitation });
```

```python title="Python"
delivery = await user.answer("…", elicitation=elicitation)
```

```rust title="Rust"
let delivery = user.answer("…").elicitation(&elicitation).await?;
```

| Parameter     | Type                  | Required |            |
| ------------- | --------------------- | -------- | ---------- |
| `body`        | `string`              | yes      | positional |
| `elicitation` | `LinearAgentActivity` | yes      | option     |

**Returns** [`LinearDelivery | undefined`](https://channelstack.dev/docs/reference/api/linear#lineardelivery).

**Errors** [`forbidden`](https://channelstack.dev/docs/reference/api/errors#forbidden).

### stop()

Press Stop on an agent session. Sends `AgentSessionEvent` (`prompted`) with the `stop` signal.

```ts title="TypeScript"
const delivery = await user.stop({ session });
```

```python title="Python"
delivery = await user.stop(session=session)
```

```rust title="Rust"
let delivery = user.stop().session(&session).await?;
```

| Parameter | Type                 | Required |        |
| --------- | -------------------- | -------- | ------ |
| `session` | `LinearAgentSession` | yes      | option |

**Returns** [`LinearDelivery`](https://channelstack.dev/docs/reference/api/linear#lineardelivery).

**Errors** [`forbidden`](https://channelstack.dev/docs/reference/api/errors#forbidden).

**Live:** needs the browser actor: Linear sends the stop signal only when a person presses Stop, and it can't be published through the API. The browser actor doesn't do this yet ([#47](https://github.com/christian-bromann/channelstack/issues/47)), so for now the call is refused with [`action_requires`](https://channelstack.dev/docs/reference/api/errors#action-requires) and the test is skipped.

## LinearComment

Returned by [`LinearApp.comment()`](https://channelstack.dev/docs/reference/api/linear#comment), [`LinearApp.reply()`](https://channelstack.dev/docs/reference/api/linear#reply), [`LinearUser.comment()`](https://channelstack.dev/docs/reference/api/linear#comment-1), [`LinearUser.reply()`](https://channelstack.dev/docs/reference/api/linear#reply-1).

| Field       | Python / Rust | Type                              |
| ----------- | ------------- | --------------------------------- |
| `id`        | `id`          | `string`                          |
| `issue`     | `issue`       | `LinearIssue`                     |
| `author`    | `author`      | `LinearUser \| LinearApp`         |
| `body`      | `body`        | `string`                          |
| `createdAt` | `created_at`  | `string`                          |
| `url`       | `url`         | `string`                          |
| `session`   | `session`     | `LinearAgentSession \| undefined` |
| `delivery`  | `delivery`    | `LinearDelivery \| undefined`     |

### replies()

The replies in a comment's thread, once the agent is quiet.

```ts title="TypeScript"
const commentReplies = await comment.replies();
```

```python title="Python"
comment_replies = await comment.replies()
```

```rust title="Rust"
let comment_replies = comment.replies().await?;
```

**Returns** [`LinearCommentReplies`](https://channelstack.dev/docs/reference/api/linear#linearcommentreplies). It reads once the app is quiet.

### deliveryFor()

The `Comment` (`create`) delivery this comment caused to this app (decision 0027), or nothing when it wasn't told. The comment's `delivery` is the built-in app's.

```ts title="TypeScript"
const delivery = await comment.deliveryFor(app);
```

```python title="Python"
delivery = await comment.delivery_for(app)
```

```rust title="Rust"
let delivery = comment.delivery_for(&app).await?;
```

| Parameter | Type        | Required |            |
| --------- | ----------- | -------- | ---------- |
| `app`     | `LinearApp` | yes      | positional |

**Returns** [`LinearDelivery | undefined`](https://channelstack.dev/docs/reference/api/linear#lineardelivery).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): Live, the platform delivers to the agent itself and channelstack isn't in the path (delivery chaos is fake-only).

### transcript()

A comment's thread as a person reads it.

```ts title="TypeScript"
const transcript = await comment.transcript();
```

```python title="Python"
transcript = await comment.transcript()
```

```rust title="Rust"
let transcript = comment.transcript().await?;
```

**Returns** [`LinearTranscript`](https://channelstack.dev/docs/reference/api/linear#lineartranscript).

## LinearIssue

Returned by [`LinearUser.createIssue()`](https://channelstack.dev/docs/reference/api/linear#createissue), [`LinearIssue.refresh()`](https://channelstack.dev/docs/reference/api/linear#refresh), [`LinearTeam.issue()`](https://channelstack.dev/docs/reference/api/linear#issue).

| Field        | Type                      |
| ------------ | ------------------------- |
| `id`         | `string`                  |
| `identifier` | `string`                  |
| `url`        | `string`                  |
| `team`       | `LinearTeam`              |
| `creator`    | `LinearUser \| LinearApp` |

### refresh()

Read the issue again.

```ts title="TypeScript"
const updated = await issue.refresh();
```

```python title="Python"
updated = await issue.refresh()
```

```rust title="Rust"
let updated = issue.refresh().await?;
```

**Returns** [`LinearIssue`](https://channelstack.dev/docs/reference/api/linear#linearissue).

### title()

The issue's title as it is now.

```ts title="TypeScript"
const result = await issue.title();
```

```python title="Python"
result = await issue.title()
```

```rust title="Rust"
let result = issue.title().await?;
```

**Returns** `string`.

### state()

The issue's workflow state.

```ts title="TypeScript"
const issueState = await issue.state();
```

```python title="Python"
issue_state = await issue.state()
```

```rust title="Rust"
let issue_state = issue.state().await?;
```

**Returns** [`LinearIssueState`](https://channelstack.dev/docs/reference/api/linear#linearissuestate).

### assignee()

Who the issue is assigned to, if anyone.

```ts title="TypeScript"
const user = await issue.assignee();
```

```python title="Python"
user = await issue.assignee()
```

```rust title="Rust"
let user = issue.assignee().await?;
```

**Returns** [`LinearUser | undefined`](https://channelstack.dev/docs/reference/api/linear#linearuser).

### delegatedTo()

The app the issue is delegated to, if any.

```ts title="TypeScript"
const app = await issue.delegatedTo();
```

```python title="Python"
app = await issue.delegated_to()
```

```rust title="Rust"
let app = issue.delegated_to().await?;
```

**Returns** [`LinearApp | undefined`](https://channelstack.dev/docs/reference/api/linear#linearapp).

### labels()

The names of the labels on the issue.

```ts title="TypeScript"
const items = await issue.labels();
```

```python title="Python"
items = await issue.labels()
```

```rust title="Rust"
let items = issue.labels().await?;
```

**Returns** `string[]`.

### comments()

The comments on the issue, oldest first, without the one Linear writes to open a delegated session's thread.

```ts title="TypeScript"
const comments = await issue.comments();
```

```python title="Python"
comments = await issue.comments()
```

```rust title="Rust"
let comments = issue.comments().await?;
```

**Returns** [`LinearComments`](https://channelstack.dev/docs/reference/api/linear#linearcomments).

### sessions()

The agent sessions on the issue, oldest first.

```ts title="TypeScript"
const agentSessions = await issue.sessions();
```

```python title="Python"
agent_sessions = await issue.sessions()
```

```rust title="Rust"
let agent_sessions = issue.sessions().await?;
```

**Returns** [`LinearAgentSessions`](https://channelstack.dev/docs/reference/api/linear#linearagentsessions).

### session()

The issue's latest agent session, waiting for one to be opened.

```ts title="TypeScript"
const agentSession = await issue.session();
```

```python title="Python"
agent_session = await issue.session()
```

```rust title="Rust"
let agent_session = issue.session().await?;
```

**Returns** [`LinearAgentSession`](https://channelstack.dev/docs/reference/api/linear#linearagentsession). While refused with [`not_found`](https://channelstack.dev/docs/reference/api/errors#not-found), it tries again until the wait's timeout.

### transcript()

The issue as a person reads it: description, comments and the agent's sessions.

```ts title="TypeScript"
const transcript = await issue.transcript();
```

```python title="Python"
transcript = await issue.transcript()
```

```rust title="Rust"
let transcript = issue.transcript().await?;
```

**Returns** [`LinearTranscript`](https://channelstack.dev/docs/reference/api/linear#lineartranscript).

### waitForComment()

Waits for the next comment after the last one this handle returned: it polls `comments()` and never sleeps longer than it must.

```ts title="TypeScript"
const comment = await issue.waitForComment({ from: "my-agent" });
```

```python title="Python"
comment = await issue.wait_for_comment(from_="my-agent")
```

```rust title="Rust"
let comment = issue.wait_for_comment().from("my-agent").await?;
```

| Parameter | Python / Rust    | Type                                | Required |                      |
| --------- | ---------------- | ----------------------------------- | -------- | -------------------- |
| `from`    | `from_` · `from` | `LinearUser \| LinearApp \| string` | no       | a handle, or a name  |
| `body`    | `body`           | `string \| RegExp`                  | no       | contains, or matches |
| `timeout` | `timeout`        | `Duration`                          | no       | default 10s          |

**Returns** [`LinearComment`](https://channelstack.dev/docs/reference/api/linear#linearcomment). When the time is up, it fails with what it was waiting for.

### latestComment()

The latest comment, once the app is quiet. Waits for at least one: it polls `comments()` and never sleeps longer than it must.

```ts title="TypeScript"
const comment = await issue.latestComment({ from: "my-agent" });
```

```python title="Python"
comment = await issue.latest_comment(from_="my-agent")
```

```rust title="Rust"
let comment = issue.latest_comment().from("my-agent").await?;
```

| Parameter  | Python / Rust    | Type                                | Required |                     |
| ---------- | ---------------- | ----------------------------------- | -------- | ------------------- |
| `from`     | `from_` · `from` | `LinearUser \| LinearApp \| string` | no       | a handle, or a name |
| `timeout`  | `timeout`        | `Duration`                          | no       | default 10s         |
| `quietFor` | `quiet_for`      | `Duration`                          | no       | default 750ms       |

**Returns** [`LinearComment`](https://channelstack.dev/docs/reference/api/linear#linearcomment). When the time is up, it fails with what it was waiting for.

## LinearTeam

Returned by [`LinearFixture.createTeam()`](https://channelstack.dev/docs/reference/api/linear#createteam).

| Field  | Type     |
| ------ | -------- |
| `id`   | `string` |
| `key`  | `string` |
| `name` | `string` |

### issue()

An issue of this team by its identifier (`ENG-12`).

```ts title="TypeScript"
const issue = await team.issue("…");
```

```python title="Python"
issue = await team.issue("…")
```

```rust title="Rust"
let issue = team.issue("…").await?;
```

| Parameter    | Type     | Required |            |
| ------------ | -------- | -------- | ---------- |
| `identifier` | `string` | yes      | positional |

**Returns** [`LinearIssue`](https://channelstack.dev/docs/reference/api/linear#linearissue).

## LinearAgentSession

Returned by [`LinearUser.delegate()`](https://channelstack.dev/docs/reference/api/linear#delegate), [`LinearIssue.session()`](https://channelstack.dev/docs/reference/api/linear#session).

| Field       | Python / Rust | Type                          |
| ----------- | ------------- | ----------------------------- |
| `id`        | `id`          | `string`                      |
| `issue`     | `issue`       | `LinearIssue`                 |
| `app`       | `app`         | `LinearApp`                   |
| `startedBy` | `started_by`  | `LinearUser`                  |
| `delivery`  | `delivery`    | `LinearDelivery \| undefined` |

### state()

The session's status.

```ts title="TypeScript"
const result = await agentSession.state();
```

```python title="Python"
result = await agent_session.state()
```

```rust title="Rust"
let result = agent_session.state().await?;
```

**Returns** `"pending" | "active" | "stopping" | "awaitingInput" | "complete" | "error" | "stale"`.

### activities()

The session's activities, oldest first: the agent's, and the prompts of people.

```ts title="TypeScript"
const agentActivities = await agentSession.activities();
```

```python title="Python"
agent_activities = await agent_session.activities()
```

```rust title="Rust"
let agent_activities = agent_session.activities().await?;
```

**Returns** [`LinearAgentActivities`](https://channelstack.dev/docs/reference/api/linear#linearagentactivities).

### externalUrls()

The links the agent attached to the session.

```ts title="TypeScript"
const externalUrls = await agentSession.externalUrls();
```

```python title="Python"
external_urls = await agent_session.external_urls()
```

```rust title="Rust"
let external_urls = agent_session.external_urls().await?;
```

**Returns** [`LinearExternalUrls`](https://channelstack.dev/docs/reference/api/linear#linearexternalurls).

### plan()

The agent's plan: each step and its status.

```ts title="TypeScript"
const plan = await agentSession.plan();
```

```python title="Python"
plan = await agent_session.plan()
```

```rust title="Rust"
let plan = agent_session.plan().await?;
```

**Returns** [`LinearPlan`](https://channelstack.dev/docs/reference/api/linear#linearplan).

### transcript()

The session as a person reads it.

```ts title="TypeScript"
const transcript = await agentSession.transcript();
```

```python title="Python"
transcript = await agent_session.transcript()
```

```rust title="Rust"
let transcript = agent_session.transcript().await?;
```

**Returns** [`LinearTranscript`](https://channelstack.dev/docs/reference/api/linear#lineartranscript).

### waitForState()

Waits for the agent session to reach that state: it polls `state()` and never sleeps longer than it must.

```ts title="TypeScript"
const result = await agentSession.waitForState(wanted);
```

```python title="Python"
result = await agent_session.wait_for_state(wanted)
```

```rust title="Rust"
let result = agent_session.wait_for_state(wanted).await?;
```

| Parameter | Type                                                                                                                                                                                              | Required |             |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ----------- |
| `wanted`  | `"pending" \| "active" \| "stopping" \| "awaitingInput" \| "complete" \| "error" \| "stale" \| Array<"pending" \| "active" \| "stopping" \| "awaitingInput" \| "complete" \| "error" \| "stale">` | yes      | positional  |
| `timeout` | `Duration`                                                                                                                                                                                        | no       | default 10s |

**Returns** `"pending" | "active" | "stopping" | "awaitingInput" | "complete" | "error" | "stale"`. When the time is up, it fails with what it was waiting for.

### waitForActivity()

Waits for the next activity after the last one this handle returned: it polls `activities()` and never sleeps longer than it must.

```ts title="TypeScript"
const agentActivity = await agentSession.waitForActivity();
```

```python title="Python"
agent_activity = await agent_session.wait_for_activity()
```

```rust title="Rust"
let agent_activity = agent_session.wait_for_activity().await?;
```

| Parameter | Python / Rust     | Type               | Required |                      |
| --------- | ----------------- | ------------------ | -------- | -------------------- |
| `type`    | `type` · `r#type` | `string \| RegExp` | no       | contains, or matches |
| `timeout` | `timeout`         | `Duration`         | no       | default 10s          |

**Returns** [`LinearAgentActivity`](https://channelstack.dev/docs/reference/api/linear#linearagentactivity). When the time is up, it fails with what it was waiting for.

## LinearDelivery

Returned by [`LinearUser.editIssue()`](https://channelstack.dev/docs/reference/api/linear#editissue), [`LinearUser.undelegate()`](https://channelstack.dev/docs/reference/api/linear#undelegate), [`LinearUser.assign()`](https://channelstack.dev/docs/reference/api/linear#assign), [`LinearUser.setState()`](https://channelstack.dev/docs/reference/api/linear#setstate).

| Field       | Python / Rust     | Type                                                                      |
| ----------- | ----------------- | ------------------------------------------------------------------------- |
| `id`        | `id`              | `string`                                                                  |
| `channel`   | `channel`         | `"linear"`                                                                |
| `app`       | `app`             | `string`                                                                  |
| `type`      | `type` · `r#type` | `string`                                                                  |
| `action`    | `action`          | `string`                                                                  |
| `webhookId` | `webhook_id`      | `string`                                                                  |
| `payload`   | `payload`         | `unknown \| undefined`                                                    |
| `attempts`  | `attempts`        | `DeliveryAttempt[]`                                                       |
| `status`    | `status`          | `"pending" \| "acknowledged" \| "failed" \| "timed_out" \| "unreachable"` |

### refresh()

Re-read a delivery: its attempts and status.

```ts title="TypeScript"
const updated = await delivery.refresh();
```

```python title="Python"
updated = await delivery.refresh()
```

```rust title="Rust"
let updated = delivery.refresh().await?;
```

**Returns** [`LinearDelivery`](https://channelstack.dev/docs/reference/api/linear#lineardelivery).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): Live, the platform delivers to the agent itself and channelstack isn't in the path (delivery chaos is fake-only).

### redeliver()

Redeliver, as Linear retries: the same delivery, with a new `webhookTimestamp` and a new signature.

```ts title="TypeScript"
const deliveryAttempt = await delivery.redeliver();
```

```python title="Python"
delivery_attempt = await delivery.redeliver()
```

```rust title="Rust"
let delivery_attempt = delivery.redeliver().await?;
```

**Returns** [`DeliveryAttempt`](https://channelstack.dev/docs/reference/api/client#deliveryattempt).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): Linear has no API to redeliver a webhook.

### resend()

Send the delivery again: stale (its `webhookTimestamp` two minutes old), or signed with a secret that isn't the app's.

```ts title="TypeScript"
const deliveryAttempt = await delivery.resend({ badSignature });
```

```python title="Python"
delivery_attempt = await delivery.resend(bad_signature=bad_signature)
```

```rust title="Rust"
let delivery_attempt = delivery.resend().bad_signature(bad_signature).await?;
```

| Parameter      | Python / Rust   | Type      | Required |        |
| -------------- | --------------- | --------- | -------- | ------ |
| `badSignature` | `bad_signature` | `boolean` | no       | option |
| `stale`        | `stale`         | `boolean` | no       | option |

**Returns** [`DeliveryAttempt`](https://channelstack.dev/docs/reference/api/client#deliveryattempt).

**Live:** refused with [`unsupported_in_live`](https://channelstack.dev/docs/reference/api/errors#unsupported-in-live): Live, the platform delivers to the agent itself and channelstack isn't in the path (delivery chaos is fake-only).

### settled()

Waits for the delivery to settle: it polls `refresh()` and never sleeps longer than it must.

```ts title="TypeScript"
const updated = await delivery.settled();
```

```python title="Python"
updated = await delivery.settled()
```

```rust title="Rust"
let updated = delivery.settled().await?;
```

| Parameter | Type       | Required |             |
| --------- | ---------- | -------- | ----------- |
| `timeout` | `Duration` | no       | default 10s |

**Returns** [`LinearDelivery`](https://channelstack.dev/docs/reference/api/linear#lineardelivery). When the time is up, it fails with what it was waiting for.

## LinearAgentActivity

| Field       | Python / Rust     | Type                                                                          |
| ----------- | ----------------- | ----------------------------------------------------------------------------- |
| `id`        | `id`              | `string`                                                                      |
| `session`   | `session`         | `LinearAgentSession`                                                          |
| `type`      | `type` · `r#type` | `"thought" \| "action" \| "elicitation" \| "response" \| "error" \| "prompt"` |
| `author`    | `author`          | `LinearUser \| LinearApp`                                                     |
| `body`      | `body`            | `string \| undefined`                                                         |
| `action`    | `action`          | `{ action: string; parameter?: string; result?: string } \| undefined`        |
| `ephemeral` | `ephemeral`       | `boolean`                                                                     |
| `createdAt` | `created_at`      | `string`                                                                      |

## Types

Plain values the handles return and take.

### LinearApps

```ts
type LinearApps = LinearApp[];
```

### LinearUsers

```ts
type LinearUsers = LinearUser[];
```

### LinearTeams

```ts
type LinearTeams = LinearTeam[];
```

### LinearIssues

```ts
type LinearIssues = LinearIssueListing[];
```

### LinearIssueListing

| Field   | Type          |
| ------- | ------------- |
| `issue` | `LinearIssue` |
| `title` | `string`      |

### LinearIssueState

| Field  | Python / Rust     | Type                                                                                            |
| ------ | ----------------- | ----------------------------------------------------------------------------------------------- |
| `name` | `name`            | `string`                                                                                        |
| `type` | `type` · `r#type` | `"backlog" \| "unstarted" \| "started" \| "completed" \| "canceled" \| "triage" \| "duplicate"` |

### LinearComments

```ts
type LinearComments = LinearComment[];
```

### LinearAgentSessions

```ts
type LinearAgentSessions = LinearAgentSession[];
```

### LinearTranscript

| Field     | Type                      |
| --------- | ------------------------- |
| `entries` | `LinearTranscriptEntry[]` |
| `text`    | `string`                  |

### LinearTranscriptEntry

| Field      | Type              |
| ---------- | ----------------- |
| `id`       | `string`          |
| `author`   | `LinearPrincipal` |
| `at`       | `string`          |
| `text`     | `string`          |
| `controls` | `string[]`        |
| `edited`   | `boolean`         |
| `depth`    | `number`          |

### LinearPrincipal

| Field  | Type              |
| ------ | ----------------- |
| `id`   | `string`          |
| `name` | `string`          |
| `kind` | `"user" \| "app"` |

### LinearCommentReplies

```ts
type LinearCommentReplies = LinearComment[];
```

### LinearAgentActivities

```ts
type LinearAgentActivities = LinearAgentActivity[];
```

### LinearExternalUrls

```ts
type LinearExternalUrls = Array<{ label: string; url: string }>;
```

### LinearPlan

```ts
type LinearPlan = Array<{ content: string; status: "pending" | "inProgress" | "completed" | "canceled" }>;
```

### LinearDeliveries

```ts
type LinearDeliveries = LinearDelivery[];
```

### LinearApiCalls

```ts
type LinearApiCalls = LinearApiCall[];
```

### LinearApiCall

| Field            | Python / Rust     | Type                   |
| ---------------- | ----------------- | ---------------------- |
| `id`             | `id`              | `string`               |
| `channel`        | `channel`         | `"linear"`             |
| `operation`      | `operation`       | `string`               |
| `method`         | `method`          | `string`               |
| `path`           | `path`            | `string`               |
| `at`             | `at`              | `string`               |
| `durationMs`     | `duration_ms`     | `number`               |
| `request`        | `request`         | `unknown \| undefined` |
| `responseStatus` | `response_status` | `number`               |
| `response`       | `response`        | `unknown \| undefined` |
| `error`          | `error`           | `string \| undefined`  |
