API マニュアル
バージョン: 1.0
概要
LayerClock の外部 API を使うと、CLI スクリプト・CI/CD パイプライン・他のツールから作業データを操作できます。
ベース URL: https://layerclock.com
認証
すべての外部 API エンドポイントは Personal Access Token(PAT) による認証が必要です。
PAT の発行
設定画面 → API キー タブ から発行できます。Business プラン以上(Business / Team)でご利用いただけます。
リクエスト方法
Authorization ヘッダーに Bearer トークンとして付与してください。
Authorization: Bearer lc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
トークンの注意事項
- トークンは発行時に一度だけ表示されます。必ず安全な場所に保管してください。
- 1 アカウントにつき最大 10 件まで発行できます。
- 有効期限を設定できます(未設定の場合は無期限)。
- 不要になったトークンは設定画面から無効化してください。
レート制限
| 制限 | 値 |
|---|---|
| リクエスト上限 | 1000 回 / 時間 / トークン |
| ウィンドウ方式 | 固定ウィンドウ(1 時間) |
上限を超えた場合、429 Too Many Requests が返ります。Retry-After ヘッダーに次のウィンドウまでの秒数(3600)が含まれます。
HTTP/1.1 429 Too Many Requests
Retry-After: 3600
レスポンス形式
すべてのレスポンスは JSON 形式です。
成功時
{
"success": true,
"data": { ... }
}
エラー時
{
"success": false,
"error": {
"code": "ERROR_CODE",
"message": "エラーの説明"
}
}
共通エラーコード
| HTTP | code | 説明 |
|---|---|---|
| 401 | UNAUTHORIZED |
トークンが無効・期限切れ、またはヘッダーがない |
| 403 | FORBIDDEN |
Business プラン以上が必要 |
| 403 | SSO_REQUIRED |
SSO を強制中のワークスペースで、その IdP でログインして発行したキーでない |
| 429 | RATE_LIMITED |
レート制限超過 |
| 500 | INTERNAL_ERROR |
サーバー内部エラー |
エンドポイント一覧
| メソッド | パス | 説明 |
|---|---|---|
| GET | /api/external/wbs |
WBS 項目一覧の取得 |
| POST | /api/external/wbs |
WBS 項目の作成 |
| GET | /api/external/wbs/{id} |
WBS 項目の取得 |
| PUT | /api/external/wbs/{id} |
WBS 項目の更新 |
| DELETE | /api/external/wbs/{id} |
WBS 項目の削除 |
| GET | /api/external/logs |
作業ログ一覧の取得 |
| POST | /api/external/logs |
作業ログの作成 |
| GET | /api/external/logs/{id} |
作業ログの取得 |
| PUT | /api/external/logs/{id} |
作業ログの更新 |
| DELETE | /api/external/logs/{id} |
作業ログの削除 |
| GET | /api/external/logs/summary |
作業ログのサマリー取得 |
| GET | /api/external/timer/current |
実行中タイマーの取得 |
| POST | /api/external/timer/start |
タイマーの開始 |
| POST | /api/external/timer/stop |
タイマーの停止 |
エンドポイント詳細
GET /api/external/wbs
WBS 項目(プロジェクト・フェーズ・成果物・タスク)の一覧を取得します。
クエリパラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
level |
integer | - | 階層レベルで絞り込む(1=プロジェクト、2=フェーズ、3=成果物、4=タスク) |
parent_id |
string | - | 指定した親 ID の子項目のみ取得 |
status |
string | - | ステータスで絞り込む(NOT_STARTED / IN_PROGRESS / COMPLETED / ON_HOLD) |
レスポンス例
{
"success": true,
"data": [
{
"id": "uuid",
"name": "Webサイトリニューアル",
"level": 1,
"status": "IN_PROGRESS",
"parent_id": null,
"order": 0,
"estimated_hours": "40.00",
"start_date": "2026-04-01T00:00:00.000Z",
"due_date": "2026-06-30T00:00:00.000Z",
"notes": null,
"created_at": "2026-03-01T00:00:00.000Z",
"updated_at": "2026-03-15T00:00:00.000Z"
}
]
}
POST /api/external/wbs
WBS 項目を作成します。階層は level と parent_id で指定します(level=1 はプロジェクトで parent_id は null、level>=2 は親項目の parent_id が必須)。
リクエストボディ
| フィールド | 型 | 必須 | 説明 |
|---|---|---|---|
name |
string | ✅ | 項目名(255 文字以内) |
level |
integer | ✅ | 階層(1=プロジェクト 〜 4=タスク) |
parent_id |
string | △ | 親項目 ID(level>=2 は必須、level=1 は null) |
status |
string | - | NOT_STARTED / IN_PROGRESS / COMPLETED / ON_HOLD |
estimated_hours |
number | - | 見積もり時間(0 以上) |
start_date |
string | - | 開始日(YYYY-MM-DD) |
due_date |
string | - | 期限日(YYYY-MM-DD) |
notes |
string | - | メモ(10000 文字以内) |
レスポンス例(201 Created)
{
"success": true,
"data": {
"id": "uuid",
"name": "Webサイトリニューアル",
"level": 1,
"status": "NOT_STARTED",
"parent_id": null,
"order": 0
}
}
エラーコード
| HTTP | code | 説明 |
|---|---|---|
| 400 | VALIDATION_ERROR |
入力値が不正 |
| 400 | INVALID_HIERARCHY |
親子の階層が不正・日付制約違反 |
| 400 | PROJECT_LIMIT_EXCEEDED |
プロジェクト数の上限に達している |
| 404 | NOT_FOUND |
親項目が存在しない |
GET /api/external/wbs/{id}
指定した WBS 項目を子孫ツリー込みで取得します。存在しない場合は 404 NOT_FOUND を返します。
PUT /api/external/wbs/{id}
WBS 項目を更新します。更新したいフィールドのみ送信します(最低 1 つ必須)。指定できるフィールドは name / status / order / parent_id / estimated_hours / start_date / due_date / notes。null を送るとクリアします(estimated_hours / start_date / due_date / notes)。
レスポンス例(200 OK)
{
"success": true,
"data": { "id": "uuid", "name": "更新後の名前", "status": "IN_PROGRESS" }
}
エラーコード
| HTTP | code | 説明 |
|---|---|---|
| 400 | VALIDATION_ERROR |
入力値が不正 |
| 400 | INVALID_HIERARCHY |
親子の階層が不正・日付制約違反 |
| 404 | NOT_FOUND |
項目が存在しない |
DELETE /api/external/wbs/{id}
WBS 項目を配下(子フェーズ・成果物・タスク)ごと削除します。作業ログは削除されず、タスク名を保ったまま WBS から切り離されて残ります。配下にタイマーが実行中の場合は削除できません。
impact は削除した項目の件数で、logs は WBS から切り離された作業ログの件数です。
レスポンス例(200 OK)
{
"success": true,
"data": {
"impact": { "phases": 2, "deliverables": 5, "tasks": 12, "logs": 34 }
}
}
エラーコード
| HTTP | code | 説明 |
|---|---|---|
| 404 | NOT_FOUND |
項目が存在しない |
| 409 | ACTIVE_TIMER_EXISTS |
配下にタイマーが実行中で削除不可 |
GET /api/external/logs
作業ログの一覧をページネーション付きで取得します。
クエリパラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
startDate |
string | - | 開始日でフィルター(ISO 8601形式、例: 2026-04-01) |
endDate |
string | - | 終了日でフィルター(ISO 8601形式) |
projectId |
string | - | プロジェクト ID でフィルター |
tagId |
string | - | タグ ID でフィルター(複数指定可: ?tagId=xxx&tagId=yyy) |
page |
integer | - | ページ番号(デフォルト: 1) |
perPage |
integer | - | 1ページあたりの件数(デフォルト: 20) |
レスポンス例
{
"success": true,
"data": {
"logs": [
{
"id": "uuid",
"wbs_item_id": "uuid",
"start_time": "2026-04-01T09:00:00.000Z",
"end_time": "2026-04-01T11:30:00.000Z",
"duration": 9000,
"created_at": "2026-04-01T11:30:00.000Z",
"actor": { "memberKey": "owner", "name": "山田太郎", "isOwner": true }
}
],
"total": 42,
"page": 1,
"perPage": 20
}
}
durationは秒単位です。
actorは記録者を表します。memberKeyはワークスペース内のハンドル (オーナーは"owner"、メンバーは内部メンバーID、退会・離脱者は"former")で、 グローバルなユーザー UUID は含みません。nameは表示名(未設定や退会・離脱者はnull)。
POST /api/external/logs
作業ログを手動で作成します。ログはタスク(level=4)にのみ追加できます。
リクエストボディ
| フィールド | 型 | 必須 | 説明 |
|---|---|---|---|
wbs_item_id |
string | ✅ | ログを記録するタスクの ID(level=4 のみ) |
start_time |
string | ✅ | 開始日時(ISO 8601、例 2026-04-01T09:00:00Z) |
end_time |
string | ✅ | 終了日時(ISO 8601、start_time より後) |
レスポンス例(201 Created)
{
"success": true,
"data": {
"id": "uuid",
"wbs_item_id": "uuid",
"start_time": "2026-04-01T09:00:00.000Z",
"end_time": "2026-04-01T11:30:00.000Z",
"duration": 9000,
"actor": { "memberKey": "owner", "name": "山田太郎", "isOwner": true }
}
}
durationは秒単位(サーバー側で算出)。actorの意味は GET 一覧の説明を参照。
エラーコード
| HTTP | code | 説明 |
|---|---|---|
| 400 | VALIDATION_ERROR |
必須項目欠落・日時形式不正・タスク以外を指定 |
| 400 | INVALID_TIME_RANGE |
end_time が start_time 以前 |
| 403 | FORBIDDEN |
対象タスクへのアクセス権がない |
| 404 | NOT_FOUND |
タスクが存在しない |
GET /api/external/logs/{id}
指定した作業ログを取得します。存在しない場合は 404 NOT_FOUND、他ワークスペースのログは 403 FORBIDDEN を返します。
PUT /api/external/logs/{id}
作業ログの開始/終了時刻を更新します(start_time / end_time の少なくとも一方が必須)。duration は再計算されます。
エラーコード
| HTTP | code | 説明 |
|---|---|---|
| 400 | VALIDATION_ERROR |
更新フィールドなし・日時形式不正 |
| 400 | INVALID_TIME_RANGE |
end_time が start_time 以前 |
| 404 | NOT_FOUND |
ログが存在しない |
DELETE /api/external/logs/{id}
作業ログを削除します。
レスポンス例(200 OK)
{
"success": true,
"data": { "deleted": true }
}
GET /api/external/logs/summary
作業ログの集計サマリーを取得します。
クエリパラメータ
/api/external/logs と同じ(page / perPage を除く)。
レスポンス例
{
"success": true,
"data": {
"totalSeconds": 72000,
"tree": [
{
"id": "uuid",
"name": "Webサイトリニューアル",
"level": 1,
"totalSeconds": 72000,
"children": [ ... ]
}
]
}
}
GET /api/external/timer/current
現在実行中のタイマーを取得します。タイマーが起動していない場合は data: null を返します。
レスポンス例(タイマー実行中)
{
"success": true,
"data": {
"timer_id": "uuid",
"task_id": "uuid",
"started_at": "2026-04-01T09:00:00.000Z",
"elapsed_seconds": 3600,
"task": {
"id": "uuid",
"name": "設計書作成"
}
}
}
レスポンス例(タイマー停止中)
{
"success": true,
"data": null
}
POST /api/external/timer/start
タスクのタイマーを開始します。1 アカウントで同時に起動できるタイマーは 1 つです。
リクエストボディ
{
"task_id": "uuid"
}
| フィールド | 型 | 必須 | 説明 |
|---|---|---|---|
task_id |
string | ✅ | タイマーを開始するタスクの ID(level=4 のみ) |
レスポンス例(201 Created)
{
"success": true,
"data": {
"timer_id": "uuid",
"task_id": "uuid",
"started_at": "2026-04-01T09:00:00.000Z"
}
}
エラーコード
| HTTP | code | 説明 |
|---|---|---|
| 400 | VALIDATION_ERROR |
task_id が未指定 |
| 404 | NOT_FOUND |
タスクが存在しない |
| 409 | TIMER_ALREADY_RUNNING |
すでにタイマーが起動中 |
POST /api/external/timer/stop
実行中のタイマーを停止し、作業ログを記録します。
リクエストボディ
{
"task_id": "uuid"
}
| フィールド | 型 | 必須 | 説明 |
|---|---|---|---|
task_id |
string | ✅ | 停止するタスクの ID |
レスポンス例(200 OK)
{
"success": true,
"data": {
"log_id": "uuid",
"task_id": "uuid",
"start_time": "2026-04-01T09:00:00.000Z",
"end_time": "2026-04-01T11:30:00.000Z",
"duration": 9000
}
}
durationは秒単位です。
エラーコード
| HTTP | code | 説明 |
|---|---|---|
| 400 | VALIDATION_ERROR |
task_id が未指定 |
| 404 | NOT_FOUND / NO_ACTIVE_TIMER |
タスクが存在しない、またはタイマーが起動していない |
MCP サーバ
LayerClock は本外部 API を MCP(Model Context Protocol)サーバとしても公開しています(POST /api/mcp)。Claude / Cursor / 自前のエージェントから自然言語で WBS・作業ログ・タイマーを操作・参照できます。認証は同じ PAT(Business プラン以上)を使用します。
詳細(対応メソッド・ツール一覧・クライアント設定・使用例)は MCP サーバ マニュアル を参照してください。
使用例
curl
TOKEN="lc_your_token_here"
BASE="https://layerclock.com"
# WBS 一覧取得(タスクのみ)
curl -H "Authorization: Bearer $TOKEN" "$BASE/api/external/wbs?level=4"
# 今月の作業ログ取得
curl -H "Authorization: Bearer $TOKEN" \
"$BASE/api/external/logs?startDate=2026-04-01&endDate=2026-04-30"
# タイマー開始
curl -X POST -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"task_id":"your-task-uuid"}' \
"$BASE/api/external/timer/start"
# タイマー停止
curl -X POST -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"task_id":"your-task-uuid"}' \
"$BASE/api/external/timer/stop"
Python
import requests
TOKEN = "lc_your_token_here"
BASE = "https://layerclock.com"
HEADERS = {"Authorization": f"Bearer {TOKEN}"}
# 作業ログのサマリー取得
res = requests.get(f"{BASE}/api/external/logs/summary", headers=HEADERS)
data = res.json()["data"]
print(f"総作業時間: {data['totalSeconds'] // 3600} 時間")