# Keys

Key management endpoints

## GET /keys

> Fetch keys with filtering and pagination

```json
{"openapi":"3.0.3","info":{"title":"Junkie Key System REST API v2","version":"2.0.0"},"tags":[{"name":"Keys","description":"Key management endpoints"}],"servers":[{"url":"https://api.jnkie.com/api/v2","description":"Production server"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"API Key with rest-api:* scope"}},"schemas":{"Key":{"type":"object","properties":{"id":{"type":"integer"},"key_value":{"type":"string"},"user_id":{"type":"integer"},"service_id":{"type":"integer","nullable":true},"provider_id":{"type":"integer"},"folder_id":{"type":"integer","nullable":true},"expires_at":{"type":"string","format":"date-time","nullable":true},"used_at":{"type":"string","format":"date-time","nullable":true},"is_premium":{"type":"boolean"},"is_invalidated":{"type":"boolean"},"one_time_use":{"type":"boolean"},"expiry_on_first_use":{"type":"boolean"},"validity_minutes":{"type":"integer","nullable":true,"description":"null for forever"},"no_hwid":{"type":"boolean"},"key_name":{"type":"string","nullable":true},"hwid_limit":{"type":"integer","nullable":true,"description":"0 or null for unlimited"},"discord_id":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"service_name":{"type":"string","nullable":true},"provider_name":{"type":"string","nullable":true},"folder_name":{"type":"string","nullable":true},"hwids":{"type":"array","items":{"$ref":"#/components/schemas/HWID"}},"keys_hwid":{"type":"array","items":{"type":"string"},"description":"Simple array of HWID strings (convenience field)"}}},"HWID":{"type":"object","properties":{"hwid":{"type":"string"},"executor_user_id":{"type":"string","nullable":true},"bound_at":{"type":"string","format":"date-time"},"bound_by":{"type":"string","description":"How HWID was bound (api, verify, manual, admin)"}}},"Pagination":{"type":"object","properties":{"page":{"type":"integer","minimum":1},"limit":{"type":"integer","minimum":1,"maximum":100},"total":{"type":"integer","minimum":0},"totalPages":{"type":"integer","minimum":0}}}}},"paths":{"/keys":{"get":{"summary":"Fetch keys with filtering and pagination","tags":["Keys"],"parameters":[{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"default":1}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":50}},{"name":"discord_id","in":"query","schema":{"type":"string"},"description":"Filter by Discord user ID"},{"name":"key","in":"query","schema":{"type":"string"},"description":"Search by key value (partial match)"},{"name":"hwid","in":"query","schema":{"type":"string"},"description":"Filter by HWID (partial match)"},{"name":"service_id","in":"query","schema":{"type":"integer"}},{"name":"provider_id","in":"query","schema":{"type":"integer"}},{"name":"folder_id","in":"query","schema":{"type":"integer"},"description":"Filter by key folder ID"},{"name":"status","in":"query","schema":{"type":"string","enum":["active","used","expired","invalidated"]}},{"name":"expires_before","in":"query","schema":{"type":"string","format":"date-time"}},{"name":"expires_after","in":"query","schema":{"type":"string","format":"date-time"}}],"responses":{"200":{"description":"List of keys","content":{"application/json":{"schema":{"type":"object","properties":{"keys":{"type":"array","items":{"$ref":"#/components/schemas/Key"}},"pagination":{"$ref":"#/components/schemas/Pagination"}}}}}}}}}}}
```

## POST /keys

> Create a single key

```json
{"openapi":"3.0.3","info":{"title":"Junkie Key System REST API v2","version":"2.0.0"},"tags":[{"name":"Keys","description":"Key management endpoints"}],"servers":[{"url":"https://api.jnkie.com/api/v2","description":"Production server"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"API Key with rest-api:* scope"}},"schemas":{"Key":{"type":"object","properties":{"id":{"type":"integer"},"key_value":{"type":"string"},"user_id":{"type":"integer"},"service_id":{"type":"integer","nullable":true},"provider_id":{"type":"integer"},"folder_id":{"type":"integer","nullable":true},"expires_at":{"type":"string","format":"date-time","nullable":true},"used_at":{"type":"string","format":"date-time","nullable":true},"is_premium":{"type":"boolean"},"is_invalidated":{"type":"boolean"},"one_time_use":{"type":"boolean"},"expiry_on_first_use":{"type":"boolean"},"validity_minutes":{"type":"integer","nullable":true,"description":"null for forever"},"no_hwid":{"type":"boolean"},"key_name":{"type":"string","nullable":true},"hwid_limit":{"type":"integer","nullable":true,"description":"0 or null for unlimited"},"discord_id":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"service_name":{"type":"string","nullable":true},"provider_name":{"type":"string","nullable":true},"folder_name":{"type":"string","nullable":true},"hwids":{"type":"array","items":{"$ref":"#/components/schemas/HWID"}},"keys_hwid":{"type":"array","items":{"type":"string"},"description":"Simple array of HWID strings (convenience field)"}}},"HWID":{"type":"object","properties":{"hwid":{"type":"string"},"executor_user_id":{"type":"string","nullable":true},"bound_at":{"type":"string","format":"date-time"},"bound_by":{"type":"string","description":"How HWID was bound (api, verify, manual, admin)"}}}}},"paths":{"/keys":{"post":{"summary":"Create a single key","tags":["Keys"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["provider_id"],"properties":{"provider_id":{"type":"integer","minimum":1},"service_id":{"type":"integer","nullable":true},"folder_id":{"type":"integer","minimum":1,"nullable":true,"description":"Key folder ID to assign on creation"},"key_name":{"type":"string","maxLength":255,"nullable":true},"validity_minutes":{"type":"integer","minimum":0,"nullable":true,"description":"null or 0 for forever"},"hwid":{"type":"string","maxLength":255,"nullable":true,"description":"Pre-bind single HWID on creation (use hwids array for multiple)"},"hwids":{"type":"array","items":{"type":"string","maxLength":255},"description":"Array of HWIDs to pre-bind on creation (replaces hwid if both provided)"},"discord_id":{"type":"string","nullable":true,"pattern":"^\\\\d{17,19}$","description":"Discord user ID to associate with this key"},"is_premium":{"type":"boolean"},"one_time_use":{"type":"boolean"},"expiry_on_first_use":{"type":"boolean"},"no_hwid":{"type":"boolean"},"hwid_limit":{"type":"integer","minimum":0,"maximum":100,"nullable":true,"description":"0 or null for unlimited"}}}}}},"responses":{"201":{"description":"Key created","content":{"application/json":{"schema":{"type":"object","properties":{"key":{"$ref":"#/components/schemas/Key"}}}}}}}}}}}
```

## GET /keys/folders

> List key folders

```json
{"openapi":"3.0.3","info":{"title":"Junkie Key System REST API v2","version":"2.0.0"},"tags":[{"name":"Keys","description":"Key management endpoints"}],"servers":[{"url":"https://api.jnkie.com/api/v2","description":"Production server"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"API Key with rest-api:* scope"}},"schemas":{"KeyFolder":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"created_at":{"type":"string","format":"date-time"}}}}},"paths":{"/keys/folders":{"get":{"summary":"List key folders","tags":["Keys"],"responses":{"200":{"description":"List of key folders","content":{"application/json":{"schema":{"type":"object","properties":{"folders":{"type":"array","items":{"$ref":"#/components/schemas/KeyFolder"}}}}}}}}}}}}
```

## POST /keys/batch

> Create multiple keys at once

```json
{"openapi":"3.0.3","info":{"title":"Junkie Key System REST API v2","version":"2.0.0"},"tags":[{"name":"Keys","description":"Key management endpoints"}],"servers":[{"url":"https://api.jnkie.com/api/v2","description":"Production server"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"API Key with rest-api:* scope"}}},"paths":{"/keys/batch":{"post":{"summary":"Create multiple keys at once","tags":["Keys"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["provider_id","amount"],"properties":{"provider_id":{"type":"integer","minimum":1},"service_id":{"type":"integer","minimum":1,"nullable":true},"folder_id":{"type":"integer","minimum":1,"nullable":true,"description":"Key folder ID to assign to all created keys"},"amount":{"type":"integer","minimum":1,"maximum":100,"description":"Number of keys to create (1-100)"},"key_name":{"type":"string","maxLength":255,"nullable":true},"validity_minutes":{"type":"integer","minimum":0,"nullable":true},"hwid":{"type":"string","maxLength":255,"nullable":true,"description":"Bind same HWID to all keys"},"discord_id":{"type":"string","nullable":true,"pattern":"^\\\\d{17,19}$","description":"Discord user ID to associate with all created keys"},"is_premium":{"type":"boolean"},"one_time_use":{"type":"boolean"},"expiry_on_first_use":{"type":"boolean"},"no_hwid":{"type":"boolean"},"hwid_limit":{"type":"integer","minimum":0,"maximum":100,"nullable":true}}}}}},"responses":{"201":{"description":"Keys created","content":{"application/json":{"schema":{"type":"object","properties":{"keys":{"type":"array","items":{"type":"string"}},"count":{"type":"integer"},"config":{"type":"object"}}}}}}}}}}}
```

## POST /keys/bulk-delete

> Delete multiple keys by IDs or key values

```json
{"openapi":"3.0.3","info":{"title":"Junkie Key System REST API v2","version":"2.0.0"},"tags":[{"name":"Keys","description":"Key management endpoints"}],"servers":[{"url":"https://api.jnkie.com/api/v2","description":"Production server"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"API Key with rest-api:* scope"}}},"paths":{"/keys/bulk-delete":{"post":{"summary":"Delete multiple keys by IDs or key values","tags":["Keys"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["keys"],"properties":{"keys":{"type":"array","minItems":1,"maxItems":1000,"items":{"oneOf":[{"type":"integer"},{"type":"string"}]},"description":"Array of key IDs (numbers) or key values (strings)"}}}}}},"responses":{"200":{"description":"Keys deleted","content":{"application/json":{"schema":{"type":"object","properties":{"deleted":{"type":"integer"},"requested":{"type":"integer"}}}}}}}}}}}
```

## GET /keys/{keyId}

> Get detailed key information

```json
{"openapi":"3.0.3","info":{"title":"Junkie Key System REST API v2","version":"2.0.0"},"tags":[{"name":"Keys","description":"Key management endpoints"}],"servers":[{"url":"https://api.jnkie.com/api/v2","description":"Production server"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"API Key with rest-api:* scope"}},"schemas":{"KeyDetailed":{"allOf":[{"$ref":"#/components/schemas/Key"},{"type":"object","properties":{"discord_redemption":{"type":"object","nullable":true,"properties":{"discord_user_id":{"type":"string"},"redemption_status":{"type":"string"},"redeemed_at":{"type":"string","format":"date-time"}}}}}]},"Key":{"type":"object","properties":{"id":{"type":"integer"},"key_value":{"type":"string"},"user_id":{"type":"integer"},"service_id":{"type":"integer","nullable":true},"provider_id":{"type":"integer"},"folder_id":{"type":"integer","nullable":true},"expires_at":{"type":"string","format":"date-time","nullable":true},"used_at":{"type":"string","format":"date-time","nullable":true},"is_premium":{"type":"boolean"},"is_invalidated":{"type":"boolean"},"one_time_use":{"type":"boolean"},"expiry_on_first_use":{"type":"boolean"},"validity_minutes":{"type":"integer","nullable":true,"description":"null for forever"},"no_hwid":{"type":"boolean"},"key_name":{"type":"string","nullable":true},"hwid_limit":{"type":"integer","nullable":true,"description":"0 or null for unlimited"},"discord_id":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"service_name":{"type":"string","nullable":true},"provider_name":{"type":"string","nullable":true},"folder_name":{"type":"string","nullable":true},"hwids":{"type":"array","items":{"$ref":"#/components/schemas/HWID"}},"keys_hwid":{"type":"array","items":{"type":"string"},"description":"Simple array of HWID strings (convenience field)"}}},"HWID":{"type":"object","properties":{"hwid":{"type":"string"},"executor_user_id":{"type":"string","nullable":true},"bound_at":{"type":"string","format":"date-time"},"bound_by":{"type":"string","description":"How HWID was bound (api, verify, manual, admin)"}}}}},"paths":{"/keys/{keyId}":{"get":{"summary":"Get detailed key information","tags":["Keys"],"responses":{"200":{"description":"Key details","content":{"application/json":{"schema":{"type":"object","properties":{"key":{"$ref":"#/components/schemas/KeyDetailed"}}}}}}}}}}}
```

## PUT /keys/{keyId}

> Update key properties

```json
{"openapi":"3.0.3","info":{"title":"Junkie Key System REST API v2","version":"2.0.0"},"tags":[{"name":"Keys","description":"Key management endpoints"}],"servers":[{"url":"https://api.jnkie.com/api/v2","description":"Production server"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"API Key with rest-api:* scope"}}},"paths":{"/keys/{keyId}":{"put":{"summary":"Update key properties","tags":["Keys"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"key_name":{"type":"string","maxLength":255,"nullable":true},"folder_id":{"type":"integer","minimum":1,"nullable":true,"description":"Key folder ID to assign; null removes the folder"},"validity_minutes":{"type":"integer","minimum":0,"nullable":true},"expires_at":{"type":"string","format":"date-time","nullable":true,"description":"ISO 8601 datetime string"},"is_premium":{"type":"boolean"},"one_time_use":{"type":"boolean"},"expiry_on_first_use":{"type":"boolean"},"no_hwid":{"type":"boolean"},"hwid_limit":{"type":"integer","minimum":0,"maximum":100,"nullable":true},"is_invalidated":{"type":"boolean"},"discord_id":{"type":"string","nullable":true,"pattern":"^\\\\d{17,19}$","description":"Discord user ID to associate with this key; null removes it"},"hwids":{"type":"array","items":{"type":"string","maxLength":255},"description":"Replace all existing HWIDs with this array. Empty array clears all HWIDs."}}}}}},"responses":{"200":{"description":"Key updated","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"keys_hwid":{"type":"array","items":{"type":"string"},"description":"Updated array of HWIDs (only present if hwids was provided)"}}}}}}}}}}}
```

## DELETE /keys/{keyId}

> Delete a single key

```json
{"openapi":"3.0.3","info":{"title":"Junkie Key System REST API v2","version":"2.0.0"},"tags":[{"name":"Keys","description":"Key management endpoints"}],"servers":[{"url":"https://api.jnkie.com/api/v2","description":"Production server"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"API Key with rest-api:* scope"}}},"paths":{"/keys/{keyId}":{"delete":{"summary":"Delete a single key","tags":["Keys"],"responses":{"200":{"description":"Key deleted"}}}}}}
```

## POST /keys/{keyId}/reset-hwid

> Reset all HWIDs for a key

```json
{"openapi":"3.0.3","info":{"title":"Junkie Key System REST API v2","version":"2.0.0"},"tags":[{"name":"Keys","description":"Key management endpoints"}],"servers":[{"url":"https://api.jnkie.com/api/v2","description":"Production server"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"API Key with rest-api:* scope"}}},"paths":{"/keys/{keyId}/reset-hwid":{"post":{"summary":"Reset all HWIDs for a key","tags":["Keys"],"responses":{"200":{"description":"HWIDs reset","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"}}}}}}}}}}}
```


---

# 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.jnkie.com/rest-api/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.
