> ## Documentation Index
> Fetch the complete documentation index at: https://apidocs.eraus.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# Connecting tools

> Melonly, Sonoran CAD, Discord bots and anything else: what to send their developers and what to set up.

## Tools that already speak ER:LC

Most private server tools, such as moderation dashboards, CAD systems and Discord bots, were built for the ER:LC API. There are two ways to connect them.

**If the tool lets you change the API URL** (self-hosted bots and many open-source tools do):

1. Make a key in the console for that tool.
2. Set the tool's API URL to `https://api.eraus.gg/prc`. Some tools want the full `https://api.eraus.gg/prc/v1` instead.
3. Paste your ERA key wherever it asks for the ER:LC server key.

**If it doesn't**, the tool's developers need to add ERA as a game. That's a small change for them, because the [compatibility layer](https://apidocs.eraus.gg/erlc-compatibility.md) uses the same shapes. Send them this page.

> [!NOTE]
>
> **For integration developers:** add ERA as a second game and switch the base URL. Everything else in your ER:LC client can stay the same. When you're ready, the [native API](https://apidocs.eraus.gg/api/server.md) gives you command results, webhooks and cursor-based logs. Keys always start with `era_`, so you can tell them apart from ER:LC keys.

## CAD and MDT tools

What CAD tools usually want, and where to find it:

| Need | Where |
| - | - |
| Units on duty, callsigns, teams | [`/v1/server/players`](https://apidocs.eraus.gg/api/players): `callsign`, `team` |
| Live unit positions | `location` on each player, plotted with [Map](https://apidocs.eraus.gg/map.md) |
| 000 calls and alerts | [`/v1/server/calls`](https://apidocs.eraus.gg/api/calls), plus the `emergency.call` webhook event |
| Who's responding | `responders` on each call |
| Wanted status | `wanted` and `wantedStars` on each player |
| Plate lookups | [`/v1/server/vehicles`](https://apidocs.eraus.gg/api/vehicles): `plate`, `owner`, `color` |
| Priority or peace from dispatch | `:prioritytimer 20` and `:peacetimer 10` through [commands](https://apidocs.eraus.gg/commands.md) |

## Moderation bots

| Need | Where |
| - | - |
| Join and leave logs | `player.join` and `player.leave` webhooks, or [`/logs/joins`](https://apidocs.eraus.gg/api/joins) |
| Kill logs | `player.kill`, or [`/logs/kills`](https://apidocs.eraus.gg/api/kills) |
| Mod call alerts | `modcall.open` and `modcall.claim` |
| Audit of staff actions | `staff.command`, or [`/logs/commands`](https://apidocs.eraus.gg/api/command-logs) |
| Kick, ban, unban, PMs | [Commands](https://apidocs.eraus.gg/commands.md) |
| Ban list | [`/v1/server/bans`](https://apidocs.eraus.gg/api/bans) |

## Discord, with no code

Paste a Discord webhook link into **API → Webhook** in the console, pick the events, and press **Send test**. Joins, kills, mod calls and 000 calls show up as embeds.

## Building your own

A small bot that posts mod calls to Discord and polls players:

```javascript theme={null}
const KEY = process.env.ERA_KEY;
const api = (path, init = {}) =>
  fetch(`https://api.eraus.gg${path}`, {
    ...init,
    headers: { Authorization: `Bearer ${KEY}`, "Content-Type": "application/json", ...init.headers },
  }).then(async (r) => {
    if (r.status === 429) throw new Error(`rate limited, retry in ${r.headers.get("retry-after")}s`);
    const body = await r.json();
    if (!r.ok) throw new Error(`${body.error.code}: ${body.error.message}`);
    return body;
  });

let cursor = 0;
setInterval(async () => {
  const { data } = await api(`/v1/server/events?types=modcall.open&after=${cursor}&limit=100`);
  for (const e of data) {
    cursor = e.id;
    console.log(`Mod call from ${e.data.caller.name}`);
  }
}, 10_000);

// run a command and wait for the result
const { id } = await api("/v1/server/commands", { method: "POST", body: JSON.stringify({ command: ":announce Server restart in 5 minutes" }) });
const result = await api(`/v1/server/commands/${id}`);
```

> [!WARNING]
>
> Keep the key on your server. Don't put it in a website, a browser extension or a Discord bot's public code.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.