---
title: "Create Thread"
method: POST
path: "/apps/{app_id}/threads"
---

# Create Thread

`POST /apps/{app_id}/threads`

## Request

- Base URL: `https://api.xhostd.com` (the document declares no server; this is the origin it was published from)
- URL: `https://api.xhostd.com/apps/{app_id}/threads`
- Auth: none declared

Open one thread on the app, with its first note.

A given ``channel_id`` must name a channel of this app;
:func:`~xhostd.access.load_channel_for` answers 404 for any other
channel. The route locks the app row and takes the next per-app
thread number; ``uq_note_threads_app_number`` is the backstop. The
route copies the token label into ``author_label`` at write time
(NOTES.md), because a token label can recycle later. The write
journals ONE ``note.thread`` event; the first note writes no
``note.add`` row.

## Path parameters

- `app_id` string, uuid, required

## Headers

- `authorization` string, nullable

## Request body

- CreateThreadRequest
  - `subject` string, required
  - `body` string, required
  - `category` string, nullable
  - `channel_id` string, uuid, nullable
  - `branch` string, nullable
  - `sha` string, nullable
  - `agent_id` string, nullable

## Response `200`

Successful Response

- CreateThreadResponse
  - `id` string, uuid, required
  - `number` integer, required
  - `subject` string, required
  - `category` string, nullable, required
  - `channel_id` string, uuid, nullable, required
  - `branch` string, nullable, required
  - `sha` string, nullable, required
  - `created_at` string, date-time, required
  - `note` NoteResponse, required
    - `id` string, uuid, required
    - `category` string, nullable, required
    - `body` string, required
    - `author_user_id` string, uuid, nullable, required
    - `author_label` string, nullable, required
    - `agent_id` string, nullable, required
    - `created_at` string, date-time, required

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/xhostd/apis/xhostd-public.md) · [All operations](https://skmtc.dev/xhostd/apis/xhostd-public/llms.txt) · [OpenAPI document](https://skmtc.dev/xhostd/apis/xhostd-public/revisions/bf439c4d1789?raw)
