概要
FIM One API は 2 つの認証方法をサポートしています:- API キー — サービス間統合用のシンプルで長期有効なトークン
- JWT トークン — ユーザーログインからの短期有効なトークン (SSE エンドポイント用)
APIキー
APIキーはユーザーアカウントに紐付けられた長期間有効な認証情報です。以下の用途に最適です:- サーバー間統合
- スケジュール済みスクリプトと自動化
- FIM Oneにアクセスする外部アプリケーション
APIキーの作成
- FIM Oneポータルにログインします
- 設定 → APIキーに移動します
- APIキーを作成をクリックします
- 名前を入力します(例:「本番環境統合」)
- (オプション)スコープを設定してアクセスを制限します
- (オプション)有効期限を設定します
- 作成をクリックします
- キーをすぐにコピーしてください — 1回だけ表示されます
fim_your44characterkeystringhere(fim_プレフィックスで始まります)
APIキーの使用
AuthorizationヘッダーにBearer tokenとしてキーを含めます:
APIキーの機能
可視性: 各キーには以下が表示されます:- キープレフィックス (識別用の最初の8文字)
- 作成日
- 最後に使用されたタイムスタンプ
- 総リクエスト数
- アクティブステータス
- 有効期限 (設定されている場合)
- キーを削除せずに有効/無効にする
- 自動有効期限を設定する
- キーを完全に削除する
- 使用パターンを追跡する
スコープ
スコープはAPIキーがアクセスできる範囲を制限します。スコープが設定されていない場合、キーはフルアクセス権を持ちます。 スコープを持つキーは、そのスコープが許可するエンドポイントのみを呼び出すことができます。その他のすべてのエンドポイントは403 で応答します。これには /api/me/api-keys 下のAPIキー管理も含まれ、スコープなしのキーまたはサインインセッションが必要です。キーは自身のスコープより広いスコープを持つキーを作成することはできません。
利用可能なスコープ:
スコープ付きのキーを作成する:
JWT Tokens
JWT tokens are short-lived and issued at login. They’re used for:- SSE Streaming Endpoints: Pass tokens in the request body for
/api/react,/api/dagand/api/auto - Portal Session: Frontend authentication
JWTトークンの取得
JWTトークンはWebポータルを通じてログインするか、認証エンドポイントを呼び出すと自動的に発行されます:Two-factor authentication
When the account has two-factor authentication enabled, sign-in does not return tokens.POST /api/auth/login and POST /api/auth/login-with-code answer with a short-lived temporary token instead:
429 with error_code 2fa_too_many_attempts; starting a new sign-in does not reset the count.
Using JWT for Streaming
For SSE endpoints, include the token in the request body. The field accepts a JWT access token or an API key (a scoped key needs thechat scope):
fetch with a readable stream (the endpoint is POST-only, so native EventSource which only supports GET cannot be used):
トークンリフレッシュ
アクセストークンは2時間後に期限切れになります。リフレッシュトークンを使用して、再度ログインせずに新しいアクセストークンを取得します:セキュリティのベストプラクティス
APIキー
-
環境変数に保存する:
その後、コードで参照します:
-
キーローテーションを使用する:
- 新しいキーを作成する
- アプリケーションを更新する
- 古いキーを削除する
- 四半期ごとに繰り返す
-
有効期限を設定する:
- 一時的な統合には短期間のキーを使用する
- 定期的に再認証を要求する
-
スコープ付きキーを使用する:
- 必要な場合を除き、「フルアクセス」キーを使用しない
- 異なるサービス用に個別のキーを作成する
- キーが侵害された場合のダメージを制限する
-
使用状況を監視する:
- 「最後に使用された」タイムスタンプを確認する
- リクエスト数を確認する
- 未使用のキーを削除する
JWTトークン
- 短命に保つ: アクセストークンは2時間後に期限切れになります
- 安全な保存:
- ブラウザ内: HttpOnlyクッキーを使用(localStorageより安全)
- サーバー内: 安全なセッションストレージを使用
- ログに公開しない: トークンのプレフィックスのみをログに記録し、完全なトークンは記録しないでください
- HTTPSのみを使用: 暗号化されていない接続でトークンを送信しないでください
レート制限
キーごとのレート制限は将来のリリースで予定されています。現在のところ、キーごとのリクエスト制限は実施されていません。Troubleshooting
Every error response has the shape{"detail", "error_code", "error_args"}. Errors raised while checking the Authorization header carry error_code: null; tell them apart by the status code and detail.
Invalid Token Error
401; detail is Invalid token, Invalid API key, API key is disabled or API key has expired):
- API key prefix is wrong (must start with
fim_) - Token is malformed or corrupted
- API key has been deleted, disabled, or is past its expiration date
Unauthorized Error
401):
- Token is missing from the request body (SSE endpoints return the body above)
- No
Authorizationheader provided (other endpoints answerNot authenticatedwitherror_code: null)
Forbidden Error
403):
- API key has scoped access and lacks the required scope (
api_key_scope_denied) - The client address is refused by the instance’s IP rules (
ip_not_allowed, see below) - The account is disabled (
detail:Account disabled) or lacks the role the endpoint needs
IP Rules
Administrators can restrict API access by client address under admin Security → IP Rules. A request from an address that matches a deny rule, or that matches no allow rule when allow rules exist, is refused before authentication:/api/version, /api/webhooks/ and CORS preflight requests are exempt. Behind a reverse proxy the instance must be told which proxy to trust (FORWARDED_ALLOW_IPS), otherwise every request appears to come from the proxy; see Environment Variables.
Expired Token
error_code token_expired.
Solution: Use the refresh token to get a new access token:
環境変数のセットアップ
Python
Node.js
Bash
Support
For authentication issues:- Check the API Overview for response format details
- Check that a token is still accepted with
GET /api/auth/me - Contact support if you believe a key has been compromised