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

# Business Operations

> Manage businesses, employees, products, and finances.

Available actions:
- `request` - create business request (userId, username, name, form, channelId).
- `approve` - approve request (requestId, approverId, +business fields).
- `cancelRequest` - cancel/delete pending request (requestId).
- `create` - direct business creation (businessData).
- `delete` - delete business (businessId).
- `addMoney` - add money to business (businessId, amount).
- `removeMoney` - remove money from business (businessId, amount).
- `withdraw` - withdraw business money to user (businessId, amount, targetUserId).
- `transfer` - transfer between businesses (fromBusinessId, toBusinessId, amount, reason, authorId).
- `addEmployee` - add employee (businessId, userId, username, position).
- `removeEmployee` - fire employee (businessId, userId).
- `addProduct` - add product (businessName, item).
- `removeProduct` - remove product (businessName, itemName).
- `buyProduct` - buy product from business (userId, businessName, itemName, quantity).
- `returnMoney` - refund money for transaction (businessId, transactionId).




## OpenAPI

````yaml en/openapi/en-economy-v2-openapi.yaml POST /moscowroleplay/civops/businesses
openapi: 3.1.0
info:
  title: ER:LC Russia API V2 - Moscow RolePlay Economy API V2
  version: 2.0.0
servers:
  - url: https://api.erlcrussia.xyz/v2
    description: ER:LC Russia API V2
security: []
tags:
  - name: Moscow RolePlay Economy API V2
    description: Endpoints for managing economy and CivOps system.
paths:
  /moscowroleplay/civops/businesses:
    post:
      tags:
        - Moscow RolePlay Economy API V2
      summary: Business Operations
      description: >
        Manage businesses, employees, products, and finances.


        Available actions:

        - `request` - create business request (userId, username, name, form,
        channelId).

        - `approve` - approve request (requestId, approverId, +business fields).

        - `cancelRequest` - cancel/delete pending request (requestId).

        - `create` - direct business creation (businessData).

        - `delete` - delete business (businessId).

        - `addMoney` - add money to business (businessId, amount).

        - `removeMoney` - remove money from business (businessId, amount).

        - `withdraw` - withdraw business money to user (businessId, amount,
        targetUserId).

        - `transfer` - transfer between businesses (fromBusinessId,
        toBusinessId, amount, reason, authorId).

        - `addEmployee` - add employee (businessId, userId, username, position).

        - `removeEmployee` - fire employee (businessId, userId).

        - `addProduct` - add product (businessName, item).

        - `removeProduct` - remove product (businessName, itemName).

        - `buyProduct` - buy product from business (userId, businessName,
        itemName, quantity).

        - `returnMoney` - refund money for transaction (businessId,
        transactionId).
      parameters:
        - name: action
          in: query
          description: Operation type.
          required: true
          schema:
            type: string
            enum:
              - request
              - approve
              - cancelRequest
              - create
              - delete
              - addMoney
              - removeMoney
              - withdraw
              - transfer
              - addEmployee
              - removeEmployee
              - addProduct
              - removeProduct
              - buyProduct
              - returnMoney
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
            examples:
              request:
                summary: Create business request (stage 1)
                value:
                  userId: '760966468715937814'
                  username: ttunku_pal
                  name: Roma Aeterna
                  form: ООО
                  channelId: '1432651696210841760'
              cancelRequest:
                summary: Cancel pending business request (remove from waiting)
                value:
                  requestId: req_abc123
              approve:
                summary: Approve request and create business (stage 2)
                value:
                  requestId: req_abc123
                  approverId: '1133665013794607114'
                  guildId: '1133665013794607114'
                  ownerId: '760966468715937814'
                  ownerName: ttunku_pal
                  channelId: '1432651696210841760'
                  channelName: roma-aeterna
                  roleId: '1432651691987304522'
                  roleName: Roma Aeterna
                  employeeRoleId: '1432651694289846302'
                  employeeRoleName: Сотрудник Бизнеса Roma Aeterna
                  description: >-
                    В «Roma Aeterna» мы верим, что лучшие беседы рождаются за
                    вкусной едой.
                  address: 2221 Southern Avenue
                  createChannel: true
                  createRoles: true
              delete:
                summary: Delete business with all Discord objects
                value:
                  businessId: UCEW29
                  guildId: '1133665013794607114'
              create:
                summary: Direct business creation
                value:
                  businessData:
                    name: Roma Aeterna
                    owner_id: '760966468715937814'
                    form: ООО
              addMoney:
                summary: Add money to business
                value:
                  businessId: UCEW29
                  amount: 5000
              removeMoney:
                summary: Remove money from business
                value:
                  businessId: UCEW29
                  amount: 5000
              withdraw:
                summary: Withdraw money from business to user account
                value:
                  businessId: UCEW29
                  amount: 1000
                  targetUserId: '1133665013794607114'
              transfer:
                summary: Transfer between businesses
                value:
                  fromBusinessId: UCEW29
                  toBusinessId: RAWDB4
                  amount: 5000
                  reason: Оплата услуг
                  authorId: '1133665013794607114'
              addEmployee:
                summary: Add employee to business
                value:
                  businessId: UCEW29
                  userId: '1335499851273601029'
                  username: ytkaytkovich_16555
                  position: Сотрудник
                  guildId: '1133665013794607114'
              removeEmployee:
                summary: Remove employee from business
                value:
                  businessId: UCEW29
                  userId: '1335499851273601029'
                  guildId: '1133665013794607114'
              addProduct:
                summary: Add product to business store
                value:
                  businessName: Roma Aeterna
                  item:
                    name: ☕ 1. Noctis Amor
                    price_buy: 250
                    description: >-
                      («Любовь ночи») Густой эспрессо с ванильной пенкой и
                      каплей карамели.
                    quantity: 100
              removeProduct:
                summary: Remove product from business store
                value:
                  businessName: Roma Aeterna
                  itemName: ☕ 1. Noctis Amor
              buyProduct:
                summary: Buy product from business
                value:
                  userId: '1133665013794607114'
                  businessName: Roma Aeterna
                  itemName: ☕ 1. Noctis Amor
                  quantity: 1
              returnMoney:
                summary: Refund money for transaction (product return)
                value:
                  businessId: UCEW29
                  transactionId: txn_20241201_xyz789
      responses:
        '200':
          description: Operation successfully completed.
          content:
            application/json:
              schema:
                type: object
              examples:
                request:
                  summary: Request created.
                  value:
                    success: true
                    requestId: req_123
                    status: pending
                    message: Request created, awaiting approval
                approve:
                  summary: Business approved and created.
                  value:
                    success: true
                    businessId: UCEW29
                    name: Roma Aeterna
                    status: active
                    owner_id: '760966468715937814'
                    owner_name: ttunku_pal
                cancelRequest:
                  summary: Request cancelled.
                  value:
                    success: true
                    requestId: req_abc123
                    action: cancelled
                    removedFromMemory: true
                    removedFromDB: false
                    message: Pending request has been cancelled and removed
                buyProduct:
                  summary: Product purchased.
                  value:
                    success: true
                    userId: '1133665013794607114'
                    businessName: Roma Aeterna
                    item: ☕ 1. Noctis Amor
                    quantity: 1
                    totalPrice: 250
        '400':
          description: Request error (missing required fields or unknown 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: Standard error format.
      required:
        - code
        - message
      properties:
        code:
          type: integer
          description: API error code.
          example: 5007
        message:
          type: string
          description: Error message/identifier.
          example: Missing Token
    UnauthorizedError:
      type: object
      description: Authentication error (missing or invalid token).
      required:
        - code
        - message
      properties:
        code:
          type: integer
          example: 5007
        message:
          type: string
          example: Missing Token
    ForbiddenError:
      type: object
      description: Access error (forbidden).
      required:
        - code
        - message
      properties:
        code:
          type: integer
          example: 5009
        message:
          type: string
          example: Forbidden
    RateLimitError:
      type: object
      description: Request limit exceeded error.
      required:
        - code
        - message
      properties:
        code:
          type: integer
          example: 6021
        message:
          type: string
          example: Rate Limit Exceeded
        retry_after:
          type: integer
          description: Time until limit reset in seconds.
          example: 30
    EconomyApiError:
      type: object
      description: Economy API error.
      required:
        - code
        - message
      properties:
        code:
          type: integer
          example: 6010
        message:
          type: string
          example: Business not found
  responses:
    UnauthorizedMissingOrInvalidToken:
      description: Authentication error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/UnauthorizedError'
          examples:
            Missing Token:
              summary: No token.
              value:
                code: 5007
                message: Missing Token
            Invalid Token:
              summary: Invalid or deactivated token.
              value:
                code: 5008
                message: Invalid Token
            Invalid Master Key:
              summary: Invalid master key.
              value:
                code: 5006
                message: Invalid Master Key
    Forbidden:
      description: Access forbidden.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ForbiddenError'
          examples:
            Forbidden:
              summary: No access rights to endpoint.
              value:
                code: 5009
                message: Forbidden
            Api Version Forbidden:
              summary: Access to this API version is forbidden.
              value:
                code: 5010
                message: Api Version Forbidden
            Query Param Forbidden:
              summary: Query parameter is forbidden.
              value:
                code: 5011
                message: Query Param Forbidden
    TooManyRequests:
      description: Request limit exceeded.
      headers:
        X-RateLimit-Limit:
          description: Maximum requests per minute.
          schema:
            type: integer
            example: 60
        X-RateLimit-Remaining:
          description: Remaining number of requests.
          schema:
            type: integer
            example: 0
        Retry-After:
          description: Seconds until limit reset.
          schema:
            type: integer
            example: 30
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitError'
          examples:
            Rate Limit Exceeded:
              summary: Request limit exceeded.
              value:
                code: 6021
                message: Rate Limit Exceeded
                retry_after: 30
    InternalServerError:
      description: Internal server error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/EconomyApiError'
          examples:
            Internal Server Error Occurred:
              summary: Economy API error.
              value:
                code: 6005
                message: Internal Server Error Occurred.
  securitySchemes:
    MRPAPIKey:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: |
        API key for accessing CivOps endpoints.

        Passed in the `Authorization: Bearer <key>` header.

        REQUIRED FOR ALL CIVOPS ENDPOINTS (except /health).

````