# Create Topic

## Task Projects API — Create Topic

### Overview

Creates a new **topic** in Task Projects.

* **Environment:** `https://sea-staging-h1.ekoapp.com`
* **Endpoint:** `POST /api/v1/task-projects/topics`
* **Auth:** Bearer JWT
* **Content-Type:** `application/json`

***

### Request

#### Headers

| Header          | Required | Value              |
| --------------- | -------- | ------------------ |
| `Content-Type`  | Yes      | `application/json` |
| `Authorization` | Yes      | `Bearer <JWT>`     |

#### Body (JSON)

| Field             | Type               | Required | Description                                        |
| ----------------- | ------------------ | -------- | -------------------------------------------------- |
| `taskTitle`       | string             | Yes      | Topic title (UTF-8; supports Thai).                |
| `taskDescription` | string             | No       | Detailed description/goal (UTF-8).                 |
| `priority`        | integer            | No       | Priority (e.g., `1`=High, `2`=Medium, `3`=Low).    |
| `dueDate`         | string (ISO 8601)  | No       | Due date/time in UTC, e.g. `2025-12-31T23:59:59Z`. |
| `labelIds`        | array\<string>     | No       | Labels to tag the topic.                           |
| `attachments`     | array\<Attachment> | No       | Files/links to attach (see below).                 |

**Example request**

```json
{
  "taskTitle": "แผนการดำเนินการเพื่อเพิ่ม Transaction (จำนวนใบเสร็จ)",
  "taskDescription": "ค่า CSAT อยู่ที่ 85.0 เปอร์เซ็นต์ ต่ำกว่าเป้าที่ตั้งไว้ที่ 87.0 เปอร์เซ็นต์ การพึงพอใจที่ต่ำกว่าทำให้ความถี่การกลับมาใช้บริการลดลง ส่งผลให้จำนวนใบเสร็จเติบโตไม่เต็มที่",
  "priority": 3,
  "dueDate": "2025-12-31T23:59:59Z",
  "labelIds": [],
  "attachments": []
}
```

***

### Responses

#### 201 Created

```json
{
  "id": "top_67a12c3de2e09e162843f949",
  "taskTitle": "แผนการดำเนินการเพื่อเพิ่ม Transaction (จำนวนใบเสร็จ)",
  "taskDescription": "ค่า CSAT อยู่ที่ 85.0 เปอร์เซ็นต์ ต่ำกว่าเป้าที่ตั้งไว้ที่ 87.0 เปอร์เซ็นต์ การพึงพอใจที่ต่ำกว่าทำให้ความถี่การกลับมาใช้บริการลดลง ส่งผลให้จำนวนใบเสร็จเติบโตไม่เต็มที่",
  "priority": 3,
  "dueDate": "2025-12-31T23:59:59Z",
  "labelIds": [],
  "attachments": [],
  "status": "open",
  "createdAt": "2025-08-18T04:10:00Z",
  "updatedAt": "2025-08-18T04:10:00Z"
}
```

#### Error responses (typical)

| Status                     | Meaning                  | Notes                       |
| -------------------------- | ------------------------ | --------------------------- |
| `400 Bad Request`          | Invalid payload          | Wrong types/missing fields. |
| `401 Unauthorized`         | Invalid/missing token    | Check `Authorization`.      |
| `403 Forbidden`            | Insufficient scope       | Requires write access.      |
| `404 Not Found`            | Related resource missing | e.g., unknown `labelIds`.   |
| `422 Unprocessable Entity` | Validation error         | Field-level details.        |
| `429 Too Many Requests`    | Rate limited             | Respect `Retry-After`.      |
| `5xx`                      | Server error             | Retry with backoff.         |

***

### cURL example

```bash
curl --location 'https://sea-staging-h1.ekoapp.com/api/v1/task-projects/topics' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <REDACTED_JWT>' \
  --data '{
    "taskTitle": "แผนการดำเนินการเพื่อเพิ่ม Transaction (จำนวนใบเสร็จ)",
    "taskDescription": "ค่า CSAT อยู่ที่ 85.0 เปอร์เซ็นต์ ต่ำกว่าเป้าที่ตั้งไว้ที่ 87.0 เปอร์เซ็นต์ การพึงพอใจที่ต่ำกว่าทำให้ความถี่การกลับมาใช้บริการลดลง ส่งผลให้จำนวนใบเสร็จเติบโตไม่เต็มที่",
    "priority": 3,
    "dueDate": "2025-12-31T23:59:59Z",
    "labelIds": [],
    "attachments": []
  }'
```

***
