CLI 参考
CLI 是 npm 包 @kasskeep/cli,用个人访问 token 调用管理 API。需要 Node.js 22 及以上,没有其它依赖。除 ads export --format csv 外,所有命令都输出 JSON。
npx @kasskeep/cli loginnpx @kasskeep/cli whoaminpx 第一次运行时会下载最新版本。想装一次、之后直接敲 kasskeep 代替 npx @kasskeep/cli,执行 npm install -g @kasskeep/cli。
npx @kasskeep/cli login # 按提示粘贴 token,输入不回显npx @kasskeep/cli login --token-file - < token.txt # 非交互npx @kasskeep/cli logoutlogin 先用 API 校验个人访问 token(kkp_...,见密钥与权限),再保存到 ~/.config/kasskeep/credentials(设置了 $XDG_CONFIG_HOME 时是 $XDG_CONFIG_HOME/kasskeep/credentials),文件权限 600。logout 删除这个文件;token 本身在过期或用 DELETE /v1/admin/me/tokens/<token_id> 吊销之前仍然有效。
| 选项或变量 | 含义 |
|---|---|
--api <url>、KASSKEEP_API_URL |
API 地址,默认 https://api.kasskeep.com |
KASSKEEP_TOKEN |
用这个 token 代替已保存的 token,适合 CI |
--tenant ten_xxx |
选择租户。如果你只属于一个租户,可以省略 |
--help |
查看某条命令的帮助,例如 npx @kasskeep/cli ads --help |
已保存的 token 只会发给保存时的那个地址;--api 换了地址时会要求重新登录。
apps create和apps rotate-keys会输出一次public_key、secret_key和webhook_secret,并提醒你保存。- 其他命令显示的公钥都经过遮盖(
pk_…a1b2);加--show-keys可查看完整公钥。私钥、回调签名密钥和 token 从不输出。 - 文件类选项会在你本机读取文件并发送其内容。
-表示从标准输入读取,每条命令只能有一个选项这样用:--apple-private-key-file - < AuthKey.p8。
出错时 CLI 输出 HTTP 状态码、错误码和说明,再给一行处理提示,退出码为 1:
401 invalid_admin_token the token is missing, expired or revoked; run: kasskeep login| 命令 | 作用 |
|---|---|
login、logout |
保存或删除 token |
whoami |
当前用户和所属租户 |
tenants |
你可见的租户 |
apps list |
租户下的 App |
apps create --name <名称> [App 选项] |
创建 App |
apps update --id <app_id> [App 选项] |
修改 App。传空字符串可清空字段,例如 --webhook-url "" |
apps rotate-keys --id <app_id> [--webhook-secret] |
生成新的公钥和私钥;可选同时更换回调签名密钥 |
apps delete --id <app_id> |
删除 App 及其数据 |
products list|set|remove --id <app_id> |
网页渠道商品映射 |
test-store <子命令> --id <app_id> |
测试商店 |
ads <子命令> --id <app_id> |
激励广告、广告位映射、统计与导出 |
notify <子命令> |
告警订阅 |
App 选项
Section titled “App 选项”| 选项 | 字段 |
|---|---|
--name |
name |
--ios-bundle-id |
ios_bundle_id |
--android-package |
android_package |
--apple-app-apple-id |
apple_app_apple_id |
--apple-environment production|sandbox |
apple_environment |
--apple-refund-preference DECLINE|GRANT_FULL|GRANT_PRORATED |
apple_refund_preference |
--apple-issuer-id、--apple-key-id、--apple-private-key-file |
Apple 凭据,三项必须一起提供;文件路径传空值表示删除 |
--google-service-account-file |
Google 凭据;传空值表示删除 |
--google-pubsub-audience、--google-pubsub-email |
RTDN token 校验 |
--google-consumable-products "coins_*,gems_100" |
替换消耗型商品列表 |
--webhook-url |
webhook_url |
--checkout-return-hosts "a.example.com,*.example.com" |
checkout_return_hosts |
--cors-origins "https://a.example.com,*.example.com" |
cors_origins |
--stripe-secret-key-file、--stripe-webhook-secret-file |
Stripe 凭据(仅 apps update) |
--ads-unmapped-policy reject|emit |
ads_unmapped_policy |
--ads-allow-shared-test-units true|false |
ads_allow_shared_test_units |
products
Section titled “products”npx @kasskeep/cli products set --id app_xxx --product-id pro_monthly --external-id price_1Q... --type subscriptionnpx @kasskeep/cli products list --id app_xxx [--channel stripe]npx @kasskeep/cli products remove --id app_xxx --product-id pro_monthly--channel 默认为 stripe。--type 可选 subscription 或 one_time。
test-store
Section titled “test-store”| 子命令 | 选项 |
|---|---|
show、enable、disable |
|
config |
--period-seconds N、--renewal-success-rate 0..1、--grace-period-seconds N、--billing-retry-seconds N、--products "demo.*,x"、--prices-file prices.json |
purchases |
--user <app_user_id>、--limit N |
simulate |
--scenario <名称>,并提供 --purchase-id <test_...> 或 --user <app_user_id> [--product-id <id>];升级和降级时用 --to-product-id |
advance |
--user <app_user_id>、--purchase-id、--outcome success|failure |
场景列表见测试商店页面。
| 子命令 | 选项 |
|---|---|
networks |
回调路径与凭据检查 |
units |
列出映射 |
unit-set |
--name <名称>,以及 --admob、--applovin、--levelplay 中的任意几项。同一选项可以重复,或用逗号分隔多个 id;加 ios: 或 android: 前缀可标注平台。传空值表示移除该广告网络 |
unit-remove |
--name <名称> |
unmatched |
--limit 50 |
credentials |
--applovin-event-key-file、--admob-app-id、--levelplay-private-key-file、--levelplay-app-key、--levelplay-timestamp-window <秒>、--levelplay-ip-allowlist levelplay|<ip,cidr,...>、--levelplay-reporting-secret-key-file、--levelplay-reporting-refresh-token-file、--levelplay-reconcile-threshold 20、--applovin-report-key-file、--applovin-reconcile-threshold 20。传空值表示删除该密钥 |
test-show、test-enable、test-disable |
测试模式开关 |
simulate |
--user、--ad-unit、--reward-type、--reward-amount、--custom-data、--outcome completed|skipped|failed、--transaction-id、--network test|admob|applovin|levelplay |
simulate-impressions |
--user、--ad-unit、--count 1..50、--network、--revenue-usd 0.01 或 --revenue 1.5 --currency JPY、--country US、--platform ios|android|web、--custom-data exp=B,cohort=7 |
stats |
--from YYYY-MM-DD、--to YYYY-MM-DD、--group-by day,ad_unit,network,country,platform,ad_format,currency、--environment production|test、--source client|report、--network、--ad-unit |
export |
--from、--to、--group-by day、--group-fields exp,cohort、--environment、--format json|csv、--limit n |
reports |
各广告网络的报表拉取状态 |
report-pull |
--network levelplay|applovin、--from、--to(默认最近三天) |
anomalies |
--open、--limit 50 |
npx @kasskeep/cli ads export --id app_xxx --from 2026-01-01 --to 2026-01-31 --group-fields exp --format csv > ads.csvnotify
Section titled “notify”| 子命令 | 选项 |
|---|---|
catalog |
告警类型及其级别 |
list |
--app-id <app_id> |
create |
--channel telegram|email|webhook、--name、--app-id(不传表示租户下所有 App),以及下表的渠道选项 |
update |
--subscription <id>,加上除 --channel 外的任意 create 选项 |
show、remove、test |
--subscription <id> |
logs |
--subscription <id>、--limit 50 |
| 渠道 | 选项 |
|---|---|
telegram |
--chat-id <id>(群组 id 是负数,写成 --chat-id=-100123)、--bot-token-file <文件|-> |
email |
--to [email protected],[email protected]、--from、--smtp-host、--smtp-port 587、--smtp-security starttls|tls|none、--smtp-user、--smtp-password-file <文件|-> |
webhook |
--url https://...、--signing-secret-file <文件|->(不传时自动生成签名密钥,只显示一次) |
所有渠道通用的过滤项:--events purchase,refund,...\|all、--environments production,sandbox、--min-severity info\|warning\|critical、--locale zh-CN\|en、--enabled true\|false、--hourly-limit 20、--window-seconds 600。