Quick Start
まずは疎通確認
最初に GET /health を呼ぶと、Hachiko Service が起動しているか確認できます。
Invoke-RestMethod http://127.0.0.1:8080/health
このページは、Hachiko のローカル HTTP API を使って通知送信や状態確認をしたいユーザー向けの仕様書です。 PowerShell、バッチ、別アプリ、常駐ツールなどから Hachiko を呼び出すときの基本形をまとめています。
関連資料: 更新案内仕様
8080 ですが、Tray の
Change port and restart で変更している場合は、そのポート番号を使ってください。
たとえば Web UI を http://127.0.0.1:8081/ で開いているなら、
API のベース URL も http://127.0.0.1:8081 です。
最初に GET /health を呼ぶと、Hachiko Service が起動しているか確認できます。
Invoke-RestMethod http://127.0.0.1:8080/health
無料本体で使える通知先は次の 4 つです。channel にはこの値を使います。
127.0.0.1 からの利用を想定しています。bind_address を変更する場合は、その影響を理解したうえで使用してください。現在の無料本体のローカル API には、API キー、Bearer Token、Basic 認証などの HTTP 認証機構はありません。
そのため、安全性は主に 127.0.0.1 バインドと、
外部公開しない運用に依存します。
POST /notifyHachiko に通知を依頼するための基本 API です。 通知はキューに入ってから送信されるため、レスポンスが返った時点では「受付完了」です。
JSON を送信します。title と body は必須です。
| フィールド | 型 | 必須 | 説明 |
|---|---|---|---|
title |
string | はい | 通知タイトルです。 |
body |
string | はい | 通知本文です。 |
channel |
string | いいえ | 指定すると、その通知先 1 つだけへ送ります。省略すると、有効化されているすべての通知先へ個別にキュー投入します。 |
metadata |
object | いいえ | 補助情報です。文字列キーと文字列値の組だけを入れてください。 |
Invoke-RestMethod -Method Post -Uri http://127.0.0.1:8080/notify -ContentType application/json -Body '{"title":"Build finished","body":"The first Hachiko notification arrived.","channel":"discord"}'
Invoke-RestMethod -Method Post -Uri http://127.0.0.1:8080/notify -ContentType application/json -Body '{"title":"Nightly build","body":"Send to every enabled target"}'
{
"id": "2f8f6cf4-1f9e-49da-bf1a-0b61bc53e7df",
"accepted": true,
"notification_ids": [
"2f8f6cf4-1f9e-49da-bf1a-0b61bc53e7df"
],
"accepted_count": 1
}
Service が応答しているかだけを軽く確認したいときに使います。
{
"status": "ok",
"queued_count": 0
}
現在の設定も含めた状態を取得します。Web UI の表示元の 1 つです。
/status と /history/summary をまとめた画面向け API です。
POST /notify/testこの API は、Web UI の接続確認とテスト送信用です。 通常の外部連携よりも、設定確認や初期セットアップ時の動作確認に向いています。
channel は必須です。
mode に connection を指定するとその場で接続確認、
queue を指定すると通常の通知キューへ積んで確認します。
| フィールド | 型 | 必須 | 説明 |
|---|---|---|---|
channel |
string | はい | 確認対象の通知先です。discord、slack、telegram、teams のいずれかを指定します。 |
title |
string | いいえ | テスト通知タイトルです。省略時は既定値が使われます。 |
body |
string | いいえ | テスト通知本文です。省略時は既定値が使われます。 |
mode |
string | いいえ | connection または queue を指定します。省略時は接続確認として扱います。 |
Invoke-RestMethod -Method Post -Uri http://127.0.0.1:8080/notify/test -ContentType application/json -Body '{"channel":"discord","mode":"connection"}'
{
"ok": true,
"mode": "connection",
"queued": false,
"notification_id": null,
"message": "接続テストに成功しました",
"error_code": null,
"error_message": null
}
通知履歴の一覧です。各レコードには受付時刻、処理時刻、失敗コードが入ります。
[
{
"id": "bb3c8cf4-371b-4f26-98fd-db7344409588",
"request": {
"title": "Hachiko test (discord)",
"body": "Web UI からのテスト送信です",
"channel": "discord",
"metadata": {}
},
"status": "queued",
"received_at": "2026-06-16T11:14:11.2956178Z",
"processed_at": null,
"error_code": null,
"error_message": null
}
]
最近の総件数、成功件数、再試行待ち件数、失敗件数と、最後の時刻情報を返します。
{
"recent_total": 1,
"recent_success_count": 0,
"recent_retry_waiting_count": 1,
"recent_failed_count": 0,
"last_received_at": "2026-06-16T11:14:11.2956178Z",
"last_sent_at": null,
"last_failure_at": null
}
現在の設定内容をそのまま JSON で返します。
設定の一部だけを更新します。送った項目だけが反映されます。
この API で変えられるのは logging、file_watch、notification_targets です。
ポート変更はこの API ではなく、Tray の Change port and restart から行います。
{
"notification_targets": {
"discord": {
"enabled": true,
"settings": {
"webhook_url": "https://discord.com/api/webhooks/..."
}
}
}
}
{
"updated": true,
"reloaded_sections": [
"notification_targets"
],
"validation_errors": []
}
{
"logging": {
"enabled": true,
"retention_days": 30
},
"file_watch": {
"enabled": true,
"watch_roots": [
"C:\\watch"
],
"recursive": true,
"notify_on_created": true,
"notify_on_deleted": true,
"notify_on_size_changed": true,
"notify_on_modified_time_changed": true,
"notify_on_extension_changed": true
}
}
Hachiko のローカル API では、エンドポイントごとに失敗時の返し方が少し異なります。
特に /settings/update は構造化されたバリデーションエラーを返します。
存在しないフォルダを監視対象にした場合の例です。
{
"updated": false,
"reloaded_sections": [],
"validation_errors": [
{
"category": "file_watch",
"field": "watch_roots",
"code": "path_not_found",
"message": "file_watch.watch_roots path was not found: C:\\not-found"
}
]
}
接続テストで通知先が無効な場合の例です。
{
"ok": false,
"mode": "connection",
"queued": false,
"notification_id": null,
"message": "接続テストに失敗しました",
"error_code": "target_disabled",
"error_message": "discord target is disabled"
}
notification_targets.discord.settings.webhook_url に Webhook URL を入れます。notification_targets.slack.settings.webhook_url に Incoming Webhook URL を入れます。bot_token と chat_id を入れます。notification_targets.teams.settings.webhook_url に Workflows の Webhook URL を入れます。/history に残ります。error_code と error_message で確認できます。