API リファレンス

Periodic Intel API を使ってジョブ、レポート、通知をプログラムから管理する方法について説明します。

概要

Periodic Intel APIを利用すると、データ収集ジョブの管理、生成されたレポートの取得、通知の設定などをプログラムから実行できます。このAPIはRESTfulインターフェースを採用しており、リクエストとレスポンスにはJSONを使用します。

バージョニングについて: 現在のAPIにはパスのバージョン接頭辞はありません(例: /v1/)。将来的に破壊的変更が生じた場合はバージョン付きパスへ移行する予定です。変更がある際は事前にお知らせします。

認証 (Authentication)

ほとんどの API は API キー または ユーザーセッションの Bearer トークン で認証できます。 ただし API キー管理 (/api-keys) はユーザーセッション必須 です。

  1. ダッシュボードの API Keys 画面にアクセスします。
  2. 作成 (Create) をクリックして、新しいAPIキーを生成します。
  3. 作成直後に表示されるシークレット(例: msk_xxxx)をコピーして安全に保管してください。再表示はできません。

API キーを使う場合は、以下のいずれかの形式で送信できます。

X-API-Key: msk_your_api_key_here
Authorization: ApiKey msk_your_api_key_here

ダッシュボード内の呼び出しでは、Firebase ID トークンを使った Bearer 認証も利用しています。

APIキーは秘密情報として扱い、公開リポジトリやクライアントサイドのコードには含めないでください。

認証エラー時の挙動:

  • 認証情報が存在しない場合は 401 Unauthorized が返ります。
  • 無効・失効・期限切れの API キーでは、現在の実装では 400 Bad Request が返ります。
  • キーは有効だが対象リソースへのアクセス権限がない場合(他ユーザーのリソースへのアクセス等)は 403 Forbidden が返ります。

ベースURL

https://api.stratum-flow.com

エラーハンドリング

共通エラーフォーマット

エラー発生時は、以下の形式のJSONレスポンスが返ります。

{
  "ok": false,
  "message": "エラーの詳細メッセージ"
}

HTTPステータスコード一覧

コード 意味 主な発生条件
400 Bad Request リクエストが不正 必須フィールド欠如、バリデーションエラー、無効/失効APIキー、一部のプラン制限エラー
401 Unauthorized 認証失敗 認証情報そのものが未指定
403 Forbidden アクセス禁止 他ユーザーのリソースへのアクセス、Starter 以上が必要なエンドポイントへのアクセス
404 Not Found リソースが存在しない 指定ID のジョブ・レポート等が存在しない
429 Too Many Requests レートリミット超過 短時間に大量のリクエストを送信した場合
500 Internal Server Error サーバー内部エラー ジョブのエンキュー失敗等

エンドポイント

ジョブ (Jobs)

ジョブは、データ収集の指示内容や実行スケジュールを定義します。

GET /jobs

設定済みのジョブ一覧を取得します。1ページあたり 10件(デフォルト)で、カーソルベースのページネーションに対応しています。

Query Parameters:

Parameter Type Description
cursor string 前ページ最後のドキュメントID(pagination.nextCursor の値)。省略時は先頭から取得
limit number 1ページの件数。デフォルト 10、最大 100

Response (200 OK):

Name Type Description
ok boolean リクエストの成否
data array Job Object の配列
pagination.nextCursor string | null 次ページ取得用カーソル。null の場合は最終ページ
pagination.hasMore boolean 次のページが存在するかどうか

:

{
  "ok": true,
  "data": [
    {
      "id": "b0DoFn4h9TKNWHsjdsEd",
      "name": "競合SaaSの動向リサーチi",
      "sourceUrl": "",
      "promptInstruction": "競合・市場・技術トレンドを横断的に調査し、重要な変化とインパクトを要約してください。",
      "intervalMinutes": 1440,
      "timezone": "UTC",
      "status": "paused",
      "running": false,
      "notificationConfigId": null,
      "nextRunAt": "2026-03-29T11:49:00.000Z"
    },
    {
      "id": "6MjSCdVQzTui3SXLAMQn",
      "name": "競合SaaSの動向リサーチh",
      "sourceUrl": "",
      "promptInstruction": "競合・市場・技術トレンドを横断的に調査し、重要な変化とインパクトを要約してください。",
      "intervalMinutes": 1440,
      "timezone": "UTC",
      "status": "paused",
      "running": false,
      "notificationConfigId": null,
      "nextRunAt": "2026-04-05T11:49:00.000Z"
    }
    /* …8 件省略… */
  ],
  "pagination": {
    "nextCursor": "X8ikRFjvXA0U6imnW7X4",
    "hasMore": true
  }
}

POST /jobs

新しいジョブを作成します。

Body (JSON):

Field Type Required Description
name string Yes ジョブの識別名
promptInstruction string Yes AIへの収集・分析指示
sourceUrl string No 情報源のURL (http/https)
intervalMinutes number No 実行間隔(分)。デフォルト 60、最小 60
timezone string No タイムゾーン(例: Asia/Tokyo)。デフォルト UTC
researchMode string No "normal" または "extended"。デフォルト "normal"。拡張モードでは検索とページ閲覧をより深く行えます。1回の実行で通常の3回分を消費します。Pro プラン以上が必要です。
researchModelProfile string No "standard" または "precision"。デフォルト "standard""precision" は事実精度とレポート品質を優先するプロファイルで、調査深度の消費クレジットに加えて +4 を加算します。Pro プラン以上が必要です。
notificationConfigId string | null No 通知先設定のID(Starterプラン以上)
nextRunAt string No 初回実行日時 (ISO8601)。省略した場合は作成直後(現在時刻)に実行されます。

Response (200 OK):

Name Type Description
ok boolean true
data object 作成された Job Object

PATCH /jobs/:id

ジョブの設定を更新します。指定したフィールドのみが更新されます。

Body (JSON):

Field Type Required Description
name string No ジョブの識別名
promptInstruction string No AIへの収集・分析指示
sourceUrl string No 情報源のURL (http/https)。空文字列でクリア可
intervalMinutes number No 実行間隔(分)。最小 60。変更しても nextRunAt は再計算されません。 次回実行日時も変更したい場合は nextRunAt を同時に指定してください。
timezone string No タイムゾーン(例: Asia/Tokyo
researchMode string No "normal" または "extended"。拡張モードでは検索とページ閲覧をより深く行えます。Pro プラン以上が必要です。
researchModelProfile string No "standard" または "precision""precision" は事実精度とレポート品質を優先するプロファイルで、調査深度の消費クレジットに加えて +4 を加算します。Pro プラン以上が必要です。
notificationConfigId string | null No 通知先設定のID(Starterプラン以上)。null で解除
nextRunAt string No 次回の実行日時 (ISO8601)。指定しない場合は変更されません。

Response (200 OK):

Name Type Description
ok boolean true
data object 更新後の Job Object

POST /jobs/:id/status

ジョブの実行状態(アクティブ/一時停止)を変更します。

Body (JSON):

Field Type Required Description
status string Yes "active" または "paused"

Response (200 OK):

Name Type Description
ok boolean true
data object 更新後の Job Object

DELETE /jobs/:id

ジョブを無効化します。ジョブは一時停止状態になり、次回実行スケジュールが解除されます(物理削除ではありません)。

Response (200 OK):

Name Type Description
ok boolean true
data object 無効化後の Job Object

POST /jobs/:id/run

ジョブを即座に実行(手動実行)します。実行はキューに追加され、非同期で処理されます。

Body (JSON):

Field Type Required Description
tbs string No 検索期間フィルター(内部用)。省略推奨

Response (202 Accepted):

Name Type Description
ok boolean true
data.runId string 発行された実行ID
data.started boolean キューへの追加成功を示す true

Error (409 Conflict):

{ "ok": false, "message": "Job is already running" }

実行結果は GET /jobs/:jobid/reports または GET /runs?jobId=:id でポーリングして確認できます。


GET /jobs/:id/running

ジョブが現在実行中かどうかを取得します。

Response (200 OK):

Name Type Description
ok boolean true
data.jobId string 対象ジョブID
data.running boolean 現在実行中なら true
data.runningStartedAt string | null 実行開始時刻 (ISO8601)
data.lockAgeMs number | null 実行開始からの経過ミリ秒

レポート (Reports)

ジョブによって生成されたインテリジェンス・レポートです。

GET /jobs/:jobid/reports

特定のジョブに関連するレポート一覧を取得します。最新順で1ページあたり 10件(デフォルト)、カーソルベースのページネーションに対応しています。

Query Parameters:

Parameter Type Description
cursor string 前ページ最後のドキュメントID(pagination.nextCursor の値)。省略時は先頭から取得
limit number 1ページの件数。デフォルト 10、最大 100

Response (200 OK):

Name Type Description
ok boolean true
data array Report Object の配列
pagination.nextCursor string | null 次ページ取得用カーソル。null の場合は最終ページ
pagination.hasMore boolean 次のページが存在するかどうか

:

{
  "ok": true,
  "data": [
    {
      "id": "X8ikR...-177243...",
      "jobId": "X8ikR...",
      "status": "success",
      "subject": "レポート1",
      "summary": "本文...",
      "abstract": null,
      "createdAt": "2026-03-29T12:00:00.000Z"
    },
    /* … */
  ],
  "pagination": {
    "nextCursor": "gU3Ed...-177243...",
    "hasMore": true
  }
}

GET /jobs/:jobid/reports/:reportid

特定のレポート単体の詳細情報を取得します。

Response (200 OK):

Name Type Description
ok boolean true
data object Report Object

GET /runs

実行ログ(Run)の一覧を取得します。最新順で最大 1200件 返ります。

Query Parameters:

Parameter Type Description
jobId string 特定のジョブIDでフィルタリング

Response (200 OK):

Name Type Description
ok boolean true
data array Run Object の配列

通知履歴 (Notifications)

GET /notifications

通知履歴の一覧を取得します。最新順で最大 50件 返ります。

Response (200 OK):

Name Type Description
ok boolean true
data array 通知オブジェクトの配列

POST /notifications/read-all

すべての未読通知を既読にします。

Response (200 OK):

{ "ok": true, "data": { "success": true } }

トレンド分析 (Trend Analysis)

ジョブに関連するトレンド分析レポート(AIによるタイムライン分析)を取得・生成します。

権限: Starter プラン以上

GET /jobs/:jobid/timeline-report

指定したジョブの最新のトレンド分析レポートを取得します。まだ生成されていない場合は data: null が返ります。

Response (200 OK):

Name Type Description
ok boolean true
data object | null TimelineReport Object、未生成時は null

POST /jobs/:jobid/timeline-report/generate

指定したジョブのトレンド分析レポートの生成を非同期で開始します。成功するには、対象ジョブに2件以上の成功済みレポートが必要です。

Response (202 Accepted):

{ "ok": true, "data": { "generating": true } }

生成完了はポーリング(GET /jobs/:jobid/timeline-report)で確認できます。data.status"generating" から完了状態に変わったタイミングで結果が利用可能になります。


通知設定 (Notification Configs)

Slack、Teams、汎用 Webhook、またはメール宛の外部連携設定を管理します。Starter プラン以上が必要です。

GET /notification-configs

登録済みの通知先設定の一覧を取得します。

Response (200 OK):

Name Type Description
ok boolean true
data array Notification Config Object の配列

POST /notification-configs

新しい通知先を作成します。

Body (JSON):

Field Type Required Description
provider string Yes "slack" / "teams" / "webhook" / "email"
name string Yes 表示名
webhookUrl string Required when provider"slack" / "teams" / "webhook" の場合 Webhook URL (https)
email string Required when provider"email" の場合 送信先メールアドレス
isActive boolean No 有効フラグ。デフォルト true

Response (200 OK):

Name Type Description
ok boolean true
data object 作成された Notification Config Object

PATCH /notification-configs/:id

通知先設定を更新します。指定したフィールドのみが更新されます。

Body (JSON):

Field Type Required Description
name string No 表示名
webhookUrl string No Webhook URL (https)
email string No メール送信先 (provider: \"email\" の場合のみ)
isActive boolean No 有効フラグ

Response (200 OK):

Name Type Description
ok boolean true
data object 更新後の Notification Config Object

DELETE /notification-configs/:id

通知先設定を削除します。この設定を参照しているジョブからは自動的に紐付けが解除されます。

Response (200 OK):

{ "ok": true, "data": { "deleted": true } }

POST /notification-configs/:id/test

通知先にテストメッセージを送信します。設定が isActive: false の場合は 400 エラーになります。

Response (200 OK):

{ "ok": true, "data": { "sent": true } }

APIキー管理 (API Keys)

APIキーの管理操作はユーザーセッション(ダッシュボードのログイン状態)でのみ実行可能です。APIキー自体を使って別のAPIキーを管理することはできません。Pro プラン以上が必要です。

GET /api-keys

登録済みのAPIキーの一覧を取得します。最大50件。

Response (200 OK):

Name Type Description
ok boolean true
data array APIキーオブジェクトの配列

POST /api-keys

新しいAPIキーを発行します。シークレット(secret)は作成時のレスポンスにのみ含まれ、以降は取得できません。

Body (JSON):

Field Type Required Description
name string Yes キーの識別名
expiration string No 有効期限 (ISO8601)。省略時は無期限

Response (200 OK):

Name Type Description
ok boolean true
data.apiKey object 作成されたAPIキーのメタデータ
data.secret string 一度だけ表示されるシークレット(例: msk_xxxx)。必ず保管してください

POST /api-keys/:id/disable

APIキーを無効化します。無効化したキーはすぐに認証に使えなくなりますが、後で再有効化できます。

Response (200 OK):

{ "ok": true, "data": { "disabled": true, "apiKey": { "id": "...", "disabledAt": "2026-03-02T10:00:00.000Z" } } }

POST /api-keys/:id/enable

無効化したAPIキーを再有効化します。期限切れのキーは再有効化しても期限切れのままです。

Response (200 OK):

{ "ok": true, "data": { "enabled": true, "apiKey": { "id": "...", "disabledAt": null } } }

DELETE /api-keys/:id

APIキーを物理削除します。削除したキーは復元できません。

Response (200 OK):

{ "ok": true, "data": { "deleted": true } }

アカウント (Account)

GET /account/usage

現在のアカウントの利用状況(今月のレポート生成数、プラン等)を取得します。

Response (200 OK):

{
  "ok": true,
  "data": {
    "monthlyReportsGenerated": 42,
    "tier": "starter",
    "usageStartAt": "2026-03-01T00:00:00Z",
    "usageEndAt": "2026-03-31T23:59:59Z"
  }
}

データモデル

Job Object

{
  "id": "job_abc123",
  "name": "競合分析",
  "sourceUrl": "https://example.com/news",
  "promptInstruction": "競合他社の最新動向を分析してください",
  "intervalMinutes": 1440,
  "timezone": "Asia/Tokyo",
  "status": "active",
  "running": false,
  "researchMode": "normal",
  "researchModelProfile": "standard",
  "notificationConfigId": "cfg_xyz456",
  "lastRunAt": "2026-03-02T10:00:00.000Z",
  "nextRunAt": "2026-03-03T10:00:00.000Z"
}
Field Type Description
id string ジョブの一意ID
name string ジョブの識別名
sourceUrl string 情報源のURL(未設定時は空文字列)
promptInstruction string AIへの収集・分析指示
intervalMinutes number 実行間隔(分)
timezone string タイムゾーン(デフォルト UTC
status string "active" または "paused"
running boolean 現在実行中かどうか
researchMode string "normal" または "extended""extended" の場合は探索とページ閲覧が深くなる
researchModelProfile string "standard" または "precision""precision" は事実精度とレポート品質を優先
notificationConfigId string | null 紐付けられた通知設定のID
lastRunAt string | null 最終実行日時 (ISO8601)
nextRunAt string | null 次回実行予定日時 (ISO8601)

Report Object

{
  "id": "rpt_def456",
  "jobId": "job_abc123",
  "status": "success",
  "subject": "競合分析レポート 2026-03-02",
  "summary": "今週の主なトピックは...",
  "abstract": "要約テキスト(存在する場合)",
  "sources": [
    {
      "index": 1,
      "url": "https://example.com/source"
    }
  ],
  "createdAt": "2026-03-02T10:05:00.000Z"
}
Field Type Description
id string レポートの一意ID
jobId string 生成元ジョブのID
status string "success" / "failed"
subject string レポートの件名
summary string レポート本文
abstract string | null 短い要約(存在する場合)
sources array 引用元ソースの配列
createdAt string 生成日時 (ISO8601)

Run Object

{
  "id": "job_abc123-1709380000000",
  "jobId": "job_abc123",
  "status": "success",
  "startedAt": "2026-03-02T10:00:00.000Z",
  "finishedAt": "2026-03-02T10:04:58.000Z",
  "durationMs": 298000,
  "triggeredBy": "manual",
  "errorCategory": null,
  "errorMessage": null
}
Field Type Description
id string 実行ログの一意ID
jobId string 対象ジョブのID
status string "success" / "failed" / "running"
startedAt string | null 実行開始日時 (ISO8601)
finishedAt string | null 実行終了日時 (ISO8601)
durationMs number | null 実行時間(ミリ秒)
triggeredBy string "manual" または "schedule"
errorCategory string | null エラー種別(失敗時)
errorMessage string | null エラーメッセージ(失敗時)

Notification Config Object

{
  "id": "cfg_xyz456",
  "provider": "slack",
  "name": "開発チーム通知",
  "webhookUrlMasked": "https://hooks.slack.com/...****",
  "destinationMasked": "https://hooks.slack.com/...****",
  "isActive": true,
  "createdAt": "2026-02-01T00:00:00.000Z",
  "updatedAt": "2026-02-15T12:30:00.000Z"
}
Field Type Description
id string 設定の一意ID
provider string "slack" / "teams" / "webhook" / "email"
name string 表示名
webhookUrlMasked string マスク済みのWebhook URL(セキュリティのため末尾のみ非表示)。メール宛の場合は emailMasked と同じ値になります。
emailMasked string マスク済みメールアドレス (provider: \"email\" の場合)
destinationMasked string 通知先のマスク済み表示(メールまたはWebhook)
isActive boolean 有効フラグ
createdAt string 作成日時 (ISO8601)
updatedAt string 最終更新日時 (ISO8601)

Timeline Report Object

{
  "id": "job_abc123",
  "jobId": "job_abc123",
  "subject": "競合動向トレンドレポート",
  "body": "過去N件のレポートを分析した結果...",
  "status": "done",
  "reportCount": 12,
  "createdAt": "2026-03-01T08:00:00.000Z",
  "updatedAt": "2026-03-02T09:00:00.000Z"
}
Field Type Description
id string ドキュメントID(ジョブIDと同一)
jobId string 対象ジョブのID
subject string | null レポートの件名
body string | null レポート本文
status string "generating"(生成中)または完了状態を示す値
reportCount number 分析に使用したレポート件数
createdAt string | null 初回生成日時 (ISO8601)
updatedAt string | null 最終更新日時 (ISO8601)

問題が解決しない場合

ヘルプを読んでも解決しない場合は、お問い合わせページよりご連絡ください。