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

# Key Endpoints

> Detailed request/response examples for RG_LIVE create and verify

# RG\_LIVE Endpoints

These are the only public routes intended for external tools using `rg_live_*` keys.

## POST `/api/keys/create`

Creates a new key for a script.

### Auth

Use one of:

* `x-api-key: rg_live_...`
* `Authorization: Bearer rg_live_...`
* body field `apiKey` or `api_key`

### Body

```json theme={null}
{
  "scriptId": "00000000-0000-0000-0000-000000000000",
  "type": "temporary",
  "duration": 1440,
  "note": "Premium User",
  "prefix": "PREM"
}
```

### Notes

* `scriptId` required
* `type`: `permanent` or `temporary`
* `duration` used for temporary keys (minutes)
* `prefix` optional, sanitized to alphanumeric/`-`/`_`

### Success (`200`)

```json theme={null}
{
  "success": true,
  "key": {
    "key": "PREM_xxxxxxxxxxxxxxxx",
    "script_id": "00000000-0000-0000-0000-000000000000",
    "type": "temporary",
    "expires_at": "2026-05-03T12:30:00.000Z"
  }
}
```

### Errors

* `400` invalid JSON, missing `scriptId`, invalid prefix
* `401` invalid API key
* `500` internal error

## POST `/api/keys/verify`

Validates whether a key exists for a script and is currently valid.

### Auth

Use one of:

* `x-api-key: rg_live_...`
* `Authorization: Bearer rg_live_...`

### Body

```json theme={null}
{
  "scriptId": "00000000-0000-0000-0000-000000000000",
  "key": "Key_xxxxxxxxxxxxx"
}
```

### Valid (`200`)

```json theme={null}
{
  "valid": true,
  "type": "permanent",
  "expires_at": null
}
```

### Invalid (`200`)

```json theme={null}
{
  "valid": false,
  "reason": "not_found"
}
```

```json theme={null}
{
  "valid": false,
  "reason": "expired",
  "expires_at": "2026-05-01T10:00:00.000Z"
}
```

### Errors

* `400` missing `scriptId` or `key`
* `401` missing/invalid API key
* `500` database/internal failure
