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

# Regenerate keys

> Reissues the API and/or WebSocket key. The old one stops working; permissions and subscriptions move to the new one.

Universal endpoint for regenerating `API` and/or `WebSocket` tokens. The previous token is canceled, and all associated settings, subscriptions and rights restrictions are transferred to the newly generated token.

### Authorization

The `erlcrussia-api-key` header is **not strictly required** if you are regenerating the WebSocket key. You can pass:

* `erlcrussia-api-key` - for regenerating the HTTP API key (`?api=true`).
* `erlcrussia-websocket-key` - for regenerating the WebSocket key (`?websocket=true`).
* Or both headers with simultaneous regeneration (`?api=true&websocket=true`).

### Query parameters

| Parameter | Type | Description |
| :- | :- | :- |
| `api` | `boolean` | Regenerate HTTP API token (`true`). |
| `websocket` | `boolean` | Regenerate WebSocket token (`true`). |

> [!NOTE]
>
> At least one of the parameters (`?api=true` or `?websocket=true`) is required. When transferring `?api=true&websocket=true`, both keys will be regenerated simultaneously.

A key may be rotated once every five minutes; respect Retry-After on 429. Successful rotation is audited with key ID and IP, without the secret.


## OpenAPI

````yaml en/openapi/en-api-v3-openapi.yaml POST /keys
openapi: 3.1.0
info:
  title: ER:LC Russia API V3
  description: >-
    ER:LC Russia API for servers, users, CDN, redirects, subscriptions, and
    access keys.
  version: 3.0.0
servers:
  - url: https://api.erlcrussia.com/v3
    description: Production server (com)
  - url: https://api.erlcrussia.xyz/v3
    description: Backup server (xyz)
security: []
tags:
  - name: ER:LC Server
    description: Obtaining status, online, lists of players and staff of the ER:LC server.
  - name: ER:LC Teams
    description: Sending and queuing in-game server commands (:h, :m, :kick, :ban, etc.).
  - name: Economics
    description: >-
      Interaction with the economic system (users, businesses, mafias, stores,
      advertising).
  - name: Statistics API
    description: >-
      High-performance obtaining statistics of discord servers and game servers
      (online, participants, bots).
  - name: Verification API
    description: Search and comparison of Discord ID and Roblox ID accounts.
  - name: CDN Assets
    description: >-
      Load, manage, statistic and clear MinIO/Edge CDN object storage file
      cache.
  - name: CDN Folders
    description: Hierarchical structure and sorting of CDN media library folders.
  - name: Punishment API
    description: Manage the balance and transaction history of players' points.
  - name: Subscriptions API
    description: >-
      Catalog of plans, FunPay orders, accrual of benefits and activation of
      subscriptions.
  - name: Authorization API
    description: >-
      Login via Discord and Roblox OAuth2, manage user sessions and link
      accounts.
  - name: Management API - WebSocket Keys
    description: Managing access keys to the WebSocket gateway and channel subscriptions.
  - name: Management API - Webhooks
    description: Registration, accessibility validation and monitoring of custom webhooks.
  - name: Control API - Panel
    description: >-
      Management of users, subscriptions, tariffs, manual balance and system
      statistics.
  - name: State API
    description: >-
      Monitoring the performance of the service, connections to PostgreSQL and
      Redis.
  - name: AI Audio
  - name: AI Studio
  - name: AI administration
  - name: API Keys
  - name: Admin API - Servers
  - name: Administration of E-Coins
  - name: CDN
  - name: CDN Domains
  - name: CDN V3
  - name: Custom Webhooks
  - name: Management API - Servers
  - name: Management API - Tokens
  - name: Organization redirects V3
  - name: Private files and library
  - name: Рекламные кампании V3
paths:
  /keys:
    post:
      tags:
        - API Keys
      summary: Regenerate keys
      description: >-
        Reissues the API and/or WebSocket key. The old one stops working;
        permissions and subscriptions move to the new one.


        A key may be rotated once every five minutes; respect Retry-After on
        429. Successful rotation is audited with key ID and IP, without the
        secret.
      parameters:
        - name: api
          in: query
          description: Перегенерировать HTTP API ключ
          schema:
            type: boolean
          example: true
        - name: websocket
          in: query
          description: Перегенерировать WebSocket ключ
          schema:
            type: boolean
          example: true
      responses:
        '200':
          description: Token(s) have been successfully regenerated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
                  oldToken:
                    type: string
                  newToken:
                    type: string
                  token:
                    type: string
                  apiKey:
                    type: string
                  key:
                    type: string
                  userId:
                    type: string
                  serverId:
                    type: string
              example:
                success: true
                message: API key regenerated successfully
                oldToken: a8Fk2L...hJkL
                newToken: Zp4Kq9LmQ2xXc7VbN3sDf6GhJ1kLp0QwErTyUiOpAsDfGhW8
                token: Zp4Kq9LmQ2xXc7VbN3sDf6GhJ1kLp0QwErTyUiOpAsDfGhW8
                apiKey: Zp4Kq9LmQ2xXc7VbN3sDf6GhJ1kLp0QwErTyUiOpAsDfGhW8
                key: Zp4Kq9LmQ2xXc7VbN3sDf6GhJ1kLp0QwErTyUiOpAsDfGhW8
                userId: '123456789012345678'
                serverId: '12345678'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
        - ApiKeyHeader: []
        - WebSocketKeyHeader: []
        - ApiKeyHeader: []
          WebSocketKeyHeader: []
components:
  responses:
    BadRequestError:
      description: Bad Request (400) - invalid request parameters.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missing_params:
              summary: Missing Parameters (5002)
              value:
                code: 5002
                message: Missing Parameters
            invalid_json:
              summary: Invalid JSON (5034)
              value:
                code: 5034
                message: Invalid Json
            invalid_param:
              summary: Invalid Param Name (5004)
              value:
                code: 5004
                message: Invalid Param Name
    UnauthorizedError:
      description: Unauthorized (401) — the API token is missing or invalid.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missing_token:
              summary: Missing Token (5007)
              value:
                code: 5007
                message: Missing Token
            invalid_token:
              summary: Invalid Token (5008)
              value:
                code: 5008
                message: Invalid Token
    InternalServerError:
      description: Internal Server Error (500) - internal server error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            internal:
              summary: Internal Error (5017)
              value:
                code: 5017
                message: Internal Error
  schemas:
    ErrorResponse:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: integer
          example: 5009
          description: Numeric error code ER:LC Russia API.
        message:
          type: string
          example: Forbidden
          description: System error message in English.
  securitySchemes:
    ApiKeyHeader:
      type: apiKey
      in: header
      name: erlcrussia-api-key
      description: >-
        Custom API key. Store on the server; do not include client-side
        JavaScript.
    WebSocketKeyHeader:
      type: apiKey
      in: header
      name: erlcrussia-websocket-key
      description: Single WebSocket key header erlcrussia-websocket-key.

````

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