# Bot API Integration
Source: https://docs.rankly.live/bots/api-integration
Use the Rankly public API from your bot or backend service.
Use this guide when your bot needs Rankly data on demand.
## When to use the API
* Show server or bot stats in a command
* Check whether a user can vote again
* Render review summaries in your own dashboard
* Cache Rankly data in a backend job
If you need Rankly to push updates to you, use the webhook guides instead.
## Recommended setup
Store the key in an environment variable. Do not ship it in a browser bundle or public client app.
Use `/server` for server stats, `/bot` for bot stats, `/votes/:userId` for cooldown checks, and `/reviews` for review summaries.
Treat `401`, `400`, and `429` as normal outcomes and show a useful message instead of crashing the command.
Rankings and review summaries do not usually need to be fetched for every message.
## Example: fetch server stats
```javascript theme={null}
const baseUrl = 'https://api.rankly.live/api/v1';
async function getServerStats() {
const response = await fetch(`${baseUrl}/server`, {
headers: {
'X-API-Key': process.env.RANKLY_API_KEY,
},
});
const payload = await response.json();
if (!payload.success) {
throw new Error(payload.error);
}
return payload.data;
}
```
```python theme={null}
import os
import requests
base_url = "https://api.rankly.live/api/v1"
headers = {"X-API-Key": os.environ["RANKLY_API_KEY"]}
response = requests.get(f"{base_url}/server", headers=headers, timeout=10)
payload = response.json()
if not payload["success"]:
raise RuntimeError(payload["error"])
server = payload["data"]
```
## Example: check vote eligibility
```javascript theme={null}
const baseUrl = 'https://api.rankly.live/api/v1';
const userId = interaction.user.id;
const response = await fetch(`${baseUrl}/votes/${userId}`, {
headers: {
'X-API-Key': process.env.RANKLY_API_KEY,
},
});
const payload = await response.json();
if (!payload.success) {
throw new Error(payload.error);
}
if (payload.data.canVote) {
// Show the vote button or reward hint.
}
```
## Good integration habits
* Never trust the client with your API key.
* Use the public API for live reads, not for write operations.
* Keep your command output short and readable.
* Cache responses that users ask for repeatedly.
* Add a small error message when the API key is invalid or the cooldown has not expired.
## Related docs
Endpoint details, auth rules, and response examples.
Receive push updates when a vote is processed.
# Premium Plans
Source: https://docs.rankly.live/bots/premium
How Rankly premium purchases, plan types, and billing state work.
Premium is the part of Rankly that lets users pay for bot or server upgrades with the platform's credit system.
## What premium covers
* Bot premium tiers
* Server premium tiers
* Weekly, monthly, and lifetime durations
* Gifted purchases
* Order history and transaction tracking
* Premium lifecycle webhooks for purchases, renewals, expirations, and revocations
## How a purchase works
Premium can be attached to a bot or a server, depending on what the product offers.
Tiers define the price, duration, and plan type that will be charged.
Rankly checks the purchaser's available credits before the order is created.
Keep your own internal record of the plan, the expiry, and whether the purchase was gifted.
## Premium webhooks
For bot premium plans, Rankly sends signed webhook events to your configured premium webhook URL.
### Headers
* `X-Webhook-Signature`: HMAC SHA-256 signature of the exact JSON body
* `Content-Type`: `application/json`
### Signature verification (Node.js)
```javascript theme={null}
import crypto from 'crypto';
function verifyRanklySignature(rawBody, signatureHeader, secret) {
const expected = crypto
.createHmac('sha256', secret)
.update(rawBody)
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(expected, 'utf8'),
Buffer.from(signatureHeader || '', 'utf8')
);
}
```
Use the raw request body for verification before parsing or mutating payload fields.
## Plan types
| Plan type | Meaning |
| --------- | ------------------------------------------ |
| Weekly | Renew or expire on a 7-day cycle. |
| Monthly | Renew or expire on a 30-day cycle. |
| Lifetime | Stays active until it is manually revoked. |
## Event types you can receive
| Event | Meaning | Common reason |
| ---------------------- | ------------------------------------------------------ | ----------------------------------------- |
| `premium_purchase` | A premium order was created successfully. | New checkout completed |
| `subscription.renewed` | A recurring plan was renewed. | Auto-renew succeeded |
| `subscription.expired` | A recurring plan was ended. | Past due, invalid buyer, tier unavailable |
| `subscription.revoked` | A plan was revoked and should be disabled immediately. | Chargeback/dispute |
## Webhook payload examples
### `premium_purchase`
```json theme={null}
{
"event": "premium_purchase",
"purchaseId": "682f4d8e8c4a93b75ad69f90",
"orderId": "682f4d8e8c4a93b75ad69f90",
"timestamp": "2026-05-24T12:00:00.000Z",
"buyer": {
"userId": "123456789012345678",
"username": "Skyline"
},
"recipient": null,
"isGift": false,
"giftedBy": null,
"tier": {
"id": "pro-monthly",
"name": "Pro Monthly",
"duration": "monthly",
"planType": "user"
},
"serverId": null
}
```
### `subscription.renewed`
```json theme={null}
{
"event": "subscription.renewed",
"orderId": "682f4d8e8c4a93b75ad69f90",
"purchaseId": "682f4d8e8c4a93b75ad69f90",
"timestamp": "2026-05-24T13:00:00.000Z",
"buyer": {
"userId": "123456789012345678",
"username": "Skyline"
},
"recipient": null,
"isGift": false,
"vendor": {
"type": "bot",
"id": "987654321098765432"
},
"tier": {
"id": "pro-monthly",
"name": "Pro Monthly",
"duration": "monthly",
"planType": "user"
},
"autoRenew": true,
"status": "active",
"currentPeriodEnd": "2026-06-24T13:00:00.000Z"
}
```
### `subscription.expired`
```json theme={null}
{
"event": "subscription.expired",
"orderId": "682f4d8e8c4a93b75ad69f90",
"purchaseId": "682f4d8e8c4a93b75ad69f90",
"timestamp": "2026-05-24T14:00:00.000Z",
"buyer": {
"userId": "123456789012345678",
"username": "Skyline"
},
"recipient": null,
"isGift": false,
"vendor": {
"type": "bot",
"id": "987654321098765432"
},
"tier": {
"id": "pro-monthly",
"name": "Pro Monthly",
"duration": "monthly",
"planType": "user"
},
"autoRenew": true,
"status": "past_due",
"currentPeriodEnd": "2026-05-24T14:00:00.000Z",
"reason": "past_due"
}
```
### `subscription.revoked`
```json theme={null}
{
"event": "subscription.revoked",
"orderId": "682f4d8e8c4a93b75ad69f90",
"purchaseId": "682f4d8e8c4a93b75ad69f90",
"timestamp": "2026-05-24T15:00:00.000Z",
"buyer": {
"userId": "123456789012345678",
"username": "Skyline"
},
"recipient": null,
"isGift": false,
"vendor": {
"type": "bot",
"id": "987654321098765432"
},
"tier": {
"id": "pro-monthly",
"name": "Pro Monthly",
"duration": "monthly",
"planType": "user"
},
"autoRenew": true,
"status": "revoked",
"currentPeriodEnd": "2026-06-24T13:00:00.000Z",
"reason": "chargeback_dispute"
}
```
## What could happen in production
* A user buys premium now: you get `premium_purchase`, then grant features immediately.
* The subscription renews a month later: you get `subscription.renewed`, and just extend access.
* Auto-renew fails: you get `subscription.expired`, and you should remove paid features.
* A chargeback happens after purchase: you get `subscription.revoked`, and you should disable access right away.
* A gift purchase is made: `isGift` is true and `recipient` is populated, so entitlement should be applied to the recipient.
## What to expect in your app
* A premium purchase becomes an order in Rankly's billing flow.
* The purchaser and recipient can be different users when the plan is gifted.
* The dashboard should always show the current status, not just the original purchase date.
* If you need to reflect the current plan in your bot, refresh your own cached state after checkout.
## Handler checklist
* Verify `X-Webhook-Signature` before processing.
* Deduplicate by `orderId` plus `event`.
* Make state transitions idempotent.
* Treat `subscription.revoked` as highest priority for entitlement removal.
* Return `2xx` quickly, then do heavy work async.
## Helpful implementation notes
* Keep tier IDs stable once users rely on them.
* Show the user what they are paying for before they confirm the purchase.
* Make expired plans obvious in the UI.
* Treat a billing failure as a recoverable state, not a fatal error.
## Related docs
See how premium purchases interact with balances.
Pull plan state into your bot commands or dashboard.
# Bot Vote Webhooks
Source: https://docs.rankly.live/bots/vote
Receive real-time vote events for bot listings and react in your own backend.
Use this guide when you want Rankly to push vote events to your bot or backend.
## What the webhook contains
Rankly sends a signed JSON payload that looks like this:
```json theme={null}
{
"event": "bot_vote",
"timestamp": "2026-01-01T12:00:00.000Z",
"voter": {
"userId": "123456789012345678",
"username": "Skyline"
},
"bot": {
"id": "987654321098765432",
"name": "Rankly Bot"
},
"creditsAwarded": true,
"adBlocker": false,
"creditDenialReason": null
}
```
The signature is sent in the `X-Webhook-Signature` header.
## How to handle it
The endpoint must be reachable from the public internet.
Recompute the HMAC with your webhook secret and compare it to the `X-Webhook-Signature` header.
Treat the webhook as at-least-once delivery and ignore duplicates by storing a stable event fingerprint.
Return a 2xx response before you do slow work like database updates or role grants.
## Example verification
```javascript theme={null}
import crypto from 'crypto';
import express from 'express';
const app = express();
app.use(express.json({
verify: (req, _res, buf) => {
req.rawBody = buf.toString('utf8');
}
}));
app.post('/rankly/bot-vote', async (req, res) => {
const receivedSignature = req.header('X-Webhook-Signature');
const expectedSignature = crypto
.createHmac('sha256', process.env.RANKLY_WEBHOOK_SECRET)
.update(req.rawBody)
.digest('hex');
if (receivedSignature !== expectedSignature) {
return res.status(401).json({ error: 'invalid signature' });
}
const { voter, bot, creditsAwarded, creditDenialReason } = req.body;
// Grant rewards, log the vote, or update your internal state here.
console.log({ voter, bot, creditsAwarded, creditDenialReason });
return res.status(200).json({ received: true });
});
```
## What to build with it
* Reward a voter inside your bot
* Log the vote in a moderation channel
* Update a dashboard badge or vote count
* Trigger a lightweight analytics event
## Security notes
* Keep the secret private and rotate it if it leaks.
* Verify the exact payload you received, not a re-serialized version that may change formatting.
* Use a unique event key to avoid double rewards.
* Do not expose your webhook endpoint with destructive actions on the first request.
## Related docs
Read data on demand when a webhook is not necessary.
Pull server and vote state directly from Rankly.
# Glossary
Source: https://docs.rankly.live/glossary
A compact reference for Rankly terms used across the docs.
| Term | Meaning |
| ------------------ | ------------------------------------------------------------------------------ |
| API key | A secret key used to authenticate a server or bot against the public API. |
| Credits | Rankly's internal balance unit used for growth, promotions, and premium flows. |
| Earned credits | Credits gained from activity such as votes. |
| Session credits | Credits tied to session-based activity or usage rewards. |
| Purchased credits | Credits added through top-ups or checkout. |
| Vote webhook | A POST request Rankly sends when a vote is verified. |
| bot\_vote | The event name used by bot vote webhooks. |
| creditsAwarded | Boolean in the webhook payload showing whether the vote earned credits. |
| creditDenialReason | Text explaining why a vote did not earn credits. |
| Auto-bump | A scheduled visibility boost that keeps a server higher in the listing. |
| Cooldown | The wait period before the same user can vote again. |
| Webhook secret | The secret you use to verify that a webhook request really came from Rankly. |
| Rate limit | The maximum number of requests Rankly accepts in a given time window. |
| Verification token | A short-lived token used during vote verification. |
| Public API | The read-only Rankly API for server and bot metadata, votes, and reviews. |
# Rankly Docs
Source: https://docs.rankly.live/index
Server growth, bot integration, credits, webhooks, and the public API in one place.
Rankly is a Discord discovery platform for communities that want better visibility, cleaner growth tools, and a compact public API.
## Choose your path
Create a polished listing, connect growth features, and launch your server page.
Send vote notifications to your own server endpoint and reward members automatically.
Read Rankly data from your bot, dashboard, or backend service.
Learn the exact endpoints, authentication rules, and response shapes.
## What Rankly documents here
* Server listing and growth setup
* Credits and monetization flows
* Vote webhooks for server owners
* Public API usage for servers and bots
* Bot-side webhook handling and billing concepts
* Troubleshooting for auth, webhooks, and rate limits
## How the docs are organized
1. Start with [Quickstart](/quickstart) if you want the shortest possible path.
2. Use the Server Owners pages if you manage a listed Discord server.
3. Use the Bot Developers pages if you are reading Rankly data inside a bot or backend.
4. Use the Reference section when you need exact API behavior or debugging help.
## Fast links
Listing, credits, and vote webhooks.
API calls, vote events, and premium plans.
Endpoints, errors, and auth details.
# Quickstart
Source: https://docs.rankly.live/quickstart
Pick the shortest path for the part of Rankly you need.
If you already know your use case, jump directly to the matching guide. If you do not, use this page to choose.
## Pick a path
List your Discord server, tune your profile, and connect vote webhooks.
Read Rankly data from your bot and process vote events in real time.
Use the public API to fetch server, bot, vote, and review data.
## The shortest route
### Server owners
Sign in at the dashboard, add your server, and fill in the details that make your listing useful.
Add your vote webhook endpoint if you want Rankly to notify your own backend when a vote lands.
Review your earned balance, spendable balance, and any growth tools you want to enable.
### Bot developers
Use the public API from your backend or bot process only. Do not ship your key to the browser.
Most integrations only need [server details](/servers/api-reference), [bot details](/servers/api-reference), or [vote status](/servers/api-reference).
For real-time vote handling, use the bot vote webhook guide instead of polling.
### If you only need the reference
Use the [Public API Reference](/servers/api-reference) for exact request and response examples.
## What to read next
Start with the basics of a solid server listing.
See authentication, response envelopes, and all supported endpoints.
Receive vote notifications in your own backend.
Fetch Rankly data in your bot or service.
# Public API Reference
Source: https://docs.rankly.live/servers/api-reference
The Rankly public API for server and bot lookups, vote status, and reviews.
The public API is read-only and requires an API key tied to a Rankly server or bot.
## Base URL
```text theme={null}
https://api.rankly.live/api/v1
```
## Authentication
Send your API key in the `X-API-Key` header.
```bash theme={null}
curl https://api.rankly.live/api/v1/server \
-H "X-API-Key: rk_live_your_key_here"
```
You can also provide the key as `?key=...`, but the header is the preferred form.
## Response shape
Most endpoints return a standard envelope:
```json theme={null}
{
"success": true,
"data": {},
"meta": {}
}
```
Errors return:
```json theme={null}
{
"success": false,
"error": "Message here"
}
```
## Endpoints at a glance
| Method | Path | Use it for | Works for |
| ------ | ---------------- | -------------------------------------------------------- | --------------- |
| GET | `/server` | Fetch the authenticated server profile and stats. | Servers only |
| GET | `/bot` | Fetch the authenticated bot profile and stats. | Bots only |
| GET | `/votes/:userId` | Check vote cooldown and eligibility for a specific user. | Servers or bots |
| GET | `/reviews` | Read the authenticated server reviews. | Servers only |
## `GET /server`
Returns the server metadata for the API key owner.
### Example response
```json theme={null}
{
"success": true,
"data": {
"id": "123456789012345678",
"name": "Rankly Community",
"description": "A friendly Discord community.",
"votes": 124,
"monthlyVotes": 37,
"tags": ["discord", "community"],
"category": "Community",
"ownerDiscordId": "234567890123456789",
"features": [],
"emojis": [],
"channelCount": 12,
"roleCount": 18,
"rules": [],
"url": "https://rankly.live/server/123456789012345678",
"stats": {
"members": 842,
"online": 114
}
}
}
```
## `GET /bot`
Returns the bot metadata for the API key owner.
### Example response
```json theme={null}
{
"success": true,
"data": {
"id": "987654321098765432",
"name": "Rankly Bot",
"description": "Bot utilities and rewards.",
"votes": 52,
"tags": [],
"url": "https://rankly.live/bot/987654321098765432",
"stats": {
"servers": 0,
"shards": 0
}
}
}
```
## `GET /votes/:userId`
Checks whether a user can vote again right now.
### Path parameters
| Parameter | Type | Description |
| --------- | ------ | ------------------------------------------ |
| `userId` | string | Discord user ID to check. Must be numeric. |
### Example response
```json theme={null}
{
"success": true,
"data": {
"canVote": false,
"nextVoteDate": "2026-01-02T00:00:00.000Z",
"lastVoteDate": "2026-01-01T12:00:00.000Z",
"secondsUntilVote": 43200
}
}
```
The cooldown window is 12 hours.
## `GET /reviews`
Returns reviews for the authenticated server.
### Query parameters
| Parameter | Type | Default | Description |
| --------- | ------ | -------- | ---------------------------------------------- |
| `limit` | number | `10` | Maximum reviews to return. The hard cap is 50. |
| `sort` | string | `newest` | Use `newest`, `highest`, or `lowest`. |
### Example response
```json theme={null}
{
"success": true,
"data": [
{
"username": "Skyline",
"rating": 5,
"comment": "Very active and welcoming.",
"createdAt": "2026-01-01T12:00:00.000Z"
}
],
"meta": {
"total": 14,
"shown": 1
}
}
```
## Example client code
```javascript theme={null}
const response = await fetch('https://api.rankly.live/api/v1/server', {
headers: {
'X-API-Key': process.env.RANKLY_API_KEY,
},
});
const payload = await response.json();
if (!payload.success) {
throw new Error(payload.error);
}
console.log(payload.data.name);
```
```bash theme={null}
curl "https://api.rankly.live/api/v1/votes/123456789012345678" \
-H "X-API-Key: rk_live_your_key_here"
```
## Error handling
* `401` means the key is missing or invalid.
* `400` means the endpoint does not match the key type or the parameter is invalid.
* `429` means the request limit was exceeded.
* `500` means the backend hit an unexpected error.
## Best practices
* Keep the API key on your server.
* Cache responses that do not need to change every second.
* Use `/votes/:userId` only when you need the live cooldown state.
* Prefer the public API reference over reverse-engineering dashboard calls.
# Credits
Source: https://docs.rankly.live/servers/credits
Understand how Rankly credits are earned, stored, and spent.
Credits are Rankly's internal balance system. They are used across growth, promotions, and premium flows.
## Credit types
| Type | What it means | Typical source |
| ----------------- | ---------------------------------------------------------- | ------------------------------- |
| Earned credits | Balance you receive from platform activity such as votes. | Community growth and engagement |
| Session credits | Balance tied to activity sessions and usage-based rewards. | Ongoing activity and sessions |
| Purchased credits | Balance added through checkout or top-ups. | Payments and credit purchases |
## Where credits are spent
| Use case | What happens |
| ----------- | -------------------------------------------------- |
| Auto-bump | Keeps a server higher in visibility on a schedule. |
| Ads | Powers paid placements and campaign budgets. |
| Bot premium | Pays for premium tiers tied to a bot or server. |
## How the balance behaves
* Earned balances are the most commonly spendable balance for growth actions.
* Session balances are useful when the platform awards activity-based credits.
* Purchased balances are added deliberately, usually when a user tops up for a specific action.
* Some checkout flows only accept the balance type that the product is designed to use.
## When to think about credits
If a user asks one of these questions, this page is the right answer:
* Why did my balance change after a vote?
* Which balance pays for a promotion?
* Why did checkout ask for credits instead of currency?
* How do I know which plan is consuming my balance?
## Related docs
See how credits fit into a listed server's growth setup.
Use webhooks to react when votes produce new credit activity.
Learn how premium purchases use the platform's billing flows.
# List Your Server
Source: https://docs.rankly.live/servers/getting-started
Create a clean Rankly listing and connect the growth features your community needs.
This guide is for server owners who want a polished listing and a clear path to growth.
## What you will set up
* A public server listing with the right name, category, and tags
* A usable invite link and a readable description
* Visual assets like an icon and banner
* Growth tools such as credits and vote webhooks
## Before you start
Make sure you have:
* Access to the Discord server you want to list
* A valid Discord server ID
* A usable invite code
* A short description and a longer description if you want one
* A server icon and optional banner URL
## Setup flow
Sign in, choose the server you want to list, and open the listing editor.
Add the server name, description, category, and tags that best match the community.
Upload or link the icon and banner that represent the server clearly on the listing page.
Save the entry and confirm that the page renders correctly from the public server view.
## What makes a strong listing
| Field | Good practice |
| ----------- | ------------------------------------------------------------------------------ |
| Name | Keep it short, recognizable, and consistent with your Discord server branding. |
| Description | Explain what the community does in one or two sharp sentences. |
| Tags | Use the tags that real members would search for. |
| Category | Pick the closest category instead of trying to be too broad. |
| Invite | Use a valid invite that does not expire immediately. |
| Visuals | Use clean, square icons and banners with enough contrast. |
## After the listing is live
Learn how Rankly balances earned, session, and purchased credits.
Send vote notifications to your own backend or bot.
## Practical tips
* Keep the invite valid and easy to test.
* Update your tags when your community focus changes.
* Use the webhook test flow before relying on live vote events.
* Treat the listing as a landing page, not just a form.
# Premium Webhooks
Source: https://docs.rankly.live/servers/premium-webhooks
Handle server-owner monetization webhook events for purchases, renewals, expirations, and revocations.
Use this page for server-owner monetization webhook handling.
## What this webhook is for
This webhook is sent for the server premium lifecycle.
## Event delivered
| Event | Meaning |
| ---------------------- | -------------------------------------------------------------------------- |
| `premium_purchase` | A server premium purchase was successfully created. |
| `subscription.renewed` | A recurring server premium order renewed successfully. |
| `subscription.expired` | A recurring server premium order expired and should be deactivated. |
| `subscription.revoked` | A server premium order was revoked (for example after chargeback/dispute). |
## Headers
* `X-Webhook-Signature`: HMAC SHA-256 signature of the exact JSON body
* `Content-Type`: `application/json`
## Payload example
```json theme={null}
{
"event": "premium_purchase",
"purchaseId": "682f4d8e8c4a93b75ad69f90",
"orderId": "682f4d8e8c4a93b75ad69f90",
"timestamp": "2026-05-24T12:00:00.000Z",
"buyer": {
"userId": "123456789012345678",
"username": "Skyline"
},
"recipient": null,
"isGift": false,
"giftedBy": null,
"tier": {
"id": "server-pro-monthly",
"name": "Server Pro Monthly",
"duration": "monthly",
"planType": "server"
},
"serverId": "987654321098765432",
"targetType": "server",
"targetName": "Rankly Community"
}
```
## Lifecycle payload examples
### `subscription.renewed`
```json theme={null}
{
"event": "subscription.renewed",
"orderId": "682f4d8e8c4a93b75ad69f90",
"purchaseId": "682f4d8e8c4a93b75ad69f90",
"timestamp": "2026-05-24T13:00:00.000Z",
"buyer": {
"userId": "123456789012345678",
"username": "Skyline"
},
"recipient": null,
"isGift": false,
"vendor": {
"type": "server",
"id": "987654321098765432"
},
"tier": {
"id": "server-pro-monthly",
"name": "Server Pro Monthly",
"duration": "monthly",
"planType": "server"
},
"autoRenew": true,
"status": "active",
"currentPeriodEnd": "2026-06-24T13:00:00.000Z"
}
```
### `subscription.expired`
```json theme={null}
{
"event": "subscription.expired",
"orderId": "682f4d8e8c4a93b75ad69f90",
"purchaseId": "682f4d8e8c4a93b75ad69f90",
"timestamp": "2026-05-24T14:00:00.000Z",
"buyer": {
"userId": "123456789012345678",
"username": "Skyline"
},
"recipient": null,
"isGift": false,
"vendor": {
"type": "server",
"id": "987654321098765432"
},
"tier": {
"id": "server-pro-monthly",
"name": "Server Pro Monthly",
"duration": "monthly",
"planType": "server"
},
"autoRenew": true,
"status": "expired",
"currentPeriodEnd": "2026-05-24T14:00:00.000Z",
"reason": "past_due"
}
```
### `subscription.revoked`
```json theme={null}
{
"event": "subscription.revoked",
"orderId": "682f4d8e8c4a93b75ad69f90",
"purchaseId": "682f4d8e8c4a93b75ad69f90",
"timestamp": "2026-05-24T15:00:00.000Z",
"buyer": {
"userId": "123456789012345678",
"username": "Skyline"
},
"recipient": null,
"isGift": false,
"vendor": {
"type": "server",
"id": "987654321098765432"
},
"tier": {
"id": "server-pro-monthly",
"name": "Server Pro Monthly",
"duration": "monthly",
"planType": "server"
},
"autoRenew": true,
"status": "revoked",
"currentPeriodEnd": "2026-06-24T13:00:00.000Z",
"reason": "chargeback_dispute"
}
```
## Signature verification
```javascript theme={null}
import crypto from 'crypto';
function verifyRanklySignature(rawBody, signatureHeader, secret) {
const expected = crypto
.createHmac('sha256', secret)
.update(rawBody)
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(expected, 'utf8'),
Buffer.from(signatureHeader || '', 'utf8')
);
}
```
Use the raw body exactly as received before JSON parsing transformations.
## Example receiver
```javascript theme={null}
import express from 'express';
import crypto from 'crypto';
const app = express();
app.use(express.json({
verify: (req, _res, buf) => {
req.rawBody = buf.toString('utf8');
}
}));
app.post('/rankly/server-premium', async (req, res) => {
const signature = req.header('X-Webhook-Signature') || '';
const expected = crypto
.createHmac('sha256', process.env.RANKLY_SERVER_WEBHOOK_SECRET)
.update(req.rawBody)
.digest('hex');
if (!crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected))) {
return res.status(401).json({ error: 'invalid signature' });
}
if (req.body.event === 'premium_purchase') {
const { orderId, purchaseId, tier, buyer, recipient, isGift } = req.body;
// Upsert entitlement, invoice, or analytics event here.
console.log({ orderId, purchaseId, tier, buyer, recipient, isGift });
} else if (req.body.event === 'subscription.renewed') {
// Extend active period and keep premium enabled.
} else if (req.body.event === 'subscription.expired' || req.body.event === 'subscription.revoked') {
// Remove premium entitlement immediately.
}
return res.status(200).json({ received: true });
});
```
## Production handling checklist
* Verify `X-Webhook-Signature` before processing any event.
* Deduplicate by `orderId` plus `event`.
* Keep handler idempotent so retries do not double-apply entitlements.
* Persist `purchaseId` and `orderId` for reconciliation.
* Treat `subscription.revoked` as highest-priority entitlement removal.
* Return 2xx quickly and move heavy work to async jobs.
## Related docs
Separate webhook flow for verified vote events.
Debug signature mismatches and duplicate deliveries.
# Vote Webhooks
Source: https://docs.rankly.live/servers/webhooks
Handle vote webhook events for your server listing.
Use vote webhooks when you want Rankly to notify your service about verified votes.
## Vote webhook
Use this for voter rewards, role grants, or vote analytics.
### What Rankly sends
When a vote is processed, Rankly posts a small JSON payload to the webhook URL saved on the server.
Example payload:
```json theme={null}
{
"userId": "123456789012345678",
"serverId": "987654321098765432",
"timestamp": "2026-01-01T12:00:00.000Z",
"creditsAwarded": true,
"adBlocker": false,
"creditDenialReason": null
}
```
A test delivery uses the same shape and may include `test: true`.
### Set it up
Your webhook must be reachable over HTTPS. Localhost and private/internal addresses are rejected.
Add the endpoint in your server settings, then optionally set an Authorization header if your backend expects one.
Use the dashboard test action before relying on live vote traffic.
Acknowledge the request fast and do your heavier work asynchronously.
### Example receiver
```javascript theme={null}
import express from 'express';
const app = express();
app.use(express.json());
app.post('/rankly/vote', async (req, res) => {
const auth = req.header('Authorization');
if (auth !== `Bearer ${process.env.RANKLY_WEBHOOK_SECRET}`) {
return res.status(401).json({ error: 'unauthorized' });
}
const { userId, serverId, creditsAwarded, creditDenialReason } = req.body;
// Update your database or trigger a reward here.
console.log({ userId, serverId, creditsAwarded, creditDenialReason });
return res.status(200).json({ received: true });
});
```
## Security notes
* Keep the endpoint public, but keep the processing logic private.
* Verify the Authorization header if you set one in Rankly.
* Treat deliveries as at-least-once and dedupe by `userId`, `serverId`, and `timestamp`.
* Never point a webhook at localhost, a private subnet, or an internal admin panel.
## Common issues
* No delivery at all: check the saved URL and whether the test request succeeds.
* 4xx response: fix your endpoint auth or JSON parsing.
* Repeated events: add deduplication before issuing rewards.
* No credits awarded: the vote may still be counted, but the payload will explain why credits were denied.
## Related docs
Handle signed monetization events for server premium purchases.
# Troubleshooting
Source: https://docs.rankly.live/troubleshooting
Common Rankly issues and the fastest way to fix them.
## Public API returns 401
Your API key is missing, invalid, or tied to the wrong entity. Make sure you are sending the key in X-API-Key and that the key belongs to the server or bot you are querying.
## Public API returns 429
The request rate is too high. Cache repeated reads, back off for a few seconds, and avoid calling the API from every message when one cached response would do.
## Webhook URL rejected
Webhook endpoints must be public HTTPS URLs. Localhost, private subnets, and other internal destinations are rejected so Rankly does not become an SSRF proxy.
## Webhook does not fire
Check that the URL is saved correctly, the endpoint is publicly reachable, and the test webhook succeeds. If the endpoint returns a non-2xx response or times out, fix that first.
## Purchase webhook issues
For server monetization webhooks, verify the X-Webhook-Signature header against the raw request body and your webhook secret. If signature verification fails, do not activate premium access.
Treat deliveries as at-least-once and deduplicate by orderId plus event. Your handler should be idempotent so replays do not double-grant entitlements.
These lifecycle events are sent only for recurring server plans. Check that the purchased tier is weekly/monthly (not lifetime), auto-renew is enabled, and your endpoint returns 2xx quickly.
Immediately remove premium entitlement and mark the order as revoked in your system. Revoked events usually indicate dispute/chargeback handling and should override normal active state.
## Vote counted but credits were not awarded
Credits can be denied for normal reasons such as captcha failure, ad blocker detection, a server that is too new, or a server that does not meet the minimum member count. The webhook payload includes the denial reason.
## Still stuck?
If none of the common cases fits, check the dashboard test action first and then contact support at [support@rankly.live](mailto:support@rankly.live).