{"openapi":"3.1.0","info":{"title":"Kuma developer API","version":"1.0.0","description":"Read your server's Kuma data from your own code: leaderboards, levels, balances, moderation cases.\n\n## Getting a key\nOn the dashboard, open **Developer → API keys**, name the key and pick its scopes. The key is shown **once**: keep it somewhere safe, like an environment variable. Anyone with the key can read what its scopes allow.\n\nUse keys from your server, never from a web page or app people download: anyone who can see the key can use it.\n\n## Authentication\n```\nAuthorization: Bearer kuma_sk_…\n```\n\n## Scopes\nA key can only be given scopes its creator has the permission for, and keeps them only while they still do. If they lose a permission, the key gets `scope_unavailable` for that scope until they have it again.\n\n| Scope | Allows |\n|---|---|\n| `server:read` | The server's name, platform, member count and which Kuma features are on. |\n| `levels:read` | The XP leaderboard and any member's level, XP and rank. |\n| `economy:read` | The coin leaderboard and any member's balance and daily streak. |\n| `cases:read` | The server's moderation cases: who, what, why, by whom and their status. |\n| `economy:write` | Add coins to or remove coins from any member's balance, up to the key's daily limit. |\n| `levels:write` | Add XP to any member, up to the key's daily limit. Level-ups give level roles and badges as usual. |\n\n## Rate limits\n120 requests a minute per key, 300 per server across all its keys. Every answer carries `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset` (seconds); a 429 carries `Retry-After`.\n\n## Pagination\nLists return `{ \"data\": [...], \"next_cursor\": \"…\" }`. Pass `next_cursor` back as `cursor` for the next page; it's `null` on the last one. Treat cursors as opaque.\n\n## Errors\nAlways `{ \"error\": { \"code\", \"message\", \"request_id\" } }`. Match on `code`, never `message`.\n\n## Conventions\nPlatform ids (servers, users) are strings; case numbers are integers. Times are ISO 8601 in UTC. Something Kuma doesn't know is `null`, never left out.\n\n## Webhooks\nInstead of asking Kuma over and over, let Kuma tell you. On the dashboard, under **Developer → Webhooks**, give Kuma an https URL and pick the events. Kuma POSTs each event as JSON (the shapes are under **Webhooks** below) and shows you a signing secret **once**.\n\n**Check every request is really from Kuma.** The `Kuma-Signature` header is `t=<unix seconds>,v1=<signature>`, where the signature is the hex HMAC-SHA256 of `<t>.<raw body>` with your signing secret. Recompute it over the raw body (before parsing JSON), compare in constant time, and refuse a `t` more than 5 minutes old:\n\n```js\nimport crypto from \"node:crypto\";\nfunction fromKuma(secret, header, rawBody) {\n  const { t, v1 } = Object.fromEntries(header.split(\",\").map((p) => p.split(\"=\")));\n  if (Math.abs(Date.now() / 1000 - Number(t)) > 300) return false;\n  const want = crypto.createHmac(\"sha256\", secret).update(`${t}.${rawBody}`).digest();\n  const got = Buffer.from(v1 ?? \"\", \"hex\");\n  return got.length === want.length && crypto.timingSafeEqual(got, want);\n}\n```\n\n**Answer quickly.** Any 2xx within 10 seconds counts as delivered; do slow work afterwards. Kuma doesn't follow redirects.\n\n**Retries.** Anything else is tried again after 1 minute, 5 minutes, 30 minutes, 2 hours, 8 hours and 24 hours, then given up. The dashboard keeps 7 days of deliveries and can resend any of them. If every delivery fails for three days, or you answer `410 Gone`, Kuma switches the webhook off until someone switches it back on.\n\n**Duplicates and order.** An event can arrive more than once, and events can arrive out of order. Use the event `id` to drop repeats and `created_at` to order them.\n\n**Permissions.** Like a key, a webhook only gets events its creator could read through the API, and stops getting them when they lose that permission or the server switches the feature off.\n\n**`member.erased` is always sent.** When someone asks Kuma to erase their data, every webhook on a server that held data about them is told. Delete what you've stored about that user.\n\n## Writing\nKeys with `economy:write` or `levels:write` can give and take coins and give XP. They go through the same code as Kuma's own commands, so linked accounts, level roles, badges, logs and webhooks all behave as usual.\n\n- **Idempotency.** Every write needs an `Idempotency-Key` header: any unique string, such as a UUID or your own event id (\"match-8812-winner\"). If a request times out, send it again with the same key: Kuma answers with the first result (and `Idempotent-Replayed: true`) instead of paying out twice. Reusing a key for a different request is refused (`idempotency_conflict`). Keys are remembered for 24 hours; only successful writes are remembered, so a refused one can be fixed and retried with the same key.\n- **Daily limits.** Each key has limits the server sets when making it: coins per day (100,000 unless changed) and XP per day (50,000 unless changed). Removals count too. Going over answers `daily_limit_reached` with `retry_after` (seconds until midnight UTC).\n- **Dry runs.** Add `\"dry_run\": true` to the body to run every check and see the answer without changing anything or using the limit.\n- **Accountability.** Every write is logged in the server's punishment log and Dashboard Activity as your key and the person who made it.\n- **Members.** Kuma doesn't check that the user is in the server (that would cost a platform request per write), so check that yourself. Users banned from Kuma are refused (`user_not_allowed`).\n\n## Stability\nNothing in v1 is renamed or removed. New endpoints, fields, enum values (feature keys, case actions and statuses) can be added at any time, so ignore what you don't recognise."},"servers":[{"url":"https://api.kumabot.xyz/v1"}],"tags":[{"name":"Key"},{"name":"Server"},{"name":"Levels"},{"name":"Economy"},{"name":"Cases"},{"name":"Webhooks","description":"What Kuma sends to your webhook URL."}],"security":[{"apiKey":[]}],"paths":{"/key":{"get":{"summary":"The key you're using","description":"Check a key works and see what it can do. Needs no scope.","tags":["Key"],"operationId":"getKey","parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Key"}}}},"400":{"description":"A malformed parameter (`invalid_parameter`, `invalid_cursor`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No valid key (`unauthorized`, `key_revoked`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed (`wrong_server`, `api_unavailable`, `missing_scope`, `scope_unavailable`, `key_creator_lost_access`, `feature_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited (`rate_limited`). Wait Retry-After seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Kuma's fault (`internal_error`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/servers/{server_id}":{"get":{"summary":"Server info","tags":["Server"],"operationId":"getServer","x-kuma-scope":"server:read","security":[{"apiKey":[]}],"parameters":[{"name":"server_id","in":"path","required":true,"schema":{"type":"string"},"description":"The key's own server."}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Server"}}}},"400":{"description":"A malformed parameter (`invalid_parameter`, `invalid_cursor`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No valid key (`unauthorized`, `key_revoked`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed (`wrong_server`, `api_unavailable`, `missing_scope`, `scope_unavailable`, `key_creator_lost_access`, `feature_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited (`rate_limited`). Wait Retry-After seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Kuma's fault (`internal_error`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/servers/{server_id}/levels/leaderboard":{"get":{"summary":"XP leaderboard","description":"Members with XP, most first. Pages follow the live board: a member whose XP changes while you page through can appear twice or not at all, so de-duplicate by user id.","tags":["Levels"],"operationId":"listLevelLeaderboard","x-kuma-scope":"levels:read","security":[{"apiKey":[]}],"parameters":[{"name":"server_id","in":"path","required":true,"schema":{"type":"string"},"description":"The key's own server."},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":25}},{"name":"cursor","in":"query","schema":{"type":"string"},"description":"The previous page's next_cursor."}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LevelPage"}}}},"400":{"description":"A malformed parameter (`invalid_parameter`, `invalid_cursor`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No valid key (`unauthorized`, `key_revoked`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed (`wrong_server`, `api_unavailable`, `missing_scope`, `scope_unavailable`, `key_creator_lost_access`, `feature_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited (`rate_limited`). Wait Retry-After seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Kuma's fault (`internal_error`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/servers/{server_id}/members/{user_id}/level":{"get":{"summary":"A member's level","description":"Someone Kuma has no XP for gets 0 XP, level 0 and a null rank.","tags":["Levels"],"operationId":"getMemberLevel","x-kuma-scope":"levels:read","security":[{"apiKey":[]}],"parameters":[{"name":"server_id","in":"path","required":true,"schema":{"type":"string"},"description":"The key's own server."},{"name":"user_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Level"}}}},"400":{"description":"A malformed parameter (`invalid_parameter`, `invalid_cursor`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No valid key (`unauthorized`, `key_revoked`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed (`wrong_server`, `api_unavailable`, `missing_scope`, `scope_unavailable`, `key_creator_lost_access`, `feature_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited (`rate_limited`). Wait Retry-After seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Kuma's fault (`internal_error`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/servers/{server_id}/economy/leaderboard":{"get":{"summary":"Coin leaderboard","description":"Members with coins, most first. Pages follow the live board: a member whose balance changes while you page through can appear twice or not at all, so de-duplicate by user id.","tags":["Economy"],"operationId":"listCoinLeaderboard","x-kuma-scope":"economy:read","security":[{"apiKey":[]}],"parameters":[{"name":"server_id","in":"path","required":true,"schema":{"type":"string"},"description":"The key's own server."},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":25}},{"name":"cursor","in":"query","schema":{"type":"string"},"description":"The previous page's next_cursor."}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CoinPage"}}}},"400":{"description":"A malformed parameter (`invalid_parameter`, `invalid_cursor`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No valid key (`unauthorized`, `key_revoked`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed (`wrong_server`, `api_unavailable`, `missing_scope`, `scope_unavailable`, `key_creator_lost_access`, `feature_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited (`rate_limited`). Wait Retry-After seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Kuma's fault (`internal_error`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/servers/{server_id}/members/{user_id}/balance":{"get":{"summary":"A member's balance","description":"Members who linked accounts across platforms share one balance; this is that balance.","tags":["Economy"],"operationId":"getMemberBalance","x-kuma-scope":"economy:read","security":[{"apiKey":[]}],"parameters":[{"name":"server_id","in":"path","required":true,"schema":{"type":"string"},"description":"The key's own server."},{"name":"user_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Balance"}}}},"400":{"description":"A malformed parameter (`invalid_parameter`, `invalid_cursor`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No valid key (`unauthorized`, `key_revoked`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed (`wrong_server`, `api_unavailable`, `missing_scope`, `scope_unavailable`, `key_creator_lost_access`, `feature_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited (`rate_limited`). Wait Retry-After seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Kuma's fault (`internal_error`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/servers/{server_id}/members/{user_id}/coins":{"post":{"summary":"Give or take coins","description":"Positive `amount` adds coins, negative removes them (never below 0). Counts against the key's `coins_per_day` limit (both ways). Logged in the server's punishment log and Dashboard Activity as this key, and sent as `member.coins_changed` to webhooks.","tags":["Economy"],"operationId":"adjustCoins","x-kuma-scope":"economy:write","security":[{"apiKey":[]}],"parameters":[{"name":"server_id","in":"path","required":true,"schema":{"type":"string"},"description":"The key's own server."},{"name":"user_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","maxLength":100,"pattern":"^[A-Za-z0-9_\\-:.]{1,100}$"},"description":"A unique string for this write. Send the same one when you retry: Kuma answers the first result again (with `Idempotent-Replayed: true`) instead of doing it twice. Remembered for 24 hours. May be left out on a dry run."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CoinWrite"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CoinTransaction"}}}},"400":{"description":"A malformed parameter (`invalid_parameter`, `invalid_cursor`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No valid key (`unauthorized`, `key_revoked`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed (`wrong_server`, `api_unavailable`, `missing_scope`, `scope_unavailable`, `key_creator_lost_access`, `feature_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The Idempotency-Key was used for a different request (`idempotency_conflict`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"The body is too large (`invalid_body`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited (`rate_limited`). Wait Retry-After seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Kuma's fault (`internal_error`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/servers/{server_id}/members/{user_id}/xp":{"post":{"summary":"Give XP","description":"Adds XP like chatting does: linked accounts share it, and a level-up gives level roles and badges and is sent as `member.level_up` to webhooks. Chat level-up announcements aren't posted for API grants. Counts against the key's `xp_per_day` limit.","tags":["Levels"],"operationId":"grantXp","x-kuma-scope":"levels:write","security":[{"apiKey":[]}],"parameters":[{"name":"server_id","in":"path","required":true,"schema":{"type":"string"},"description":"The key's own server."},{"name":"user_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","maxLength":100,"pattern":"^[A-Za-z0-9_\\-:.]{1,100}$"},"description":"A unique string for this write. Send the same one when you retry: Kuma answers the first result again (with `Idempotent-Replayed: true`) instead of doing it twice. Remembered for 24 hours. May be left out on a dry run."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/XpWrite"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/XpGrant"}}}},"400":{"description":"A malformed parameter (`invalid_parameter`, `invalid_cursor`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No valid key (`unauthorized`, `key_revoked`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed (`wrong_server`, `api_unavailable`, `missing_scope`, `scope_unavailable`, `key_creator_lost_access`, `feature_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The Idempotency-Key was used for a different request (`idempotency_conflict`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"The body is too large (`invalid_body`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited (`rate_limited`). Wait Retry-After seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Kuma's fault (`internal_error`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/servers/{server_id}/cases":{"get":{"summary":"Moderation cases","description":"Newest first.","tags":["Cases"],"operationId":"listCases","x-kuma-scope":"cases:read","security":[{"apiKey":[]}],"parameters":[{"name":"server_id","in":"path","required":true,"schema":{"type":"string"},"description":"The key's own server."},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":25}},{"name":"cursor","in":"query","schema":{"type":"string"},"description":"The previous page's next_cursor."},{"name":"user_id","in":"query","schema":{"type":"string"},"description":"Only cases about this member."},{"name":"action","in":"query","schema":{"type":"string"},"description":"Only this kind, e.g. `warn`."},{"name":"status","in":"query","schema":{"type":"string"},"description":"Only this status, e.g. `active`."}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CasePage"}}}},"400":{"description":"A malformed parameter (`invalid_parameter`, `invalid_cursor`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No valid key (`unauthorized`, `key_revoked`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed (`wrong_server`, `api_unavailable`, `missing_scope`, `scope_unavailable`, `key_creator_lost_access`, `feature_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited (`rate_limited`). Wait Retry-After seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Kuma's fault (`internal_error`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/servers/{server_id}/cases/{case_id}":{"get":{"summary":"One case","tags":["Cases"],"operationId":"getCase","x-kuma-scope":"cases:read","security":[{"apiKey":[]}],"parameters":[{"name":"server_id","in":"path","required":true,"schema":{"type":"string"},"description":"The key's own server."},{"name":"case_id","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Case"}}}},"400":{"description":"A malformed parameter (`invalid_parameter`, `invalid_cursor`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No valid key (`unauthorized`, `key_revoked`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed (`wrong_server`, `api_unavailable`, `missing_scope`, `scope_unavailable`, `key_creator_lost_access`, `feature_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such case (`not_found`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited (`rate_limited`). Wait Retry-After seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Kuma's fault (`internal_error`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"webhooks":{"case.created":{"post":{"summary":"Case opened","description":"A moderation case was opened (a warning, mute, kick, ban, AutoMod action…). Needs the creator to hold `cases:read`.","x-kuma-scope":"cases:read","operationId":"event_case_created","tags":["Webhooks"],"parameters":[{"name":"Kuma-Signature","in":"header","required":true,"schema":{"type":"string"},"description":"`t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with your signing secret>`."},{"name":"Kuma-Event-Id","in":"header","required":true,"schema":{"type":"string"}},{"name":"Kuma-Event-Type","in":"header","required":true,"schema":{"type":"string"}},{"name":"Kuma-Delivery-Id","in":"header","required":true,"schema":{"type":"string"}},{"name":"Kuma-Delivery-Attempt","in":"header","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CaseCreatedEvent"}}}},"responses":{"200":{"description":"Any 2xx within 10 seconds counts as delivered. Anything else is retried."}}}},"case.updated":{"post":{"summary":"Case changed","description":"A case's status or reason changed (appealed, resolved, reason edited). Needs the creator to hold `cases:read`.","x-kuma-scope":"cases:read","operationId":"event_case_updated","tags":["Webhooks"],"parameters":[{"name":"Kuma-Signature","in":"header","required":true,"schema":{"type":"string"},"description":"`t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with your signing secret>`."},{"name":"Kuma-Event-Id","in":"header","required":true,"schema":{"type":"string"}},{"name":"Kuma-Event-Type","in":"header","required":true,"schema":{"type":"string"}},{"name":"Kuma-Delivery-Id","in":"header","required":true,"schema":{"type":"string"}},{"name":"Kuma-Delivery-Attempt","in":"header","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CaseUpdatedEvent"}}}},"responses":{"200":{"description":"Any 2xx within 10 seconds counts as delivered. Anything else is retried."}}}},"member.level_up":{"post":{"summary":"Level up","description":"A member reached a new level. Needs the creator to hold `levels:read`.","x-kuma-scope":"levels:read","operationId":"event_member_level_up","tags":["Webhooks"],"parameters":[{"name":"Kuma-Signature","in":"header","required":true,"schema":{"type":"string"},"description":"`t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with your signing secret>`."},{"name":"Kuma-Event-Id","in":"header","required":true,"schema":{"type":"string"}},{"name":"Kuma-Event-Type","in":"header","required":true,"schema":{"type":"string"}},{"name":"Kuma-Delivery-Id","in":"header","required":true,"schema":{"type":"string"}},{"name":"Kuma-Delivery-Attempt","in":"header","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LevelUpEvent"}}}},"responses":{"200":{"description":"Any 2xx within 10 seconds counts as delivered. Anything else is retried."}}}},"member.coins_changed":{"post":{"summary":"Coins given or taken","description":"Someone's coins were changed by staff (!coins give, take or set, or the dashboard) or through the API. Not sent for coins earned by chatting. Needs the creator to hold `economy:read`.","x-kuma-scope":"economy:read","operationId":"event_member_coins_changed","tags":["Webhooks"],"parameters":[{"name":"Kuma-Signature","in":"header","required":true,"schema":{"type":"string"},"description":"`t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with your signing secret>`."},{"name":"Kuma-Event-Id","in":"header","required":true,"schema":{"type":"string"}},{"name":"Kuma-Event-Type","in":"header","required":true,"schema":{"type":"string"}},{"name":"Kuma-Delivery-Id","in":"header","required":true,"schema":{"type":"string"}},{"name":"Kuma-Delivery-Attempt","in":"header","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CoinsChangedEvent"}}}},"responses":{"200":{"description":"Any 2xx within 10 seconds counts as delivered. Anything else is retried."}}}},"member.erased":{"post":{"summary":"Member data erased","description":"Someone asked Kuma to erase their data. Delete what you hold about them. Always sent.","operationId":"event_member_erased","tags":["Webhooks"],"parameters":[{"name":"Kuma-Signature","in":"header","required":true,"schema":{"type":"string"},"description":"`t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with your signing secret>`."},{"name":"Kuma-Event-Id","in":"header","required":true,"schema":{"type":"string"}},{"name":"Kuma-Event-Type","in":"header","required":true,"schema":{"type":"string"}},{"name":"Kuma-Delivery-Id","in":"header","required":true,"schema":{"type":"string"}},{"name":"Kuma-Delivery-Attempt","in":"header","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MemberErasedEvent"}}}},"responses":{"200":{"description":"Any 2xx within 10 seconds counts as delivered. Anything else is retried."}}}},"ping":{"post":{"summary":"Test","description":"Sent when you press \"Send test\".","operationId":"event_ping","tags":["Webhooks"],"parameters":[{"name":"Kuma-Signature","in":"header","required":true,"schema":{"type":"string"},"description":"`t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with your signing secret>`."},{"name":"Kuma-Event-Id","in":"header","required":true,"schema":{"type":"string"}},{"name":"Kuma-Event-Type","in":"header","required":true,"schema":{"type":"string"}},{"name":"Kuma-Delivery-Id","in":"header","required":true,"schema":{"type":"string"}},{"name":"Kuma-Delivery-Attempt","in":"header","required":true,"schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PingEvent"}}}},"responses":{"200":{"description":"Any 2xx within 10 seconds counts as delivered. Anything else is retried."}}}}},"components":{"securitySchemes":{"apiKey":{"type":"http","scheme":"bearer","bearerFormat":"kuma_sk_…","description":"A key from Developer → API keys on the dashboard."}},"schemas":{"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message","request_id"],"properties":{"code":{"type":"string","enum":["unauthorized","key_revoked","wrong_server","api_unavailable","missing_scope","scope_unavailable","key_creator_lost_access","feature_disabled","not_found","invalid_parameter","invalid_cursor","invalid_body","idempotency_key_required","idempotency_conflict","daily_limit_reached","user_not_allowed","rate_limited","temporarily_unavailable","internal_error"],"description":"- `unauthorized`: No key, or a key Kuma doesn't recognise (401).\n- `key_revoked`: The key was revoked (401).\n- `wrong_server`: The server in the path isn't the key's server (403).\n- `api_unavailable`: The developer API isn't available on this server yet (403).\n- `missing_scope`: The key wasn't given the scope this endpoint needs (403).\n- `scope_unavailable`: The key's creator no longer has the permission behind the scope (403).\n- `key_creator_lost_access`: The key's creator can no longer use the developer API on the server, so the key is paused (403).\n- `feature_disabled`: The server has the Kuma feature behind this data switched off (403).\n- `not_found`: No such endpoint or object (404).\n- `invalid_parameter`: A path or query parameter is malformed or out of range (400).\n- `invalid_cursor`: The cursor wasn't a next_cursor from this list (400).\n- `invalid_body`: The JSON body is missing, malformed, too large or has a bad field (400, or 413 for size).\n- `idempotency_key_required`: A write was sent without an Idempotency-Key header (400).\n- `idempotency_conflict`: That Idempotency-Key was already used for a different request (409).\n- `daily_limit_reached`: The key has used today's limit for this kind of write; see retry_after (429).\n- `user_not_allowed`: Kuma doesn't act for that user (403).\n- `rate_limited`: Too many requests; wait Retry-After seconds (429).\n- `temporarily_unavailable`: Kuma couldn't check the key's permissions just now; retry shortly (503).\n- `internal_error`: Something failed on Kuma's side; quote request_id if you report it (500)."},"message":{"type":"string","description":"A sentence a person can read. Don't match on it: use `code`."},"request_id":{"type":"string","description":"Also sent as the X-Request-Id header."}},"additionalProperties":true}}},"User":{"type":"object","required":["id","username","avatar_url"],"description":"A user as Kuma last saw them. Names come from Kuma's own records, so they can be out of date or null.","properties":{"id":{"type":"string"},"username":{"type":["string","null"]},"avatar_url":{"type":["string","null"]}}},"Key":{"type":"object","required":["id","name","server_id","scopes","active_scopes","api_available","created_at","rate_limit"],"properties":{"id":{"type":"string","examples":["key_3f9a1c2b7d4e5f60"]},"name":{"type":"string"},"server_id":{"type":"string"},"scopes":{"type":"array","items":{"type":"string","enum":["server:read","levels:read","economy:read","cases:read","economy:write","levels:write"]},"description":"What the key was given."},"active_scopes":{"type":"array","items":{"type":"string","enum":["server:read","levels:read","economy:read","cases:read","economy:write","levels:write"]},"description":"The scopes that work right now: the creator still holds each one's permission."},"api_available":{"type":"boolean","description":"Whether the developer API is available on the key's server."},"created_at":{"type":"string","format":"date-time"},"rate_limit":{"type":"object","required":["per_minute","server_per_minute"],"properties":{"per_minute":{"type":"integer"},"server_per_minute":{"type":"integer"}}}}},"Server":{"type":"object","required":["id","name","platform","member_count","features"],"properties":{"id":{"type":"string"},"name":{"type":["string","null"]},"platform":{"type":["string","null"],"enum":["stoat","discord","fluxer",null]},"member_count":{"type":["integer","null"],"description":"Kuma's latest count; can be a few hours old."},"features":{"type":"array","description":"Kuma's modules and whether each is on here. New modules may appear.","items":{"type":"object","required":["key","enabled"],"properties":{"key":{"type":"string"},"enabled":{"type":"boolean"}}}}}},"Level":{"type":"object","required":["user","rank","xp","level","xp_for_next_level"],"properties":{"user":{"$ref":"#/components/schemas/User"},"rank":{"type":["integer","null"],"minimum":1,"description":"1 = most XP. Ties share a rank. Null for someone with no XP."},"xp":{"type":"integer","minimum":0},"level":{"type":"integer","minimum":0},"xp_for_next_level":{"type":"integer","description":"The total XP the next level starts at."}}},"LevelEntry":{"type":"object","required":["rank","user","xp","level","xp_for_next_level"],"properties":{"rank":{"type":"integer","minimum":1},"user":{"$ref":"#/components/schemas/User"},"xp":{"type":"integer","minimum":0},"level":{"type":"integer","minimum":0},"xp_for_next_level":{"type":"integer"}}},"Balance":{"type":"object","required":["user","coins","daily_streak","best_streak","last_daily_at"],"properties":{"user":{"$ref":"#/components/schemas/User"},"coins":{"type":"integer"},"daily_streak":{"type":"integer","minimum":0,"description":"0 once the streak has lapsed."},"best_streak":{"type":"integer","minimum":0},"last_daily_at":{"type":["string","null"],"format":"date-time"}}},"CoinEntry":{"type":"object","required":["rank","user","coins"],"properties":{"rank":{"type":"integer","minimum":1},"user":{"$ref":"#/components/schemas/User"},"coins":{"type":"integer"}}},"Case":{"type":"object","required":["id","user","moderator","action","reason","status","appealable","created_at"],"properties":{"id":{"type":"integer","description":"The case number staff and members see (#12)."},"user":{"$ref":"#/components/schemas/User"},"moderator":{"$ref":"#/components/schemas/User"},"action":{"type":"string","description":"warn, mute, kick, tempban, softban, ban, automod, … New kinds may appear."},"reason":{"type":["string","null"]},"status":{"type":["string","null"],"description":"active, appealed, resolved, … New statuses may appear."},"appealable":{"type":"boolean"},"created_at":{"type":["string","null"],"format":"date-time"}}},"CaseCreatedEvent":{"type":"object","required":["id","type","api_version","created_at","server_id","data"],"properties":{"id":{"type":"string","description":"evt_…: the same on every retry and for every webhook. Drop an event you've already handled."},"type":{"type":"string","enum":["case.created"]},"api_version":{"type":"string","enum":["v1"]},"created_at":{"type":"string","format":"date-time","description":"When it happened."},"server_id":{"type":"string"},"data":{"type":"object","required":["case"],"properties":{"case":{"$ref":"#/components/schemas/Case"}}}}},"CaseUpdatedEvent":{"type":"object","required":["id","type","api_version","created_at","server_id","data"],"properties":{"id":{"type":"string","description":"evt_…: the same on every retry and for every webhook. Drop an event you've already handled."},"type":{"type":"string","enum":["case.updated"]},"api_version":{"type":"string","enum":["v1"]},"created_at":{"type":"string","format":"date-time","description":"When it happened."},"server_id":{"type":"string"},"data":{"type":"object","required":["case","changes"],"properties":{"case":{"$ref":"#/components/schemas/Case"},"changes":{"type":"array","items":{"type":"string","enum":["status","reason","appealable"]},"description":"What changed. New values may appear."}}}}},"LevelUpEvent":{"type":"object","required":["id","type","api_version","created_at","server_id","data"],"properties":{"id":{"type":"string","description":"evt_…: the same on every retry and for every webhook. Drop an event you've already handled."},"type":{"type":"string","enum":["member.level_up"]},"api_version":{"type":"string","enum":["v1"]},"created_at":{"type":"string","format":"date-time","description":"When it happened."},"server_id":{"type":"string"},"data":{"type":"object","required":["user","level","previous_level","xp"],"properties":{"user":{"$ref":"#/components/schemas/User"},"level":{"type":"integer","minimum":1},"previous_level":{"type":"integer","minimum":0},"xp":{"type":"integer","minimum":0}}}}},"MemberErasedEvent":{"type":"object","required":["id","type","api_version","created_at","server_id","data"],"properties":{"id":{"type":"string","description":"evt_…: the same on every retry and for every webhook. Drop an event you've already handled."},"type":{"type":"string","enum":["member.erased"]},"api_version":{"type":"string","enum":["v1"]},"created_at":{"type":"string","format":"date-time","description":"When it happened."},"server_id":{"type":"string"},"data":{"type":"object","required":["user"],"properties":{"user":{"type":"object","required":["id"],"properties":{"id":{"type":"string"}}}}}}},"PingEvent":{"type":"object","required":["id","type","api_version","created_at","server_id","data"],"properties":{"id":{"type":"string","description":"evt_…: the same on every retry and for every webhook. Drop an event you've already handled."},"type":{"type":"string","enum":["ping"]},"api_version":{"type":"string","enum":["v1"]},"created_at":{"type":"string","format":"date-time","description":"When it happened."},"server_id":{"type":"string"},"data":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}},"CoinsChangedEvent":{"type":"object","required":["id","type","api_version","created_at","server_id","data"],"properties":{"id":{"type":"string","description":"evt_…: the same on every retry and for every webhook. Drop an event you've already handled."},"type":{"type":"string","enum":["member.coins_changed"]},"api_version":{"type":"string","enum":["v1"]},"created_at":{"type":"string","format":"date-time","description":"When it happened."},"server_id":{"type":"string"},"data":{"type":"object","required":["user","amount","balance","reason","source"],"properties":{"user":{"$ref":"#/components/schemas/User"},"amount":{"type":"integer","description":"What changed, negative for a removal."},"balance":{"type":"integer"},"reason":{"type":["string","null"]},"source":{"type":"string","enum":["api","command","dashboard"],"description":"Through the API, a staff command (!coins give, take, set) or the dashboard's economy panel. New sources may appear."}}}}},"CoinWrite":{"type":"object","required":["amount"],"properties":{"amount":{"type":"integer","description":"Coins to add (positive) or remove (negative), up to 1,000,000 either way. Not 0."},"reason":{"type":"string","maxLength":200,"description":"Shown in the server's logs and the webhook event."},"dry_run":{"type":"boolean","default":false,"description":"Run every check and answer as if it happened, without changing anything or using the daily limit."}}},"XpWrite":{"type":"object","required":["amount"],"properties":{"amount":{"type":"integer","description":"XP to add, 1 to 100,000."},"reason":{"type":"string","maxLength":200,"description":"Shown in the server's logs and the webhook event."},"dry_run":{"type":"boolean","default":false,"description":"Run every check and answer as if it happened, without changing anything or using the daily limit."}}},"CoinTransaction":{"type":"object","required":["id","user","amount","applied","balance","reason","created_at","dry_run"],"properties":{"id":{"type":"string","description":"txn_…"},"user":{"$ref":"#/components/schemas/User"},"amount":{"type":"integer","description":"What you asked for."},"applied":{"type":"integer","description":"What actually changed: a removal stops at 0 coins, so this can be smaller."},"balance":{"type":"integer","description":"Their balance afterwards."},"reason":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"},"dry_run":{"type":"boolean"}}},"XpGrant":{"type":"object","required":["id","user","amount","xp","level","previous_level","leveled_up","rank","reason","created_at","dry_run"],"properties":{"id":{"type":"string","description":"txn_…"},"user":{"$ref":"#/components/schemas/User"},"amount":{"type":"integer"},"xp":{"type":"integer","description":"Their XP afterwards. Members who linked accounts share one total across their community."},"level":{"type":"integer"},"previous_level":{"type":"integer"},"leveled_up":{"type":"boolean","description":"When true, level roles and badges are given as for a level-up in chat (a moment later)."},"rank":{"type":"integer","minimum":1},"reason":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"},"dry_run":{"type":"boolean"}}},"LevelPage":{"type":"object","required":["data","next_cursor"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/LevelEntry"}},"next_cursor":{"type":["string","null"],"description":"Pass as `cursor` for the next page; null on the last page."}}},"CoinPage":{"type":"object","required":["data","next_cursor"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/CoinEntry"}},"next_cursor":{"type":["string","null"],"description":"Pass as `cursor` for the next page; null on the last page."}}},"CasePage":{"type":"object","required":["data","next_cursor"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Case"}},"next_cursor":{"type":["string","null"],"description":"Pass as `cursor` for the next page; null on the last page."}}}}}}