Overview
Pomodoro (ポモドーロ)
ポモドーロ API
ポモドーロ API リファレンス
TaskWorks API のポモドーロセッション管理関連エンドポイントの詳細ドキュメントです。
# ポモドーロ API リファレンス
TaskWorks API のポモドーロセッション管理関連エンドポイントの詳細ドキュメントです。すべてのエンドポイントはユーザー固有のデータのみを返します(RLS保護)。
## 認証方式
### ApiKey 認証(推奨)
```
Authorization: ApiKey <token>
```
- 設定 > APIキー管理 から生成
- トークンは一度しか表示されないため安全に保管
- ほとんどのエンドポイントで使用可能
### Bearer トークン認証
```
Authorization: Bearer <token>
```
- サービス間通信で使用
- 一部のエンドポイントで必須(例: /api/v1/blocks/windows)
### Cookie 認証
- 標準のセッションベース認証
- Webクライアントで使用
- Cookie専用エンドポイントで必須
## 共通レスポンス形式
すべての成功レスポンスは以下の構造に従います:
```json
{
"data": <response_data>,
"error": null
}
```
すべてのエラーレスポンスは以下の構造に従います:
```json
{
"error": "<error_type>",
"message": "<human_readable_message>",
"code": "<optional_error_code>",
"context": <optional_additional_context>
}
```
## HTTP ステータスコード
- 200: 成功
- 201: 作成完了
- 400: 不正なリクエスト(検証エラー)
- 401: 未認証(認証が必要)
- 403: 禁止(権限なし)
- 404: 未検出
- 409: 衝突(リソースの競合)
- 500: サーバー内部エラー
## ページネーション
一部のエンドポイントはカーソルベースのページネーションをサポート:
- cursor: 次ページの開始位置
- limit: 返す項目数(1-100、デフォルトはエンドポイントにより異なる)
レスポンス形式:
```json
{
"data": {
"items": [...],
"nextCursor": "string | null",
"hasMore": boolean
},
"error": null
}
```
## API エンドポイント
### ポモドーロ(Pomodoro)
#### GET /api/v1/pomodoro
アクティブなポモドーロセッションを取得します。
**認証:** ApiKey / Bearer / Cookie
**レスポンス スキーマ:**
```json
{
"data": {
"id": "string",
"user_id": "string",
"task_id": "string | null",
"session_type": "work" | "short_break" | "long_break",
"duration_minutes": number,
"started_at": "string",
"scheduled_end_at": "string",
"actual_end_at": "string | null",
"status": "active" | "completed" | "cancelled",
"notification_sent": boolean,
"evaluation_submitted": boolean,
"created_at": "string",
"updated_at": "string"
} | null,
"error": null
}
```
---
#### POST /api/v1/pomodoro
新しいポモドーロセッションを開始します。
**認証:** ApiKey / Bearer / Cookie
**リクエストボディ:**
```json
{
"task_id": "string | null",
"session_type": "work" | "short_break" | "long_break",
"duration_minutes": number (required, positive)
}
```
**レスポンス スキーマ:**
```json
{
"data": {
"id": "string",
"user_id": "string",
"task_id": "string | null",
"session_type": "work" | "short_break" | "long_break",
"duration_minutes": number,
"started_at": "string",
"scheduled_end_at": "string",
"status": "active",
"notification_sent": false,
"evaluation_submitted": false,
"created_at": "string",
"updated_at": "string"
},
"error": null
}
```
**エラーケース:**
- 400: duration_minutesは必須で正の値である必要があります
---
#### POST /api/v1/pomodoro/:id/complete
ポモドーロセッションを完了します。
**認証:** ApiKey / Bearer / Cookie
**パスパラメータ:**
- id: string(必須)- セッションID
**レスポンス スキーマ:**
```json
{
"data": {
"id": "string",
"actual_end_at": "string",
"status": "completed"
},
"error": null
}
```
---
#### DELETE /api/v1/pomodoro/:id/cancel
ポモドーロセッションをキャンセルします。
**認証:** ApiKey / Bearer / Cookie
**パスパラメータ:**
- id: string(必須)- セッションID
**レスポンス スキーマ:**
```json
{
"data": {
"id": "string",
"status": "cancelled"
},
"error": null
}
```