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

# Security API Reference

> Manage HWID and IP blacklists and whitelists via the AuthForge Developer API.

Control which devices and IP addresses can authenticate with your application.

***

## Response signature model (Ed25519)

AuthForge signs `/auth/validate` and `/auth/heartbeat` success responses with a per-app Ed25519 private key.

* SDKs verify `signature` against the exact base64 `payload` string using your app's `publicKey`.
* `appSecret` authenticates validate requests, but is **not** used for response signature verification.
* Response shape includes `keyId` so clients can identify which signing key version produced the signature.

### Success response shape

```json theme={null}
{
  "status": "success",
  "payload": "<base64-encoded JSON payload>",
  "signature": "<base64 Ed25519 signature>",
  "keyId": "<app signing key version>"
}
```

This prevents network-level payload forgery without access to your app's private signing key.

***

## Tamper self-ban endpoint (public auth)

When your app detects tampering (anti-debug, runtime integrity checks, patch detection), you can call:

**POST**

Trigger a self-ban request against the public auth host (`https://auth.authforge.cc`).

### Request modes

`/auth/selfban` supports two request styles:

1. **Pre-session**: `appId`, `appSecret`, `licenseKey`, `hwid`, `nonce`
2. **Post-session**: `appId`, `sessionToken`, `hwid`

A post-session request is rejected with `hwid_mismatch`, and nothing is revoked or blacklisted, when `hwid` is no longer bound to the license (for example after an HWID reset moved the seat to another machine). Unlimited-seat licenses skip this check.

Common optional flags:

| Field | Type | Default | Meaning |
| - | - | - | - |
| `revokeLicense` | boolean | `false` pre-session / `true` post-session | Revoke the license key (post-session only) |
| `blacklistHwid` | boolean | `true` | Add current HWID to app HWID blacklist |
| `blacklistIp` | boolean | `true` | Add caller IP to app IP blacklist |

### Critical safety rule

> [!WARNING]
>
> Pre-session requests cannot revoke by key. If a pre-session request sets `revokeLicense: true`, the API returns `revoke_requires_session`.

This prevents accidentally revoking arbitrary or attacker-supplied keys before the key is proven by a valid authenticated session.

### Example (pre-session, blacklist only)

```bash theme={null}
curl -X POST https://auth.authforge.cc/auth/selfban \
  -H "Content-Type: application/json" \
  -d '{
    "appId": "YOUR_APP_ID",
    "appSecret": "YOUR_APP_SECRET",
    "licenseKey": "AF-XXXX-XXXX-XXXX",
    "hwid": "device-hwid",
    "nonce": "fresh-random-nonce",
    "revokeLicense": false,
    "blacklistHwid": true,
    "blacklistIp": true
  }'
```

### Example (post-session, full lockout)

```bash theme={null}
curl -X POST https://auth.authforge.cc/auth/selfban \
  -H "Content-Type: application/json" \
  -d '{
    "appId": "YOUR_APP_ID",
    "sessionToken": "SESSION_TOKEN_FROM_VALIDATE",
    "hwid": "device-hwid",
    "revokeLicense": true,
    "blacklistHwid": true,
    "blacklistIp": true
  }'
```

***

## Get security config

**GET**

Retrieve the current blacklist and whitelist configuration for an application.

### Path parameters

| Param | Type | Description |
| - | - | - |
| `appId` | string | The application ID |

### Example

```bash theme={null}
curl https://api.authforge.cc/v1/apps/YOUR_APP_ID/security \
  -H "Authorization: Bearer af_live_your_key"
```

### Response (200)

```json theme={null}
{
  "hwidBlacklist": ["a1b2c3d4e5f6..."],
  "hwidWhitelist": [],
  "ipBlacklist": ["203.0.113.50"],
  "ipWhitelist": []
}
```

Empty arrays indicate no entries for that list. An empty whitelist means whitelist mode is **not active** (all values are allowed).

***

## Update security config

**PUT**

Replace the security configuration. Only included fields are updated; omitted lists remain unchanged.

### Request body

| Field | Type | Required | Description |
| - | - | - | - |
| `hwidBlacklist` | string\[] | No | HWIDs to block (max 500) |
| `hwidWhitelist` | string\[] | No | Allowed HWIDs only (max 500) |
| `ipBlacklist` | string\[] | No | IPs to block (max 500) |
| `ipWhitelist` | string\[] | No | Allowed IPs only (max 500) |

### Example

```bash theme={null}
curl -X PUT https://api.authforge.cc/v1/apps/YOUR_APP_ID/security \
  -H "Authorization: Bearer af_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "hwidBlacklist": ["a1b2c3d4e5f6...", "7g8h9i0j1k2l..."],
    "ipBlacklist": ["203.0.113.50"]
  }'
```

### Response (200)

```json theme={null}
{
  "hwidBlacklist": ["a1b2c3d4e5f6...", "7g8h9i0j1k2l..."],
  "hwidWhitelist": [],
  "ipBlacklist": ["203.0.113.50"],
  "ipWhitelist": []
}
```

### Errors

| HTTP | Code | Cause |
| - | - | - |
| 400 | `bad_request` | Invalid entry format, or a new HWID over 256 bytes (UTF-8) or new IP over 45 bytes |
| 409 | `list_full` | The update would grow a list past 500 entries |
| 403 | `forbidden` | The app doesn't belong to your account |

### Clearing a list

Set the list to an empty array:

```bash theme={null}
curl -X PUT https://api.authforge.cc/v1/apps/YOUR_APP_ID/security \
  -H "Authorization: Bearer af_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{"hwidBlacklist": []}'
```

***

## Add to blacklist

**POST**

Add a single HWID or IP to the blacklist.

### Request body

| Field | Type | Required | Description |
| - | - | - | - |
| `type` | string | Yes | `"hwid"` or `"ip"` |
| `value` | string | Yes | The HWID hash or IP address to block |

### Example

```bash theme={null}
curl -X POST https://api.authforge.cc/v1/apps/YOUR_APP_ID/security/blacklist \
  -H "Authorization: Bearer af_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{"type": "hwid", "value": "a1b2c3d4e5f6..."}'
```

### Response (200)

```json theme={null}
{ "ok": true }
```

***

## Remove from blacklist

**DELETE**

Remove a single HWID or IP from the blacklist.

### Request body

| Field | Type | Required | Description |
| - | - | - | - |
| `type` | string | Yes | `"hwid"` or `"ip"` |
| `value` | string | Yes | The entry to remove |

### Example

```bash theme={null}
curl -X DELETE https://api.authforge.cc/v1/apps/YOUR_APP_ID/security/blacklist \
  -H "Authorization: Bearer af_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{"type": "hwid", "value": "a1b2c3d4e5f6..."}'
```

### Response (200)

```json theme={null}
{ "ok": true }
```

***

## Add to whitelist

**POST**

Add a single HWID or IP to the whitelist. Enabling a whitelist restricts authentication to only listed entries.

### Request body

| Field | Type | Required | Description |
| - | - | - | - |
| `type` | string | Yes | `"hwid"` or `"ip"` |
| `value` | string | Yes | The HWID hash or IP address to allow |

### Example

```bash theme={null}
curl -X POST https://api.authforge.cc/v1/apps/YOUR_APP_ID/security/whitelist \
  -H "Authorization: Bearer af_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{"type": "ip", "value": "198.51.100.10"}'
```

### Response (200)

```json theme={null}
{ "ok": true }
```

> [!WARNING]
>
> Adding an entry to a whitelist activates allowlist mode for that type. All non-listed HWIDs or IPs will be blocked.

***

## Remove from whitelist

**DELETE**

Remove a single HWID or IP from the whitelist. If the whitelist becomes empty, allowlist mode is deactivated.

### Request body

| Field | Type | Required | Description |
| - | - | - | - |
| `type` | string | Yes | `"hwid"` or `"ip"` |
| `value` | string | Yes | The entry to remove |

### Example

```bash theme={null}
curl -X DELETE https://api.authforge.cc/v1/apps/YOUR_APP_ID/security/whitelist \
  -H "Authorization: Bearer af_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{"type": "ip", "value": "198.51.100.10"}'
```

### Response (200)

```json theme={null}
{ "ok": true }
```

***

## Limits

| Constraint | Value |
| - | - |
| Max entries per list | 500 |
| HWID value max length | 256 bytes (UTF-8); SDK-generated HWIDs are 64 characters |
| IP value max length | 45 characters (IPv4 and IPv6) |
| HWID value min length | 1 character |
| IP value min length | 7 characters |

Limits apply to entries you add. Entries and lists saved before a limit existed (lists could previously hold up to 5,000 entries) are still returned, can be re-saved, and can be removed; an over-limit list just cannot grow until it is back under 500.

## Evaluation order

During authentication, lists are checked in this order:

1. IP blacklist (reject if matched)
2. IP whitelist (reject if list is non-empty and IP not listed)
3. HWID blacklist (reject if matched)
4. HWID whitelist (reject if list is non-empty and HWID not listed)

**Blacklist always takes precedence.** An entry present on both blacklist and whitelist is blocked.


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