개요
FIM One API는 두 가지 인증 방법을 지원합니다:- API 키 — 서비스 간 통합을 위한 간단한 장기 토큰
- JWT 토큰 — 사용자 로그인의 단기 토큰 (SSE 엔드포인트용)
API 키
API 키는 사용자 계정에 연결된 장기 자격 증명입니다. 다음과 같은 경우에 이상적입니다:- 서버 간 통합
- 예약된 스크립트 및 자동화
- FIM One에 액세스하는 외부 애플리케이션
API 키 생성
- FIM One 포털에 로그인
- 설정 → API 키로 이동
- API 키 생성 클릭
- 이름 입력 (예: “Production Integration”)
- (선택사항) 액세스를 제한하기 위해 범위 설정
- (선택사항) 만료 날짜 설정
- 생성 클릭
- 키를 즉시 복사 — 한 번만 표시됨
fim_your44characterkeystringhere (fim_ 접두사로 시작)
API 키 사용
Authorization 헤더에 Bearer 토큰으로 키를 포함하세요:
API 키 기능
가시성: 각 키는 다음을 표시합니다:- 키 접두사 (식별을 위한 처음 8자)
- 생성 날짜
- 마지막 사용 타임스탬프
- 총 요청 수
- 활성 상태
- 만료 날짜 (설정된 경우)
- 키를 삭제하지 않고 활성화/비활성화
- 자동 만료 날짜 설정
- 키 영구 삭제
- 사용 패턴 추적
범위
범위는 API 키가 액세스할 수 있는 항목을 제한합니다. 범위를 설정하지 않으면 키는 전체 액세스 권한을 가집니다. 범위가 있는 키는 해당 범위에서 허용하는 엔드포인트만 호출할 수 있습니다. 다른 모든 엔드포인트는/api/me/api-keys 아래의 API 키 관리를 포함하여 403으로 응답하며, 이는 범위가 없는 키 또는 로그인된 세션이 필요합니다. 키는 자신의 범위보다 더 넓은 범위를 가진 키를 생성할 수 없습니다.
사용 가능한 범위:
범위가 있는 키 생성:
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 토큰은 웹 포털을 통해 로그인하거나 인증 엔드포인트를 호출할 때 자동으로 발급됩니다: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