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

# Update User Subscription

> Update user subscription.

Actions:
- **extend**: Extend subscription by X days
- **set_end_date**: Set specific end date
- **change_tariff**: Change subscription tariff
- **set_traffic**: Set traffic limit and/or used traffic
- **toggle_autopay**: Enable/disable autopay
- **cancel**: Cancel subscription (set status to expired)
- **activate**: Activate subscription
- **create**: Create new subscription if not exists



## OpenAPI

````yaml /openapi.json post /cabinet/admin/users/{user_id}/subscription
openapi: 3.1.0
info:
  title: Remnawave Bot Admin API
  version: 1.0.0
servers: []
security: []
tags:
  - name: health
    description: Проверка состояния сервера и базы данных
  - name: stats
    description: Общая и детальная статистика системы
  - name: logs
    description: Просмотр логов и ошибок
  - name: users
    description: Управление пользователями бота
  - name: subscriptions
    description: Управление подписками и ключами подключения
  - name: transactions
    description: Финансовые операции и платежи
  - name: partners
    description: Партнёрская программа
  - name: broadcasts
    description: Массовые рассылки пользователям
  - name: pages
    description: Информационные страницы (оферта, политика и др.)
  - name: welcome-texts
    description: Приветственные сообщения
  - name: main-menu
    description: Настройки главного меню бота
  - name: menu-layout
    description: Конструктор расположения кнопок меню
  - name: pinned-messages
    description: Закреплённые сообщения в чатах
  - name: notifications
    description: Системные уведомления
  - name: promo-codes
    description: Промокоды для скидок и бонусов
  - name: promo-groups
    description: Группы промо-акций
  - name: promo-offers
    description: Рекламные предложения
  - name: campaigns
    description: Рекламные кампании с UTM-трекингом
  - name: contests
    description: Конкурсы, розыгрыши и ежедневные задания
  - name: polls
    description: Опросы пользователей
  - name: remnawave
    description: RemnaWave интеграция (ноды, сквады, инбаунды)
  - name: servers
    description: Управление VPN-серверами
  - name: settings
    description: Настройки бота
  - name: backups
    description: Резервное копирование данных
  - name: auth
    description: Аутентификация и токены Web API
  - name: webhooks
    description: Webhook-обработчики внешних событий
  - name: miniapp
    description: API для Telegram Mini App
  - name: media
    description: Загрузка и хранение медиафайлов
  - name: support
    description: Система тикетов поддержки
  - name: ban-notifications
    description: Уведомления о банах пользователей
  - name: Landing Pages
    description: Публичные лендинги для привлечения клиентов
  - name: Cabinet Auth
    description: Авторизация через Telegram, email, виджет
  - name: Cabinet OAuth
    description: OAuth 2.0 провайдеры (Google, Яндекс, Discord, VK)
  - name: Cabinet Account Linking
    description: Привязка и отвязка аккаунтов провайдеров
  - name: Cabinet Account Merge
    description: Объединение нескольких аккаунтов в один
  - name: Cabinet Subscription
    description: Управление подписками, тарифами и ключами
  - name: Cabinet Balance
    description: Баланс, пополнение и сохранённые карты
  - name: Cabinet Gift
    description: Подарочные подписки — покупка и активация
  - name: Fortune Wheel
    description: Колесо фортуны с бонусами
  - name: Cabinet Withdrawal
    description: Вывод партнёрских средств
  - name: Cabinet Referral
    description: Реферальная программа
  - name: Cabinet Partner
    description: Партнёрская программа для пользователей
  - name: Cabinet Promo
    description: Промо-акции в личном кабинете
  - name: Cabinet Promocode
    description: Применение промокодов
  - name: Cabinet Contests
    description: Участие в конкурсах
  - name: Cabinet Polls
    description: Участие в опросах
  - name: Cabinet Tickets
    description: Тикеты поддержки
  - name: Cabinet Ticket Notifications
    description: Уведомления по тикетам
  - name: Cabinet Notifications
    description: Системные уведомления
  - name: Cabinet Info
    description: Информация о сервисе, FAQ, контакты
  - name: Cabinet Media
    description: Медиафайлы личного кабинета
  - name: Branding
    description: Брендирование и оформление кабинета
  - name: Cabinet Admin Users
    description: Управление пользователями через админ-панель
  - name: Cabinet Admin Ban System
    description: Система банов и блокировок
  - name: Admin RBAC
    description: Управление ролями и разрешениями
  - name: Admin RBAC Policies
    description: Политики контроля доступа
  - name: Admin RBAC Audit Log
    description: Журнал аудита действий
  - name: Cabinet Admin Tariffs
    description: Управление тарифами
  - name: Cabinet Admin Servers
    description: Управление серверами
  - name: Cabinet Admin RemnaWave
    description: RemnaWave интеграция из админ-панели
  - name: Cabinet Admin Payments
    description: Просмотр и управление платежами
  - name: Cabinet Admin Payment Methods
    description: Настройка способов оплаты
  - name: Admin Traffic
    description: Мониторинг трафика
  - name: Cabinet Admin Broadcasts
    description: Массовые рассылки из админ-панели
  - name: Cabinet Admin Campaigns
    description: Управление рекламными кампаниями
  - name: Cabinet Admin Channels
    description: Обязательные подписки на каналы
  - name: Cabinet Admin Pinned Messages
    description: Закреплённые сообщения
  - name: Cabinet Admin Landings
    description: Управление лендинговыми страницами
  - name: Cabinet Admin Apps
    description: VPN-приложения для скачивания
  - name: Cabinet Admin Updates
    description: Проверка обновлений бота
  - name: Admin Menu Layout
    description: Конструктор меню админ-панели
  - name: Admin Promo Groups
    description: Управление промо-группами
  - name: Admin Promo Offers
    description: Управление промо-предложениями
  - name: Admin Promocodes
    description: Управление промокодами
  - name: Admin Fortune Wheel
    description: Настройка колеса фортуны
  - name: Admin Email Templates
    description: Email-шаблоны
  - name: Admin Button Styles
    description: Стили кнопок интерфейса
  - name: Cabinet Admin Stats
    description: Статистика и аналитика
  - name: Cabinet Admin Sales Stats
    description: Статистика продаж и доходов
  - name: Cabinet Admin Referral Network
    description: Граф реферальной сети
  - name: Cabinet Admin Partners
    description: Управление партнёрами
  - name: Cabinet Admin Tickets
    description: Тикеты поддержки из админ-панели
  - name: Cabinet Admin Ticket Notifications
    description: Уведомления по тикетам
  - name: Cabinet Admin Withdrawals
    description: Выводы партнёрских средств
  - name: Admin Settings
    description: Системные настройки
paths:
  /cabinet/admin/users/{user_id}/subscription:
    post:
      tags:
        - Cabinet Admin Users
      summary: Update User Subscription
      description: |-
        Update user subscription.

        Actions:
        - **extend**: Extend subscription by X days
        - **set_end_date**: Set specific end date
        - **change_tariff**: Change subscription tariff
        - **set_traffic**: Set traffic limit and/or used traffic
        - **toggle_autopay**: Enable/disable autopay
        - **cancel**: Cancel subscription (set status to expired)
        - **activate**: Activate subscription
        - **create**: Create new subscription if not exists
      operationId: update_user_subscription_cabinet_admin_users__user_id__subscription_post
      parameters:
        - name: user_id
          in: path
          required: true
          schema:
            type: integer
            title: User Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateSubscriptionRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpdateSubscriptionResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    UpdateSubscriptionRequest:
      properties:
        action:
          type: string
          title: Action
          description: >-
            Action: extend, shorten, set_end_date, change_tariff, set_traffic,
            toggle_autopay, cancel
        days:
          anyOf:
            - type: integer
              maximum: 3650
              minimum: 1
            - type: 'null'
          title: Days
          description: Days to extend
        end_date:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: End Date
          description: New end date
        tariff_id:
          anyOf:
            - type: integer
            - type: 'null'
          title: Tariff Id
          description: New tariff ID
        traffic_limit_gb:
          anyOf:
            - type: integer
              minimum: 0
            - type: 'null'
          title: Traffic Limit Gb
          description: New traffic limit in GB
        traffic_used_gb:
          anyOf:
            - type: number
              minimum: 0
            - type: 'null'
          title: Traffic Used Gb
          description: Set traffic used in GB
        autopay_enabled:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Autopay Enabled
          description: Enable/disable autopay
        traffic_gb:
          anyOf:
            - type: integer
              minimum: 1
            - type: 'null'
          title: Traffic Gb
          description: Traffic GB to add
        traffic_purchase_id:
          anyOf:
            - type: integer
            - type: 'null'
          title: Traffic Purchase Id
          description: Traffic purchase ID to remove
        is_trial:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Is Trial
          description: Is trial subscription
        device_limit:
          anyOf:
            - type: integer
              minimum: 1
            - type: 'null'
          title: Device Limit
          description: Device limit
      type: object
      required:
        - action
      title: UpdateSubscriptionRequest
      description: Request to update user subscription.
    UpdateSubscriptionResponse:
      properties:
        success:
          type: boolean
          title: Success
        message:
          type: string
          title: Message
        subscription:
          anyOf:
            - $ref: '#/components/schemas/UserSubscriptionInfo'
            - type: 'null'
      type: object
      required:
        - success
        - message
      title: UpdateSubscriptionResponse
      description: Response after subscription update.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    UserSubscriptionInfo:
      properties:
        id:
          type: integer
          title: Id
        status:
          type: string
          title: Status
        is_trial:
          type: boolean
          title: Is Trial
        start_date:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Start Date
        end_date:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: End Date
        traffic_limit_gb:
          type: integer
          title: Traffic Limit Gb
          default: 0
        traffic_used_gb:
          type: number
          title: Traffic Used Gb
          default: 0
        device_limit:
          type: integer
          title: Device Limit
          default: 1
        tariff_id:
          anyOf:
            - type: integer
            - type: 'null'
          title: Tariff Id
        tariff_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Tariff Name
        autopay_enabled:
          type: boolean
          title: Autopay Enabled
          default: false
        is_active:
          type: boolean
          title: Is Active
          default: false
        days_remaining:
          type: integer
          title: Days Remaining
          default: 0
        purchased_traffic_gb:
          type: integer
          title: Purchased Traffic Gb
          default: 0
        traffic_purchases:
          items:
            $ref: '#/components/schemas/TrafficPurchaseItem'
          type: array
          title: Traffic Purchases
          default: []
      type: object
      required:
        - id
        - status
        - is_trial
      title: UserSubscriptionInfo
      description: User subscription information.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    TrafficPurchaseItem:
      properties:
        id:
          type: integer
          title: Id
        traffic_gb:
          type: integer
          title: Traffic Gb
        expires_at:
          type: string
          format: date-time
          title: Expires At
        created_at:
          type: string
          format: date-time
          title: Created At
        days_remaining:
          type: integer
          title: Days Remaining
        is_expired:
          type: boolean
          title: Is Expired
      type: object
      required:
        - id
        - traffic_gb
        - expires_at
        - created_at
        - days_remaining
        - is_expired
      title: TrafficPurchaseItem
      description: Individual traffic purchase record.
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````