> Let your mod bot run the RestoreCord firewall: a SERVER_FIREWALL key, endpoints for rules, logs and bypasses, plus curl examples for a raid lockout command.

Source: https://restorecord.sh/automate-firewall-api

# Automate your Discord firewall with the RestoreCord API

Your moderators already live in Discord and your own tools. The firewall API lets those tools add rules, read the activity log and hand out timed bypasses without anyone opening a dashboard.

[Get started free](https://restorecord.com/register)[View pricing](https://restorecord.com/pricing)

Short answer

Create a RestoreCord API key with only the SERVER\_FIREWALL permission, send it as a Bearer token from server-side code, and call the endpoints under /api/v3/servers/{serverId}/ to manage rules, passwords, bypasses, logs and ban imports.

## Why drive the firewall from code

During a raid, every click between "we see the pattern" and "the pattern is blocked" costs you. Teams that run their own moderation bot can wire a staff-only slash command straight to the firewall, so the moderator who spots the problem fixes it in the same window. Others pull the activity log into their own dashboards or alerting.

## Create a key that can only touch the firewall

1. 1Create a new API key in the RestoreCord dashboard and give it a name that identifies the job, such as mod-bot-firewall.
2. 2Grant only `SERVER_FIREWALL`. It covers rules, passwords, bypasses, logs and ban imports, and nothing else.
3. 3Choose the shortest useful expiration and add an IP allowlist if your bot runs on fixed infrastructure.
4. 4Copy the full key once and put it in your secret store. Rotate it if it ever shows up in a log, screenshot or repository.

API keys belong in server-side code only. Never ship one inside a browser bundle, a public client or a Discord message.

## The endpoints you will use

All paths start from `https://restorecord.com/api/v3`. Note that `serverId` is RestoreCord's internal server ID, not your Discord guild ID.

| Path                                     | What it does                                                                       |
| ---------------------------------------- | ---------------------------------------------------------------------------------- |
| /servers/{serverId}/firewall/logs        | List activity, filtered by user ID or action. Also clears the log.                 |
| /servers/{serverId}/firewall/rules       | List, create and toggle rules. Single rules can be read, updated or deleted by ID. |
| /servers/{serverId}/firewall/passwords   | Manage verification passwords with labels, max uses and expiry.                    |
| /servers/{serverId}/bypass               | List, grant and remove temporary access for a Discord user.                        |
| /servers/{serverId}/firewall/import-bans | Preview and import your Discord banlist into the blacklist.                        |

## Example: an emergency block from a slash command

When a moderator runs your bot's lockout command with an ASN from the log, the bot sends one request:

Block a hosting networkbash

```
curl -X POST "https://restorecord.com/api/v3/servers/$SERVER_ID/firewall/rules" \
  -H "Authorization: Bearer $RC_KEY_ID.$RC_SECRET" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Raid lockout (mod command)",
    "targetType": "ASN",
    "operator": "IS",
    "targetValue": "AS64500",
    "actions": [{ "type": "BLOCK" }]
  }'
```

Exactly one decision goes in `actions`, and a block can't be paired with `GIVE_ROLE`. The full field list is in the [firewall rules guide](https://restorecord.sh/discord-firewall-rules).

## Example: a timed pass for a travelling moderator

Grant 24 hours of accessbash

```
curl -X POST "https://restorecord.com/api/v3/servers/$SERVER_ID/bypass" \
  -H "Authorization: Bearer $RC_KEY_ID.$RC_SECRET" \
  -H "Content-Type: application/json" \
  -d '{ "userId": "402917736118", "duration": "24h" }'
```

Durations are fixed to `15m`, `1h`, `6h`, `24h` and `7d`, the same windows staff see in the dashboard, so a pass granted by the bot still runs out on its own.

## Guardrails worth keeping

The API follows your plan exactly like the dashboard does: server-membership rules need Business or higher, and ban imports need a paid plan plus a bot with the Ban Members permission. Restrict your slash commands to staff roles, log who ran them, and test any new automated rule against a staff account first. Prefer a hands-on approach? Start from the [VPN blocking guide](https://restorecord.sh/block-vpn-verification) or the [Shield overview](https://restorecord.sh/).

## From zero to a scripted firewall

1. 1  
### Create a scoped key  
In the RestoreCord dashboard, create an API key with only the SERVER\_FIREWALL permission, a short expiry and an IP allowlist.
2. 2  
### Store it server-side  
Keep the key in your bot or backend's secret store and send it as a Bearer token.
3. 3  
### Call the firewall endpoints  
Create rules, read logs and grant bypasses under /api/v3/servers/{serverId}/, then test with a staff account.
[Firewall API reference](https://restorecord.com/docs/api/firewall)

## Before your bot goes live

A short review that keeps automation from becoming a new way in.

Key scoped to SERVER\_FIREWALL only

No backup, pull or member permissions on a moderation key.

Expiry and IP allowlist set

A leaked key is worth far less when it only works from your host.

Commands limited to staff roles

Members should never be able to reach a command that edits the firewall.

Every call logged on your side

Pair RestoreCord's activity log with your bot's own record of who did what.

## Firewall API questions

### 

### 

### 

## Give your mod bot a firewall

Create a scoped key in RestoreCord and turn raid response into a single slash command.

[Create an account](https://restorecord.com/register)[View pricing](https://restorecord.com/pricing)
