> ## 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.

# Операции с мафиями

> Управление мафиями, членами и финансами.

Доступные действия:
- `create` - создать мафию (name, leaderId, leaderName, roleId, roleName, color)
- `delete` - удалить мафию (mafiaId)
- `addMoney` - добавить деньги в мафию (mafiaId, amount)
- `removeMoney` - забрать деньги из мафии (mafiaId, amount)
- `withdraw` - вывести деньги мафии пользователю (mafiaId, amount, targetUserId)
- `transfer` - перевод между мафиями (fromMafiaId, toMafiaId, amount, reason, authorId)
- `addMember` - добавить члена (mafiaId, userId, username, position)
- `removeMember` - удалить члена (mafiaId, userId)




## OpenAPI

````yaml ru/openapi/ru-economy-v2-openapi.yaml POST /moscowroleplay/civops/mafias
openapi: 3.1.0
info:
  title: ER:LC Россия API V2 - Moscow RolePlay API Экономики V2
  version: 2.0.0
servers:
  - url: https://api.erlcrussia.xyz/v2
    description: ER:LC Россия API V2
security: []
tags:
  - name: Moscow RolePlay API Экономики V2
    description: Эндпоинты для управления экономикой и CivOps системой.
paths:
  /moscowroleplay/civops/mafias:
    post:
      tags:
        - Moscow RolePlay API Экономики V2
      summary: Операции с мафиями
      description: >
        Управление мафиями, членами и финансами.


        Доступные действия:

        - `create` - создать мафию (name, leaderId, leaderName, roleId,
        roleName, color)

        - `delete` - удалить мафию (mafiaId)

        - `addMoney` - добавить деньги в мафию (mafiaId, amount)

        - `removeMoney` - забрать деньги из мафии (mafiaId, amount)

        - `withdraw` - вывести деньги мафии пользователю (mafiaId, amount,
        targetUserId)

        - `transfer` - перевод между мафиями (fromMafiaId, toMafiaId, amount,
        reason, authorId)

        - `addMember` - добавить члена (mafiaId, userId, username, position)

        - `removeMember` - удалить члена (mafiaId, userId)
      parameters:
        - name: action
          in: query
          description: Тип операции.
          required: true
          schema:
            type: string
            enum:
              - create
              - delete
              - addMoney
              - removeMoney
              - withdraw
              - transfer
              - addMember
              - removeMember
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
            examples:
              create:
                summary: Создать мафию
                value:
                  name: UKpanik
                  leaderId: '1104388035199639585'
                  leaderName: forziknerves
                  roleId: '1473315569175625811'
                  roleName: Состоит в ОПГ "UKpanik"
                  color: '#060568'
              delete:
                summary: Удалить мафию
                value:
                  mafiaId: 2KH2WQEO
              addMoney:
                summary: Добавить деньги в мафию
                value:
                  mafiaId: 2KH2WQEO
                  amount: 10000
              removeMoney:
                summary: Снять деньги с мафии
                value:
                  mafiaId: 2KH2WQEO
                  amount: 5000
              withdraw:
                summary: Вывести деньги с мафии на счет пользователя
                value:
                  mafiaId: 2KH2WQEO
                  amount: 3000
                  targetUserId: '1170030084300742680'
              transfer:
                summary: Перевод между мафиями
                value:
                  fromMafiaId: 2KH2WQEO
                  toMafiaId: OTHER123ID
                  amount: 5000
                  reason: Взятка за покровительство
                  authorId: '1104388035199639585'
              addMember:
                summary: Добавить участника в мафию
                value:
                  mafiaId: 2KH2WQEO
                  userId: '1170030084300742680'
                  username: NewMember
                  position: Участник
              removeMember:
                summary: Удалить участника из мафии
                value:
                  mafiaId: 2KH2WQEO
                  userId: '1170030084300742680'
      responses:
        '200':
          description: Операция успешно выполнена.
          content:
            application/json:
              schema:
                type: object
              examples:
                create:
                  summary: Мафия создана.
                  value:
                    success: true
                    mafiaId: 2KH2WQEO
                    name: UKpanik
                    leader_id: '1104388035199639585'
                    leader_name: forziknerves
                    role_id: '1473315569175625811'
                    role_name: Состоит в ОПГ "UKpanik"
                    leader_role_id: '1473315758783201354'
                    leader_role_name: Лидер ОПГ "UKpanik"
                    channel_id: '1473316097032716381'
                    channel_name: 💬┃ukpanik
                    color: '#060568'
                    created_at: 1776881763
                    bank: 0
                addMember:
                  summary: Участник добавлен.
                  value:
                    success: true
                    mafiaId: 2KH2WQEO
                    userId: '1170030084300742680'
                    username: NewMember
                    position: Участник
                transfer:
                  summary: Перевод выполнен.
                  value:
                    success: true
                    transferId: V0CWNF2J
                    fromMafiaId: 2KH2WQEO
                    toMafiaId: OTHER123ID
                    amount: 5000
                    reason: Взятка за покровительство
        '400':
          description: >-
            Ошибка запроса (отсутствуют обязательные поля или неизвестный
            action).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          $ref: '#/components/responses/UnauthorizedMissingOrInvalidToken'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
        - MRPAPIKey: []
components:
  schemas:
    ErrorResponse:
      type: object
      description: Стандартный формат ошибки.
      required:
        - code
        - message
      properties:
        code:
          type: integer
          description: Код ошибки API.
          example: 5007
        message:
          type: string
          description: Сообщение/идентификатор ошибки.
          example: Missing Token
    UnauthorizedError:
      type: object
      description: Ошибка аутентификации (отсутствует или неверный токен).
      required:
        - code
        - message
      properties:
        code:
          type: integer
          example: 5007
        message:
          type: string
          example: Missing Token
    ForbiddenError:
      type: object
      description: Ошибка доступа (запрещено).
      required:
        - code
        - message
      properties:
        code:
          type: integer
          example: 5009
        message:
          type: string
          example: Forbidden
    RateLimitError:
      type: object
      description: Ошибка превышения лимита запросов.
      required:
        - code
        - message
      properties:
        code:
          type: integer
          example: 6021
        message:
          type: string
          example: Rate Limit Exceeded
        retry_after:
          type: integer
          description: Время до сброса лимита в секундах.
          example: 30
    EconomyApiError:
      type: object
      description: Ошибка API Экономики.
      required:
        - code
        - message
      properties:
        code:
          type: integer
          example: 6010
        message:
          type: string
          example: Business not found
  responses:
    UnauthorizedMissingOrInvalidToken:
      description: Ошибка аутентификации.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/UnauthorizedError'
          examples:
            Missing Token:
              summary: Нет токена.
              value:
                code: 5007
                message: Missing Token
            Invalid Token:
              summary: Неверный или деактивированный токен.
              value:
                code: 5008
                message: Invalid Token
            Invalid Master Key:
              summary: Неверный мастер-ключ.
              value:
                code: 5006
                message: Invalid Master Key
    Forbidden:
      description: Доступ запрещён.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ForbiddenError'
          examples:
            Forbidden:
              summary: Нет прав доступа к эндпоинту.
              value:
                code: 5009
                message: Forbidden
            Api Version Forbidden:
              summary: Доступ к этой версии API запрещён.
              value:
                code: 5010
                message: Api Version Forbidden
            Query Param Forbidden:
              summary: Query-параметр запрещён.
              value:
                code: 5011
                message: Query Param Forbidden
    TooManyRequests:
      description: Превышено количество запросов.
      headers:
        X-RateLimit-Limit:
          description: Максимум запросов в минуту.
          schema:
            type: integer
            example: 60
        X-RateLimit-Remaining:
          description: Оставшееся количество запросов.
          schema:
            type: integer
            example: 0
        Retry-After:
          description: Секунд до сброса лимита.
          schema:
            type: integer
            example: 30
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitError'
          examples:
            Rate Limit Exceeded:
              summary: Превышение лимита запросов.
              value:
                code: 6021
                message: Rate Limit Exceeded
                retry_after: 30
    InternalServerError:
      description: Внутренняя ошибка сервера.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/EconomyApiError'
          examples:
            Internal Server Error Occurred:
              summary: Ошибка API экономики.
              value:
                code: 6005
                message: Internal Server Error Occurred.
  securitySchemes:
    MRPAPIKey:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: |
        API ключ для доступа к эндпоинтам Гражданских Операций.

        Передается в заголовке `Authorization: Bearer <ключ>`.

        ОБЯЗАТЕЛЕН ДЛЯ ВСЕХ ЭНДПОИНТОВ ГРАЖДАНСКИХ ОПЕРАЦИЙ (кроме /health).

````