Examples
Copy-and-paste examples for curl, JavaScript, Python and a Discord bot.
Every example reads the key from the environment variable ROWARDEN_KEY.
curl
curl "https://rowarden.com/api/v1/experiences/34/moderation/records?limit=10&action=ban" \
-H "Authorization: Bearer $ROWARDEN_KEY"JavaScript (Node 18+)
const base = 'https://rowarden.com/api/v1';
const headers = { Authorization: `Bearer ${process.env.ROWARDEN_KEY}`, 'Content-Type': 'application/json' };
async function ban(experienceId, target, reason) {
const res = await fetch(`${base}/experiences/${experienceId}/moderation/bans`, {
method: 'POST',
headers: { ...headers, 'Idempotency-Key': crypto.randomUUID() },
body: JSON.stringify({ target, reason, duration_seconds: 86400 })
});
const body = await res.json();
if (!res.ok) throw new Error(`${body.error.code}: ${body.error.message} (${body.error.request_id})`);
return body.data;
}
// All bans in force, page by page.
async function* activeBans(experienceId) {
let cursor = '';
do {
const res = await fetch(`${base}/experiences/${experienceId}/moderation/records?status=active&limit=100${cursor}`, { headers });
const body = await res.json();
yield* body.data;
cursor = body.next_cursor ? `&cursor=${body.next_cursor}` : '';
} while (cursor);
}Python
import os, uuid, requests
BASE = "https://rowarden.com/api/v1"
S = requests.Session()
S.headers["Authorization"] = f"Bearer {os.environ['ROWARDEN_KEY']}"
def warn(experience_id, target, reason):
r = S.post(f"{BASE}/experiences/{experience_id}/moderation/warnings",
json={"target": target, "reason": reason},
headers={"Idempotency-Key": str(uuid.uuid4())})
if not r.ok:
e = r.json()["error"]
raise RuntimeError(f"{e['code']}: {e['message']} ({e['request_id']})")
return r.json()["data"]A Discord /ban command
With discord.js, a slash command that calls the API instead of touching Roblox itself:
client.on('interactionCreate', async (i) => {
if (!i.isChatInputCommand() || i.commandName !== 'ban') return;
await i.deferReply({ ephemeral: true });
const res = await fetch(`${base}/experiences/${process.env.EXPERIENCE_ID}/moderation/bans`, {
method: 'POST',
headers: { ...headers, 'Idempotency-Key': i.id }, // the interaction id is unique and stable across retries
body: JSON.stringify({ target: i.options.getString('player'), reason: i.options.getString('reason') })
});
const body = await res.json();
await i.editReply(res.ok ? body.data.message : `Failed: ${body.error.message}`);
});RoWarden already ships a Discord bot with these commands; build your own when you need different rules, your own server layout, or a connection to other tools.