---
title: "Thread"
description: "The `Thread` entity."
section: "Reference"
group: "Types"
order: 230
---

## Definition

```ts
interface Thread {
  id: string;
  workspaceId: string;
  title: string | null;
  createdByUserId: string | null;
  parentMessageId: string | null;
  lastMessageAt: string | null;
  createdAt: string;
  updatedAt: string;
  unreadCount: number;
}
```

## Fields

| Field             | Type             | Notes                                                                                                                                               |
| ----------------- | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`              | `string`         | `readonly` `required`                                                                                                                               |
| `workspaceId`     | `string`         | `required` — Workspace that owns this thread.                                                                                                       |
| `title`           | `string \| null` | `required` — Thread title; auto-generated from the first assistant turn or user-set.                                                                |
| `createdByUserId` | `string \| null` | `required` — User who initiated this thread; null for threads initiated by external visitors on deployed apps.                                      |
| `parentMessageId` | `string \| null` | `required` — For sub-threads spawned by a delegation, the message that rooted the delegation. Null for top-level threads.                           |
| `lastMessageAt`   | `string \| null` | `required` — ISO-8601 timestamp of the most recent message; denormalized for recency sort.                                                          |
| `createdAt`       | `string`         | `readonly` `required` — ISO-8601 timestamp of creation.                                                                                             |
| `updatedAt`       | `string`         | `readonly` `required` — ISO-8601 timestamp of the last update.                                                                                      |
| `unreadCount`     | `number`         | `required` — Number of messages newer than the caller's read pointer in this thread. 0 if the caller has no participant row or has read everything. |
