K-OTP

잔액 조회

GET /v1/balance

GET https://api.k-otp.dev/v1/balance

개요

Returns the current balance of the credit wallet the authenticated app spends from: the organization wallet shared by every app of the organization (walletScope: organization), or a legacy per-app wallet (walletScope: app). balance is a credit quantity (not money) and currency is CREDIT. Reading the balance never affects OTP issue status.

Test mode. A sk_test_ key never reads the real wallet: it gets a fixed simulated balance (walletScope: test, walletId: test:<appId>, balance: 1000000, promoBalance: 0, promoNextExpiry: null, mode: test) that test issues never reduce. Scenarios 07/08 of POST /issue simulate the insufficient-credit paths.

Requires an sk_ secret key; pk_ public keys are rejected with 403.

인증

허용 키필요 scope대체 허용 scope
sk_otp:balance*

응답 (200)

Current wallet balance.

필드타입필수설명
appIdstring예The calling app.
walletIdstring예org:<organizationId> for the organization wallet; app:<appId> for a legacy per-app wallet; test:<appId> for the simulated wallet of a test-mode key.
walletScope"app" | "organization" | "test"예organization when the balance is shared by every app of the organization; test for the simulated wallet of a test-mode key.
organizationIdstringOwning organization, present when walletScope is organization.
balancenumber예Current total balance as a credit quantity (not money): purchased plus promotional credits.
currencystring예Unit of balance; currently always CREDIT.
updatedAtstring예When the wallet last changed (RFC 3339).
promoBalanceinteger예Unused, unexpired promotional (free) credits included in balance. Purchased credits are roughly balance - promoBalance. Computed from the promotional lot summary, which can lag recent sends by about 10 minutes; never more than balance. Always 0 for a legacy per-app wallet.
promoNextExpirynull | object예The promotional credits that expire first, or null when there are none.
mode"live" | "test"Mode of the API key that made the request. A test key gets a fixed simulated balance (walletScope: 'test', walletId: 'test:<appId>') that never changes; the real wallet is never read.

오류 응답

모든 오류는 { defined, code, status, message, data? } 형태입니다. 자세한 내용은 오류를 참고하세요.

상태code설명
400BAD_REQUESTthe request failed input validation. message describes the first failing constraint.
401UNAUTHORIZEDthe Authorization: Bearer credential is missing, malformed, inactive, or rejected by introspection.
403FORBIDDENthe credential lacks otp:balance (or an accepted alias), or a pk_ public key was used. Public keys are limited to issue/verify.
409CONFLICTthe request conflicts with the current state of the resource.
429TOO_MANY_REQUESTSonly for test-mode (sk_test_) keys, whose reads are metered (data.limit: perKey per minute or perKeyDaily per day, data.policy: platform). Wait data.retryAfterMs milliseconds (Retry-After in seconds). Live keys are never rate limited on reads.
500INTERNAL_SERVER_ERRORunexpected server failure. Undefined errors (defined: false) use the same envelope.
503SERVICE_UNAVAILABLEcredential introspection or a downstream dependency is temporarily unavailable. Retry with backoff.

요청 예시

curl "https://api.k-otp.dev/v1/balance" \
  -H "Authorization: Bearer $KOTP_SECRET_KEY"

이 페이지의 내용