---
title: "API Reference Overview"
icon : "api"
description: "Auth, base URL, response envelope, identifier kinds, and rate limits for the EnvyAuth API."
---

# Overview

Every endpoint authenticates with an API token and returns the same JSON envelope.

## Authentication

Every request must carry an API token in the `Authorization` header:

```text
Authorization: Bearer YOUR_API_TOKEN
```

Generate a token at **Settings → API Tokens**. The raw token is shown once at creation; save it somewhere safe.

<Warning title="The Discord bot login key is not an API token">
  The 32-character key on **Settings → Profile** is the login key the Discord bot uses for `/login`. It is **not** valid as a Bearer token. Sending it returns `401` with `code: "LOGIN_KEY_AS_BEARER"`. Generate a proper API token at **Settings → API Tokens**.
</Warning>

## Token scopes

Each token holds one or more scopes. A request is allowed if at least one scope covers the method and path.

| Scope | What it allows |
|---|---|
| `admin` | Every method on every path. |
| `read_only` | `GET` and `HEAD` only, on any path. |
| `delete` | `DELETE` only, on any path. |
| `update_script` | `PUT` and `PATCH` on `/api/v3/projects/:project_uuid/scripts/...` only. |

A token whose scopes don't cover the request returns `403` with `code: "SCOPE_DENIED"`.

Pick the narrowest set that covers your use case.

## Base URL

```text
https://api.envyauth.my.id
```

## Response envelope

On success:

```json
{
  "success":   true,
  "data":      { },
  "requestid": "uuid"
}
```

On error:

```json
{
  "success":   false,
  "error":     "Human-readable message",
  "code":      "ERROR_CODE",
  "requestid": "uuid"
}
```

Each endpoint page documents the shape of `data` on success. Common `code` values: `VALIDATION`, `NOT_FOUND`, `RATE_LIMIT`, `UNAUTHORIZED`, `LOGIN_KEY_AS_BEARER`, `SCOPE_DENIED`, `ALREADY_HAS_KEY`, `EXPIRED`, `INTERNAL`.

## Endpoints without a token

Two families are public by design, because they're called by buyers and community members rather than by you:

- **[Store](/docs/api-reference/store)** — storefront availability, promo-code checks, checkout, and key claim. The `account_uuid` in the path and the claim token are the only credentials involved.
- **[Invite Rewards](/docs/api-reference/invites)** — the endpoints behind the public `/invite/<slug>` page. Visitors are identified by a Discord cookie, not a Bearer token. The one exception is join attribution, which does take an API token.

Their owner-side counterparts — `/api/v3/store/manage/*` and the invite config endpoints — stay behind the dashboard session cookie plus CSRF and are not reachable with an API token.

## User identifiers

Endpoints under `/projects/:project_uuid/users/:identifier` accept any of three shapes:

| Kind | Format |
|---|---|
| Discord ID | 17–20 digit snowflake |
| Script key | 32 alphanumeric characters (the value stored as `script_key` / `user_key`) |
| User UUID | Standard 36-character UUID with dashes |

If no user matches, the response is `404` with `code: "NOT_FOUND"`.

## Rate limits

Default: **60 requests per minute per IP**. Response headers report the state:

```text
X-RateLimit-Limit:     60
X-RateLimit-Remaining: 47
X-RateLimit-Reset:     1748430000
```

`X-RateLimit-Reset` is a Unix timestamp in seconds. When the bucket is empty, the response is `429` with `code: "RATE_LIMIT"`. Retry after the reset time.

Token creation is rate-limited separately: at most **10 tokens per 15 minutes** per account.

## Example

Shut down every session for a user, with an in-game toast:

```bash
curl -X POST "https://api.envyauth.my.id/api/v3/projects/<project_uuid>/users/<discord_id>/shutdown?message=Maintenance%20in%202%20minutes" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

The same call in TypeScript:

```ts
const res = await fetch(
  `https://api.envyauth.my.id/api/v3/projects/${project_uuid}/users/${discord_id}/shutdown?message=Maintenance in 2 minutes`,
  {
    method : "POST",
    headers: { Authorization: `Bearer ${process.env.LUAEGIS_API_TOKEN}` },
  },
)
const json = await res.json()
if (!json.success) throw new Error(json.error)
console.log(json.data)  // { terminated, pending, elapsed_time }
```
