# Thread

URL: /business/nouns/thread · Id: `noun:thread`

> A Thread is a set of Messages replying to one another inside a Channel.

A Thread is a set of [Messages](/business/nouns/message) replying to one another inside a [Channel](/business/nouns/channel).

## Properties
| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `subject` | `string` | No | What the Thread is about. |

## Object
```json
{
  "$id": "https://api.sb/kilnbakery.com/threads/thread_1",
  "$type": "Thread",
  "subject": "Example subject"
}
```

## Relationships
- <a id="rel-groups"></a>A Thread **groups** many [Messages](/business/nouns/message): a Thread groups [Messages](/business/nouns/message) that reply to one another. `groups`, inverse [`thread`](/business/nouns/message#rel-thread).
- <a id="rel-hosted-in"></a>A Thread **is hosted in** one [Channel](/business/nouns/channel): a [Channel](/business/nouns/channel) holds Threads. `hostedIn`, inverse [`hosts`](/business/nouns/channel#rel-hosts).
- <a id="rel-questions"></a>A Thread **has** many [Questions](/business/nouns/question): each [Question](/business/nouns/question) posts in the Thread of the record it concerns, where free-text replies land. `questions`, inverse [`postedIn`](/business/nouns/question#rel-posted-in).
- <a id="rel-raised-in"></a>A Thread **is raised in** one [Conversation](/business/nouns/conversation): the intake Threads a support [Conversation](/business/nouns/conversation) opens, each deadline counted from the Conversation’s first [Message](/business/nouns/message). `raisedIn`, inverse [`raises`](/business/nouns/conversation#rel-raises).

## Verbs
| Verb | Description | Subject | Event | Class |
| --- | --- | --- | --- | --- |
| <a id="create"></a>[Thread.create](/business/nouns/thread/create) | Creates a Thread. Inherited from [Noun](/business/nouns/noun). | None. | `Thread.created` | Two-way: `try`, `send`, `do` |
| <a id="get"></a>[Thread.get](/business/nouns/thread/get) | Returns one Thread by id. Inherited from [Noun](/business/nouns/noun). | None. | None. | Read: `try`, `do` |
| <a id="list"></a>[Thread.list](/business/nouns/thread/list) | Returns Threads, newest first, one page at a time. Inherited from [Noun](/business/nouns/noun). | None. | None. | Read: `try`, `do` |
| <a id="update"></a>[Thread.update](/business/nouns/thread/update) | Changes the given properties of a Thread. Inherited from [Noun](/business/nouns/noun). | None. | `Thread.updated` | Two-way: `try`, `send`, `do` |
| <a id="delete"></a>[Thread.delete](/business/nouns/thread/delete) | Deletes a Thread; its history is kept. Inherited from [Noun](/business/nouns/noun). | None. | `Thread.deleted` | One-way: `send`, `do` |

## Permissions
Which Access level may call each Verb. One-way Verbs wait their delay window.

| Operation | `owner` | `admin` | `member` | `viewer` |
| --- | --- | --- | --- | --- |
| `Thread.create` | Yes | Yes | Yes | No |
| `Thread.get` | Yes | Yes | Yes | Yes |
| `Thread.list` | Yes | Yes | Yes | Yes |
| `Thread.update` | Yes | Yes | Yes | No |
| `Thread.delete` | Yes | Yes | Yes | No |

## Call it

**Ask**

```text
Add a thread to PetPantry.
```

**API**

```bash
curl -X POST https://api.sb/petpantry.shop/threads \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"subject":"Example subject"}'
```

```json
{
  "api": "https://api.sb/petpantry.shop",
  "thread": {
    "$id": "https://api.sb/petpantry.shop/threads/thread_1",
    "$type": "Thread",
    "subject": "Example subject"
  },
  "action": {
    "$id": "https://api.sb/petpantry.shop/actions/action_1",
    "operation": "Thread.create",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/petpantry.shop/actions/action_1"
  }
}
```

**SDK**

```ts
import { $ } from 'startup-builder'

const thread = await $.Thread.create({ subject: 'Example subject' })
```

**CLI**

```bash
npx startup-builder do Thread.create --json '{"subject":"Example subject"}'
```

**MCP**

```json
{
  "name": "do",
  "arguments": {
    "code": "return await $.Thread.create({ subject: 'Example subject' })"
  }
}
```

## Example
A parent's question about a missed session, the tutor's reply, and the parent's follow-up form one Thread in the `help@` [Channel](/business/nouns/channel).