# Keys

Key routes manage lookup, creation, generation, updates, blacklist flags, deletion, and HWID resets.

## Fetch Keys

**`GET`** `/api/v1/keys/fetch`

#### Query

<table><thead><tr><th width="168">Query</th><th>Description</th></tr></thead><tbody><tr><td>hub</td><td>HubId to look for. Default will look for every Hub.</td></tr><tr><td>discordId</td><td>Discord ID to look for. Default will look for every discord ID.</td></tr><tr><td>key</td><td>Key to look for. Default will look for every key.</td></tr><tr><td>hwid</td><td>HWID to look for. Default will look for every HWID.</td></tr><tr><td>blacklisted</td><td>Key should be blacklisted. (boolean) Default will not filter by blacklisted.</td></tr><tr><td>expired</td><td>Key should be expired. (boolean) Default will not filter by expired.</td></tr><tr><td>unassigned</td><td>Key should be unassigned. (boolean) Default will not filter by unassigned.</td></tr><tr><td>active</td><td>Key should be active. (boolean) Default will not filter by active.</td></tr><tr><td>page</td><td>Page of the query. Default is 1.</td></tr></tbody></table>

#### Response

{% tabs %}
{% tab title="200" %}

```json
{
  "success": true,
  "message": "Successfully fetched keys.",
  "keys": [
    {
      "hubId": "40511091490620200512",
      "hubName": "Main Hub",
      "advertiseId": null,
      "discordId": "123456789012345678",
      "key": "73978994376e1f3e307914c4",
      "expire": 1764835962,
      "note": "Customer note",
      "created": 1764749562,
      "activated": true,
      "hwid": "589401805431295092384985734",
      "hwidResetCount": 0,
      "lastHwidReset": 0,
      "executionCount": 0,
      "lastExecution": 0,
      "blacklisted": false,
      "blacklistReason": null,
      "limitedScripts": ["45006455740750038081"],
      "discordData": {
        "id": "123456789012345678",
        "username": "wompus_dompus",
        "avatar": null,
        "global_name": "Wompus",
        "modified": 1759761781,
        "created": 1759761781
      }
    }
  ],
  "limitPerPage": 25,
  "totalPages": 1,
  "totalKeys": 1
}
```

{% endtab %}
{% endtabs %}

Returned key objects use the same masked key shape as Add Key, Update Key, and Key Info. Internal fields such as database IDs, modified timestamps, and HWID-lock internals are not returned.

## Bulk Delete Keys

**`POST`** `/api/v1/keys/bulk-delete`

#### Payload

```json
[
  "key1",
  "key2",
  "key3"
]
```

#### Response

{% tabs %}
{% tab title="200" %}

```json
{
  "success": true,
  "message": "Key(s) have been deleted."
}
```

{% endtab %}

{% tab title="404" %}

```json
{
  "success": false,
  "message": "No hub(s) linked to your account."
}
```

{% endtab %}
{% endtabs %}

## Add Key

**`POST`** `/api/v2/hubs/:hubId/keys/add`

#### Params

| Param | Description               |
| ----- | ------------------------- |
| hubId | Hub ID to add the key to. |

#### Payload

```json
{
  "discordId": "123456789012345678",
  "expire": 86400,
  "note": "Customer note",
  "limitedScripts": ["45006455740750038081"]
}
```

{% hint style="info" %}
`discordId`, `expire`, `note`, and `limitedScripts` are optional. `expire` is given in seconds and must be at least 3600. `limitedScripts` limits the key to the listed script IDs from the same hub.
{% endhint %}

#### Response

{% tabs %}
{% tab title="200" %}

```json
{
  "success": true,
  "message": "Key has been created successfully.",
  "key": {
    "hubId": "40511091490620200512",
    "discordId": "123456789012345678",
    "key": "73978994376e1f3e307914c4",
    "expire": 1764835962,
    "note": "Customer note",
    "created": 1764749562,
    "hwidResetCount": 0,
    "lastHwidReset": 0,
    "executionCount": 0,
    "lastExecution": 0,
    "blacklisted": false,
    "blacklistReason": null,
    "limitedScripts": ["45006455740750038081"],
    "discordData": {
      "id": "123456789012345678",
      "username": "wompus_dompus",
      "avatar": null,
      "global_name": "Wompus",
      "modified": 1759761781,
      "created": 1759761781
    }
  }
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "success": false,
  "message": "Discord ID is already whitelisted to the hub."
}
```

{% endtab %}
{% endtabs %}

## Blacklist Key

Use the Update Key route with this payload:

```json
{
  "blacklisted": true,
  "blacklistReason": "why not?"
}
```

## Generate Keys

**`POST`** `/api/v2/hubs/:hubId/keys/generate`

#### Params

| Param | Description                  |
| ----- | ---------------------------- |
| hubId | Hub ID to generate keys for. |

#### Payload

```json
{
  "amount": 10,
  "expire": 86400,
  "note": "Batch note",
  "limitedScripts": ["45006455740750038081"]
}
```

{% hint style="info" %}
`amount` must be between 5 and 300. `expire`, `note`, and `limitedScripts` are optional. `expire` is given in seconds and must be at least 3600.
{% endhint %}

#### Response

{% tabs %}
{% tab title="200" %}

```json
{
  "success": true,
  "message": "Keys have been generated successfully.",
  "keys": [
    "73978994376e1f3e307914c4",
    "84c370d09e13438149d705c4"
  ]
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "success": false,
  "message": "You can only have a maximum of 300 unassigned keys per hub."
}
```

{% endtab %}
{% endtabs %}

## Key Info

**`GET`** `/api/v1/hubs/:hubId/keys/info`

#### Query

<table><thead><tr><th width="168">Query</th><th>Description</th></tr></thead><tbody><tr><td>discordId</td><td>Discord ID to look for.</td></tr><tr><td>key</td><td>Key to look for.</td></tr></tbody></table>

{% hint style="warning" %}
One of these queries must be given.
{% endhint %}

#### Response

{% tabs %}
{% tab title="200" %}

```json
{
  "success": true,
  "message": "Successfully fetched key info.",
  "key": {
    "hubId": "40511091490620200512",
    "advertiseId": "78078400606734922815",
    "discordId": "123456789098765432",
    "key": "73978994376e1f3e307914c4",
    "expire": 1764749562,
    "note": "Customer note",
    "created": 1764749562,
    "activated": false,
    "hwid": "589401805431295092384985734",
    "hwidResetCount": 0,
    "lastHwidReset": 0,
    "executionCount": 0,
    "lastExecution": 0,
    "blacklisted": false,
    "blacklistReason": null,
    "limitedScripts": ["45006455740750038081"],
    "discordData": {
      "id": "12345678909876543",
      "username": "wompus_dompus",
      "avatar": null,
      "global_name": "Wompus",
      "modified": 1759761781,
      "created": 1759761781
    }
  }
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "success": false,
  "message": "Key could not be found."
}
```

{% endtab %}
{% endtabs %}

## Update Key

**`PATCH`** `/api/v2/hubs/:hubId/keys/update`

#### Params

| Param | Description                |
| ----- | -------------------------- |
| hubId | Hub ID the key belongs to. |

#### Query

| Query     | Description             |
| --------- | ----------------------- |
| discordId | Discord ID to look for. |
| key       | Key to look for.        |

{% hint style="warning" %}
One of these queries must be given.
{% endhint %}

#### Payload

```json
{
  "discordId": "123456789098765432",
  "expire": 86400,
  "note": "Updated note",
  "blacklisted": true,
  "blacklistReason": "Annoying",
  "limitedScripts": ["45006455740750038081"]
}
```

{% hint style="info" %}
All payload fields are optional. Omit `expire` to keep the current expiration. `limitedScripts` replaces the previous script limitation; omit it to keep the current value.
{% endhint %}

#### Response

{% tabs %}
{% tab title="200" %}

```json
{
  "success": true,
  "message": "Key has been updated successfully.",
  "key": {
    "hubId": "40511091490620200512",
    "discordId": "123456789098765432",
    "key": "73978994376e1f3e307914c4",
    "expire": 1764835962,
    "note": "Updated note",
    "created": 1764749562,
    "hwidResetCount": 0,
    "lastHwidReset": 0,
    "executionCount": 0,
    "lastExecution": 0,
    "blacklisted": true,
    "blacklistReason": "Annoying",
    "limitedScripts": ["45006455740750038081"],
    "discordData": {
      "id": "123456789098765432",
      "username": "wompus_dompus",
      "avatar": null,
      "global_name": "Wompus",
      "modified": 1759761781,
      "created": 1759761781
    }
  }
}
```

{% endtab %}

{% tab title="403" %}

```json
{
  "success": false,
  "message": "This key is globally blacklisted and can only be unblacklisted by LuaProt."
}
```

{% endtab %}

{% tab title="404" %}

```json
{
  "success": false,
  "message": "Key has not been found."
}
```

{% endtab %}
{% endtabs %}

## Delete Key

**`DELETE`** `/api/v1/hubs/:hubId/keys/delete`

#### Query

<table><thead><tr><th width="168">Query</th><th>Description</th></tr></thead><tbody><tr><td>discordId</td><td>Discord ID to look for.</td></tr><tr><td>key</td><td>Key to look for.</td></tr></tbody></table>

{% hint style="warning" %}
One of these queries must be given.
{% endhint %}

#### Response

{% tabs %}
{% tab title="200" %}

```json
{
  "success": true,
  "message": "Key has been deleted."
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "success": false,
  "message": "Key could not be found."
}
```

{% endtab %}
{% endtabs %}

## Reset HWID

**`PATCH`** `/api/v1/hubs/:hubId/hwid/reset`

{% hint style="info" %}
**INFO**: This will force a HWID reset, ignoring the automatic reset gap (if configured).
{% endhint %}

#### Query

<table><thead><tr><th width="168">Query</th><th>Description</th></tr></thead><tbody><tr><td>discordId</td><td>Discord ID to look for.</td></tr><tr><td>key</td><td>Key to look for.</td></tr></tbody></table>

{% hint style="warning" %}
One of these queries must be given.
{% endhint %}

#### Response

{% tabs %}
{% tab title="200" %}

```json
{
  "succcess": true,
  "message": "HWID(s) have been reset successfully.",
  "resets": [
    "657bebfefc7bbc7c798d39b4",
    "657b3665865c7c798d39b4HI"
  ]
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "success": false,
  "message": "No key(s) found."
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.luaprot.net/luaprot/api-documentation/keys.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
