디렉터리 토큰 생성

POST /v1/directories/{directory_id}/tokens · 권한 directories:write

교체용 새 SCIM 토큰을 발급합니다. 디렉터리에는 유효한 토큰이 최대 2개까지 있을 수 있습니다. 새 토큰을 ID 공급자에 제공한 다음, DELETE /v1/directories/{directory_id}/tokens/{token_id}로 이전 토큰을 취소하세요. token은 이 응답에서만 한 번 반환됩니다(Cache-Control: no-store). 같은 Idempotency-Key로 다시 재생된 응답에는 이 값이 빠지고 secret_redacted: true가 포함됩니다. 빈 객체({})를 보내면 기본값을 사용합니다. 생성은 directory.token_created로 감사 기록됩니다.

요청

필드 유형 필수 설명
directory_id path 예 SCIM 디렉터리 ID (dir_…).
필드 유형 필수 설명
label string 아니요 1–100자. 기본값 Token.
expires_in_days integer 아니요 30–730. 기본값 365.

응답

201 Created와 토큰 메타데이터, 일회용 token을 반환합니다.

{
  "id": "0192a3b5-0a1b-7c2d-8e3f-4a5b6c7d8e9f",
  "label": "rotation",
  "created_at": "2026-10-19T09:40:00.123456Z",
  "expires_at": "2027-01-17T09:40:00.123456Z",
  "revoked_at": null,
  "last_used_at": null,
  "token": "idp_scim_<token>"
}

오류

HTTP code 발생 시점
404 not_found 이 환경에 디렉터리가 없습니다.
409 conflict 디렉터리에 이미 유효한 토큰이 2개 있습니다. 먼저 하나를 취소하세요.
422 validation_failed label이 비었거나 너무 길거나, expires_in_days가 30–730 범위를 벗어났습니다.
401 unauthenticated 자격 증명이 없거나, 잘못되었거나, 취소되었습니다.
403 insufficient_permissions 자격 증명에 필요한 권한이 없습니다.
429 rate_limited 요청 한도를 초과했습니다. Retry-After 기간 후에 다시 시도하세요.
503 service_unavailable 디렉터리 동기화를 일시적으로 사용할 수 없거나 이 배포에서 구성되지 않았습니다. Retry-After 기간 후에 다시 시도하세요.

예제

curl -i -X POST "https://api.eu.keenauth.com/v1/directories/dir_01j9xm2n4p6q8r0s2t4v6w8y0z/tokens" \
  -H "Authorization: Bearer $KEENAUTH_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"label":"rotation","expires_in_days":90}'