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

# Upgrade viewers

> Increase an order's viewer limit. Use max_amount to set the maximum charge.

1. [Get a quote](/api-reference/endpoints/purchases/actions/upgrade-viewers-quote) for the new total viewer limit.
2. Send the same `target_viewers` and the quoted `amount` as `max_amount`.
3. Read the actual cost from `amount` and the payment ID from `payment_id`.

If the cost exceeds `max_amount`, the API returns `409 price_changed` without applying the upgrade. Request a new quote before trying again. Omit `max_amount` or pass `null` to allow the upgrade without a spending limit.

The new viewer limit also applies to future renewals. The upgrade does not extend the order duration. In the response, `status: "completed"` refers to the upgrade payment; the original order can continue running.


## OpenAPI

````yaml POST /purchases/{orderId}/upgrade-viewers
openapi: 3.0.0
info:
  title: StreamSkill - OpenApi 3.0
  description: ''
  termsOfService: https://streamskill.pro/en/privacy_policy
  version: 1.0.0
  contact:
    email: streamskillpro@gmail.com
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
  - url: https://api.streamskill.pro/v1
    description: Production server - v1
security:
  - bearerAuth: []
paths:
  /purchases/{orderId}/upgrade-viewers:
    parameters:
      - name: orderId
        in: path
        required: true
        description: ID of the order to upgrade.
        schema:
          type: integer
          format: int64
          minimum: 1
      - $ref: '#/components/parameters/Accept-Language'
    post:
      summary: Upgrade viewers
      description: >-
        Increase an order's viewer limit. Use max_amount to set the maximum
        charge.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpgradeViewersRequest'
            example:
              target_viewers: 200
              max_amount: 12.5
      responses:
        '200':
          description: Viewer limit increased successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpgradeViewersResult'
              example:
                to_viewers: 200
                remaining_seconds: 3600
                amount: 12.5
                currency: usd
                payment_id: 12346
                status: completed
        '402':
          $ref: '#/components/responses/InsufficientFunds'
        '404':
          $ref: '#/components/responses/NotFound'
        '405':
          $ref: '#/components/responses/NotAllowed'
        '409':
          $ref: '#/components/responses/ViewersUpgradeConflict'
        '422':
          $ref: '#/components/responses/validationError'
components:
  parameters:
    Accept-Language:
      name: Accept-Language
      in: header
      required: false
      description: The language of the response
      schema:
        $ref: '#/components/schemas/LanguageObject'
  schemas:
    UpgradeViewersRequest:
      type: object
      required:
        - target_viewers
      properties:
        target_viewers:
          type: integer
          description: >-
            New total viewer limit. For example, send 200 to increase from 100
            to 200 viewers. Must exceed the current limit and stay within the
            maximum allowed for the order.
          example: 200
        max_amount:
          type: number
          minimum: 0
          nullable: true
          description: >-
            Maximum amount you agree to pay, in the quoted currency. If the cost
            exceeds this limit, the API returns 409 price_changed without
            applying the upgrade. Omit or pass null for no spending limit.
          example: 12.5
    UpgradeViewersResult:
      allOf:
        - $ref: '#/components/schemas/UpgradeViewersQuote'
        - type: object
          required:
            - payment_id
            - status
          properties:
            payment_id:
              type: integer
              description: ID of the upgrade payment.
              example: 12346
            status:
              type: string
              enum:
                - completed
              description: Status of the upgrade payment, not the original order.
              example: completed
    LanguageObject:
      type: string
      enum:
        - en
        - ru
      default: en
    UpgradeViewersQuote:
      type: object
      required:
        - to_viewers
        - remaining_seconds
        - amount
        - currency
      properties:
        to_viewers:
          type: integer
          description: New total viewer limit.
          example: 200
        remaining_seconds:
          type: integer
          minimum: 0
          description: Remaining order time in seconds.
          example: 3600
        amount:
          type: number
          minimum: 0.01
          description: Cost of the upgrade in the returned currency, including discounts.
          example: 12.5
        currency:
          $ref: '#/components/schemas/CurrencyObject'
    InsufficientFundsErrorObject:
      allOf:
        - $ref: '#/components/schemas/ErrorObject'
        - type: object
          required:
            - required_balance
            - current_balance
          properties:
            required_balance:
              type: number
              description: Amount required to complete the operation.
            current_balance:
              type: number
              description: Available account balance in the same currency.
    ErrorObject:
      type: object
      required:
        - error_code
        - name
        - message
        - code
        - status
        - type
      properties:
        error_code:
          type: string
          description: Error identifier for handling the response in your application.
        name:
          type: string
          description: Localized error message; equal to message.
        message:
          type: string
          description: Localized explanation of the error.
        code:
          type: integer
          description: Error code, usually 0.
        status:
          type: integer
          description: HTTP status code.
        type:
          type: string
          description: Error type.
    ValidationErrorObject:
      allOf:
        - $ref: '#/components/schemas/ErrorObject'
        - type: object
          required:
            - errors
          properties:
            errors:
              type: object
              description: >-
                Validation messages grouped by field name. Nested fields may use
                dot notation, such as ids.0.
              additionalProperties:
                type: array
                items:
                  type: string
    CurrencyObject:
      type: string
      enum:
        - usd
        - rub
      example: usd
  responses:
    InsufficientFunds:
      description: Insufficient balance.
      headers:
        Date:
          $ref: '#/components/headers/Date'
        Server:
          $ref: '#/components/headers/Server'
        Content-Length:
          $ref: '#/components/headers/Content-Length'
        Keep-Alive:
          $ref: '#/components/headers/Keep-Alive'
        Connection:
          $ref: '#/components/headers/Connection'
        Content-Type:
          $ref: '#/components/headers/Content-Type'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/InsufficientFundsErrorObject'
          example:
            error_code: insufficient_funds
            name: Insufficient funds
            message: Insufficient funds
            code: 0
            status: 402
            type: insufficient_funds_exception
            required_balance: 100
            current_balance: 50
    NotFound:
      description: The requested resource was not found or is not accessible.
      headers:
        Date:
          $ref: '#/components/headers/Date'
        Server:
          $ref: '#/components/headers/Server'
        Content-Length:
          $ref: '#/components/headers/Content-Length'
        Keep-Alive:
          $ref: '#/components/headers/Keep-Alive'
        Connection:
          $ref: '#/components/headers/Connection'
        Content-Type:
          $ref: '#/components/headers/Content-Type'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorObject'
          example:
            error_code: not_found
            name: Record not found.
            message: Record not found.
            code: 0
            status: 404
            type: record_not_found_exception
    NotAllowed:
      description: This action is unavailable for the order.
      headers:
        Date:
          $ref: '#/components/headers/Date'
        Server:
          $ref: '#/components/headers/Server'
        Content-Length:
          $ref: '#/components/headers/Content-Length'
        Keep-Alive:
          $ref: '#/components/headers/Keep-Alive'
        Connection:
          $ref: '#/components/headers/Connection'
        Content-Type:
          $ref: '#/components/headers/Content-Type'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorObject'
          example:
            error_code: not_supported
            name: Action is not available for this order
            message: Action is not available for this order
            code: 0
            status: 405
            type: action_unavailable
    ViewersUpgradeConflict:
      description: >-
        The order is already completed (already_done), or the upgrade cost
        exceeds max_amount (price_changed). For price_changed, no upgrade is
        applied; request a new quote.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorObject'
          examples:
            priceChanged:
              summary: Cost exceeds max_amount
              value:
                error_code: price_changed
                name: >-
                  The price has changed since the quote was calculated. Refresh
                  the quote and try again.
                message: >-
                  The price has changed since the quote was calculated. Refresh
                  the quote and try again.
                code: 0
                status: 409
                type: price_changed_exception
            completedOrder:
              summary: Order already completed
              value:
                error_code: already_done
                name: Order already completed
                message: Order already completed
                code: 0
                status: 409
                type: purchase_done
    validationError:
      description: Validation Error
      headers:
        Date:
          $ref: '#/components/headers/Date'
        Server:
          $ref: '#/components/headers/Server'
        Content-Length:
          $ref: '#/components/headers/Content-Length'
        Keep-Alive:
          $ref: '#/components/headers/Keep-Alive'
        Connection:
          $ref: '#/components/headers/Connection'
        Content-Type:
          $ref: '#/components/headers/Content-Type'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ValidationErrorObject'
          example:
            error_code: validation_error
            name: The Channel field is required.
            message: The Channel field is required.
            code: 0
            status: 422
            type: validate_exception
            errors:
              channel:
                - The Channel field is required.
  headers:
    Date:
      schema:
        type: string
        example: Sat, 25 May 2024 23:59:59 GMT
    Server:
      schema:
        type: string
        example: Apache/2.4.38 (Debian)
    Content-Length:
      schema:
        type: integer
        example: '100'
    Keep-Alive:
      schema:
        type: string
        example: timeout=5, max=100
    Connection:
      schema:
        type: string
        example: Keep-Alive
    Content-Type:
      schema:
        type: string
      example: application/json; charset=UTF-8
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````

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