# Bitstream admin API. Contract between bs-control, the web SPA and integrators.
openapi: 3.1.0
info:
  title: Bitstream Admin API
  version: 1.0.0
  description: |-
    Admin API of Bitstream, an IPTV management panel. Everything the web panel does goes through this API, so anything you can click you can automate.

    This document is for people and for AI agents. Each operation lists the roles that may call it (`x-roles`) and the API key scopes it needs (`x-required-scopes`). The client facing Xtream compatible API (`player_api.php`, `get.php`, `xmltv.php`, stream URLs) is not part of this spec; see `spec/client-api.md`.

    ## Base URL

    All paths are relative to `https://<your panel>/api/v1`. JSON in and out, UTF-8, snake_case field names. Times are RFC 3339 in UTC. Ids are 64 bit integers.

    ## Authentication

    There are two ways to authenticate. Both use the `Authorization: Bearer ...` header.

    ### 1. Access tokens (people and the web panel)

    1. `POST /auth/login` with `username`, `password` and, if 2FA is on, `totp_code`.
    2. The response body has `access_token`, an EdDSA (Ed25519) JWT valid for 15 minutes. Send it as `Authorization: Bearer <access_token>`.
    3. The response also sets a `bs_refresh` cookie (httpOnly, Secure, SameSite=Strict, scoped to `/api/v1/auth`). Before the access token expires, call `POST /auth/refresh`; it returns a new access token and rotates the cookie.
    4. Each refresh token works once. If an old one is presented again, every session of that login is revoked (token theft protection), and the user must sign in again.
    5. `POST /auth/logout` revokes the session.

    2FA uses TOTP (RFC 6238, 30 second steps, 6 digits): `POST /auth/2fa/enroll`, then `POST /auth/2fa/verify`.

    ### 2. API keys (integrations, scripts, agents)

    Create a key in the panel or with `POST /api-keys`. The full key is shown once and looks like `bsk_<prefix>_<secret>`, where `prefix` is 8 lowercase letters or digits. Send it as:

    ```
    Authorization: Bearer bsk_a1b2c3d4_Q2xvdWQgc2VjcmV0IGtleSBleGFtcGxl
    ```

    A key acts as the user who created it, limited to the key `scopes`. The effective permission is the intersection of the owner permissions and the key scopes, so a reseller key can never do more than that reseller. Keys can have an IP allowlist (`allowed_ips`, CIDR list) and an expiry. A few account operations (2FA, password, creating keys) need an access token and refuse API keys.

    #### Optional request signing

    When a key has `require_signature: true`, every request must also carry:

    | Header | Value |
    |---|---|
    | `X-BS-Timestamp` | Unix time in seconds. Must be within 5 minutes of the server clock. |
    | `X-BS-Nonce` | Random string, 16 to 64 characters. Each nonce is accepted once within the 5 minute window. |
    | `X-BS-Signature` | Lowercase hex of `HMAC-SHA256(secret, string_to_sign)`. |

    `secret` is the part of the key after the second underscore. `string_to_sign` is:

    ```
    METHOD + "\n" + PATH_WITH_QUERY + "\n" + TIMESTAMP + "\n" + NONCE + "\n" + hex(sha256(BODY))
    ```

    - `METHOD` is upper case (`POST`).
    - `PATH_WITH_QUERY` is the request target exactly as sent, starting at `/api/v1`, for example `/api/v1/lines?page=2`.
    - `BODY` is the raw request body bytes; for an empty body use the SHA-256 of the empty string (`e3b0c442...b855`).

    Example in shell:

    ```
    ts=$(date +%s); nonce=$(openssl rand -hex 16); body='{"periods":1}'
    sig=$(printf 'POST\n/api/v1/lines/812/renew\n%s\n%s\n%s' "$ts" "$nonce" "$(printf %s "$body" | sha256sum | cut -d' ' -f1)" \
          | openssl dgst -sha256 -hmac "$SECRET" -hex | sed 's/^.* //')
    curl -X POST https://panel.example.com/api/v1/lines/812/renew \
      -H "Authorization: Bearer $KEY" -H "X-BS-Timestamp: $ts" -H "X-BS-Nonce: $nonce" \
      -H "X-BS-Signature: $sig" -H 'Content-Type: application/json' -d "$body"
    ```

    Signature failures return `401` with code `bad_signature`, `stale_timestamp` or `nonce_reused`.

    ## Roles, permissions and reseller scope

    - `admin`: everything allowed by their group.
    - `reseller`: only their own data and their tree. A reseller sees and changes lines, sub-resellers, connections and tickets that belong to them or to any reseller below them. Anything outside the tree answers `404`, not `403`, so ids cannot be probed.
    - Group permissions use the same strings as API key scopes. `GET /me` returns the effective list.

    ## Errors

    Every error uses one envelope:

    ```json
    {"error": {"code": "validation_failed", "message": "Some fields are invalid.", "details": {"fields": {"username": "already taken"}}}}
    ```

    `code` is stable and safe to branch on. `message` is for humans and may change. `details` is optional. Common codes: `validation_failed`, `unauthorized`, `totp_required`, `refresh_reused`, `missing_scope`, `forbidden`, `ip_not_allowed`, `not_found`, `already_exists`, `conflict`, `insufficient_credits`, `rate_limited`, `internal`.

    ## Lists and pagination

    List endpoints take `page` (from 1), `per_page` (default 50, max 500), `sort` (field, `-field` for descending, comma separated) and `q` (text search), plus filters documented per endpoint. They return:

    ```json
    {"data": [...], "meta": {"page": 1, "per_page": 50, "total": 1234}}
    ```

    Single resources are returned as plain objects. Create returns `201` with the object. Delete returns `204`. Partial updates use `PATCH` with only the fields to change.

    ## Rate limits

    Limits are per API key, or per user for access tokens, plus a per IP limit on `/auth/*`. Default: 600 requests per minute per key or user, 10 login attempts per minute per IP. Every response carries:

    - `X-RateLimit-Limit`: requests allowed in the window.
    - `X-RateLimit-Remaining`: requests left.
    - `X-RateLimit-Reset`: Unix time when the window resets.

    Over the limit you get `429` with `Retry-After` (seconds). Back off and retry after that.

    ## Bulk operations

    Endpoints named `/bulk` take a list of ids and an action. They process every id and report `succeeded` and `failed` separately; one bad id does not stop the rest.

    ## Monitoring

    Prometheus metrics are served at `/metrics` on the control and on each node (not under `/api/v1`). Access is controlled by settings group `monitoring`.
  license:
    name: AGPL-3.0-only
    identifier: AGPL-3.0-only
servers:
- url: /api/v1
  description: Relative to your panel URL.
- url: https://{panel}/api/v1
  variables:
    panel:
      default: panel.example.com
security:
- bearerAuth: []
- apiKey: []
tags:
- name: Auth
  description: Sign in, token refresh, 2FA.
- name: Me
  description: The signed in user.
- name: Setup
  description: First run wizard.
- name: Users
  description: Admins, resellers, groups and credits.
- name: Packages
  description: What resellers sell.
- name: Lines
  description: Client subscriptions used by IPTV apps.
- name: Catalog
  description: Bouquets and categories.
- name: Streams
  description: Live channels, sources, server tree, start and stop, logs, provider accounts.
- name: Radios
  description: Radio stations.
- name: Created channels
  description: Channels made from looped VOD.
- name: Movies
  description: VOD movies.
- name: Series
  description: Series, seasons and episodes.
- name: TMDB
  description: Movie and series details from The Movie Database. This product uses the TMDB API but is not endorsed or certified by TMDB.
- name: Imports
  description: M3U import and XC_VM migration.
- name: EPG
  description: Guide sources and channel mapping.
- name: Nodes
  description: Streaming nodes and enrollment.
- name: Panel proxies
  description: Disposable proxies (bs-edge) that hide the control IP behind Cloudflare.
- name: Connections
  description: Live viewers.
- name: Stats
  description: Dashboard, history, bandwidth and map.
- name: Security
  description: Blocklists and login attempts.
- name: Tickets
  description: Support tickets.
- name: Backups
  description: Database backups.
- name: Settings
  description: Panel settings by group.
- name: Cloudflare
  description: Automatic DNS.
- name: Domains
  description: Domains plan, host routing, DNS records and the list of addresses.
- name: GeoIP
  description: IP geolocation databases (country, ASN) and their updates.
- name: Certificates
  description: ACME certificates.
- name: AI
  description: AI explanations.
- name: API keys
  description: Keys for automation.
- name: Audit
  description: Audit log.
- name: Logs
  description: Logs service views, detections, notes and the logs AI.
- name: License
  description: The free license. No limits; the platform can only revoke a key used for abuse.
- name: System
  description: Version, health, cache, ffmpeg, permissions.
- name: Tools
  description: Mass delete, channel order, source find and replace, quick tools. Mass edit is the `update` action of each bulk endpoint.
- name: Modules
  description: Install, enable and watch modules (plugins).
paths:
  /auth/login:
    post:
      operationId: login
      tags:
      - Auth
      summary: Sign in with username and password
      description: |-
        Returns a 15 minute access token in the body and a refresh token in a cookie. Sets `bs_refresh` cookie: httpOnly, Secure, SameSite=Strict, Path=/api/v1/auth, 30 day lifetime.

        If the user has 2FA enabled and `totp_code` is missing, the call fails with `401 totp_required`; ask for the code and call again with it.
        Failed attempts are rate limited per IP and per username and are recorded in the login attempts log.
        API keys cannot be created from this endpoint; use `POST /api-keys` with a bearer token.

        Roles: `admin`, `reseller`.
      x-roles:
      - admin
      - reseller
      x-required-scopes: []
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LoginRequest'
            example:
              username: admin
              password: correct horse battery staple
              totp_code: '492817'
      responses:
        '200':
          description: Signed in.
          headers:
            Set-Cookie:
              description: The refresh token cookie.
              schema:
                type: string
                examples:
                - bs_refresh=rt_...; Path=/api/v1/auth; HttpOnly; Secure; SameSite=Strict; Max-Age=2592000
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /auth/refresh:
    post:
      operationId: refreshToken
      tags:
      - Auth
      summary: Get a new access token
      description: |-
        Reads the `bs_refresh` cookie, returns a fresh access token and rotates the cookie. Each refresh token works once.
        Presenting a refresh token that was already rotated is treated as theft: every session of that login is revoked and the call fails with `401 refresh_reused`.
        Exception: within 30 seconds of the rotation, from the same user agent, the old token still works (two tabs, or a reload while a refresh was in flight).
        Rate limit: 60 per minute per IP, separate from the login limit.
        Sets `bs_refresh` cookie: httpOnly, Secure, SameSite=Strict, Path=/api/v1/auth, 30 day lifetime.

        Roles: `admin`, `reseller`.
      x-roles:
      - admin
      - reseller
      x-required-scopes: []
      security: []
      parameters:
      - name: bs_refresh
        in: cookie
        required: true
        description: Refresh token set by login or a previous refresh.
        schema:
          type: string
      responses:
        '200':
          description: New tokens.
          headers:
            Set-Cookie:
              description: Rotated refresh token cookie.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /auth/logout:
    post:
      operationId: logout
      tags:
      - Auth
      summary: Sign out
      description: |-
        Revokes the current refresh token family and clears the cookie. The access token stays valid until it expires (at most 15 minutes).

        Roles: `admin`, `reseller`.
      x-roles:
      - admin
      - reseller
      x-required-scopes: []
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /auth/2fa/enroll:
    post:
      operationId: enrollTotp
      tags:
      - Auth
      summary: Start 2FA enrollment
      description: |-
        Creates a new pending TOTP secret. 2FA is not active until `POST /auth/2fa/verify` succeeds. Calling it again replaces the pending secret. Bearer token only.

        Roles: `admin`, `reseller`.
      x-roles:
      - admin
      - reseller
      x-required-scopes: []
      security:
      - bearerAuth: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TotpEnrollment'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /auth/2fa/verify:
    post:
      operationId: verifyTotp
      tags:
      - Auth
      summary: Confirm 2FA enrollment
      description: |-
        Checks a code against the pending secret, turns 2FA on and returns recovery codes (shown once).

        Roles: `admin`, `reseller`.
      x-roles:
      - admin
      - reseller
      x-required-scopes: []
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TotpCode'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RecoveryCodes'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /auth/2fa/disable:
    post:
      operationId: disableTotp
      tags:
      - Auth
      summary: Turn 2FA off
      description: |-
        Needs the password and a valid code. Fails with `403 2fa_required_by_group` when the user group requires 2FA.

        Roles: `admin`, `reseller`.
      x-roles:
      - admin
      - reseller
      x-required-scopes: []
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TotpDisable'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /auth/2fa/recovery-codes:
    post:
      operationId: regenerateRecoveryCodes
      tags:
      - Auth
      summary: Replace recovery codes
      description: |-
        Invalidates the old recovery codes and returns ten new ones.

        Roles: `admin`, `reseller`.
      x-roles:
      - admin
      - reseller
      x-required-scopes: []
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TotpCode'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RecoveryCodes'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /me:
    get:
      operationId: getMe
      tags:
      - Me
      summary: Who am I
      description: |-
        Profile, role, effective permissions and credit balance of the caller. With an API key, returns the key owner and `permissions` is the intersection of the owner permissions and the key scopes.

        Roles: `admin`, `reseller`.
      x-roles:
      - admin
      - reseller
      x-required-scopes: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Me'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    patch:
      operationId: updateMe
      tags:
      - Me
      summary: Update my profile
      description: 'Roles: `admin`, `reseller`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes: []
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MeUpdate'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Me'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /me/password:
    post:
      operationId: changeMyPassword
      tags:
      - Me
      summary: Change my password
      description: |-
        Revokes every other session of the user.

        Roles: `admin`, `reseller`.
      x-roles:
      - admin
      - reseller
      x-required-scopes: []
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PasswordChange'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /me/sessions:
    get:
      operationId: listMySessions
      tags:
      - Me
      summary: List my signed in sessions
      description: 'Roles: `admin`, `reseller`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes: []
      security:
      - bearerAuth: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Session'
                required:
                - data
        '401':
          $ref: '#/components/responses/Unauthorized'
  /me/sessions/{session_id}:
    delete:
      operationId: revokeMySession
      tags:
      - Me
      summary: Sign out one session
      description: 'Roles: `admin`, `reseller`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes: []
      security:
      - bearerAuth: []
      parameters:
      - name: session_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
  /setup/status:
    get:
      operationId: getSetupStatus
      tags:
      - Setup
      summary: Setup wizard status
      description: |-
        Unauthenticated. Tells the SPA whether to show the first run wizard.

        Roles: `admin`.
      x-roles:
      - admin
      x-required-scopes: []
      security: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SetupStatus'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /setup/check-code:
    post:
      operationId: checkSetupCode
      tags:
      - Setup
      summary: Check the setup code
      description: |-
        Unauthenticated, and only while setup is not complete. Lets the wizard reject a wrong `X-BS-Setup-Code` on its first screen. Shares the 10 per minute rate limit of `/setup/complete`. A loopback connection (SSH tunnel) passes without a code.

        Roles: `admin`.
      x-roles:
      - admin
      x-required-scopes: []
      security: []
      parameters:
      - name: X-BS-Setup-Code
        in: header
        description: One time code printed by the installer.
        schema:
          type: string
          examples:
          - XXXX-XXXX
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /setup/cloudflare/zones:
    post:
      operationId: listSetupCloudflareZones
      tags:
      - Setup
      summary: Zones a Cloudflare token can see (setup)
      description: |-
        Unauthenticated, and only while setup is not complete. Protected like `/setup/complete`: `X-BS-Setup-Code` unless loopback, same 10 per minute rate limit. Checks the token and lists its zones. Also returns the public IP this server guesses for itself, for the wizard to prefill. The token is never logged, stored or returned here.

        Roles: `admin`.
      x-roles:
      - admin
      x-required-scopes: []
      security: []
      parameters:
      - name: X-BS-Setup-Code
        in: header
        description: One time code printed by the installer.
        schema:
          type: string
          examples:
          - XXXX-XXXX
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                api_token:
                  type: string
                  writeOnly: true
                  minLength: 20
                  maxLength: 200
              required:
              - api_token
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        name:
                          type: string
                          examples:
                          - example.com
                        status:
                          type: string
                      required:
                      - id
                      - name
                  public_ipv4:
                    type: string
                    description: Empty when unknown.
                    examples:
                    - 203.0.113.10
                  public_ipv6:
                    type: string
                    description: Empty when unknown.
                required:
                - data
                - public_ipv4
                - public_ipv6
        '400':
          $ref: '#/components/responses/BadRequest'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '502':
          description: Cloudflare could not be reached (`cloudflare_unreachable`) or failed (`cloudflare_error`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /setup/cloudflare/test:
    post:
      operationId: testSetupCloudflare
      tags:
      - Setup
      summary: Test the Cloudflare settings (setup)
      description: |-
        Unauthenticated, and only while setup is not complete. Protected like `/setup/complete`. Runs every check `/setup/complete` runs (token, zone access, names inside the zone, no CNAME on the names, public IP) and proves DNS edit access by adding and removing a TXT record `_bitstream-check.<panel_domain>`. Changes nothing else. Errors are `400 validation_failed` with `details.fields` and `details.reasons` (stable codes: `token_invalid`, `zone_read_missing`, `no_zones`, `zone_not_found`, `domain_invalid`, `domain_not_in_zone`, `domain_same`, `dns_edit_missing`, `record_conflict`, `ip_required`, `ip_invalid`).

        Roles: `admin`.
      x-roles:
      - admin
      x-required-scopes: []
      security: []
      parameters:
      - name: X-BS-Setup-Code
        in: header
        description: One time code printed by the installer.
        schema:
          type: string
          examples:
          - XXXX-XXXX
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SetupCloudflare'
      responses:
        '200':
          description: Everything works. Lists the records setup will write.
          content:
            application/json:
              schema:
                type: object
                properties:
                  zone_name:
                    type: string
                    examples:
                    - example.com
                  panel_url:
                    type: string
                    examples:
                    - https://painel.example.com
                  records:
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                        type:
                          type: string
                          enum:
                          - A
                          - AAAA
                        content:
                          type: string
                        proxied:
                          type: boolean
                      required:
                      - name
                      - type
                      - content
                      - proxied
                required:
                - zone_name
                - panel_url
                - records
        '400':
          $ref: '#/components/responses/BadRequest'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '502':
          description: Cloudflare could not be reached (`cloudflare_unreachable`) or failed (`cloudflare_error`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /setup/complete:
    post:
      operationId: completeSetup
      tags:
      - Setup
      summary: Finish first run setup
      description: |-
        Unauthenticated, and only while setup is not complete; afterwards it returns `409 setup_already_complete`. Creates the first admin, stores the base settings and signs the admin in (same response as login). The `cloudflare` block is required: the server checks the token and zone with Cloudflare again and writes the panel DNS records before it creates the admin, then sets `panel_url` to `https://<panel_domain>`, stores the token encrypted (same setting as the Cloudflare page) and starts the dns-01 certificate in the background. Failures are `400 validation_failed` with `details.fields` and `details.reasons` keyed `cloudflare.<field>`. Only `BS_SETUP_SKIP_CLOUDFLARE=1` on the control process (test labs) lifts the requirement. The free license is required too: the server registers the panel with the license server (panel id, panel URL, version, and `license_email` only if given) before it creates the admin. When the license server cannot be reached it answers `502 license_server_unreachable` and creates nothing: try again. `BS_LICENSE_SKIP=1` (test labs) lifts this. Needs the one time setup code printed by the installer in `X-BS-Setup-Code`, unless the connection comes straight from the panel host's loopback (an SSH tunnel) with no proxy forwarding headers.

        Roles: `admin`.
      x-roles:
      - admin
      x-required-scopes: []
      security: []
      parameters:
      - name: X-BS-Setup-Code
        in: header
        description: One time code printed by the installer.
        schema:
          type: string
          examples:
          - XXXX-XXXX
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SetupRequest'
      responses:
        '200':
          description: Setup done, signed in.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '502':
          description: Cloudflare (`cloudflare_unreachable`, `cloudflare_error`) or the license server (`license_server_unreachable`, `license_rejected`) could not be used. Nothing was created; try again.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /users:
    get:
      operationId: listUsers
      tags:
      - Users
      summary: List users
      description: |-
        Admins see everyone. Resellers see their sub-resellers (whole subtree).

        Sortable fields: id, username, credits, created_at, last_login_at.

        Roles: `admin`, `reseller`. API key scopes: `users:read`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - users:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/Q'
      - name: role
        in: query
        schema:
          type: string
          examples:
          - admin
          enum:
          - admin
          - reseller
      - name: parent_id
        in: query
        schema:
          type: integer
          format: int64
      - name: group_id
        in: query
        schema:
          type: integer
          format: int64
      - $ref: '#/components/parameters/EnabledQ'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    post:
      operationId: createUser
      tags:
      - Users
      summary: Create a user
      description: |-
        Resellers creating a sub-reseller need the `can_create_subresellers` group limit and pay `subreseller_price` credits. A reseller can only pick its own group or one that grants nothing more: permissions, every limit (`subreseller_price` at least its own), the packages sold to the group, and `require_2fa` when its own group has it. For staff (admin) accounts the role in `group_id` must hold only permissions you hold; the Owner role needs the Owner, and a role with sensitive permissions needs the Owner or `roles:delegate`.

        Roles: `admin`, `reseller`. API key scopes: `users:write`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - users:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserCreate'
      responses:
        '201':
          description: Created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /users/{id}:
    get:
      operationId: getUser
      tags:
      - Users
      summary: Get a user
      description: 'Roles: `admin`, `reseller`. API key scopes: `users:read`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - users:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    patch:
      operationId: updateUser
      tags:
      - Users
      summary: Update a user
      description: |-
        On your own account, `password`, `username` and `email` are refused with `403 use_account_endpoint` (use `/me/password` and `PATCH /me`); resellers cannot edit their own `notes` either. A password change through an API key gets `403 api_key_not_allowed`. Group changes follow the same rules as create. A staff account whose role has permissions you lack is `403 permission_not_held`; an Owner account can only be changed by an Owner (`403 owner_only`). Demoting or disabling the last enabled Owner is `409 last_owner`.

        Roles: `admin`, `reseller`. API key scopes: `users:write`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - users:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserUpdate'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    delete:
      operationId: deleteUser
      tags:
      - Users
      summary: Delete a user
      description: |-
        Fails with `409 user_has_lines` or `409 user_has_children` while the user still owns lines or sub-resellers. Move or delete them first. Staff accounts follow the rules of `PATCH /users/{id}`, including `409 last_owner`.

        Roles: `admin`, `reseller`. API key scopes: `users:write`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - users:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /users/{id}/credits:
    post:
      operationId: adjustUserCredits
      tags:
      - Users
      summary: Add or remove credits
      description: |-
        Admins mint or remove credits freely. Resellers transfer between their balance and a direct or indirect sub-reseller. A balance can never go below zero (`402 insufficient_credits`).

        Roles: `admin`, `reseller`. API key scopes: `users:write`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - users:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreditAdjust'
            example:
              amount: 100
              note: November payment
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreditBalance'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /users/{id}/credits/ledger:
    get:
      operationId: listUserCreditLedger
      tags:
      - Users
      summary: Credit history of a user
      description: 'Roles: `admin`, `reseller`. API key scopes: `users:read`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - users:read
      parameters:
      - $ref: '#/components/parameters/Id'
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/From'
      - $ref: '#/components/parameters/To'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreditEntryList'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /user-groups:
    get:
      operationId: listUserGroups
      tags:
      - Users
      summary: List usergroups
      description: |-
        Sortable fields: id, name. Admin groups are the staff roles, see `/roles`.

        Roles: `admin`. API key scopes: `users:read`.
      x-roles:
      - admin
      x-required-scopes:
      - users:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/Q'
      - name: role
        in: query
        description: Only groups for this kind of user.
        schema:
          type: string
          enum:
          - admin
          - reseller
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserGroupList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    post:
      operationId: createUserGroup
      tags:
      - Users
      summary: Create a userGroup
      description: 'Roles: `admin`. API key scopes: `users:write`. Writing an admin group (a staff role) also needs `roles:write` and follows the rules of `/roles`.'
      x-roles:
      - admin
      x-required-scopes:
      - users:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserGroupCreate'
      responses:
        '201':
          description: Created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserGroup'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /user-groups/{id}:
    get:
      operationId: getUserGroup
      tags:
      - Users
      summary: Get a userGroup
      description: 'Roles: `admin`. API key scopes: `users:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - users:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserGroup'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    patch:
      operationId: updateUserGroup
      tags:
      - Users
      summary: Update a userGroup
      description: 'Roles: `admin`. API key scopes: `users:write`. Writing an admin group (a staff role) also needs `roles:write` and follows the rules of `/roles`.'
      x-roles:
      - admin
      x-required-scopes:
      - users:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserGroupUpdate'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserGroup'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    delete:
      operationId: deleteUserGroup
      tags:
      - Users
      summary: Delete a userGroup
      description: |-
        Fails with `409 group_in_use` while users belong to the group.

        Roles: `admin`. API key scopes: `users:write`.
      x-roles:
      - admin
      x-required-scopes:
      - users:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /roles:
    get:
      operationId: listRoles
      tags:
      - Users
      summary: List staff roles
      description: |-
        Staff roles (profiles) are the admin user groups. Sortable fields: id, name.

        Roles: `admin`. API key scopes: `roles:read`.
      x-roles:
      - admin
      x-required-scopes:
      - roles:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/Q'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserGroupList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    post:
      operationId: createRole
      tags:
      - Users
      summary: Create a staff role
      description: |-
        You can only give permissions you hold (`403 permission_not_held`). Roles with sensitive permissions (see `sensitive` in `GET /system/permissions`) need the Owner or `roles:delegate` (`403 sensitive_permission`). The Owner role cannot change (`409 role_locked`).

        Roles: `admin`. API key scopes: `roles:write`.
      x-roles:
      - admin
      x-required-scopes:
      - roles:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RoleCreate'
      responses:
        '201':
          description: Created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserGroup'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /roles/{id}:
    get:
      operationId: getRole
      tags:
      - Users
      summary: Get a staff role
      description: |-
        Reseller groups answer 404 here; use `/user-groups`.

        Roles: `admin`. API key scopes: `roles:read`.
      x-roles:
      - admin
      x-required-scopes:
      - roles:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserGroup'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    patch:
      operationId: updateRole
      tags:
      - Users
      summary: Update a staff role
      description: |-
        You can only give permissions you hold (`403 permission_not_held`). Roles with sensitive permissions (see `sensitive` in `GET /system/permissions`) need the Owner or `roles:delegate` (`403 sensitive_permission`). The Owner role cannot change (`409 role_locked`). Built-in roles keep their name. Users of the role get the new permissions on their next request.

        Roles: `admin`. API key scopes: `roles:write`.
      x-roles:
      - admin
      x-required-scopes:
      - roles:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RoleUpdate'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserGroup'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    delete:
      operationId: deleteRole
      tags:
      - Users
      summary: Delete a staff role
      description: |-
        Fails with `409 group_in_use` while users have it and `409 role_builtin` for built-in roles.

        Roles: `admin`. API key scopes: `roles:write`.
      x-roles:
      - admin
      x-required-scopes:
      - roles:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /roles/{id}/clone:
    post:
      operationId: cloneRole
      tags:
      - Users
      summary: Copy a staff role
      description: |-
        New custom role with the same permissions (the Owner "*" becomes the explicit list), description and 2FA rule. You can only give permissions you hold (`403 permission_not_held`). Roles with sensitive permissions (see `sensitive` in `GET /system/permissions`) need the Owner or `roles:delegate` (`403 sensitive_permission`).

        Roles: `admin`. API key scopes: `roles:write`.
      x-roles:
      - admin
      x-required-scopes:
      - roles:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RoleClone'
      responses:
        '201':
          description: Created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserGroup'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /packages:
    get:
      operationId: listPackages
      tags:
      - Packages
      summary: List packages
      description: |-
        Resellers only see packages allowed for their group.

        Sortable fields: id, name, official_credits, created_at.

        Roles: `admin`, `reseller`. API key scopes: `packages:read`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - packages:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/Q'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PackageList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    post:
      operationId: createPackage
      tags:
      - Packages
      summary: Create a package
      description: 'Roles: `admin`. API key scopes: `packages:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - packages:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PackageCreate'
      responses:
        '201':
          description: Created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Package'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /packages/{id}:
    get:
      operationId: getPackage
      tags:
      - Packages
      summary: Get a package
      description: 'Roles: `admin`, `reseller`. API key scopes: `packages:read`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - packages:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Package'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    patch:
      operationId: updatePackage
      tags:
      - Packages
      summary: Update a package
      description: 'Roles: `admin`. API key scopes: `packages:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - packages:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PackageUpdate'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Package'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    delete:
      operationId: deletePackage
      tags:
      - Packages
      summary: Delete a package
      description: 'Roles: `admin`. API key scopes: `packages:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - packages:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /lines:
    get:
      operationId: listLines
      tags:
      - Lines
      summary: List lines
      description: |-
        Resellers see lines owned by themselves and their sub-resellers.

        Sortable fields: id, username, exp_date, created_at, last_activity_at, max_connections.

        Roles: `admin`, `reseller`. API key scopes: `lines:read`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - lines:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/Q'
      - name: status
        in: query
        description: Filter by status. `expiring` means active and expiring in 7 days. `online` means it has live connections.
        schema:
          type: string
          examples:
          - active
          enum:
          - active
          - expired
          - disabled
          - banned
          - expiring
          - online
          - trial
      - name: owner_id
        in: query
        description: Lines of this owner.
        schema:
          type: integer
          format: int64
      - name: include_subtree
        in: query
        description: With owner_id, also include lines of that owner sub-resellers.
        schema:
          type: boolean
          default: false
      - name: package_id
        in: query
        schema:
          type: integer
          format: int64
      - $ref: '#/components/parameters/BouquetIdQ'
      - name: exp_before
        in: query
        schema:
          type: string
          format: date-time
      - name: exp_after
        in: query
        schema:
          type: string
          format: date-time
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LineList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    post:
      operationId: createLine
      tags:
      - Lines
      summary: Create a line
      description: |-
        Charges the package credits (official or trial) to the owner. Trials count against `max_trials_per_day` of the reseller group. There is no limit on the number of lines. Refused with `403 license_revoked` only when the platform revoked this panel's license.

        Roles: `admin`, `reseller`. API key scopes: `lines:write`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - lines:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LineCreate'
            example:
              package_id: 2
              username: joao2291
              reseller_notes: Paid by pix
      responses:
        '201':
          description: Created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Line'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /lines/{id}:
    get:
      operationId: getLine
      tags:
      - Lines
      summary: Get a line
      description: 'Roles: `admin`, `reseller`. API key scopes: `lines:read`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - lines:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Line'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    patch:
      operationId: updateLine
      tags:
      - Lines
      summary: Update a line
      description: |-
        Resellers cannot change exp_date, max_connections above the package, `package_id` (`403 package_change_not_allowed`: renew with the new package instead), or restrictions without `allow_line_restrictions`. Changes apply to new connections; use `/kill` to force reconnects.

        Roles: `admin`, `reseller`. API key scopes: `lines:write`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - lines:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LineUpdate'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Line'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    delete:
      operationId: deleteLine
      tags:
      - Lines
      summary: Delete a line
      description: |-
        Kills its connections. No credit refund.

        Roles: `admin`, `reseller`. API key scopes: `lines:write`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - lines:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /lines/{id}/renew:
    post:
      operationId: renewLine
      tags:
      - Lines
      summary: Renew or extend a line with credits
      description: |-
        Renewing with a different `package_id` switches the line to it: bouquets, max_connections, allowed_outputs, is_restreamer and forced_country are reset to the new package.

        Roles: `admin`, `reseller`. API key scopes: `lines:write`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - lines:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LineRenew'
            example:
              periods: 3
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  line:
                    $ref: '#/components/schemas/Line'
                  credits_charged:
                    type: integer
                    examples:
                    - 3
                    format: int64
                  owner_credits:
                    type: integer
                    description: Owner balance after the charge.
                    examples:
                    - 247
                    format: int64
                required:
                - line
                - credits_charged
                - owner_credits
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /lines/{id}/enable:
    post:
      operationId: enableLine
      tags:
      - Lines
      summary: Enable a line
      description: 'Roles: `admin`, `reseller`. API key scopes: `lines:write`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - lines:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Line'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /lines/{id}/disable:
    post:
      operationId: disableLine
      tags:
      - Lines
      summary: Disable a line
      description: |-
        Kills its connections. Apps get `auth: 0` with status Disabled.

        Roles: `admin`, `reseller`. API key scopes: `lines:write`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - lines:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Line'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /lines/{id}/ban:
    post:
      operationId: banLine
      tags:
      - Lines
      summary: Ban a line
      description: |-
        Admin only. The owner cannot re-enable it. Kills its connections.

        Roles: `admin`. API key scopes: `lines:write`.
      x-roles:
      - admin
      x-required-scopes:
      - lines:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Line'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /lines/{id}/unban:
    post:
      operationId: unbanLine
      tags:
      - Lines
      summary: Unban a line
      description: 'Roles: `admin`. API key scopes: `lines:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - lines:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Line'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /lines/{id}/kill:
    post:
      operationId: killLineConnections
      tags:
      - Lines
      summary: Kill all connections of a line
      description: |-
        Apps usually reconnect at once; disable the line first to keep it off.

        Roles: `admin`, `reseller`. API key scopes: `connections:kill`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - connections:kill
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  killed:
                    type: integer
                    examples:
                    - 2
                    format: int32
                required:
                - killed
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /lines/{id}/playlist-links:
    get:
      operationId: getLinePlaylistLinks
      tags:
      - Lines
      summary: Playlist and app links for a line
      description: |-
        Ready to copy into a message to the customer. Uses settings general.client_url (or the panel URL).

        Roles: `admin`, `reseller`. API key scopes: `lines:read`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - lines:read
      parameters:
      - $ref: '#/components/parameters/Id'
      - name: https
        in: query
        description: Build https links.
        schema:
          type: boolean
          default: false
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlaylistLinks'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /lines/{id}/connections:
    get:
      operationId: listLineConnections
      tags:
      - Lines
      summary: Live connections of a line
      description: 'Roles: `admin`, `reseller`. API key scopes: `connections:read`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - connections:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Connection'
                required:
                - data
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /lines/{id}/history:
    get:
      operationId: listLineHistory
      tags:
      - Lines
      summary: Viewing history of a line
      description: |-
        Finished sessions: what was watched, when, from where. Useful in customer disputes.

        Roles: `admin`, `reseller`. API key scopes: `lines:read`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - lines:read
      parameters:
      - $ref: '#/components/parameters/Id'
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/From'
      - $ref: '#/components/parameters/To'
      - name: proxy_id
        in: query
        description: Only sessions that came through this proxy node.
        schema:
          type: integer
          format: int64
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HistorySessionList'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /lines/bulk:
    post:
      operationId: bulkLines
      tags:
      - Lines
      summary: Bulk action on lines
      description: |-
        Operators use this for mass changes, for example moving every line of a package to a new bouquet.

        Each id is processed on its own; the response lists what succeeded and what failed and why. The call never fails half way silently.

        Roles: `admin`, `reseller`. API key scopes: `lines:write`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - lines:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LineBulkRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BulkResult'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /categories:
    get:
      operationId: listCategorys
      tags:
      - Catalog
      summary: List categories
      description: |-
        Sortable fields: position, name, id.

        Roles: `admin`, `reseller`. API key scopes: `catalog:read`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - catalog:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/Q'
      - name: kind
        in: query
        schema:
          type: string
          examples:
          - live
          enum:
          - live
          - movie
          - series
          - radio
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CategoryList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    post:
      operationId: createCategory
      tags:
      - Catalog
      summary: Create a category
      description: 'Roles: `admin`. API key scopes: `catalog:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - catalog:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CategoryCreate'
      responses:
        '201':
          description: Created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Category'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /categories/{id}:
    get:
      operationId: getCategory
      tags:
      - Catalog
      summary: Get a category
      description: 'Roles: `admin`, `reseller`. API key scopes: `catalog:read`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - catalog:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Category'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    patch:
      operationId: updateCategory
      tags:
      - Catalog
      summary: Update a category
      description: 'Roles: `admin`. API key scopes: `catalog:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - catalog:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CategoryUpdate'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Category'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    delete:
      operationId: deleteCategory
      tags:
      - Catalog
      summary: Delete a category
      description: |-
        Items in it become uncategorised.

        Roles: `admin`. API key scopes: `catalog:write`.
      x-roles:
      - admin
      x-required-scopes:
      - catalog:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /categories/reorder:
    post:
      operationId: reorderCategories
      tags:
      - Catalog
      summary: Reorder categories
      description: |-
        Send the full ordered list of ids of one kind.

        Roles: `admin`. API key scopes: `catalog:write`.
      x-roles:
      - admin
      x-required-scopes:
      - catalog:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                kind:
                  type: string
                  examples:
                  - live
                  enum:
                  - live
                  - movie
                  - series
                  - radio
                ids:
                  type: array
                  items:
                    type: integer
                    format: int64
                  minItems: 1
              required:
              - kind
              - ids
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /bouquets:
    get:
      operationId: listBouquets
      tags:
      - Catalog
      summary: List bouquets
      description: |-
        Sortable fields: position, name, id.

        Roles: `admin`, `reseller`. API key scopes: `catalog:read`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - catalog:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/Q'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BouquetList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    post:
      operationId: createBouquet
      tags:
      - Catalog
      summary: Create a bouquet
      description: 'Roles: `admin`. API key scopes: `catalog:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - catalog:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BouquetCreate'
      responses:
        '201':
          description: Created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Bouquet'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /bouquets/{id}:
    get:
      operationId: getBouquet
      tags:
      - Catalog
      summary: Get a bouquet
      description: 'Roles: `admin`, `reseller`. API key scopes: `catalog:read`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - catalog:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Bouquet'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    patch:
      operationId: updateBouquet
      tags:
      - Catalog
      summary: Update a bouquet
      description: 'Roles: `admin`. API key scopes: `catalog:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - catalog:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BouquetUpdate'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Bouquet'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    delete:
      operationId: deleteBouquet
      tags:
      - Catalog
      summary: Delete a bouquet
      description: |-
        Removes it from lines and packages.

        Roles: `admin`. API key scopes: `catalog:write`.
      x-roles:
      - admin
      x-required-scopes:
      - catalog:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /bouquets/reorder:
    post:
      operationId: reorderBouquets
      tags:
      - Catalog
      summary: Reorder bouquets
      description: 'Roles: `admin`. API key scopes: `catalog:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - catalog:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReorderRequest'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /bouquets/{id}/items:
    get:
      operationId: getBouquetItems
      tags:
      - Catalog
      summary: Get bouquet contents
      description: 'Roles: `admin`, `reseller`. API key scopes: `catalog:read`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - catalog:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BouquetItems'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    put:
      operationId: replaceBouquetItems
      tags:
      - Catalog
      summary: Replace bouquet contents
      description: |-
        Replaces all four lists. Use this to reorder.

        Roles: `admin`. API key scopes: `catalog:write`.
      x-roles:
      - admin
      x-required-scopes:
      - catalog:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BouquetItems'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BouquetItems'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    patch:
      operationId: patchBouquetItems
      tags:
      - Catalog
      summary: Add or remove bouquet items
      description: 'Roles: `admin`. API key scopes: `catalog:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - catalog:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BouquetItemsPatch'
            example:
              add:
                live:
                - 140
                - 141
              remove:
                movies:
                - 9001
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BouquetItems'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /streams:
    get:
      operationId: listStreams
      tags:
      - Streams
      summary: List streams
      description: |-
        Live channels (kind live). Radios and created channels have their own lists; every other `/streams/{id}/...` action works for all three kinds.

        Sortable fields: position, name, id, created_at, clients.

        Roles: `admin`. API key scopes: `streams:read`.
      x-roles:
      - admin
      x-required-scopes:
      - streams:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/Q'
      - $ref: '#/components/parameters/CategoryIdQ'
      - $ref: '#/components/parameters/NodeIdQ'
      - $ref: '#/components/parameters/EnabledQ'
      - $ref: '#/components/parameters/BouquetIdQ'
      - name: parent_id
        in: query
        description: Only the sub channels of this stream.
        schema:
          type: integer
          format: int64
      - name: health
        in: query
        description: Filter by health color.
        schema:
          type: string
          examples:
          - green
          enum:
          - green
          - yellow
          - red
          - grey
      - name: mode
        in: query
        schema:
          type: string
          examples:
          - ffmpeg
          enum:
          - ffmpeg
          - llod
          - direct
      - name: epg
        in: query
        description: '`mapped` or `unmapped`.'
        schema:
          type: string
          examples:
          - mapped
          enum:
          - mapped
          - unmapped
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StreamList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    post:
      operationId: createStream
      tags:
      - Streams
      summary: Create a stream
      description: |-
        Refused with `403 license_revoked` when the platform revoked this panel's license (also for radios, created channels, sub-channels, duplicates and imports). Existing streams keep working.

        Roles: `admin`. API key scopes: `streams:write`.
      x-roles:
      - admin
      x-required-scopes:
      - streams:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StreamCreate'
      responses:
        '201':
          description: Created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Stream'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /streams/{id}:
    get:
      operationId: getStream
      tags:
      - Streams
      summary: Get a stream
      description: 'Roles: `admin`. API key scopes: `streams:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - streams:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Stream'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    patch:
      operationId: updateStream
      tags:
      - Streams
      summary: Update a stream
      description: 'Roles: `admin`. API key scopes: `streams:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - streams:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StreamUpdate'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Stream'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    delete:
      operationId: deleteStream
      tags:
      - Streams
      summary: Delete a stream
      description: |-
        Stops it on every node and removes it from bouquets.

        Roles: `admin`. API key scopes: `streams:write`.
      x-roles:
      - admin
      x-required-scopes:
      - streams:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /radios:
    get:
      operationId: listRadios
      tags:
      - Radios
      summary: List radio stations
      description: |-
        Radio stations (kind radio). Read, update and delete them through `/streams/{id}`.

        Sortable fields: position, name, id.

        Roles: `admin`. API key scopes: `streams:read`.
      x-roles:
      - admin
      x-required-scopes:
      - streams:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/Q'
      - $ref: '#/components/parameters/CategoryIdQ'
      - $ref: '#/components/parameters/NodeIdQ'
      - $ref: '#/components/parameters/EnabledQ'
      - $ref: '#/components/parameters/BouquetIdQ'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StreamList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    post:
      operationId: createRadio
      tags:
      - Radios
      summary: Create a radio station
      description: 'Roles: `admin`. API key scopes: `streams:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - streams:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StreamCreate'
      responses:
        '201':
          description: Created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Stream'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /created-channels:
    get:
      operationId: listCreatedChannels
      tags:
      - Created channels
      summary: List createdchannels
      description: |-
        Sortable fields: position, name, id.

        Roles: `admin`. API key scopes: `streams:read`.
      x-roles:
      - admin
      x-required-scopes:
      - streams:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/Q'
      - $ref: '#/components/parameters/CategoryIdQ'
      - $ref: '#/components/parameters/NodeIdQ'
      - $ref: '#/components/parameters/EnabledQ'
      - $ref: '#/components/parameters/BouquetIdQ'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreatedChannelList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    post:
      operationId: createCreatedChannel
      tags:
      - Created channels
      summary: Create a createdChannel
      description: |-
        Fails with `400 incompatible_items` and the offending item ids when items do not share codec parameters.

        Roles: `admin`. API key scopes: `streams:write`.
      x-roles:
      - admin
      x-required-scopes:
      - streams:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatedChannelCreate'
      responses:
        '201':
          description: Created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreatedChannel'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /created-channels/{id}:
    get:
      operationId: getCreatedChannel
      tags:
      - Created channels
      summary: Get a createdChannel
      description: 'Roles: `admin`. API key scopes: `streams:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - streams:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreatedChannel'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    patch:
      operationId: updateCreatedChannel
      tags:
      - Created channels
      summary: Update a createdChannel
      description: 'Roles: `admin`. API key scopes: `streams:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - streams:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatedChannelUpdate'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreatedChannel'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    delete:
      operationId: deleteCreatedChannel
      tags:
      - Created channels
      summary: Delete a createdChannel
      description: 'Roles: `admin`. API key scopes: `streams:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - streams:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /streams/bulk:
    post:
      operationId: bulkStreams
      tags:
      - Streams
      summary: Bulk action on streams
      description: |-
        Works for live channels, radios and created channels.

        Each id is processed on its own; the response lists what succeeded and what failed and why. The call never fails half way silently.

        Roles: `admin`. API key scopes: `streams:write`.
      x-roles:
      - admin
      x-required-scopes:
      - streams:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StreamBulkRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BulkResult'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /streams/{id}/sources:
    put:
      operationId: replaceStreamSources
      tags:
      - Streams
      summary: Replace sources
      description: |-
        Replaces the ordered list. Running nodes get the new list and switch on their next fallback; restart to switch now.

        Roles: `admin`. API key scopes: `streams:write`.
      x-roles:
      - admin
      x-required-scopes:
      - streams:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: array
              items:
                $ref: '#/components/schemas/StreamSource'
              minItems: 1
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/StreamSource'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /streams/{id}/sources/reorder:
    post:
      operationId: reorderStreamSources
      tags:
      - Streams
      summary: Reorder sources
      description: |-
        Send every source id in the new order. The first is the primary.

        Roles: `admin`. API key scopes: `streams:write`.
      x-roles:
      - admin
      x-required-scopes:
      - streams:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReorderRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/StreamSource'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /streams/{id}/sub-channels:
    post:
      operationId: createStreamSubChannels
      tags:
      - Streams
      summary: Create sub channels, one per DASH quality
      description: |-
        For a DASH source with several qualities: each item becomes a channel that copies this one (settings, bouquets,
        server tree) with its sources pinned to `variant`. Sub channels are linked by `parent_id`: deleting this channel
        deletes them, and source changes here are copied to them. They play as TS and HLS like any channel.

        Roles: `admin`. API key scopes: `streams:write`.
      x-roles:
      - admin
      x-required-scopes:
      - streams:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                items:
                  type: array
                  minItems: 1
                  maxItems: 20
                  items:
                    type: object
                    properties:
                      name:
                        type: string
                        maxLength: 255
                        examples:
                        - Sports HD
                      variant:
                        type: string
                        maxLength: 128
                        description: Representation id from the probe `qualities`.
                        examples:
                        - '1'
                    required:
                    - name
                    - variant
                adaptive:
                  type: boolean
                  description: Also make the new sub channels this channel's HLS qualities (adaptive_variants), so HLS players
                    switch quality on their own. Default false.
              required:
              - items
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Stream'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /streams/{id}/duplicate:
    post:
      operationId: duplicateStream
      tags:
      - Streams
      summary: Duplicate a live channel, radio or created channel
      description: |-
        Copies the channel with new ids: settings, category, EPG mapping, DASH and archive settings, custom SID, sources in
        the same order (health reset), playlist items of a created channel, bouquets and the server tree. Not copied: sub
        channels, stats, live connections and archive recordings. The copy is disabled unless `enabled` is true, so no
        server runs it until you turn it on.

        Roles: `admin`. API key scopes: `streams:write`.
      x-roles:
      - admin
      x-required-scopes:
      - streams:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DuplicateRequest'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Stream'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /streams/{id}/tree:
    get:
      operationId: getStreamTree
      tags:
      - Streams
      summary: Get the server tree of a stream
      description: 'Roles: `admin`. API key scopes: `streams:read`, `nodes:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - streams:read
      - nodes:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StreamTree'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    put:
      operationId: replaceStreamTree
      tags:
      - Streams
      summary: Set the server tree of a stream
      description: |-
        Nodes removed from the tree stop the stream.

        Roles: `admin`. API key scopes: `streams:write`, `nodes:write`.
      x-roles:
      - admin
      x-required-scopes:
      - streams:write
      - nodes:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StreamTree'
            example:
              nodes:
              - node_id: 1
                parent_node_id: null
              - node_id: 2
                parent_node_id: 1
                may_pull_source: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StreamTree'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /streams/{id}/start:
    post:
      operationId: startStream
      tags:
      - Streams
      summary: Start a stream
      description: |-
        Starts on the given nodes (sets desired_state running). On-demand streams start now and stop again when idle.

        Roles: `admin`. API key scopes: `streams:write`.
      x-roles:
      - admin
      x-required-scopes:
      - streams:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NodeTarget'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  nodes:
                    type: array
                    items:
                      type: object
                      properties:
                        node_id:
                          type: integer
                          format: int64
                        accepted:
                          type: boolean
                        error:
                          type: string
                        code:
                          type: string
                          description: error as a code to translate.
                          enum:
                          - not_assigned
                          - node_offline
                          - node_error
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: '`no_nodes`: the stream is not assigned to any node yet.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /streams/{id}/stop:
    post:
      operationId: stopStream
      tags:
      - Streams
      summary: Stop a stream
      description: |-
        Stops on the given nodes and sets desired_state stopped. Viewers are disconnected.

        Roles: `admin`. API key scopes: `streams:write`.
      x-roles:
      - admin
      x-required-scopes:
      - streams:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NodeTarget'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  nodes:
                    type: array
                    items:
                      type: object
                      properties:
                        node_id:
                          type: integer
                          format: int64
                        accepted:
                          type: boolean
                        error:
                          type: string
                        code:
                          type: string
                          description: error as a code to translate.
                          enum:
                          - not_assigned
                          - node_offline
                          - node_error
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /streams/{id}/restart:
    post:
      operationId: restartStream
      tags:
      - Streams
      summary: Restart a stream
      description: |-
        Restarts with the primary source. Viewers on TS see a short gap; HLS viewers get a discontinuity.

        Roles: `admin`. API key scopes: `streams:write`.
      x-roles:
      - admin
      x-required-scopes:
      - streams:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NodeTarget'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  nodes:
                    type: array
                    items:
                      type: object
                      properties:
                        node_id:
                          type: integer
                          format: int64
                        accepted:
                          type: boolean
                        error:
                          type: string
                        code:
                          type: string
                          description: error as a code to translate.
                          enum:
                          - not_assigned
                          - node_offline
                          - node_error
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: '`no_nodes`: the stream is not assigned to any node yet.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /streams/{id}/probe:
    post:
      operationId: probeStream
      tags:
      - Streams
      summary: Probe a stream source
      description: |-
        Runs ffprobe on a node against one source and reports codecs. Takes up to 15 seconds.

        Roles: `admin`. API key scopes: `streams:read`.
      x-roles:
      - admin
      x-required-scopes:
      - streams:read
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                source_id:
                  type: integer
                  description: Defaults to the primary.
                  format: int64
                node_id:
                  type: integer
                  description: Defaults to the first root node.
                  format: int64
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProbeResult'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /sources/probe:
    post:
      operationId: probeSourceUrl
      tags:
      - Streams
      summary: Probe a source URL before saving it
      description: |-
        Runs ffprobe on a node against a URL that is not saved yet, so the stream editor can test a source before the channel exists. Same result as probing a saved source. Takes up to 15 seconds.

        Roles: `admin`. API key scopes: `streams:write` (the node fetches whatever URL you send).
      x-roles:
      - admin
      x-required-scopes:
      - streams:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - url
              properties:
                url:
                  type: string
                  description: Source URL (http, https, rtmp, rtmps, rtsp, rtsps, udp, rtp, srt).
                  examples:
                  - http://provider.example.com/live/user/pass/123.ts
                user_agent:
                  type: string
                  description: Empty uses the default user agent from settings.
                headers:
                  type: object
                  additionalProperties:
                    type: string
                  description: Up to 20 extra HTTP headers.
                node_id:
                  type: integer
                  format: int64
                  description: Defaults to the first online node.
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProbeResult'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '400':
          $ref: '#/components/responses/BadRequest'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /streams/{id}/logs:
    get:
      operationId: getStreamLogs
      tags:
      - Streams
      summary: Recent stream logs
      description: |-
        Last events from the nodes (supervisor and ffmpeg stderr). Kept in memory on the nodes, roughly the last 500 lines per stream per node.

        Roles: `admin`. API key scopes: `streams:read`.
      x-roles:
      - admin
      x-required-scopes:
      - streams:read
      parameters:
      - $ref: '#/components/parameters/Id'
      - $ref: '#/components/parameters/NodeIdQ'
      - name: level
        in: query
        schema:
          type: string
          examples:
          - debug
          enum:
          - debug
          - info
          - warn
          - error
      - name: limit
        in: query
        schema:
          type: integer
          format: int32
          default: 200
          maximum: 1000
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/LogEntry'
                required:
                - data
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /streams/{id}/stats:
    get:
      operationId: getStreamStats
      tags:
      - Streams
      summary: Live stats of a stream per node
      description: 'Roles: `admin`. API key scopes: `streams:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - streams:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  health:
                    $ref: '#/components/schemas/StreamHealth'
                  nodes:
                    type: array
                    items:
                      $ref: '#/components/schemas/StreamNodeStats'
                required:
                - health
                - nodes
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /streams/{id}/archive:
    get:
      operationId: getStreamArchive
      tags:
      - Streams
      summary: TV archive of a stream
      description: 'Settings and the stored window of a channel''s catch-up recording. Roles: `admin`. API key scopes: `streams:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - streams:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StreamArchive'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /streams/{id}/archive/preview:
    post:
      operationId: previewStreamArchive
      tags:
      - Streams
      summary: Short link to watch a time range of the archive
      description: 'Signs a 2 minute link to the archive node for the panel player. No line and no connection slot are used. Roles:
        `admin`. API key scopes: `streams:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - streams:read
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                start:
                  type: string
                  format: date-time
                  description: Start of the range, in the past.
                minutes:
                  type: integer
                  minimum: 1
                  maximum: 360
                  format: int32
                format:
                  type: string
                  enum:
                  - hls
                  - ts
                  default: hls
              required:
              - start
              - minutes
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  url:
                    type: string
                  format:
                    type: string
                  start:
                    type: string
                    format: date-time
                  minutes:
                    type: integer
                    format: int32
                required:
                - url
                - format
                - start
                - minutes
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /source-accounts:
    get:
      operationId: listSourceAccounts
      tags:
      - Streams
      summary: List sourceaccounts
      description: |-
        Sortable fields: id, name.

        Roles: `admin`. API key scopes: `streams:read`.
      x-roles:
      - admin
      x-required-scopes:
      - streams:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/Q'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SourceAccountList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    post:
      operationId: createSourceAccount
      tags:
      - Streams
      summary: Create a sourceAccount
      description: 'Roles: `admin`. API key scopes: `streams:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - streams:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SourceAccountCreate'
      responses:
        '201':
          description: Created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SourceAccount'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /source-accounts/{id}:
    get:
      operationId: getSourceAccount
      tags:
      - Streams
      summary: Get a sourceAccount
      description: 'Roles: `admin`. API key scopes: `streams:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - streams:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SourceAccount'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    patch:
      operationId: updateSourceAccount
      tags:
      - Streams
      summary: Update a sourceAccount
      description: 'Roles: `admin`. API key scopes: `streams:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - streams:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SourceAccountUpdate'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SourceAccount'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    delete:
      operationId: deleteSourceAccount
      tags:
      - Streams
      summary: Delete a sourceAccount
      description: |-
        Linked sources become unlimited.

        Roles: `admin`. API key scopes: `streams:write`.
      x-roles:
      - admin
      x-required-scopes:
      - streams:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /movies:
    get:
      operationId: listMovies
      tags:
      - Movies
      summary: List movies
      description: |-
        Sortable fields: id, name, year, rating, created_at, position.

        Roles: `admin`. API key scopes: `vod:read`.
      x-roles:
      - admin
      x-required-scopes:
      - vod:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/Q'
      - $ref: '#/components/parameters/CategoryIdQ'
      - $ref: '#/components/parameters/EnabledQ'
      - $ref: '#/components/parameters/BouquetIdQ'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MovieList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    post:
      operationId: createMovie
      tags:
      - Movies
      summary: Create a movie
      description: 'Roles: `admin`. API key scopes: `vod:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - vod:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MovieCreate'
      responses:
        '201':
          description: Created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Movie'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /movies/{id}:
    get:
      operationId: getMovie
      tags:
      - Movies
      summary: Get a movie
      description: 'Roles: `admin`. API key scopes: `vod:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - vod:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Movie'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    patch:
      operationId: updateMovie
      tags:
      - Movies
      summary: Update a movie
      description: 'Roles: `admin`. API key scopes: `vod:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - vod:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MovieUpdate'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Movie'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    delete:
      operationId: deleteMovie
      tags:
      - Movies
      summary: Delete a movie
      description: 'Roles: `admin`. API key scopes: `vod:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - vod:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /movies/bulk:
    post:
      operationId: bulkMovies
      tags:
      - Movies
      summary: Bulk action on movies
      description: |-
        Each id is processed on its own; the response lists what succeeded and what failed and why. The call never fails half way silently.

        Roles: `admin`. API key scopes: `vod:write`.
      x-roles:
      - admin
      x-required-scopes:
      - vod:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MovieBulkRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BulkResult'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /movies/{id}/duplicate:
    post:
      operationId: duplicateMovie
      tags:
      - Movies
      summary: Duplicate a movie
      description: |-
        Copies the movie with a new id: metadata, TMDB data, probe, category and bouquets. The file is not copied: the copy
        plays the same source URL or local file. The copy is disabled unless `enabled` is true.

        Roles: `admin`. API key scopes: `vod:write`.
      x-roles:
      - admin
      x-required-scopes:
      - vod:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DuplicateRequest'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Movie'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /movies/{id}/probe:
    post:
      operationId: probeMovie
      tags:
      - Movies
      summary: Probe a movie file
      description: 'Roles: `admin`. API key scopes: `vod:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - vod:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProbeResult'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /series:
    get:
      operationId: listSeries
      tags:
      - Series
      summary: List series
      description: |-
        Sortable fields: id, name, year, rating, updated_at.

        Roles: `admin`. API key scopes: `vod:read`.
      x-roles:
      - admin
      x-required-scopes:
      - vod:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/Q'
      - $ref: '#/components/parameters/CategoryIdQ'
      - $ref: '#/components/parameters/EnabledQ'
      - $ref: '#/components/parameters/BouquetIdQ'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SeriesList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    post:
      operationId: createSeries
      tags:
      - Series
      summary: Create a series
      description: 'Roles: `admin`. API key scopes: `vod:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - vod:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SeriesCreate'
      responses:
        '201':
          description: Created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Series'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /series/{id}:
    get:
      operationId: getSeries
      tags:
      - Series
      summary: Get a series
      description: 'Roles: `admin`. API key scopes: `vod:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - vod:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Series'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    patch:
      operationId: updateSeries
      tags:
      - Series
      summary: Update a series
      description: 'Roles: `admin`. API key scopes: `vod:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - vod:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SeriesUpdate'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Series'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    delete:
      operationId: deleteSeries
      tags:
      - Series
      summary: Delete a series
      description: |-
        Deletes its seasons and episodes.

        Roles: `admin`. API key scopes: `vod:write`.
      x-roles:
      - admin
      x-required-scopes:
      - vod:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /series/{id}/duplicate:
    post:
      operationId: duplicateSeries
      tags:
      - Series
      summary: Duplicate a series with its seasons and episodes
      description: |-
        Copies the series, its seasons and episodes with new ids, plus TMDB data, category and bouquets. Episode files are
        not copied: the copies play the same sources. The copy is disabled unless `enabled` is true.

        Roles: `admin`. API key scopes: `vod:write`.
      x-roles:
      - admin
      x-required-scopes:
      - vod:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DuplicateRequest'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Series'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /series/{id}/seasons:
    get:
      operationId: listSeasons
      tags:
      - Series
      summary: List seasons of a series
      description: 'Roles: `admin`. API key scopes: `vod:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - vod:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Season'
                required:
                - data
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    post:
      operationId: createSeason
      tags:
      - Series
      summary: Add a season
      description: 'Roles: `admin`. API key scopes: `vod:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - vod:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SeasonCreate'
      responses:
        '201':
          description: Created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Season'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /seasons/{id}:
    patch:
      operationId: updateSeason
      tags:
      - Series
      summary: Update a season
      description: 'Roles: `admin`. API key scopes: `vod:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - vod:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SeasonUpdate'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Season'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    delete:
      operationId: deleteSeason
      tags:
      - Series
      summary: Delete a season and its episodes
      description: 'Roles: `admin`. API key scopes: `vod:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - vod:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /series/{id}/episodes:
    get:
      operationId: listEpisodes
      tags:
      - Series
      summary: List episodes of a series
      description: 'Roles: `admin`. API key scopes: `vod:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - vod:read
      parameters:
      - $ref: '#/components/parameters/Id'
      - name: season_number
        in: query
        schema:
          type: integer
          format: int32
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EpisodeList'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    post:
      operationId: createEpisode
      tags:
      - Series
      summary: Add an episode
      description: 'Roles: `admin`. API key scopes: `vod:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - vod:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EpisodeCreate'
      responses:
        '201':
          description: Created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Episode'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /episodes/{id}:
    get:
      operationId: getEpisode
      tags:
      - Series
      summary: Get an episode
      description: 'Roles: `admin`. API key scopes: `vod:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - vod:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Episode'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    patch:
      operationId: updateEpisode
      tags:
      - Series
      summary: Update an episode
      description: 'Roles: `admin`. API key scopes: `vod:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - vod:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EpisodeUpdate'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Episode'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    delete:
      operationId: deleteEpisode
      tags:
      - Series
      summary: Delete an episode
      description: 'Roles: `admin`. API key scopes: `vod:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - vod:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /imports/m3u:
    post:
      operationId: importM3u
      tags:
      - Imports
      summary: Import an M3U playlist
      description: 'Roles: `admin`. API key scopes: `streams:write`, `vod:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - streams:write
      - vod:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/M3uImportRequest'
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
                options:
                  type: string
                  description: M3uImportRequest as JSON.
              required:
              - file
      responses:
        '202':
          $ref: '#/components/responses/Accepted'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /imports/xcvm:
    post:
      operationId: importXcvm
      tags:
      - Imports
      summary: Migrate from XC_VM
      description: 'Roles: `admin`. API key scopes: `imports:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - imports:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/XcvmImportRequest'
      responses:
        '202':
          $ref: '#/components/responses/Accepted'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /imports:
    get:
      operationId: listImports
      tags:
      - Imports
      summary: List import jobs
      description: 'Roles: `admin`. API key scopes: `imports:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - imports:write
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Job'
                  meta:
                    $ref: '#/components/schemas/PageMeta'
                required:
                - data
                - meta
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /imports/{id}:
    get:
      operationId: getImport
      tags:
      - Imports
      summary: Get an import job
      description: 'Roles: `admin`. API key scopes: `imports:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - imports:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Job'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /imports/{id}/cancel:
    post:
      operationId: cancelImport
      tags:
      - Imports
      summary: Cancel an import job
      description: |-
        Items already created are kept.

        Roles: `admin`. API key scopes: `imports:write`.
      x-roles:
      - admin
      x-required-scopes:
      - imports:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Job'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /epg/sources:
    get:
      operationId: listEpgSources
      tags:
      - EPG
      summary: List epgsources
      description: |-
        Sortable fields: id, name, priority.

        Roles: `admin`. API key scopes: `epg:read`.
      x-roles:
      - admin
      x-required-scopes:
      - epg:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/Q'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EpgSourceList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    post:
      operationId: createEpgSource
      tags:
      - EPG
      summary: Create a epgSource
      description: 'Roles: `admin`. API key scopes: `epg:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - epg:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EpgSourceCreate'
      responses:
        '201':
          description: Created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EpgSource'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /epg/sources/{id}:
    get:
      operationId: getEpgSource
      tags:
      - EPG
      summary: Get a epgSource
      description: 'Roles: `admin`. API key scopes: `epg:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - epg:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EpgSource'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    patch:
      operationId: updateEpgSource
      tags:
      - EPG
      summary: Update a epgSource
      description: 'Roles: `admin`. API key scopes: `epg:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - epg:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EpgSourceUpdate'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EpgSource'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    delete:
      operationId: deleteEpgSource
      tags:
      - EPG
      summary: Delete a epgSource
      description: |-
        Streams mapped to its channels lose their mapping.

        Roles: `admin`. API key scopes: `epg:write`.
      x-roles:
      - admin
      x-required-scopes:
      - epg:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /epg/sources/{id}/refresh:
    post:
      operationId: refreshEpgSource
      tags:
      - EPG
      summary: Refresh an EPG source now
      description: 'Roles: `admin`. API key scopes: `epg:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - epg:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '202':
          $ref: '#/components/responses/Accepted'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /epg/channels:
    get:
      operationId: listEpgChannels
      tags:
      - EPG
      summary: List channels found in EPG sources
      description: 'Roles: `admin`. API key scopes: `epg:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - epg:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/Q'
      - name: epg_source_id
        in: query
        schema:
          type: integer
          format: int64
      - name: id
        in: query
        description: Only the channel with this id.
        schema:
          type: integer
          format: int64
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EpgChannelList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /epg/channels/{id}/programmes:
    get:
      operationId: listEpgProgrammes
      tags:
      - EPG
      summary: Preview programmes of an EPG channel
      description: 'Roles: `admin`. API key scopes: `epg:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - epg:read
      parameters:
      - $ref: '#/components/parameters/Id'
      - $ref: '#/components/parameters/From'
      - $ref: '#/components/parameters/To'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/EpgProgramme'
                required:
                - data
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /epg/mapping:
    get:
      operationId: listEpgMapping
      tags:
      - EPG
      summary: Streams and their EPG mapping
      description: |-
        Includes the best automatic suggestion for unmapped streams.

        Roles: `admin`. API key scopes: `epg:read`.
      x-roles:
      - admin
      x-required-scopes:
      - epg:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/Q'
      - name: state
        in: query
        schema:
          type: string
          examples:
          - all
          enum:
          - all
          - mapped
          - unmapped
      - $ref: '#/components/parameters/CategoryIdQ'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/EpgMappingRow'
                  meta:
                    $ref: '#/components/schemas/PageMeta'
                required:
                - data
                - meta
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    put:
      operationId: setEpgMapping
      tags:
      - EPG
      summary: Set EPG mapping for many streams
      description: |-
        epg_channel_id null removes the mapping.

        Roles: `admin`. API key scopes: `epg:write`, `streams:write`.
      x-roles:
      - admin
      x-required-scopes:
      - epg:write
      - streams:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                mappings:
                  type: array
                  items:
                    $ref: '#/components/schemas/EpgMapping'
                  minItems: 1
                  maxItems: 5000
              required:
              - mappings
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BulkResult'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /epg/mapping/auto:
    post:
      operationId: autoMapEpg
      tags:
      - EPG
      summary: Map streams to EPG channels by name
      description: |-
        Matches normalised names (drops HD, FHD, country prefixes). With apply false it only returns suggestions.

        Roles: `admin`. API key scopes: `epg:write`, `streams:write`.
      x-roles:
      - admin
      x-required-scopes:
      - epg:write
      - streams:write
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                stream_ids:
                  type: array
                  items:
                    type: integer
                    format: int64
                  description: Defaults to every unmapped stream.
                source_id:
                  type: integer
                  format: int64
                  description: Match only channels of this EPG source. Default all enabled sources.
                min_score:
                  type: number
                  default: 0.85
                  minimum: 0
                  maximum: 1
                apply:
                  type: boolean
                  default: false
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/EpgMappingRow'
                  applied:
                    type: integer
                    examples:
                    - 210
                    format: int32
                required:
                - data
                - applied
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /nodes:
    get:
      operationId: listNodes
      tags:
      - Nodes
      summary: List nodes
      description: |-
        Sortable fields: id, name, status, clients, cpu_pct.

        Roles: `admin`. API key scopes: `nodes:read`.
      x-roles:
      - admin
      x-required-scopes:
      - nodes:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/Q'
      - name: status
        in: query
        schema:
          type: string
          examples:
          - pending
          enum:
          - pending
          - online
          - offline
          - maintenance
          - disabled
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NodeList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /nodes/{id}:
    get:
      operationId: getNode
      tags:
      - Nodes
      summary: Get a node
      description: 'Roles: `admin`. API key scopes: `nodes:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - nodes:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Node'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    patch:
      operationId: updateNode
      tags:
      - Nodes
      summary: Update a node
      description: 'Roles: `admin`. API key scopes: `nodes:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - nodes:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NodeUpdate'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Node'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    delete:
      operationId: deleteNode
      tags:
      - Nodes
      summary: Delete a node
      description: |-
        Revokes its certificate and secret and removes it from every server tree. Fails with `409 node_in_use` if it is the only root of a stream unless `?force=true`.

        Roles: `admin`. API key scopes: `nodes:write`.
      x-roles:
      - admin
      x-required-scopes:
      - nodes:write
      parameters:
      - $ref: '#/components/parameters/Id'
      - name: force
        in: query
        schema:
          type: boolean
          default: false
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /node-join-tokens:
    post:
      operationId: createJoinToken
      tags:
      - Nodes
      summary: Create a node join token
      description: |-
        Single use, expires in ttl_minutes. The node enrolls with it over `POST /node/v1/enroll` (node protocol, not this API).

        Roles: `admin`. API key scopes: `nodes:write`.
      x-roles:
      - admin
      x-required-scopes:
      - nodes:write
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/JoinTokenCreate'
      responses:
        '201':
          description: Created. Copy the token now, it is not shown again.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JoinToken'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    get:
      operationId: listJoinTokens
      tags:
      - Nodes
      summary: List join tokens
      description: 'Roles: `admin`. API key scopes: `nodes:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - nodes:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/JoinToken'
                required:
                - data
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /node-join-tokens/{id}:
    delete:
      operationId: deleteJoinToken
      tags:
      - Nodes
      summary: Revoke a join token
      description: 'Roles: `admin`. API key scopes: `nodes:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - nodes:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /nodes/ssh/host-key:
    post:
      operationId: getSSHHostKey
      tags:
      - Nodes
      summary: Read the SSH host key of a server
      description: |-
        First step of an install over SSH. The control connects to the server and returns its host key fingerprint without logging in. Show it to the admin and send it back as `host_key` once they confirm it (trust on first use). Errors: `502 ssh_unreachable`.

        Roles: `admin`. API key scopes: `nodes:write`.
      x-roles:
      - admin
      x-required-scopes:
      - nodes:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SSHTarget'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SSHHostKey'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '502':
          description: The SSH server could not be reached (`ssh_unreachable`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /nodes/ssh/install:
    post:
      operationId: startSSHInstall
      tags:
      - Nodes
      summary: Install a node or a proxy over SSH
      description: |-
        Connects to the server over SSH, checks that its host key matches `host_key`, uploads the installer that ships with this control version (checked by SHA-256 on the server) and runs install.sh with the join token and its role. Runs in the background: poll `GET /nodes/ssh/install/{id}`.

        The SSH password, private key, passphrase and sudo password are used once in memory. They are never stored or logged. Users other than root run the installer with sudo (`sudo_password`, else the SSH password, else passwordless sudo). One install per host at a time.

        Needs a signed in user and a fresh check of their password (and TOTP or recovery code when two-step sign-in is on): API keys get `403 api_key_not_allowed`. Errors: `400 invalid_password`, `400 totp_invalid`, `409 join_token_invalid`, `409 install_running`, `409 install_bundle_missing`, `429 rate_limited`.

        Roles: `admin`. API key scopes: `nodes:write`.
      x-roles:
      - admin
      x-required-scopes:
      - nodes:write
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SSHInstallRequest'
      responses:
        '202':
          description: Started.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                  join_token_id:
                    type: integer
                    format: int64
                required:
                - id
                - join_token_id
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /nodes/ssh/install/{id}:
    get:
      operationId: getSSHInstall
      tags:
      - Nodes
      summary: Status and log of an install over SSH
      description: |-
        Poll every second or two. `lines` are the install log lines from `from` on (redacted); pass `next` as `from` on the next call. `node_id` is set once the new server joined. Kept for 2 hours.

        Roles: `admin`. API key scopes: `nodes:write`.
      x-roles:
      - admin
      x-required-scopes:
      - nodes:write
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: from
        in: query
        required: false
        schema:
          type: integer
          minimum: 0
          default: 0
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SSHInstallJob'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /nodes/{id}/stats:
    get:
      operationId: getNodeStats
      tags:
      - Nodes
      summary: Node stats over time
      description: |-
        Live sample plus history. Under 24 hours uses 1 minute points from Redis, longer ranges use hourly rollups.

        Roles: `admin`. API key scopes: `nodes:read`.
      x-roles:
      - admin
      x-required-scopes:
      - nodes:read
      parameters:
      - $ref: '#/components/parameters/Id'
      - $ref: '#/components/parameters/From'
      - $ref: '#/components/parameters/To'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  live:
                    $ref: '#/components/schemas/NodeLiveStats'
                  series:
                    type: array
                    items:
                      $ref: '#/components/schemas/TimeSeries'
                    description: cpu_pct, mem_pct, load1, rx_mbps, tx_mbps, clients, streams.
                required:
                - series
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /nodes/{id}/tuning:
    get:
      operationId: getNodeTuning
      tags:
      - Nodes
      summary: CPU and memory tuning suggestions
      description: |-
        Rule based suggestions from the last 24 hours of stats (buffer sizes, llod candidates, on-demand candidates, ffmpeg build, kernel network settings).

        Roles: `admin`. API key scopes: `nodes:read`.
      x-roles:
      - admin
      x-required-scopes:
      - nodes:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/TuningSuggestion'
                required:
                - data
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /nodes/{id}/system-tuning:
    get:
      operationId: getNodeSystemTuning
      tags:
      - Nodes
      summary: Kernel tuning, current and recommended
      description: |-
        The kernel settings bs-node manages (sysctl network and memory keys, CPU governor) as the node last reported them, next to the values it recommends for its RAM, cores and link speed.

        Roles: `admin`. API key scopes: `nodes:read`.
      x-roles:
      - admin
      x-required-scopes:
      - nodes:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NodeSystemTuning'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /nodes/{id}/system-tuning/apply:
    post:
      operationId: applyNodeSystemTuning
      tags:
      - Nodes
      summary: Apply the recommended kernel tuning
      description: |-
        Asks the node to apply its recommended values. bs-node runs unprivileged: it writes a request that a small root helper (bs-node-tune, a systemd path unit) validates against a fixed list of keys and ranges, applies and saves to /etc/sysctl.d/90-bitstream.conf. The outcome shows up in `last_result` of the system-tuning view within about a minute. `409 node_offline`, `409 node_too_old` (bs-node without this feature) or `409 tuning_unavailable` (helper not installed).

        Roles: `admin`. API key scopes: `nodes:write`.
      x-roles:
      - admin
      x-required-scopes:
      - nodes:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '202':
          description: Requested.
          content:
            application/json:
              schema:
                type: object
                properties:
                  request_id:
                    type: string
                required:
                - request_id
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /nodes/{id}/domains:
    get:
      operationId: getNodeDomains
      tags:
      - Nodes
      summary: DNS and certificate status of the node domains
      description: |-
        For each domain: the records it needs, what it resolves to now, and its certificate. With the Cloudflare token and a zone set, records are created by the Cloudflare sync and certificates are issued with dns-01 and pushed to the node over its control channel (no port 80 needed); renewals are pushed too. Without Cloudflare, create the `expected` records by hand.

        Roles: `admin`. API key scopes: `nodes:read`.
      x-roles:
      - admin
      x-required-scopes:
      - nodes:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NodeDomains'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /nodes/{id}/streams:
    get:
      operationId: listNodeStreams
      tags:
      - Nodes
      summary: Streams assigned to a node with live status
      description: 'Roles: `admin`. API key scopes: `nodes:read`, `streams:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - nodes:read
      - streams:read
      parameters:
      - $ref: '#/components/parameters/Id'
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - name: state
        in: query
        schema:
          type: string
          examples:
          - running
          enum:
          - running
          - starting
          - idle
          - stopped
          - error
          - fallback
          - frozen
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        stream_id:
                          type: integer
                          format: int64
                        name:
                          type: string
                        kind:
                          type: string
                          examples:
                          - live
                          enum:
                          - live
                          - radio
                          - created
                        parent_node_id:
                          type:
                          - integer
                          - 'null'
                          format: int64
                        stats:
                          $ref: '#/components/schemas/StreamNodeStats'
                  meta:
                    $ref: '#/components/schemas/PageMeta'
                required:
                - data
                - meta
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /nodes/{id}/processes:
    get:
      operationId: listNodeProcesses
      tags:
      - Nodes
      summary: Process monitor of a node
      description: |-
        Processes the node supervises, with CPU and memory.

        Roles: `admin`. API key scopes: `nodes:read`.
      x-roles:
      - admin
      x-required-scopes:
      - nodes:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Process'
                required:
                - data
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /processes:
    get:
      operationId: listMachineProcesses
      tags:
      - Nodes
      summary: Every process of every machine
      description: |-
        All processes of the control host and of each online node, one entry per machine.
        Each machine measures itself on request (CPU over about 0.5 s, cached 2 s), never in the background.
        A node on the panel machine (same machine id) is one entry with both roles, its processes listed once.

        Command lines are redacted on the machine before they leave it: URLs become scheme://host,
        values of flags named like pass, password, token, key, secret, auth, cookie or header become ***.
        The environment is never read. Disk I/O of processes of other users is null: nodes do not run as root.

        Nodes older than this feature send only their ffmpeg processes (`full` false).

        Roles: `admin`. API key scopes: `nodes:read`.
      x-roles:
      - admin
      x-required-scopes:
      - nodes:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  generated_at:
                    type: string
                    format: date-time
                  machines:
                    type: array
                    items:
                      $ref: '#/components/schemas/ProcessMachine'
                required:
                - generated_at
                - machines
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /connections:
    get:
      operationId: listConnections
      tags:
      - Connections
      summary: List live connections
      description: |-
        From Redis, near real time. Resellers see connections of lines in their tree.

        Sortable fields: started_at, bytes_out, bitrate_kbps.

        Roles: `admin`, `reseller`. API key scopes: `connections:read`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - connections:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/Q'
      - name: line_id
        in: query
        schema:
          type: integer
          format: int64
      - name: content_id
        in: query
        schema:
          type: integer
          format: int64
      - name: content_kind
        in: query
        schema:
          type: string
          examples:
          - live
          enum:
          - live
          - radio
          - movie
          - episode
      - $ref: '#/components/parameters/NodeIdQ'
      - name: proxy_id
        in: query
        description: Only sessions that came through this proxy node.
        schema:
          type: integer
          format: int64
      - name: owner_id
        in: query
        schema:
          type: integer
          format: int64
      - name: ip
        in: query
        schema:
          type: string
      - name: country_code
        in: query
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConnectionList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /connections/{session_id}:
    delete:
      operationId: killConnection
      tags:
      - Connections
      summary: Kill one connection
      description: 'Roles: `admin`, `reseller`. API key scopes: `connections:kill`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - connections:kill
      parameters:
      - name: session_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /connections/kill:
    post:
      operationId: killConnections
      tags:
      - Connections
      summary: Kill connections by filter
      description: |-
        At least one filter is required. Kills only what you can see.

        Roles: `admin`, `reseller`. API key scopes: `connections:kill`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - connections:kill
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                session_ids:
                  type: array
                  items:
                    type: string
                    format: uuid
                line_ids:
                  type: array
                  items:
                    type: integer
                    format: int64
                content_id:
                  type: integer
                  format: int64
                node_id:
                  type: integer
                  format: int64
                ip:
                  type: string
                all:
                  type: boolean
                  description: Close every connection you can see. Cannot be combined with other filters.
              minProperties: 1
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  killed:
                    type: integer
                    examples:
                    - 14
                    format: int32
                required:
                - killed
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /history/connections:
    get:
      operationId: listHistory
      tags:
      - Stats
      summary: Finished sessions
      description: |-
        Sortable fields: started_at, duration_s, bytes_out.

        Roles: `admin`, `reseller`. API key scopes: `stats:read`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - stats:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/From'
      - $ref: '#/components/parameters/To'
      - name: line_id
        in: query
        schema:
          type: integer
          format: int64
      - name: content_id
        in: query
        schema:
          type: integer
          format: int64
      - name: content_kind
        in: query
        schema:
          type: string
          examples:
          - live
          enum:
          - live
          - radio
          - movie
          - episode
      - $ref: '#/components/parameters/NodeIdQ'
      - name: proxy_id
        in: query
        description: Only sessions that came through this proxy node.
        schema:
          type: integer
          format: int64
      - name: ip
        in: query
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HistorySessionList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /stats/bandwidth:
    get:
      operationId: getBandwidth
      tags:
      - Stats
      summary: Bandwidth and watch time over time
      description: |-
        Daily buckets from the usage aggregate. `group_by` splits the series.

        Roles: `admin`, `reseller`. API key scopes: `stats:read`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - stats:read
      parameters:
      - $ref: '#/components/parameters/From'
      - $ref: '#/components/parameters/To'
      - name: group_by
        in: query
        schema:
          type: string
          examples:
          - none
          enum:
          - none
          - node
          - content_kind
      - $ref: '#/components/parameters/NodeIdQ'
      - name: line_id
        in: query
        schema:
          type: integer
          format: int64
      - name: content_id
        in: query
        schema:
          type: integer
          format: int64
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  series:
                    type: array
                    items:
                      type: object
                      properties:
                        key:
                          type: string
                          description: Group key, `total` when group_by is none.
                          examples:
                          - total
                        points:
                          type: array
                          items:
                            type: object
                            properties:
                              day:
                                type: string
                                format: date
                              bytes_out:
                                type: integer
                                format: int64
                              watch_seconds:
                                type: integer
                                format: int64
                              sessions:
                                type: integer
                                format: int64
                required:
                - series
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /stats/top:
    get:
      operationId: getTop
      tags:
      - Stats
      summary: Top content or lines
      description: 'Roles: `admin`, `reseller`. API key scopes: `stats:read`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - stats:read
      parameters:
      - $ref: '#/components/parameters/From'
      - $ref: '#/components/parameters/To'
      - name: subject
        in: query
        required: true
        schema:
          type: string
          examples:
          - content
          enum:
          - content
          - lines
          - countries
          - user_agents
      - name: metric
        in: query
        schema:
          type: string
          examples:
          - watch_seconds
          enum:
          - watch_seconds
          - bytes_out
          - sessions
      - name: limit
        in: query
        schema:
          type: integer
          format: int32
          default: 10
          maximum: 100
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        key:
                          type: string
                          examples:
                          - '101'
                        label:
                          type: string
                          examples:
                          - SporTV HD
                        value:
                          type: integer
                          examples:
                          - 8123400
                          format: int64
                required:
                - data
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /stats/summary:
    get:
      operationId: getStatsSummary
      tags:
      - Stats
      summary: Live summary strip
      description: |-
        The few live numbers shown on top of every page. Read from what the control keeps in Redis (connection slots, node stats, stream states), the same sources and rules as `GET /dashboard`, so the numbers match. Cached for 5 seconds per caller scope; poll every 10 seconds while the page is visible.

        Admins get connections, streams online and offline, and bandwidth in and out summed over nodes with a per node breakdown. Resellers get their own connections, online lines and active lines; the admin only fields are null.

        Roles: `admin`, `reseller`. API key scopes: `stats:read`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - stats:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StatsSummary'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /search:
    get:
      operationId: search
      tags:
      - Stats
      summary: Search everything (command palette)
      description: |-
        Lines (username, client name, reseller notes), resellers (username, email; admins are not listed), streams, movies and series whose name contains `q`, at most 5 per group, prefix matches first. Each group follows the rules of its list endpoint: a group needs its read scope (`lines:read`, `users:read`, `streams:read`, `vod:read`) and is empty without it, resellers only find lines and sub-resellers in their tree, and content groups are admin only.

        Roles: `admin`, `reseller`.
      x-roles:
      - admin
      - reseller
      parameters:
      - name: q
        in: query
        required: true
        description: 2 to 100 characters.
        schema:
          type: string
          minLength: 2
          maxLength: 100
          examples:
          - maria
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResults'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /dashboard/health:
    get:
      operationId: getServiceHealth
      tags:
      - Stats
      summary: Service status checks
      description: |-
        Best practice checks the control can verify itself (2FA of admins, HTTPS, API key scopes, license, backups, database TLS, Redis password, nodes on the control host, panel edges and panel_url, node clocks, disk free, node tuning, ffmpeg, nodes offline). A check whose data is not available (no nodes, no node reports its tuning) is left out instead of shown as passing. `state` is `problem` when a critical check fails, `attention` when a warning check fails, else `ok`. Cached 60 seconds (`bs:cache:health:admin`).

        Roles: `admin`. API key scopes: `stats:read`. Resellers get 403.
      x-roles:
      - admin
      x-required-scopes:
      - stats:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServiceHealth'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /dashboard/machines:
    get:
      operationId: getMachines
      tags:
      - Stats
      summary: Machine tiles
      description: |-
        Every machine of the cluster in one call: each control replica, node, node proxy and panel edge, with its latest numbers and one point per minute for the last hour. `metrics` lists the numbers that apply to that machine, in display order. Cached 5 seconds; poll every 10 seconds while the page is visible.

        Roles: `admin`. API key scopes: `stats:read`. Resellers get 403.
      x-roles:
      - admin
      x-required-scopes:
      - stats:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MachineList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /stats/cluster:
    get:
      operationId: getClusterStats
      tags:
      - Stats
      summary: Cluster CPU and memory
      description: |-
        CPU % (weighted by cores) and memory % (used over total bytes) of every machine together, one point a minute kept 7 days in Redis. `24h` is averaged into 5 minute buckets, `7d` into 30 minute buckets.

        Roles: `admin`. API key scopes: `stats:read`. Resellers get 403.
      x-roles:
      - admin
      x-required-scopes:
      - stats:read
      parameters:
      - name: range
        in: query
        schema:
          type: string
          enum:
          - 1h
          - 24h
          - 7d
          default: 1h
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClusterStats'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /stats/geo:
    get:
      operationId: getGeo
      tags:
      - Stats
      summary: Map data of live connections
      description: 'Roles: `admin`, `reseller`. API key scopes: `stats:read`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - stats:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GeoData'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /dashboard:
    get:
      operationId: getDashboard
      tags:
      - Stats
      summary: Dashboard summary
      description: |-
        One request for all widgets. Cached for 5 seconds per caller scope; poll every 10 to 30 seconds.

        Roles: `admin`, `reseller`. API key scopes: `stats:read`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - stats:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Dashboard'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /security/blocked-ips:
    get:
      operationId: listBlockedIps
      tags:
      - Security
      summary: List blockedips
      description: |-
        Sortable fields: id, created_at, expires_at.

        Roles: `admin`. API key scopes: `security:read`.
      x-roles:
      - admin
      x-required-scopes:
      - security:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/Q'
      - name: source
        in: query
        schema:
          type: string
          examples:
          - manual
          enum:
          - manual
          - auto
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BlockedIpList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    post:
      operationId: createBlockedIp
      tags:
      - Security
      summary: Create a blockedIp
      description: 'Roles: `admin`. API key scopes: `security:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - security:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BlockedIpCreate'
      responses:
        '201':
          description: Created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BlockedIp'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /security/blocked-ips/{id}:
    delete:
      operationId: deleteBlockedIp
      tags:
      - Security
      summary: Delete a blockedIp
      description: 'Roles: `admin`. API key scopes: `security:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - security:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /security/blocked-countries:
    get:
      operationId: listBlockedCountries
      tags:
      - Security
      summary: List blocked countries
      description: 'Roles: `admin`. API key scopes: `security:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - security:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/BlockedCountry'
                required:
                - data
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    put:
      operationId: replaceBlockedCountries
      tags:
      - Security
      summary: Replace blocked countries
      description: 'Roles: `admin`. API key scopes: `security:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - security:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                countries:
                  type: array
                  items:
                    $ref: '#/components/schemas/BlockedCountry'
              required:
              - countries
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/BlockedCountry'
                required:
                - data
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /security/blocked-countries/{country_code}:
    delete:
      operationId: unblockCountry
      tags:
      - Security
      summary: Unblock a country
      description: 'Roles: `admin`. API key scopes: `security:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - security:write
      parameters:
      - name: country_code
        in: path
        required: true
        schema:
          type: string
          pattern: ^[A-Z]{2}$
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /security/blocked-asns:
    get:
      operationId: listBlockedAsns
      tags:
      - Security
      summary: List blocked ASNs
      description: 'Roles: `admin`. API key scopes: `security:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - security:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/BlockedAsn'
                required:
                - data
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    post:
      operationId: blockAsn
      tags:
      - Security
      summary: Block an ASN
      description: 'Roles: `admin`. API key scopes: `security:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - security:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BlockedAsn'
      responses:
        '201':
          description: Created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BlockedAsn'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /security/blocked-asns/{asn}:
    delete:
      operationId: unblockAsn
      tags:
      - Security
      summary: Unblock an ASN
      description: 'Roles: `admin`. API key scopes: `security:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - security:write
      parameters:
      - name: asn
        in: path
        required: true
        schema:
          type: integer
          format: int64
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /security/blocked-user-agents:
    get:
      operationId: listBlockedUserAgents
      tags:
      - Security
      summary: List blockeduseragents
      description: |-
        Sortable fields: id, pattern.

        Roles: `admin`. API key scopes: `security:read`.
      x-roles:
      - admin
      x-required-scopes:
      - security:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/Q'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BlockedUserAgentList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    post:
      operationId: createBlockedUserAgent
      tags:
      - Security
      summary: Create a blockedUserAgent
      description: 'Roles: `admin`. API key scopes: `security:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - security:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BlockedUserAgentCreate'
      responses:
        '201':
          description: Created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BlockedUserAgent'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /security/blocked-user-agents/{id}:
    delete:
      operationId: deleteBlockedUserAgent
      tags:
      - Security
      summary: Delete a blockedUserAgent
      description: 'Roles: `admin`. API key scopes: `security:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - security:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /security/login-attempts:
    get:
      operationId: listLoginAttempts
      tags:
      - Security
      summary: Login attempts
      description: |-
        Panel logins and client (line) logins. Sortable: at.

        Roles: `admin`. API key scopes: `security:read`.
      x-roles:
      - admin
      x-required-scopes:
      - security:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Q'
      - $ref: '#/components/parameters/From'
      - $ref: '#/components/parameters/To'
      - name: kind
        in: query
        schema:
          type: string
          examples:
          - panel
          enum:
          - panel
          - line
      - name: success
        in: query
        schema:
          type: boolean
      - name: ip
        in: query
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LoginAttemptList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /tickets:
    get:
      operationId: listTickets
      tags:
      - Tickets
      summary: List tickets
      description: |-
        Sortable fields: updated_at, created_at, priority.

        Roles: `admin`, `reseller`. API key scopes: `tickets:read`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - tickets:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/Q'
      - name: status
        in: query
        schema:
          type: string
          examples:
          - open
          enum:
          - open
          - answered
          - closed
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TicketList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    post:
      operationId: createTicket
      tags:
      - Tickets
      summary: Create a ticket
      description: |-
        Resellers open tickets. Panel staff answer them but cannot open one: `403 tickets_staff_cannot_open`.
        Roles: `admin`, `reseller`. API key scopes: `tickets:write`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - tickets:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TicketCreate'
      responses:
        '201':
          description: Created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Ticket'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /tickets/{id}:
    get:
      operationId: getTicket
      tags:
      - Tickets
      summary: Get a ticket
      description: 'Roles: `admin`, `reseller`. API key scopes: `tickets:read`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - tickets:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Ticket'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    patch:
      operationId: updateTicket
      tags:
      - Tickets
      summary: Update a ticket
      description: 'Roles: `admin`, `reseller`. API key scopes: `tickets:write`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - tickets:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TicketUpdate'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Ticket'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /tickets/{id}/messages:
    post:
      operationId: replyTicket
      tags:
      - Tickets
      summary: Reply to a ticket
      description: |-
        A reply from the other side sets status answered; a reply from the opener sets it open.

        Roles: `admin`, `reseller`. API key scopes: `tickets:write`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - tickets:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TicketMessage'
      responses:
        '201':
          description: Created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TicketMessage'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /backups:
    get:
      operationId: listBackups
      tags:
      - Backups
      summary: List backups
      description: 'Roles: `admin`. API key scopes: `backups:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - backups:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BackupList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    post:
      operationId: createBackup
      tags:
      - Backups
      summary: Create a backup now
      description: |-
        Encrypted pg_dump of the database plus settings. Connection history can be excluded to keep it small.

        Roles: `admin`. API key scopes: `backups:write`.
      x-roles:
      - admin
      x-required-scopes:
      - backups:write
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                include_history:
                  type: boolean
                  default: false
                note:
                  type: string
      responses:
        '202':
          description: Started.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Backup'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /backups/{id}:
    get:
      operationId: getBackup
      tags:
      - Backups
      summary: Get a backup
      description: 'Roles: `admin`. API key scopes: `backups:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - backups:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Backup'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    delete:
      operationId: deleteBackup
      tags:
      - Backups
      summary: Delete a backup
      description: 'Roles: `admin`. API key scopes: `backups:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - backups:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /backups/{id}/download:
    get:
      operationId: downloadBackup
      tags:
      - Backups
      summary: Download a backup file
      description: 'Roles: `admin`. API key scopes: `backups:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - backups:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: The encrypted backup file.
          headers:
            Content-Disposition:
              schema:
                type: string
                examples:
                - attachment; filename="bitstream-2026-11-28T030000Z.dump.enc"
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /backups/upload:
    post:
      operationId: uploadBackup
      tags:
      - Backups
      summary: Upload a backup file
      description: |-
        The file must be encrypted with this instance master key or the key given in `master_key`. A file uploaded with another `master_key` is stored and can be downloaded, but it cannot be restored (`backup_not_local`): only backups made by this panel can be restored. To move a panel to a new server, copy its master key there.

        Needs a signed in user: API keys get `403 api_key_not_allowed`.

        Roles: `admin`. API key scopes: `backups:write`.
      x-roles:
      - admin
      x-required-scopes:
      - backups:write
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
                master_key:
                  type: string
                  description: Master key of the instance that made it, if different.
              required:
              - file
      responses:
        '201':
          description: Stored.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Backup'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /backups/{id}/restore:
    post:
      operationId: restoreBackup
      tags:
      - Backups
      summary: Restore a backup
      description: |-
        Takes a pre_restore backup first, then replaces the database. All sessions are signed out and nodes resync. Send `confirm: "RESTORE"`, your password and, when two-step sign-in is on, a TOTP or recovery code.

        Needs a signed in user: API keys get `403 api_key_not_allowed`. Errors: `400 invalid_password`, `400 totp_invalid`, `409 backup_not_local` (the file was uploaded with another master key), `429 rate_limited` (5 password tries per 15 minutes).

        Roles: `admin`. API key scopes: `backups:write`.
      x-roles:
      - admin
      x-required-scopes:
      - backups:write
      security:
      - bearerAuth: []
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                confirm:
                  type: string
                  const: RESTORE
                password:
                  type: string
                  format: password
                  description: The current password of the signed in user.
                totp_code:
                  type: string
                  description: TOTP or recovery code. Required when two-step sign-in is on.
              required:
              - confirm
              - password
      responses:
        '202':
          $ref: '#/components/responses/Accepted'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /cache/flush:
    post:
      operationId: flushCache
      tags:
      - System
      summary: Flush caches
      description: |-
        Bumps catalog_rev and drops in-memory caches of the client API. Clients get fresh data on their next request. Safe at any time.

        Roles: `admin`. API key scopes: `settings:write`.
      x-roles:
      - admin
      x-required-scopes:
      - settings:write
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                targets:
                  type: array
                  items:
                    type: string
                    examples:
                    - all
                    enum:
                    - all
                    - catalog
                    - playlists
                    - epg
                    - lines
                    - geoip
                  default:
                  - all
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  catalog_rev:
                    type: integer
                    examples:
                    - 1834
                    format: int64
                  flushed:
                    type: array
                    items:
                      type: string
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /cache/stats:
    get:
      operationId: getCacheStats
      tags:
      - System
      summary: Cache usage
      description: 'Roles: `admin`. API key scopes: `settings:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - settings:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  catalog_rev:
                    type: integer
                    format: int64
                  memory_bytes:
                    type: integer
                    format: int64
                  memory_limit_bytes:
                    type: integer
                    format: int64
                  entries:
                    type: integer
                    format: int64
                  hit_ratio:
                    type: number
                    examples:
                    - 0.97
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /settings:
    get:
      operationId: getSettings
      tags:
      - Settings
      summary: Get all settings
      description: 'Roles: `admin`. API key scopes: `settings:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - settings:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Settings'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /settings/{group}:
    get:
      operationId: getSettingsGroup
      tags:
      - Settings
      summary: Get one settings group
      description: 'Roles: `admin`. API key scopes: `settings:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - settings:read
      parameters:
      - name: group
        in: path
        required: true
        schema:
          type: string
          examples:
          - general
          enum:
          - general
          - streaming
          - client_api
          - security
          - epg
          - history
          - backups
          - monitoring
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                oneOf:
                - $ref: '#/components/schemas/SettingsGeneral'
                - $ref: '#/components/schemas/SettingsStreaming'
                - $ref: '#/components/schemas/SettingsClientApi'
                - $ref: '#/components/schemas/SettingsSecurity'
                - $ref: '#/components/schemas/SettingsEpg'
                - $ref: '#/components/schemas/SettingsHistory'
                - $ref: '#/components/schemas/SettingsBackups'
                - $ref: '#/components/schemas/SettingsMonitoring'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    patch:
      operationId: updateSettingsGroup
      tags:
      - Settings
      summary: Update one settings group
      description: |-
        Send only the keys to change. Most settings apply within seconds; streaming buffer changes apply on the next stream start.

        Roles: `admin`. API key scopes: `settings:write`.
      x-roles:
      - admin
      x-required-scopes:
      - settings:write
      parameters:
      - name: group
        in: path
        required: true
        schema:
          type: string
          examples:
          - general
          enum:
          - general
          - streaming
          - client_api
          - security
          - epg
          - history
          - backups
          - monitoring
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
              - $ref: '#/components/schemas/SettingsGeneral'
              - $ref: '#/components/schemas/SettingsStreaming'
              - $ref: '#/components/schemas/SettingsClientApi'
              - $ref: '#/components/schemas/SettingsSecurity'
              - $ref: '#/components/schemas/SettingsEpg'
              - $ref: '#/components/schemas/SettingsHistory'
              - $ref: '#/components/schemas/SettingsBackups'
              - $ref: '#/components/schemas/SettingsMonitoring'
            example:
              message_of_day: Maintenance tonight at 02:00
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                oneOf:
                - $ref: '#/components/schemas/SettingsGeneral'
                - $ref: '#/components/schemas/SettingsStreaming'
                - $ref: '#/components/schemas/SettingsClientApi'
                - $ref: '#/components/schemas/SettingsSecurity'
                - $ref: '#/components/schemas/SettingsEpg'
                - $ref: '#/components/schemas/SettingsHistory'
                - $ref: '#/components/schemas/SettingsBackups'
                - $ref: '#/components/schemas/SettingsMonitoring'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /geoip:
    get:
      operationId: getGeoIP
      tags:
      - GeoIP
      summary: IP geolocation status
      description: 'Roles: `admin`. API key scopes: `settings:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - settings:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GeoIPStatus'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    patch:
      operationId: updateGeoIP
      tags:
      - GeoIP
      summary: Choose the IP geolocation provider
      description: 'Roles: `admin`. API key scopes: `settings:write`. Changing the provider or MaxMind credentials starts an update in the background.'
      x-roles:
      - admin
      x-required-scopes:
      - settings:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                provider:
                  type: string
                  enum:
                  - dbip
                  - maxmind
                maxmind_account_id:
                  type: string
                  examples:
                  - '123456'
                maxmind_license_key:
                  type:
                  - string
                  - 'null'
                  description: Write only, stored encrypted. null removes it.
                  minLength: 6
                  maxLength: 100
              minProperties: 1
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GeoIPStatus'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /geoip/update:
    post:
      operationId: runGeoIPUpdate
      tags:
      - GeoIP
      summary: Update the IP geolocation databases now
      description: 'Roles: `admin`. API key scopes: `settings:write`. Runs in the background; poll GET /geoip until `updating` is false.'
      x-roles:
      - admin
      x-required-scopes:
      - settings:write
      responses:
        '202':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GeoIPStatus'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /geoip/lookup:
    get:
      operationId: lookupGeoIP
      tags:
      - GeoIP
      summary: Look up one IP
      description: 'Roles: `admin`. API key scopes: `settings:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - settings:read
      parameters:
      - name: ip
        in: query
        required: true
        schema:
          type: string
        examples:
          ip:
            value: 8.8.8.8
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GeoIPLookup'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /cloudflare:
    get:
      operationId: getCloudflare
      tags:
      - Cloudflare
      summary: Cloudflare integration status
      description: 'Roles: `admin`. API key scopes: `settings:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - settings:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CloudflareStatus'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    patch:
      operationId: updateCloudflare
      tags:
      - Cloudflare
      summary: Configure Cloudflare
      description: 'Roles: `admin`. API key scopes: `settings:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - settings:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                zone_id:
                  type: string
                panel_record:
                  type:
                  - string
                  - 'null'
                panel_proxied:
                  type: boolean
                auto_sync:
                  type: boolean
              minProperties: 1
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CloudflareStatus'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /cloudflare/token:
    put:
      operationId: setCloudflareToken
      tags:
      - Cloudflare
      summary: Set the Cloudflare API token
      description: |-
        Needs Zone:Read and DNS:Edit. Verified before saving, stored encrypted, never returned.

        Roles: `admin`. API key scopes: `settings:write`.
      x-roles:
      - admin
      x-required-scopes:
      - settings:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                api_token:
                  type: string
                  minLength: 20
                  writeOnly: true
              required:
              - api_token
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CloudflareStatus'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    delete:
      operationId: deleteCloudflareToken
      tags:
      - Cloudflare
      summary: Remove the Cloudflare API token
      description: 'Roles: `admin`. API key scopes: `settings:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - settings:write
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /cloudflare/zones:
    get:
      operationId: listCloudflareZones
      tags:
      - Cloudflare
      summary: Zones the token can see
      description: 'Roles: `admin`. API key scopes: `settings:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - settings:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        name:
                          type: string
                          examples:
                          - example.com
                        status:
                          type: string
                          examples:
                          - active
                required:
                - data
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /cloudflare/sync:
    post:
      operationId: syncCloudflareDns
      tags:
      - Cloudflare
      summary: Sync DNS records
      description: |-
        Creates or updates the panel record and one DNS only record per node public_host. With dry_run, only lists the changes.

        Roles: `admin`. API key scopes: `settings:write`.
      x-roles:
      - admin
      x-required-scopes:
      - settings:write
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                dry_run:
                  type: boolean
                  default: false
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  changes:
                    type: array
                    items:
                      type: object
                      properties:
                        action:
                          type: string
                          examples:
                          - create
                          enum:
                          - create
                          - update
                          - delete
                          - none
                        name:
                          type: string
                          examples:
                          - edge1.example.com
                        type:
                          type: string
                          examples:
                          - A
                          enum:
                          - A
                          - AAAA
                        content:
                          type: string
                          examples:
                          - 198.51.100.10
                        proxied:
                          type: boolean
                required:
                - changes
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /panel-edges:
    get:
      operationId: listPanelEdges
      tags:
      - Panel proxies
      summary: List panel proxies
      description: |-
        Panel proxies (bs-edge) sit between Cloudflare and the control so the control IP is never published. Lists them with status, requests per second and last report, plus the settings, the lockdown state and the DNS check.

        Roles: `admin`. API key scopes: `nodes:read`.
      x-roles:
      - admin
      x-required-scopes:
      - nodes:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PanelEdgeView'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
    post:
      operationId: createPanelEdge
      tags:
      - Panel proxies
      summary: Add a panel proxy
      description: |-
        Adds a pending proxy and returns its one hour join token and install command (shown once). Give its IP when the control firewall lockdown is on, so the new proxy can enrol.

        Roles: `admin`. API key scopes: `nodes:write`.
      x-roles:
      - admin
      x-required-scopes:
      - nodes:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PanelEdgeCreate'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PanelEdgeCreated'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /panel-edges/settings:
    patch:
      operationId: updatePanelEdgeSettings
      tags:
      - Panel proxies
      summary: Change panel proxy settings
      description: |-
        Cloudflare only, nodes through proxies (with or without the direct fallback), rate limit, body limit, DNS sync. Answers like the list.

        Roles: `admin`. API key scopes: `settings:write`.
      x-roles:
      - admin
      x-required-scopes:
      - settings:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PanelEdgeSettings'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PanelEdgeView'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /panel-edges/lockdown:
    post:
      operationId: setPanelLockdown
      tags:
      - Panel proxies
      summary: Accept only from proxies
      description: |-
        Turns the lockdown on or off. On, the control answers its public ports from loopback only, and the firewall helper closes them to all but the proxies, the direct nodes and the database. Turning it on needs `confirm: true`, a request that came through a proxy (`lockdown_not_via_edge` otherwise) and one proxy online (`no_edge_online`). It rolls back by itself unless confirmed through a proxy within 5 minutes, and when no proxy reported for 10 minutes.

        Roles: `admin`. API key scopes: `settings:write`.
      x-roles:
      - admin
      x-required-scopes:
      - settings:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                enabled:
                  type: boolean
                confirm:
                  type: boolean
                  default: false
              required:
              - enabled
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PanelEdgeView'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
  /panel-edges/lockdown/confirm:
    post:
      operationId: confirmPanelLockdown
      tags:
      - Panel proxies
      summary: Confirm the lockdown
      description: |-
        Keeps the lockdown on. Must come through a proxy (`lockdown_not_via_edge` otherwise).

        Roles: `admin`. API key scopes: `settings:write`.
      x-roles:
      - admin
      x-required-scopes:
      - settings:write
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PanelEdgeView'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
  /panel-edges/dns/sync:
    post:
      operationId: syncPanelEdgeDns
      tags:
      - Panel proxies
      summary: Sync the panel DNS records
      description: |-
        Points the panel record (proxied A and AAAA) at the online proxies, removes removed and replaced ones, never publishes the control IP, and warns about any record of the zone that points to it.

        Roles: `admin`. API key scopes: `settings:write`.
      x-roles:
      - admin
      x-required-scopes:
      - settings:write
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PanelEdgeDnsResult'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '502':
          description: Cloudflare returned an error (cloudflare_error).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /panel-edges/{id}/replace:
    post:
      operationId: replacePanelEdge
      tags:
      - Panel proxies
      summary: Replace a panel proxy
      description: |-
        Burns the proxy (its certificate stops working, DNS drops it) and adds a pending one in its place with a new join token.

        Roles: `admin`. API key scopes: `nodes:write`.
      x-roles:
      - admin
      x-required-scopes:
      - nodes:write
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
          format: int64
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PanelEdgeCreate'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PanelEdgeCreated'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
  /panel-edges/{id}:
    delete:
      operationId: deletePanelEdge
      tags:
      - Panel proxies
      summary: Remove a panel proxy
      description: |-
        Deletes the proxy. Its certificate stops working at once and DNS drops it.

        Roles: `admin`. API key scopes: `nodes:write`.
      x-roles:
      - admin
      x-required-scopes:
      - nodes:write
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
          format: int64
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /domains:
    get:
      operationId: getDomains
      tags:
      - Domains
      summary: Domains plan
      description: |-
        The host names of the admin panel, admin API, reseller panel and client API, the streaming names of the nodes, and the warnings about the layout. Warnings never block.

        Roles: `admin`. API key scopes: `settings:read`.
      x-roles:
      - admin
      x-required-scopes:
      - settings:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DomainsView'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
    put:
      operationId: putDomains
      tags:
      - Domains
      summary: Save the domains plan
      description: |-
        Saves the plan. Once a plan has a host, bs-control routes by host: the admin API only on admin and reseller hosts, the client API not on them unless `client_api_on_admin_hosts`, the SPA not on the client host. IP addresses and localhost are never restricted. Only setups that cannot work are refused (`invalid_host`, `external_panel_needs_api`, `panel_api_cross_site`, `invalid_hosting` in `details.fields`).

        Roles: `admin`. API key scopes: `settings:write`.
      x-roles:
      - admin
      x-required-scopes:
      - settings:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DomainsPlan'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DomainsView'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /domains/verify:
    post:
      operationId: verifyDomains
      tags:
      - Domains
      summary: Check DNS of every planned host
      description: |-
        Resolves each host of the plan and of the nodes, and tells whether it answers with Cloudflare proxy addresses.

        Roles: `admin`. API key scopes: `settings:read`.
      x-roles:
      - admin
      x-required-scopes:
      - settings:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/DomainCheck'
                required:
                - data
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /domains/dns:
    post:
      operationId: syncDomainsDns
      tags:
      - Domains
      summary: Create the DNS records in Cloudflare
      description: |-
        Writes A/AAAA records for every planned host inside the Cloudflare zone: control hosts point at `ipv4`/`ipv6` (default the public IP of the node API URL), node hosts at the node's public IP. Proxy follows the plan; nodes stay DNS only unless the node asks for the proxy. An external panel is skipped (its static host gives a CNAME).

        Roles: `admin`. API key scopes: `settings:write`.
      x-roles:
      - admin
      x-required-scopes:
      - settings:write
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                ipv4:
                  type: string
                  examples:
                  - 198.51.100.10
                ipv6:
                  type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/DomainDnsChange'
                required:
                - data
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
  /domains/links:
    get:
      operationId: getDomainLinks
      tags:
      - Domains
      summary: Every address of this install
      description: |-
        Admin panel, reseller panel, admin API, client API base for apps, and each node. Before a plan is saved, the address of this request is used.

        Roles: `admin`. API key scopes: `settings:read`.
      x-roles:
      - admin
      x-required-scopes:
      - settings:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/DomainLink'
                required:
                - data
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /certificates:
    get:
      operationId: listCertificates
      tags:
      - Certificates
      summary: List certificates and ACME status
      description: 'Roles: `admin`. API key scopes: `settings:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - settings:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Certificate'
                required:
                - data
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    post:
      operationId: issueCertificate
      tags:
      - Certificates
      summary: Issue a certificate
      description: |-
        Requests a Let's Encrypt certificate. Renewal is automatic 30 days before expiry.

        Roles: `admin`. API key scopes: `settings:write`.
      x-roles:
      - admin
      x-required-scopes:
      - settings:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Certificate'
      responses:
        '202':
          description: Issuing started.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Certificate'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /certificates/{id}/renew:
    post:
      operationId: renewCertificate
      tags:
      - Certificates
      summary: Renew a certificate now
      description: 'Roles: `admin`. API key scopes: `settings:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - settings:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '202':
          description: Renewal started.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Certificate'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /certificates/{id}:
    delete:
      operationId: deleteCertificate
      tags:
      - Certificates
      summary: Delete a certificate
      description: 'Roles: `admin`. API key scopes: `settings:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - settings:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /ai/settings:
    get:
      operationId: getAiSettings
      tags:
      - AI
      summary: Get AI provider settings
      description: 'Roles: `admin`. API key scopes: `settings:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - settings:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiSettings'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    patch:
      operationId: updateAiSettings
      tags:
      - AI
      summary: Update AI provider settings
      description: |-
        The key is tested with a tiny request before saving.

        Roles: `admin`. API key scopes: `settings:write`.
      x-roles:
      - admin
      x-required-scopes:
      - settings:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AiSettings'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiSettings'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /ai/explain:
    post:
      operationId: aiExplain
      tags:
      - AI
      summary: Explain a problem in plain language
      description: |-
        Collects recent stats and logs about the subject, redacts source credentials and client IPs, and asks the configured provider. Fails with `409 ai_not_configured` without a key. Takes up to 60 seconds.

        Roles: `admin`. API key scopes: `ai:use`.
      x-roles:
      - admin
      x-required-scopes:
      - ai:use
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AiExplainRequest'
            example:
              subject_type: stream
              subject_id: '101'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiExplanation'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /api-keys:
    get:
      operationId: listApiKeys
      tags:
      - API keys
      summary: List apikeys
      description: |-
        Your keys. Admins can pass `user_id` to see keys of any user, or `all=true` to see every key (resellers' included).

        A reseller can use API keys only when their group has `apikeys:read` (off by default for reseller groups). Without it their keys
        answer 403 `api_keys_not_allowed`. A key never has more than its owner: the reseller's own scopes and only their own clients.

        Sortable fields: id, name, created_at, last_used_at.

        Roles: `admin`, `reseller`. API key scopes: `apikeys:read`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - apikeys:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/Q'
      - name: user_id
        in: query
        schema:
          type: integer
          format: int64
      - name: all
        in: query
        description: Admins only. Every key of every user.
        schema:
          type: boolean
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiKeyList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    post:
      operationId: createApiKey
      tags:
      - API keys
      summary: Create a apiKey
      description: 'Roles: `admin`, `reseller`. API key scopes: `apikeys:write`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - apikeys:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiKeyCreate'
      responses:
        '201':
          description: Created. Store `key` now; it cannot be shown again.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiKeyCreated'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
      security:
      - bearerAuth: []
  /api-keys/{id}:
    get:
      operationId: getApiKey
      tags:
      - API keys
      summary: Get a apiKey
      description: 'Roles: `admin`, `reseller`. API key scopes: `apikeys:read`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - apikeys:read
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiKey'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    patch:
      operationId: updateApiKey
      tags:
      - API keys
      summary: Update a apiKey
      description: |-
        Bearer token only: an API key cannot change its own (or another key's) IP allowlist, signature requirement or expiry.

        Roles: `admin`, `reseller`. API key scopes: `apikeys:write`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - apikeys:write
      security:
      - bearerAuth: []
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiKeyUpdate'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiKey'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    delete:
      operationId: deleteApiKey
      tags:
      - API keys
      summary: Delete a apiKey
      description: |-
        Revokes the key at once.

        Roles: `admin`, `reseller`. API key scopes: `apikeys:write`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - apikeys:write
      parameters:
      - $ref: '#/components/parameters/Id'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /api-keys/{id}/rotate:
    post:
      operationId: rotateApiKey
      tags:
      - API keys
      summary: Rotate an API key secret
      description: |-
        Issues a new secret with the same prefix id, scopes and settings. The old secret stops working after `grace_seconds`.

        Roles: `admin`, `reseller`. API key scopes: `apikeys:write`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - apikeys:write
      security:
      - bearerAuth: []
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                grace_seconds:
                  type: integer
                  format: int32
                  default: 0
                  minimum: 0
                  maximum: 86400
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiKeyCreated'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /audit-log:
    get:
      operationId: listAuditLog
      tags:
      - Audit
      summary: Audit log
      description: |-
        Every change made through the API. Resellers see entries made by themselves and their sub-resellers.

        Roles: `admin`, `reseller`. API key scopes: `audit:read`.
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - audit:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/From'
      - $ref: '#/components/parameters/To'
      - $ref: '#/components/parameters/Q'
      - name: actor_user_id
        in: query
        schema:
          type: integer
          format: int64
      - name: action
        in: query
        description: Exact or prefix with `*`, for example `line.*`.
        schema:
          type: string
      - name: target_type
        in: query
        schema:
          type: string
      - name: target_id
        in: query
        schema:
          type: integer
          format: int64
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuditEntryList'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /license:
    get:
      operationId: getLicense
      tags:
      - License
      summary: License status
      description: |-
        The free license of this panel: key, status and the last check-in. Bitstream has no limits. `revoked` means the platform revoked the key (abuse or illegal use): creating lines and streams answers `403 license_revoked`, everything that exists keeps working. A failed check-in only sets `last_check_ok` to false; it never blocks anything.

        Roles: `admin`. API key scopes: `system:read`.
      x-roles:
      - admin
      x-required-scopes:
      - system:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LicenseStatus'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /license/activate:
    post:
      operationId: activateLicense
      tags:
      - License
      summary: Activate the free license again
      description: |-
        Registers this panel with the license server again and refreshes the status. The same panel always gets the same key. `email` is optional and sent only when given. `502 license_server_unreachable` when the server cannot be reached: nothing changes, try again later.

        Roles: `admin`. API key scopes: `license:write`.
      x-roles:
      - admin
      x-required-scopes:
      - license:write
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type:
                  - string
                  - 'null'
                  description: Optional contact email for license notices.
                  examples:
                  - owner@example.com
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LicenseStatus'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '502':
          description: The license server could not be reached (`license_server_unreachable`) or refused (`license_rejected`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /system/version:
    get:
      operationId: getVersion
      tags:
      - System
      summary: Control version
      description: 'Roles: `admin`, `reseller`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  version:
                    type: string
                    examples:
                    - 1.0.0
                  commit:
                    type: string
                    examples:
                    - 3f2a9c1
                  built_at:
                    type: string
                    description: RFC 3339 timestamp in UTC.
                    examples:
                    - '2026-11-28T14:30:00Z'
                    format: date-time
                  api_version:
                    type: string
                    examples:
                    - v1
                  node_proto:
                    type: integer
                    examples:
                    - 1
                    format: int32
                  update_available:
                    type:
                    - string
                    - 'null'
                    examples:
                    - 1.0.1
                required:
                - version
                - api_version
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /system/health:
    get:
      operationId: getHealth
      tags:
      - System
      summary: Health check
      description: |-
        Unauthenticated, for load balancers and uptime monitors. 200 when healthy, 503 when a dependency is down. Prometheus metrics are at `/metrics` (outside /api/v1), see settings group monitoring.

        Roles: `admin`.
      x-roles:
      - admin
      x-required-scopes: []
      security: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    examples:
                    - ok
                    enum:
                    - ok
                    - degraded
                    - down
                  checks:
                    type: object
                    properties:
                      database:
                        type: string
                        examples:
                        - ok
                        enum:
                        - ok
                        - down
                      redis:
                        type: string
                        examples:
                        - ok
                        enum:
                        - ok
                        - down
                      nodes_online:
                        type: integer
                        format: int32
                required:
                - status
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '503':
          description: Unhealthy.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    examples:
                    - down
                  checks:
                    type: object
                    properties: {}
                    additionalProperties: true
  /system/ffmpeg:
    get:
      operationId: getFfmpeg
      tags:
      - System
      summary: ffmpeg builds and allowed flags
      description: |-
        Builds available per node, and the allowlist for custom stream flags.

        Roles: `admin`. API key scopes: `nodes:read`.
      x-roles:
      - admin
      x-required-scopes:
      - nodes:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  builds:
                    type: array
                    items:
                      type: object
                      properties:
                        version:
                          type: string
                          examples:
                          - '7.1'
                        node_ids:
                          type: array
                          items:
                            type: integer
                            format: int64
                  allowed_input_flags:
                    type: array
                    items:
                      type: string
                    examples:
                    - - -re
                      - -fflags
                      - -analyzeduration
                      - -probesize
                      - -rw_timeout
                  allowed_output_flags:
                    type: array
                    items:
                      type: string
                    examples:
                    - - -map
                      - -bsf:v
                      - -metadata
                required:
                - builds
                - allowed_input_flags
                - allowed_output_flags
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /system/permissions:
    get:
      operationId: listPermissions
      tags:
      - System
      summary: All permissions and API key scopes
      description: |-
        Same strings are used in user groups and API keys.

        Roles: `admin`, `reseller`.
      x-roles:
      - admin
      - reseller
      x-required-scopes: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                          examples:
                          - lines:write
                        description:
                          type: string
                        roles:
                          type: array
                          items:
                            type: string
                            examples:
                            - admin
                            enum:
                            - admin
                            - reseller
                        area:
                          type: string
                          description: Part before the colon, used to group permissions.
                          examples:
                          - lines
                        access:
                          type: string
                          description: read for :read scopes, write for everything else.
                          enum:
                          - read
                          - write
                        sensitive:
                          type: boolean
                          description: Can hurt the whole panel. Only the Owner or roles:delegate may give it.
                      required:
                      - name
                      - description
                      - roles
                      - area
                      - access
                      - sensitive
                required:
                - data
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /modules:
    get:
      operationId: listModules
      tags:
      - Modules
      summary: List installed modules
      description: |-
        Every installed module with its state. `safe_mode` is true when no module is loaded (env `BS_MODULES_SAFE_MODE=1` or the panel switch).

        Roles: `admin`. API key scopes: `modules:read`.
      x-roles:
      - admin
      x-required-scopes:
      - modules:read
      responses:
        '200':
          description: Modules.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Module'
                  safe_mode:
                    type: boolean
                required:
                - data
                - safe_mode
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
    post:
      operationId: installModule
      tags:
      - Modules
      summary: Install or upgrade a module
      description: |-
        Installs a module package (zip). A higher version of an installed module upgrades it and keeps its settings and data. The same or a lower version is `409 already_installed` / `409 downgrade`.

        The package must be signed by a trusted publisher key, unless developer mode is on. Needs the password again, plus a 2FA code when 2FA is on.

        Needs a signed in user: API keys get `403 api_key_not_allowed`.

        Roles: `admin`. API key scopes: `modules:write`.
      x-roles:
      - admin
      x-required-scopes:
      - modules:write
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
                password:
                  type: string
                code:
                  type: string
                  description: TOTP or recovery code, when 2FA is on.
                enable:
                  type: boolean
                  default: false
              required:
              - file
              - password
      responses:
        '201':
          description: Installed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Module'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /modules/inspect:
    post:
      operationId: inspectModule
      tags:
      - Modules
      summary: Check a module package before installing
      description: |-
        Validates the package (manifest, file hashes, signature, Bitstream version) and returns what it asks for, without installing anything. Problems that block the install are in `problems`.

        Roles: `admin`. API key scopes: `modules:write`.
      x-roles:
      - admin
      x-required-scopes:
      - modules:write
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
              required:
              - file
      responses:
        '200':
          description: Review.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ModuleReview'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /modules/config:
    get:
      operationId: getModulesConfig
      tags:
      - Modules
      summary: Module system settings
      description: |-
        Roles: `admin`. API key scopes: `modules:read`.
      x-roles:
      - admin
      x-required-scopes:
      - modules:read
      responses:
        '200':
          description: Config.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ModulesConfig'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
    put:
      operationId: setModulesConfig
      tags:
      - Modules
      summary: Change module system settings
      description: |-
        Turning developer mode on or changing trusted keys needs the password again (and a 2FA code when 2FA is on). Turning safe mode on stops every module at once.

        Needs a signed in user: API keys get `403 api_key_not_allowed`.

        Roles: `admin`. API key scopes: `modules:write`.
      x-roles:
      - admin
      x-required-scopes:
      - modules:write
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                safe_mode:
                  type: boolean
                developer_mode:
                  type: boolean
                trusted_keys:
                  type: array
                  maxItems: 50
                  items:
                    $ref: '#/components/schemas/ModuleTrustedKey'
                password:
                  type: string
                code:
                  type: string
      responses:
        '200':
          description: Saved.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ModulesConfig'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /modules/ui:
    get:
      operationId: listModuleUI
      tags:
      - Modules
      summary: Frontend parts to load
      description: |-
        Enabled modules with a frontend part, for the panel to load after sign in. Empty in safe mode. Load each `url` as `<script type="module" integrity="...">`.

        Roles: `admin`.
      x-roles:
      - admin
      responses:
        '200':
          description: Bundles.
          content:
            application/json:
              schema:
                type: object
                properties:
                  safe_mode:
                    type: boolean
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/ModuleUI'
                required:
                - safe_mode
                - data
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /modules/{module_id}:
    parameters:
    - $ref: '#/components/parameters/ModuleId'
    get:
      operationId: getModule
      tags:
      - Modules
      summary: Get a module
      description: |-
        Roles: `admin`. API key scopes: `modules:read`.
      x-roles:
      - admin
      x-required-scopes:
      - modules:read
      responses:
        '200':
          description: Module.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Module'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    delete:
      operationId: uninstallModule
      tags:
      - Modules
      summary: Uninstall a module
      description: |-
        Stops it, removes its files, settings and API key. Its data (`module_kv`) is deleted unless `keep_data=true`.

        Needs a signed in user: API keys get `403 api_key_not_allowed`.

        Roles: `admin`. API key scopes: `modules:write`.
      x-roles:
      - admin
      x-required-scopes:
      - modules:write
      security:
      - bearerAuth: []
      parameters:
      - name: keep_data
        in: query
        schema:
          type: boolean
          default: false
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /modules/{module_id}/enable:
    parameters:
    - $ref: '#/components/parameters/ModuleId'
    post:
      operationId: enableModule
      tags:
      - Modules
      summary: Enable a module
      description: |-
        Starts its backend, mints its API key and loads its frontend on the next page load. Also clears an automatic disable.

        Needs a signed in user: API keys get `403 api_key_not_allowed`.

        Roles: `admin`. API key scopes: `modules:write`.
      x-roles:
      - admin
      x-required-scopes:
      - modules:write
      security:
      - bearerAuth: []
      responses:
        '200':
          description: Enabled.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Module'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
  /modules/{module_id}/disable:
    parameters:
    - $ref: '#/components/parameters/ModuleId'
    post:
      operationId: disableModule
      tags:
      - Modules
      summary: Disable a module
      description: |-
        Stops its backend, revokes its API key and removes its hooks, routes and frontend.

        Roles: `admin`. API key scopes: `modules:write`.
      x-roles:
      - admin
      x-required-scopes:
      - modules:write
      responses:
        '200':
          description: Disabled.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Module'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /modules/{module_id}/settings:
    parameters:
    - $ref: '#/components/parameters/ModuleId'
    put:
      operationId: setModuleSettings
      tags:
      - Modules
      summary: Change module settings
      description: |-
        Values are checked against the module `settings_schema`. A running module restarts to pick them up.

        Roles: `admin`. API key scopes: `modules:write`.
      x-roles:
      - admin
      x-required-scopes:
      - modules:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                values:
                  type: object
                  additionalProperties: true
              required:
              - values
      responses:
        '200':
          description: Saved.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Module'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /modules/{module_id}/health:
    parameters:
    - $ref: '#/components/parameters/ModuleId'
    get:
      operationId: getModuleHealth
      tags:
      - Modules
      summary: Module health
      description: |-
        Counters since the control started.

        Roles: `admin`. API key scopes: `modules:read`.
      x-roles:
      - admin
      x-required-scopes:
      - modules:read
      responses:
        '200':
          description: Health.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ModuleHealth'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /modules/{module_id}/logs:
    parameters:
    - $ref: '#/components/parameters/ModuleId'
    get:
      operationId: getModuleLogs
      tags:
      - Modules
      summary: Module logs
      description: |-
        Last 500 lines of the last 24 hours, newest first: what the module wrote to stderr or sent with `log`, plus supervisor messages.

        Roles: `admin`. API key scopes: `modules:read`.
      x-roles:
      - admin
      x-required-scopes:
      - modules:read
      responses:
        '200':
          description: Logs.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/ModuleLogLine'
                required:
                - data
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /modules/{module_id}/ui/{file}:
    parameters:
    - $ref: '#/components/parameters/ModuleId'
    - name: file
      in: path
      required: true
      schema:
        type: string
        pattern: ^[0-9a-f]{64}\.js$
    get:
      operationId: getModuleBundle
      tags:
      - Modules
      summary: Frontend bundle of a module
      description: |-
        The JavaScript of an enabled module, addressed by its sha256 (from `GET /modules/ui`). No credentials needed (script tags cannot send the bearer token); the hash is the address. Cached for a year.
      security: []
      responses:
        '200':
          description: ES module.
          content:
            text/javascript:
              schema:
                type: string
        '404':
          $ref: '#/components/responses/NotFound'
  /modules/{module_id}/api/{path}:
    parameters:
    - $ref: '#/components/parameters/ModuleId'
    - name: path
      in: path
      required: true
      description: Any path, may contain slashes.
      schema:
        type: string
    get:
      operationId: moduleRouteGet
      tags:
      - Modules
      summary: Call a module route (GET)
      description: |-
        Forwarded to the module backend (`http` call, 10 s deadline). The answer is whatever the module returns. `503 module_unavailable` when it is not running.

        Roles: `admin`. API key scopes: `modules:read`.
      x-roles:
      - admin
      x-required-scopes:
      - modules:read
      responses:
        '200':
          description: Module answer.
          content:
            application/json:
              schema: {}
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    post:
      operationId: moduleRoutePost
      tags:
      - Modules
      summary: Call a module route (POST)
      description: |-
        Same as GET. PUT, PATCH and DELETE are forwarded too.

        Roles: `admin`. API key scopes: `modules:read`.
      x-roles:
      - admin
      x-required-scopes:
      - modules:read
      requestBody:
        content:
          application/json:
            schema: {}
      responses:
        '200':
          description: Module answer.
          content:
            application/json:
              schema: {}
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /tmdb/settings:
    get:
      operationId: getTmdbSettings
      tags:
      - TMDB
      summary: TMDB settings
      description: 'The API key is write only. Roles: `admin`. API key scopes: `settings:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - settings:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TmdbSettings'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
    patch:
      operationId: updateTmdbSettings
      tags:
      - TMDB
      summary: Change TMDB settings
      description: |-
        A new api_key is checked against TMDB before it is saved (401 from TMDB is a validation error on api_key). When TMDB cannot be reached the key is saved anyway and `key_checked` is false. `api_key: null` removes the key.

        Roles: `admin`. API key scopes: `settings:write`.
      x-roles:
      - admin
      x-required-scopes:
      - settings:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TmdbSettingsUpdate'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TmdbSettings'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /tmdb/search:
    get:
      operationId: searchTmdb
      tags:
      - TMDB
      summary: Search TMDB by title and year
      description: |-
        Up to 20 results, best first. 409 `tmdb_not_configured` without a key, 503 `tmdb_unavailable` when TMDB does not answer.

        Roles: `admin`. API key scopes: `vod:read`.
      x-roles:
      - admin
      x-required-scopes:
      - vod:read
      parameters:
      - name: kind
        in: query
        required: true
        schema:
          type: string
          enum:
          - movie
          - series
      - name: q
        in: query
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 200
      - name: year
        in: query
        schema:
          type: integer
          format: int32
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  results:
                    type: array
                    items:
                      $ref: '#/components/schemas/TmdbSearchResult'
                required:
                - results
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
  /tmdb/details:
    get:
      operationId: getTmdbDetails
      tags:
      - TMDB
      summary: Details of one TMDB title
      description: |-
        In the TMDB language setting (default: the panel language), with empty fields filled from English. Use it to fill a form before saving.

        Roles: `admin`. API key scopes: `vod:read`.
      x-roles:
      - admin
      x-required-scopes:
      - vod:read
      parameters:
      - name: kind
        in: query
        required: true
        schema:
          type: string
          enum:
          - movie
          - series
      - name: tmdb_id
        in: query
        required: true
        schema:
          type: integer
          format: int32
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TmdbDetails'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
  /tmdb/refresh:
    post:
      operationId: refreshTmdbBulk
      tags:
      - TMDB
      summary: Refresh many items from TMDB in the background
      description: |-
        Items are queued (tmdb_status `refresh`) and updated a few per second, within TMDB rate limits. Items without tmdb_id are matched by title and year first.

        Roles: `admin`. API key scopes: `vod:write`.
      x-roles:
      - admin
      x-required-scopes:
      - vod:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                kind:
                  type: string
                  enum:
                  - movie
                  - series
                ids:
                  type: array
                  minItems: 1
                  maxItems: 5000
                  items:
                    type: integer
                    format: int64
              required:
              - kind
              - ids
      responses:
        '202':
          description: Queued.
          content:
            application/json:
              schema:
                type: object
                properties:
                  queued:
                    type: integer
                required:
                - queued
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
  /tmdb/review:
    get:
      operationId: listTmdbReview
      tags:
      - TMDB
      summary: Items whose automatic TMDB match was not sure
      description: 'Roles: `admin`. API key scopes: `vod:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - vod:read
      parameters:
      - name: kind
        in: query
        schema:
          type: string
          enum:
          - movie
          - series
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/TmdbReviewItem'
                  total:
                    type: integer
                required:
                - data
                - total
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
    post:
      operationId: resolveTmdbReview
      tags:
      - TMDB
      summary: Pick the right TMDB title for an item, or skip it
      description: |-
        tmdb_id set: the item is linked and refreshed from TMDB now. tmdb_id null: the item is marked skipped and never matched again automatically.

        Roles: `admin`. API key scopes: `vod:write`.
      x-roles:
      - admin
      x-required-scopes:
      - vod:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                kind:
                  type: string
                  enum:
                  - movie
                  - series
                id:
                  type: integer
                  format: int64
                tmdb_id:
                  type:
                  - integer
                  - 'null'
                  format: int32
              required:
              - kind
              - id
              - tmdb_id
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
  /movies/{id}/tmdb-refresh:
    post:
      operationId: refreshMovieTmdb
      tags:
      - TMDB
      summary: Refresh one movie from TMDB
      description: |-
        Replaces plot, cast, director, genre, dates, rating, country, trailer, images and collection with TMDB data (empty TMDB values keep what you had). The name is kept. Body tmdb_id links another title first.

        Roles: `admin`. API key scopes: `vod:write`.
      x-roles:
      - admin
      x-required-scopes:
      - vod:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TmdbRefreshRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Movie'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
  /series/{id}/tmdb-refresh:
    post:
      operationId: refreshSeriesTmdb
      tags:
      - TMDB
      summary: Refresh one series, its seasons and episodes from TMDB
      description: |-
        Updates the series like a movie refresh, and the names, overviews, air dates and images of seasons and episodes that already exist (matched by number). It does not create episodes.

        Roles: `admin`. API key scopes: `vod:write`.
      x-roles:
      - admin
      x-required-scopes:
      - vod:write
      parameters:
      - $ref: '#/components/parameters/Id'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TmdbRefreshRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Series'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
  /vod-jobs:
    get:
      operationId: listVodJobs
      tags:
      - Movies
      summary: Download and reprocess jobs
      description: |-
        Newest first. A running job with no news from its server for 10 minutes (a queued one for 2 hours) is shown as failed.

        Roles: `admin`. API key scopes: `vod:read`.
      x-roles:
      - admin
      x-required-scopes:
      - vod:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - name: kind
        in: query
        schema:
          type: string
          enum:
          - movie
          - episode
      - name: item_id
        in: query
        schema:
          type: integer
          format: int64
      - name: active
        in: query
        description: Only queued and running jobs.
        schema:
          type: boolean
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/VodJob'
                  meta:
                    $ref: '#/components/schemas/PageMeta'
                required:
                - data
                - meta
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
    post:
      operationId: createVodJobs
      tags:
      - Movies
      summary: Download to storage, or reprocess, one or many movies or episodes
      description: |-
        `download`: the storage node copies the remote file into its VOD folder, then the item plays from that file. Needs `storage_node_id` and an url source.
        `reprocess`: the storage node remuxes a local file to MP4 with the index at the front (copy only: same quality, no conversion). The original stays until the new file is ready. `keep_original: false` then deletes it, but only when Bitstream downloaded it; files you placed yourself are never deleted.
        Each id is checked on its own; refused ids are listed in `failed`.

        Roles: `admin`. API key scopes: `vod:write`.
      x-roles:
      - admin
      x-required-scopes:
      - vod:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                kind:
                  type: string
                  enum:
                  - movie
                  - episode
                ids:
                  type: array
                  minItems: 1
                  maxItems: 1000
                  items:
                    type: integer
                    format: int64
                action:
                  type: string
                  enum:
                  - download
                  - reprocess
                storage_node_id:
                  type:
                  - integer
                  - 'null'
                  format: int64
                keep_original:
                  type: boolean
                  default: true
              required:
              - kind
              - ids
              - action
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  jobs:
                    type: array
                    items:
                      $ref: '#/components/schemas/VodJob'
                  failed:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          format: int64
                        code:
                          type: string
                        message:
                          type: string
                      required:
                      - id
                      - code
                      - message
                required:
                - jobs
                - failed
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /bouquets/membership/{kind}/{id}:
    get:
      operationId: getBouquetMembership
      tags:
      - Catalog
      summary: Bouquets that contain one item
      description: 'kind stream covers live channels, radios and created channels. Roles: `admin`. API key scopes: `catalog:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - catalog:read
      parameters:
      - name: kind
        in: path
        required: true
        schema:
          type: string
          enum:
          - stream
          - movie
          - series
      - $ref: '#/components/parameters/Id'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BouquetMembership'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      operationId: setBouquetMembership
      tags:
      - Catalog
      summary: Set the bouquets that contain one item
      description: 'Added bouquets get the item at the end; removed ones lose it; the rest keep their order. Roles: `admin`. API key scopes: `catalog:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - catalog:write
      parameters:
      - name: kind
        in: path
        required: true
        schema:
          type: string
          enum:
          - stream
          - movie
          - series
      - $ref: '#/components/parameters/Id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BouquetMembership'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BouquetMembership'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /logs/status:
    get:
      operationId: getLogsStatus
      tags:
      - Logs
      summary: Logs service status
      description: 'Writer queue and drop counters, partitions with row estimates, last maintenance run.


        Roles: `admin`. API key scopes: `logs:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - logs:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LogsStatus'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /logs/settings:
    get:
      operationId: getLogSettings
      tags:
      - Logs
      summary: Logs settings
      description: 'Retention, detection thresholds and actions, VOD open limit, source signers, AI limits.


        Roles: `admin`. API key scopes: `settings:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - settings:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LogSettings'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    patch:
      operationId: updateLogSettings
      tags:
      - Logs
      summary: Change logs settings
      description: 'Send the fields to change. Nested objects (restream, theft, ai, signers) are replaced whole. signer_secrets sets the key of
        a signer; it is stored encrypted and never returned. Writes the audit log.


        Roles: `admin`. API key scopes: `settings:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - settings:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LogSettings'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LogSettings'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /logs/events:
    get:
      operationId: listLogEvents
      tags:
      - Logs
      summary: Log events
      description: 'Typed events of every view backed by log_events: client logs (client.*), stream errors (stream.*), on-demand (ondemand.*), panel
        errors (panel.error), system logs (system.log), detections (detect.*), AI (ai.*). Resellers see only client.* events of lines in their tree.
        Sort: `at`. Range at most 93 days, default the last 24 hours.


        Roles: `admin`, `reseller`. API key scopes: `logs:read`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - logs:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/LogFrom'
      - $ref: '#/components/parameters/LogTo'
      - $ref: '#/components/parameters/LogLineId'
      - $ref: '#/components/parameters/LogResellerId'
      - $ref: '#/components/parameters/LogStreamId'
      - $ref: '#/components/parameters/LogNodeId'
      - $ref: '#/components/parameters/LogIp'
      - $ref: '#/components/parameters/LogCountry'
      - $ref: '#/components/parameters/LogLevel'
      - $ref: '#/components/parameters/LogType'
      - $ref: '#/components/parameters/LogCode'
      - $ref: '#/components/parameters/Q'
      - name: format
        in: query
        description: csv downloads up to 10 000 rows as text/csv instead of JSON.
        schema:
          type: string
          enum:
          - json
          - csv
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LogEventList'
            text/csv:
              schema:
                type: string
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /logs/events/series:
    get:
      operationId: getLogSeries
      tags:
      - Logs
      summary: Events over time
      description: 'Counts per time bucket (total, warn, error) plus top codes and top streams, for the charts of Stream errors and the other views.
        Same filters as the list.


        Roles: `admin`, `reseller`. API key scopes: `logs:read`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - logs:read
      parameters:
      - $ref: '#/components/parameters/LogFrom'
      - $ref: '#/components/parameters/LogTo'
      - $ref: '#/components/parameters/LogLineId'
      - $ref: '#/components/parameters/LogResellerId'
      - $ref: '#/components/parameters/LogStreamId'
      - $ref: '#/components/parameters/LogNodeId'
      - $ref: '#/components/parameters/LogIp'
      - $ref: '#/components/parameters/LogCountry'
      - $ref: '#/components/parameters/LogLevel'
      - $ref: '#/components/parameters/LogType'
      - $ref: '#/components/parameters/LogCode'
      - $ref: '#/components/parameters/Q'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LogSeries'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /logs/ondemand:
    get:
      operationId: listOnDemandStats
      tags:
      - Logs
      summary: On-demand scanner
      description: 'Per stream: on-demand starts, ready, failures, idle stops, average and p95 time to ready. Sort: `starts`, `fails`, `avg_start_ms`,
        `last_at`, `stream_id`.


        Roles: `admin`. API key scopes: `logs:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - logs:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/LogFrom'
      - $ref: '#/components/parameters/LogTo'
      - $ref: '#/components/parameters/LogStreamId'
      - $ref: '#/components/parameters/LogNodeId'
      - name: format
        in: query
        description: csv downloads up to 10 000 rows as text/csv instead of JSON.
        schema:
          type: string
          enum:
          - json
          - csv
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/OnDemandRow'
                  meta:
                    $ref: '#/components/schemas/PageMeta'
                required:
                - data
                - meta
            text/csv:
              schema:
                type: string
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /logs/open-times:
    get:
      operationId: getOpenTimes
      tags:
      - Logs
      summary: Open time of live connections
      description: 'Average and p95 server side open time (control_ms + node_first_byte_ms from connection history), overall (first row)
        and for the 20 live channels with the most sessions in the range, as one page. Default range: the last 24 hours. The player adds
        its own start time on top.


        Roles: `admin`. API key scopes: `logs:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - logs:read
      parameters:
      - $ref: '#/components/parameters/LogFrom'
      - $ref: '#/components/parameters/LogTo'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    description: The overall row first (stream_id null), then up to 20 channels by sessions.
                    items:
                      $ref: '#/components/schemas/OpenTimeRow'
                  meta:
                    $ref: '#/components/schemas/PageMeta'
                required:
                - data
                - meta
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /logs/stream-ranks:
    get:
      operationId: listStreamRanks
      tags:
      - Logs
      summary: Stream ranks
      description: 'Most watched content from the daily bandwidth totals.


        Roles: `admin`. API key scopes: `logs:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - logs:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/LogFrom'
      - $ref: '#/components/parameters/LogTo'
      - $ref: '#/components/parameters/LogNodeId'
      - name: by
        in: query
        schema:
          type: string
          enum:
          - viewers
          - hours
          - bytes
          default: viewers
      - name: content_kind
        in: query
        schema:
          type: string
          enum:
          - live
          - radio
          - movie
          - episode
      - name: format
        in: query
        description: csv downloads up to 10 000 rows as text/csv instead of JSON.
        schema:
          type: string
          enum:
          - json
          - csv
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/RankRow'
                  meta:
                    $ref: '#/components/schemas/PageMeta'
                required:
                - data
                - meta
            text/csv:
              schema:
                type: string
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /logs/line-ips:
    get:
      operationId: listLineIps
      tags:
      - Logs
      summary: IPs per line
      description: 'Each IP a line used in the range from finished sessions, with the number of other lines seen on the same IP. Sort: `last_at`,
        `sessions`, `first_at`.


        Roles: `admin`, `reseller`. API key scopes: `logs:read`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - logs:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/LogFrom'
      - $ref: '#/components/parameters/LogTo'
      - $ref: '#/components/parameters/LogLineId'
      - $ref: '#/components/parameters/LogResellerId'
      - $ref: '#/components/parameters/LogIp'
      - $ref: '#/components/parameters/LogCountry'
      - name: format
        in: query
        description: csv downloads up to 10 000 rows as text/csv instead of JSON.
        schema:
          type: string
          enum:
          - json
          - csv
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/LineIp'
                  meta:
                    $ref: '#/components/schemas/PageMeta'
                required:
                - data
                - meta
            text/csv:
              schema:
                type: string
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /logs/credits:
    get:
      operationId: listCreditLogs
      tags:
      - Logs
      summary: Credit logs
      description: 'Credit ledger with the balance before and after each entry. Resellers see their own tree. Sort: `at`, `id`, `delta`.


        Roles: `admin`, `reseller`. API key scopes: `logs:read`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - logs:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/LogFrom'
      - $ref: '#/components/parameters/LogTo'
      - $ref: '#/components/parameters/LogResellerId'
      - $ref: '#/components/parameters/LogLineId'
      - name: reason
        in: query
        schema:
          type: string
      - name: format
        in: query
        description: csv downloads up to 10 000 rows as text/csv instead of JSON.
        schema:
          type: string
          enum:
          - json
          - csv
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/CreditLog'
                  meta:
                    $ref: '#/components/schemas/PageMeta'
                required:
                - data
                - meta
            text/csv:
              schema:
                type: string
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /logs/reseller-actions:
    get:
      operationId: listResellerActions
      tags:
      - Logs
      summary: Reseller logs
      description: 'Audit entries made by resellers, with the credits each action cost. Resellers see their own tree. Sort: `at`, `id`.


        Roles: `admin`, `reseller`. API key scopes: `logs:read`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - logs:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/LogFrom'
      - $ref: '#/components/parameters/LogTo'
      - $ref: '#/components/parameters/LogResellerId'
      - $ref: '#/components/parameters/Q'
      - name: format
        in: query
        description: csv downloads up to 10 000 rows as text/csv instead of JSON.
        schema:
          type: string
          enum:
          - json
          - csv
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/ResellerAction'
                  meta:
                    $ref: '#/components/schemas/PageMeta'
                required:
                - data
                - meta
            text/csv:
              schema:
                type: string
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /logs/vod-jobs:
    get:
      operationId: listVodJobs
      tags:
      - Logs
      summary: Encoding queue
      description: 'VOD jobs on the nodes. stale: running with no update for 10 minutes. Sort: `id`, `updated_at`.


        Roles: `admin`. API key scopes: `logs:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - logs:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - $ref: '#/components/parameters/LogNodeId'
      - name: status
        in: query
        schema:
          type: string
      - name: format
        in: query
        description: csv downloads up to 10 000 rows as text/csv instead of JSON.
        schema:
          type: string
          enum:
          - json
          - csv
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/LogVodJob'
                  meta:
                    $ref: '#/components/schemas/PageMeta'
                required:
                - data
                - meta
            text/csv:
              schema:
                type: string
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /logs/detections:
    get:
      operationId: listDetections
      tags:
      - Logs
      summary: Restream and VOD theft detections
      description: 'Latest score per line and kind with the evidence. Default: score above 0. Sort: `score`, `updated_at`, `line_id`.


        Roles: `admin`. API key scopes: `logs:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - logs:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - name: kind
        in: query
        schema:
          type: string
          enum:
          - restream
          - vod_theft
      - name: status
        in: query
        schema:
          type: string
          enum:
          - ok
          - flagged
          - marked
          - disabled
          - allowed
          - cleared
      - name: min_score
        in: query
        schema:
          type: integer
          minimum: 0
          maximum: 100
      - $ref: '#/components/parameters/LogLineId'
      - $ref: '#/components/parameters/LogResellerId'
      - $ref: '#/components/parameters/Q'
      - name: format
        in: query
        description: csv downloads up to 10 000 rows as text/csv instead of JSON.
        schema:
          type: string
          enum:
          - json
          - csv
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Detection'
                  meta:
                    $ref: '#/components/schemas/PageMeta'
                required:
                - data
                - meta
            text/csv:
              schema:
                type: string
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /logs/detections/summary:
    get:
      operationId: getDetectionSummary
      tags:
      - Logs
      summary: Detection counts
      description: 'Lines flagged, marked and disabled per kind (badges).


        Roles: `admin`. API key scopes: `logs:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - logs:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DetectionSummary'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /logs/detections/{kind}/{id}:
    parameters:
    - $ref: '#/components/parameters/DetectionKind'
    - $ref: '#/components/parameters/Id'
    get:
      operationId: getDetection
      tags:
      - Logs
      summary: Detection detail
      description: 'Score, evidence, the last 24 hours of client events and the last 48 hours of sessions of the line.


        Roles: `admin`. API key scopes: `logs:read`.'
      x-roles:
      - admin
      x-required-scopes:
      - logs:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DetectionDetail'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /logs/detections/{kind}/{id}/action:
    parameters:
    - $ref: '#/components/parameters/DetectionKind'
    - $ref: '#/components/parameters/Id'
    post:
      operationId: actOnDetection
      tags:
      - Logs
      summary: Act on a detection
      description: 'mark: keep watching. clear: dismiss; flags again only above the cleared peak. allow: mark the line as a restreamer (restream
        only). disable: turn the line off and kick it. Writes the audit log.


        Roles: `admin`. API key scopes: `logs:write`.'
      x-roles:
      - admin
      x-required-scopes:
      - logs:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                action:
                  type: string
                  enum:
                  - mark
                  - clear
                  - disable
                  - allow
              required:
              - action
      responses:
        '204':
          description: Done
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /logs/notes:
    get:
      operationId: listLogNotes
      tags:
      - Logs
      summary: Incident notes
      description: 'Notes saved from the Logs area (often an AI answer) and the daily AI digests. Resellers see their own notes. Sort: `created_at`,
        `id`.


        Roles: `admin`, `reseller`. API key scopes: `logs:read`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - logs:read
      parameters:
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Sort'
      - name: kind
        in: query
        schema:
          type: string
          enum:
          - note
          - digest
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/LogNote'
                  meta:
                    $ref: '#/components/schemas/PageMeta'
                required:
                - data
                - meta
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
    post:
      operationId: createLogNote
      tags:
      - Logs
      summary: Save an incident note
      description: 'Saves a note, for example an AI answer.


        Roles: `admin`, `reseller`. API key scopes: `logs:read`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - logs:read
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                view:
                  type: string
                  maxLength: 40
                title:
                  type: string
                  maxLength: 200
                body:
                  type: string
                  minLength: 1
                  maxLength: 100000
              required:
              - body
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LogNote'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /logs/notes/{id}:
    parameters:
    - $ref: '#/components/parameters/Id'
    delete:
      operationId: deleteLogNote
      tags:
      - Logs
      summary: Delete a note
      description: 'Admins delete any note, resellers their own.


        Roles: `admin`, `reseller`. API key scopes: `logs:read`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - logs:read
      responses:
        '204':
          description: Deleted
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /logs/ai/analyze:
    post:
      operationId: analyzeLogs
      tags:
      - Logs
      summary: Analyze a logs view with AI
      description: 'Builds a compact summary on the server (aggregates, top 10 lists, a time series, detection evidence; never raw rows) and streams
        the model answer. IPs are cut to /24 or /48 unless include_ips; line usernames become stable pseudonyms. Takes the same filter query parameters
        as the list. Needs the AI assistant configured (409 ai_not_configured). Limits: 10 requests per 10 minutes per user (429 rate_limited),
        the daily token budget of logs settings (429 ai_budget_exhausted). Each request writes the audit entry logs.ai (view, tokens, never the
        content).


        Roles: `admin`, `reseller`. API key scopes: `logs:read`, `ai:use`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - logs:read
      - ai:use
      parameters:
      - $ref: '#/components/parameters/LogFrom'
      - $ref: '#/components/parameters/LogTo'
      - $ref: '#/components/parameters/LogLineId'
      - $ref: '#/components/parameters/LogResellerId'
      - $ref: '#/components/parameters/LogStreamId'
      - $ref: '#/components/parameters/LogNodeId'
      - $ref: '#/components/parameters/LogIp'
      - $ref: '#/components/parameters/LogCountry'
      - $ref: '#/components/parameters/LogLevel'
      - $ref: '#/components/parameters/LogType'
      - $ref: '#/components/parameters/LogCode'
      - $ref: '#/components/parameters/Q'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LogAiRequest'
      responses:
        '200':
          description: 'Server-sent events. `used` (data sent to the model), `tool` (each tool call: name, input), `text` (answer chunks), then
            `done` (provider, model, tokens_in, tokens_out, refused, lang, pseudonyms) or `error` (code, message). Pseudonyms map line-xxxxxxxx
            codes in the answer to line id and username.'
          content:
            text/event-stream:
              schema:
                type: string
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /logs/ai/ask:
    post:
      operationId: askLogs
      tags:
      - Logs
      summary: Ask a question about the logs
      description: 'The model answers with a fixed set of read-only tools (aggregate_events, top_errors, detection_scores, connection_counts, stream_events),
        each validated, limited to 7 days and 20 rows, and scoped like the views: a reseller only sees its own lines. No SQL comes from the model.
        Same limits, redaction and audit as analyze.


        Roles: `admin`, `reseller`. API key scopes: `logs:read`, `ai:use`.'
      x-roles:
      - admin
      - reseller
      x-required-scopes:
      - logs:read
      - ai:use
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LogAiRequest'
      responses:
        '200':
          description: 'Server-sent events. `used` (data sent to the model), `tool` (each tool call: name, input), `text` (answer chunks), then
            `done` (provider, model, tokens_in, tokens_out, refused, lang, pseudonyms) or `error` (code, message). Pseudonyms map line-xxxxxxxx
            codes in the answer to line id and username.'
          content:
            text/event-stream:
              schema:
                type: string
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /series/bulk:
    post:
      operationId: bulkSeries
      tags:
      - Series
      summary: Mass edit series
      description: |-
        The only action is `update` (mass edit, see `VodMassEdit`): the fields you send change on every id, the rest stay as they are. Deleting many series is the mass delete tool.

        Roles: `admin`. API key scopes: `vod:write`.
      x-roles:
      - admin
      x-required-scopes:
      - vod:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VodBulkUpdateRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BulkResult'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /episodes/bulk:
    post:
      operationId: bulkEpisodes
      tags:
      - Series
      summary: Mass edit episodes
      description: |-
        The only action is `update` (mass edit, see `VodMassEdit`; episodes take `enabled`, `rating` and `container`).

        Roles: `admin`. API key scopes: `vod:write`.
      x-roles:
      - admin
      x-required-scopes:
      - vod:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VodBulkUpdateRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BulkResult'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /tools/match:
    get:
      operationId: toolsMatch
      tags:
      - Tools
      summary: Ids matching a filter
      description: |-
        Every id of `type` that matches the filters, up to 100000 (`409 too_many` above), so a page can select all matching rows and send them to a bulk endpoint. Resellers never include your own account.

        Needs `tools:write` and the write permission of the type (for example `streams:write` for `live`).

        Roles: `admin`. API key scopes: `tools:write`.
      x-roles:
      - admin
      x-required-scopes:
      - tools:write
      parameters:
      - name: type
        in: query
        required: true
        schema:
          $ref: '#/components/schemas/ToolsItemType'
      - name: q
        in: query
        schema:
          type: string
      - name: category_id
        in: query
        schema:
          type: integer
          format: int64
      - name: category_kind
        in: query
        description: Categories only.
        schema:
          type: string
          enum: [live, movie, series, radio]
      - name: node_id
        in: query
        description: Streams assigned to the node, or movies and episodes stored on it.
        schema:
          type: integer
          format: int64
      - name: series_id
        in: query
        schema:
          type: integer
          format: int64
      - name: owner_id
        in: query
        description: Lines only.
        schema:
          type: integer
          format: int64
      - name: enabled
        in: query
        schema:
          type: boolean
      - name: expired
        in: query
        description: Lines only.
        schema:
          type: boolean
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  ids:
                    type: array
                    items:
                      type: integer
                      format: int64
                  total:
                    type: integer
                required: [ids, total]
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
  /tools/items:
    get:
      operationId: toolsItems
      tags:
      - Tools
      summary: Items for the mass tools
      description: |-
        One page of `type` with the same filters as `/tools/match`: id, name, a detail (category, series, owner or parent) and enabled.

        Roles: `admin`. API key scopes: `tools:write`.
      x-roles:
      - admin
      x-required-scopes:
      - tools:write
      parameters:
      - name: type
        in: query
        required: true
        schema:
          $ref: '#/components/schemas/ToolsItemType'
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      - $ref: '#/components/parameters/Q'
      - name: sort
        in: query
        schema:
          type: string
          enum: [id, -id, name, -name]
      - name: category_id
        in: query
        schema:
          type: integer
          format: int64
      - name: category_kind
        in: query
        description: Categories only.
        schema:
          type: string
          enum: [live, movie, series, radio]
      - name: node_id
        in: query
        description: Streams assigned to the node, or movies and episodes stored on it.
        schema:
          type: integer
          format: int64
      - name: series_id
        in: query
        schema:
          type: integer
          format: int64
      - name: owner_id
        in: query
        description: Lines only.
        schema:
          type: integer
          format: int64
      - name: enabled
        in: query
        schema:
          type: boolean
      - name: expired
        in: query
        description: Lines only.
        schema:
          type: boolean
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          format: int64
                        name:
                          type: string
                        detail:
                          type:
                          - string
                          - 'null'
                        enabled:
                          type: boolean
                      required: [id, name, detail, enabled]
                  meta:
                    $ref: '#/components/schemas/PageMeta'
                required: [data, meta]
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /tools/mass-delete/preview:
    post:
      operationId: massDeletePreview
      tags:
      - Tools
      summary: Preview a mass delete
      description: |-
        The exact number of rows that would go, what goes with them (`cascades`) and the word to type (`confirm_word`, the count). Nothing changes.

        Cascade keys: `bouquet_entries`, `node_assignments`, `running`, `sources`, `sub_channels`, `created_items`, `seasons`, `episodes`, `uncategorized_items`, `line_links`, `package_links`, `epg_channels`, `unmapped_streams`, `bouquet_links`, `connections`, `owned_lines`, `other_sub_resellers`, `credits_refunded`.

        Roles: `admin`. API key scopes: `tools:write`.
      x-roles:
      - admin
      x-required-scopes:
      - tools:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MassDeleteTarget'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MassDeletePreview'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /tools/mass-delete:
    post:
      operationId: massDelete
      tags:
      - Tools
      summary: Mass delete
      description: |-
        Deletes the selected ids, or every row of the type with `all: true`, with the same cascades as the single delete. Admin accounts and your own account are never deleted. Resellers who still own lines are skipped (listed in the job).

        Send `confirm` equal to the count from the preview, your password and, with two-step sign-in on, a code. `backup: true` takes a full backup first (needs `backups:write`); the delete does not start if it fails. Streams are stopped on their nodes first. Runs in the background in batches of 500, one transaction each: poll `GET /tools/jobs/{id}`. One mass delete at a time (`409 busy`).

        Needs a signed in user: API keys get `403 api_key_not_allowed`. Errors: `400 confirmation_required` (wrong count, `details.count` is the current one), `400 invalid_password`, `400 totp_invalid`, `409 nothing_to_delete`, `429 rate_limited`.

        Roles: `admin`. API key scopes: `tools:write`.
      x-roles:
      - admin
      x-required-scopes:
      - tools:write
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
              - $ref: '#/components/schemas/MassDeleteTarget'
              - type: object
                properties:
                  confirm:
                    type: string
                    description: The count shown by the preview.
                  password:
                    type: string
                    format: password
                  totp_code:
                    type: string
                  backup:
                    type: boolean
                    default: false
                required: [confirm, password]
      responses:
        '202':
          description: Started.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ToolsJob'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
  /tools/jobs/{id}:
    get:
      operationId: getToolsJob
      tags:
      - Tools
      summary: Mass delete progress
      description: |-
        Kept for 24 hours. Only the user who started it (or the Owner) sees it.

        Roles: `admin`. API key scopes: `tools:write`.
      x-roles:
      - admin
      x-required-scopes:
      - tools:write
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ToolsJob'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /tools/channel-order:
    get:
      operationId: getChannelOrder
      tags:
      - Tools
      summary: Channel order
      description: |-
        Live channels (with created channels), radios or movies in their current order, optionally one category. player_api, get.php and M3U playlists sort by this order first, then by bouquet order.

        Roles: `admin`. API key scopes: `tools:write`, `streams:read`.
      x-roles:
      - admin
      x-required-scopes:
      - tools:write
      - streams:read
      parameters:
      - name: kind
        in: query
        required: true
        schema:
          type: string
          enum: [live, radio, movie]
      - name: category_id
        in: query
        schema:
          type: integer
          format: int64
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/ChannelOrderItem'
                required: [data]
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
    put:
      operationId: putChannelOrder
      tags:
      - Tools
      summary: Save the channel order
      description: |-
        `ids` is the new order of every item of the kind, or of one category (`category_id`). A category keeps the places it holds in the global order. `409 list_changed` when the ids are not exactly the current list. Needs `streams:write` (live, radio) or `vod:write` (movie) too.

        Roles: `admin`. API key scopes: `tools:write`.
      x-roles:
      - admin
      x-required-scopes:
      - tools:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                kind:
                  type: string
                  enum: [live, radio, movie]
                category_id:
                  type:
                  - integer
                  - 'null'
                  format: int64
                ids:
                  type: array
                  items:
                    type: integer
                    format: int64
              required: [kind, ids]
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
  /tools/source-replace:
    post:
      operationId: sourceReplace
      tags:
      - Tools
      summary: Find and replace in source URLs
      description: |-
        Replaces a plain text (at least 3 characters) in the source URLs of live channels and radios, for example an old provider host by a new one. Filter by `kind`, `category_id` or `node_id`. `apply: false` is the preview: counts and up to 20 samples. URLs in the answer and in the audit log are redacted (no user info, path segments or query). `400 validation_failed` when the result would not be a valid source URL. Running streams switch on their next fallback; restart them to switch now.

        Roles: `admin`. API key scopes: `tools:write`, `streams:write`.
      x-roles:
      - admin
      x-required-scopes:
      - tools:write
      - streams:write
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                find:
                  type: string
                  minLength: 3
                  maxLength: 512
                replace:
                  type: string
                  maxLength: 512
                kind:
                  type: string
                  enum: [live, radio]
                category_id:
                  type: integer
                  format: int64
                node_id:
                  type: integer
                  format: int64
                apply:
                  type: boolean
                  default: false
              required: [find, replace]
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  sources:
                    type: integer
                  streams:
                    type: integer
                  applied:
                    type: boolean
                  samples:
                    type: array
                    items:
                      type: object
                      properties:
                        stream_id:
                          type: integer
                          format: int64
                        name:
                          type: string
                        before:
                          type: string
                        after:
                          type: string
                      required: [stream_id, name, before, after]
                required: [sources, streams, applied, samples]
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /tools/quick/expired-lines:
    post:
      operationId: quickExpiredLines
      tags:
      - Tools
      summary: Disable or delete expired lines
      description: |-
        `disable` turns off every expired line that is still on, `delete` removes every expired line. Both need your password (and 2FA code) again.

        Needs a signed in user. Roles: `admin`. API key scopes: `tools:write`, `lines:write`.
      x-roles:
      - admin
      x-required-scopes:
      - tools:write
      - lines:write
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                action:
                  type: string
                  enum: [disable, delete]
                password:
                  type: string
                  format: password
                totp_code:
                  type: string
              required: [action, password]
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  lines:
                    type: integer
                required: [lines]
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /tools/quick/clear-logs:
    post:
      operationId: quickClearLogs
      tags:
      - Tools
      summary: Clear old logs
      description: |-
        Deletes log events and connection history older than `days`. The audit log is never cleared. Needs your password (and 2FA code) again.

        Needs a signed in user. Roles: `admin`. API key scopes: `tools:write`, `logs:write`.
      x-roles:
      - admin
      x-required-scopes:
      - tools:write
      - logs:write
      security:
      - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                days:
                  type: integer
                  minimum: 1
                  maximum: 3650
                password:
                  type: string
                  format: password
                totp_code:
                  type: string
              required: [days, password]
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  days:
                    type: integer
                  log_events:
                    type: integer
                  connection_history:
                    type: integer
                required: [days, log_events, connection_history]
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /tools/quick/unblock-ips:
    post:
      operationId: quickUnblockIps
      tags:
      - Tools
      summary: Unblock every IP
      description: |-
        Removes every blocked IP (manual and automatic).

        Roles: `admin`. API key scopes: `tools:write`, `security:write`.
      x-roles:
      - admin
      x-required-scopes:
      - tools:write
      - security:write
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  unblocked:
                    type: integer
                required: [unblocked]
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /tools/quick/stream-health:
    get:
      operationId: quickStreamHealth
      tags:
      - Tools
      summary: Stream health now
      description: |-
        How many enabled streams are in each health state, from the nodes' latest stats, and up to 100 ids in `error` or `frozen`.

        Roles: `admin`. API key scopes: `tools:write`, `streams:read`.
      x-roles:
      - admin
      x-required-scopes:
      - tools:write
      - streams:read
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  total:
                    type: integer
                  states:
                    type: object
                    additionalProperties:
                      type: integer
                  problem_ids:
                    type: array
                    items:
                      type: integer
                      format: int64
                required: [total, states, problem_ids]
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Access token from `POST /auth/login` or `POST /auth/refresh`. EdDSA (Ed25519) JWT, valid 15 minutes.
    apiKey:
      type: http
      scheme: bearer
      bearerFormat: bsk_<prefix>_<secret>
      description: 'API key sent as `Authorization: Bearer bsk_<prefix>_<secret>`. Limited to its scopes, optional IP allowlist and optional HMAC
        request signing (see the top level description).'
      x-scopes:
        lines:read: Read lines, playlist links, line history.
        lines:write: Create, change, renew, enable, disable and delete lines.
        users:read: Read users, groups and credit ledgers.
        users:write: Manage users, groups and credits.
        packages:read: Read packages.
        packages:write: Manage packages.
        catalog:read: Read bouquets and categories.
        catalog:write: Manage bouquets and categories.
        streams:read: Read live channels, radios, created channels, sources, logs and stats.
        streams:write: Manage and start or stop streams, sources and provider accounts.
        vod:read: Read movies, series, seasons and episodes.
        vod:write: Manage movies, series, seasons and episodes.
        epg:read: Read EPG sources, channels and mapping.
        epg:write: Manage EPG sources and mapping.
        nodes:read: Read nodes, stats, processes and tuning.
        nodes:write: Manage nodes, join tokens and server trees.
        connections:read: See live connections.
        connections:kill: Kill live connections.
        stats:read: Dashboard, history, bandwidth and map data.
        security:read: Read blocklists and login attempts.
        security:write: Manage blocklists.
        tickets:read: Read tickets.
        tickets:write: Open and reply to tickets.
        backups:read: List and download backups.
        backups:write: Create, upload, restore and delete backups.
        settings:read: Read settings, cache, Cloudflare, certificates and AI settings.
        settings:write: Change settings, flush caches, Cloudflare, certificates and AI settings.
        ai:use: Ask the AI to explain a problem.
        apikeys:read: List API keys.
        apikeys:write: Create, rotate and revoke API keys.
        audit:read: Read the audit log.
        imports:write: Run M3U imports and XC_VM migrations.
        license:write: Activate the free license again.
        system:read: Read license and system information.
        modules:read: List modules, their health and logs, and call module routes.
        modules:write: Install, enable, disable, configure and uninstall modules.
        roles:read: Read staff roles.
        roles:write: Create, change and delete staff roles and assign them. Sensitive.
        roles:delegate: Give sensitive permissions to roles and staff. Sensitive.
        tools:write: Use the admin tools (mass delete, mass edit, channel order, source replace, quick tools). Sensitive.
  parameters:
    LogFrom:
      name: from
      in: query
      description: 'Start of the range (inclusive), RFC 3339. Default: 24 hours ago. The range can be at most 93 days.'
      schema:
        type: string
        format: date-time
    LogTo:
      name: to
      in: query
      description: 'End of the range (exclusive), RFC 3339. Default: now.'
      schema:
        type: string
        format: date-time
    LogLineId:
      name: line_id
      in: query
      description: Only this line.
      schema:
        type: integer
        format: int64
        minimum: 1
    LogResellerId:
      name: reseller_id
      in: query
      description: Only lines owned by this user.
      schema:
        type: integer
        format: int64
        minimum: 1
    LogStreamId:
      name: stream_id
      in: query
      description: Only this stream or content id.
      schema:
        type: integer
        format: int64
        minimum: 1
    LogNodeId:
      name: node_id
      in: query
      description: Only this node.
      schema:
        type: integer
        format: int64
        minimum: 1
    LogIp:
      name: ip
      in: query
      description: An IP address or a CIDR such as 203.0.113.0/24.
      schema:
        type: string
    LogCountry:
      name: country
      in: query
      description: Two letter country code.
      schema:
        type: string
        minLength: 2
        maxLength: 2
    LogLevel:
      name: level
      in: query
      description: This level and worse.
      schema:
        type: string
        enum:
        - debug
        - info
        - warn
        - error
    LogType:
      name: type
      in: query
      description: Event family (client, stream, ondemand, panel, system, detect, ai) or exact type (client.play). Resellers may use client only.
      schema:
        type: string
    LogCode:
      name: code
      in: query
      description: Exact event code, for example bad_password or exit_1.
      schema:
        type: string
    DetectionKind:
      name: kind
      in: path
      required: true
      schema:
        type: string
        enum:
        - restream
        - vod_theft
    ModuleId:
      name: module_id
      in: path
      required: true
      description: Module id.
      schema:
        type: string
        pattern: ^[a-z][a-z0-9_]{1,31}$
    Id:
      name: id
      in: path
      required: true
      description: Resource id.
      schema:
        type: integer
        examples:
        - 42
        format: int64
    Page:
      name: page
      in: query
      description: Page number, starting at 1.
      schema:
        type: integer
        format: int32
        minimum: 1
        default: 1
    PerPage:
      name: per_page
      in: query
      description: Items per page. Maximum 500.
      schema:
        type: integer
        format: int32
        minimum: 1
        maximum: 500
        default: 50
    Sort:
      name: sort
      in: query
      description: Sort field. Prefix with `-` for descending order, for example `-created_at`. Several fields can be joined with commas. Each
        list documents the fields it accepts; unknown fields return `400 invalid_sort`.
      schema:
        type: string
        examples:
        - -created_at
    Q:
      name: q
      in: query
      description: Free text search. Case insensitive substring match on the main text fields of the resource (name, username, ...).
      schema:
        type: string
        examples:
        - sport
        maxLength: 200
    From:
      name: from
      in: query
      description: Start of the time range (inclusive), RFC 3339.
      schema:
        type: string
        examples:
        - '2026-11-01T00:00:00Z'
        format: date-time
    To:
      name: to
      in: query
      description: End of the time range (exclusive), RFC 3339. Defaults to now.
      schema:
        type: string
        examples:
        - '2026-11-28T00:00:00Z'
        format: date-time
    NodeIdQ:
      name: node_id
      in: query
      description: Only items on this node.
      schema:
        type: integer
        format: int64
    CategoryIdQ:
      name: category_id
      in: query
      description: Only items in this category.
      schema:
        type: integer
        format: int64
    EnabledQ:
      name: enabled
      in: query
      description: Filter by enabled flag.
      schema:
        type: boolean
    BouquetIdQ:
      name: bouquet_id
      in: query
      description: Only items that belong to this bouquet.
      schema:
        type: integer
        format: int64
  headers:
    Retry-After:
      description: Seconds to wait before retrying.
      schema:
        type: integer
        examples:
        - 12
        format: int32
    X-RateLimit-Limit:
      description: Requests allowed in the current window.
      schema:
        type: integer
        examples:
        - 600
        format: int32
    X-RateLimit-Remaining:
      description: Requests left in the current window.
      schema:
        type: integer
        examples:
        - 598
        format: int32
    X-RateLimit-Reset:
      description: Unix time (seconds) when the window resets.
      schema:
        type: integer
        examples:
        - 1795876260
        format: int64
  responses:
    BadRequest:
      description: The request is malformed or failed validation. `details` lists the offending fields.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: validation_failed
              message: Some fields are invalid.
              details:
                fields:
                  username: must be 3 to 64 characters
                  max_connections: must be between 1 and 1000
    Unauthorized:
      description: Missing, expired or invalid credentials.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: unauthorized
              message: Access token expired.
    Forbidden:
      description: Authenticated, but the role, group permission, API key scope or IP allowlist does not allow this call, or the target is outside
        your reseller tree. `2fa_enrollment_required` means the account must turn on two-step sign-in first (see `Me.totp_required`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: missing_scope
              message: This API key lacks the lines:write scope.
              details:
                required_scopes:
                - lines:write
    NotFound:
      description: No such resource, or it is not visible to you.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: not_found
              message: Line 42 not found.
    Conflict:
      description: The request conflicts with current state (duplicate name, resource in use, setup already done).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: already_exists
              message: A line with this username already exists.
    PaymentRequired:
      description: Not enough credits for this operation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: insufficient_credits
              message: This needs 3 credits, you have 1.
              details:
                required: 3
                available: 1
    TooManyRequests:
      description: Rate limit exceeded. Wait `Retry-After` seconds.
      headers:
        Retry-After:
          $ref: '#/components/headers/Retry-After'
        X-RateLimit-Limit:
          $ref: '#/components/headers/X-RateLimit-Limit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/X-RateLimit-Remaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/X-RateLimit-Reset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: rate_limited
              message: Too many requests, retry in 12 seconds.
    NoContent:
      description: Done. No body.
    Accepted:
      description: Accepted. The work continues in the background; poll the returned job.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Job'
  schemas:
    LogLineRef:
      type: object
      properties:
        id:
          type: integer
          format: int64
        username:
          type: string
      required:
      - id
      - username
    LogUserRef:
      type: object
      properties:
        id:
          type: integer
          format: int64
        username:
          type: string
        role:
          type: string
      required:
      - id
      - username
      - role
    LogEvent:
      type: object
      properties:
        id:
          type: integer
          format: int64
        at:
          type: string
          format: date-time
        type:
          type: string
        level:
          type: string
          enum:
          - debug
          - info
          - warn
          - error
        line:
          oneOf:
          - $ref: '#/components/schemas/LogLineRef'
          - type: 'null'
        owner_id:
          type:
          - integer
          - 'null'
          format: int64
        stream_id:
          type:
          - integer
          - 'null'
          format: int64
        content_name:
          type:
          - string
          - 'null'
        content_kind:
          type:
          - string
          - 'null'
        node_id:
          type:
          - integer
          - 'null'
          format: int64
        ip:
          type:
          - string
          - 'null'
        country_code:
          type:
          - string
          - 'null'
        asn:
          type:
          - integer
          - 'null'
          format: int64
        user_agent:
          type: string
        code:
          type: string
        msg:
          type: string
        data:
          type:
          - object
          - 'null'
          additionalProperties: true
        request_id:
          type: string
      required:
      - id
      - at
      - type
      - level
      - line
      - owner_id
      - stream_id
      - content_name
      - content_kind
      - node_id
      - ip
      - country_code
      - asn
      - user_agent
      - code
      - msg
      - data
      - request_id
    LogEventList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/LogEvent'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    LogSeries:
      type: object
      properties:
        bucket_s:
          type: integer
        points:
          type: array
          items:
            type: object
            properties:
              t:
                type: string
                format: date-time
              total:
                type: integer
                format: int64
              warn:
                type: integer
                format: int64
              error:
                type: integer
                format: int64
            required:
            - t
            - total
            - warn
            - error
        top_codes:
          type: array
          items:
            $ref: '#/components/schemas/LogTopItem'
        top_streams:
          type: array
          items:
            $ref: '#/components/schemas/LogTopItem'
      required:
      - bucket_s
      - points
      - top_codes
      - top_streams
    LogTopItem:
      type: object
      properties:
        key:
          type: string
        id:
          type:
          - integer
          - 'null'
          format: int64
        name:
          type:
          - string
          - 'null'
        n:
          type: integer
          format: int64
      required:
      - key
      - id
      - name
      - n
    OnDemandRow:
      type: object
      properties:
        stream_id:
          type: integer
          format: int64
        name:
          type:
          - string
          - 'null'
        starts:
          type: integer
          format: int64
        ready:
          type: integer
          format: int64
        fails:
          type: integer
          format: int64
        idle_stops:
          type: integer
          format: int64
        avg_start_ms:
          type:
          - number
          - 'null'
        p95_start_ms:
          type:
          - number
          - 'null'
        last_at:
          type:
          - string
          - 'null'
          format: date-time
      required:
      - stream_id
      - name
      - starts
      - ready
      - fails
      - idle_stops
      - avg_start_ms
      - p95_start_ms
      - last_at
    OpenTimeRow:
      type: object
      description: Server side open time of finished live sessions that have both halves measured (control_ms + node_first_byte_ms).
      properties:
        stream_id:
          type:
          - integer
          - 'null'
          description: Null on the overall row.
          format: int64
        name:
          type:
          - string
          - 'null'
        sessions:
          type: integer
          format: int64
        avg_ms:
          type:
          - number
          - 'null'
        p95_ms:
          type:
          - number
          - 'null'
        avg_control_ms:
          type:
          - number
          - 'null'
        avg_node_ms:
          type:
          - number
          - 'null'
      required:
      - stream_id
      - name
      - sessions
      - avg_ms
      - p95_ms
      - avg_control_ms
      - avg_node_ms
    RankRow:
      type: object
      properties:
        rank:
          type: integer
        content_kind:
          type: string
        content_id:
          type: integer
          format: int64
        name:
          type:
          - string
          - 'null'
        viewers:
          type: integer
          format: int64
        hours:
          type: number
        bytes:
          type: integer
          format: int64
        sessions:
          type: integer
          format: int64
      required:
      - rank
      - content_kind
      - content_id
      - name
      - viewers
      - hours
      - bytes
      - sessions
    LineIp:
      type: object
      properties:
        line:
          $ref: '#/components/schemas/LogLineRef'
        ip:
          type: string
        sessions:
          type: integer
          format: int64
        first_at:
          type: string
          format: date-time
        last_at:
          type: string
          format: date-time
        country_code:
          type:
          - string
          - 'null'
        asn:
          type:
          - integer
          - 'null'
          format: int64
        isp:
          type: string
        bytes:
          type: integer
          format: int64
        other_lines:
          type: integer
          format: int64
      required:
      - line
      - ip
      - sessions
      - first_at
      - last_at
      - country_code
      - asn
      - isp
      - bytes
      - other_lines
    CreditLog:
      type: object
      properties:
        id:
          type: integer
          format: int64
        at:
          type: string
          format: date-time
        user:
          $ref: '#/components/schemas/LogUserRef'
        delta:
          type: integer
          format: int64
        balance_before:
          type: integer
          format: int64
        balance_after:
          type: integer
          format: int64
        reason:
          type: string
        actor:
          oneOf:
          - $ref: '#/components/schemas/LogUserRef'
          - type: 'null'
        line:
          oneOf:
          - $ref: '#/components/schemas/LogLineRef'
          - type: 'null'
        note:
          type: string
      required:
      - id
      - at
      - user
      - delta
      - balance_before
      - balance_after
      - reason
      - actor
      - line
      - note
    ResellerAction:
      type: object
      properties:
        id:
          type: integer
          format: int64
        at:
          type: string
          format: date-time
        reseller:
          $ref: '#/components/schemas/LogUserRef'
        action:
          type: string
        target_type:
          type: string
        target_id:
          type:
          - integer
          - 'null'
          format: int64
        credits:
          type:
          - integer
          - 'null'
          format: int64
        details:
          type:
          - object
          - 'null'
          additionalProperties: true
      required:
      - id
      - at
      - reseller
      - action
      - target_type
      - target_id
      - credits
      - details
    LogVodJob:
      type: object
      properties:
        id:
          type: integer
          format: int64
        kind:
          type: string
        item_id:
          type: integer
          format: int64
        name:
          type:
          - string
          - 'null'
        action:
          type: string
        node_id:
          type: integer
          format: int64
        node_name:
          type: string
        status:
          type: string
        stale:
          type: boolean
        progress:
          type: integer
        message:
          type: string
        attempts:
          type: integer
          format: int64
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        finished_at:
          type:
          - string
          - 'null'
          format: date-time
      required:
      - id
      - kind
      - item_id
      - name
      - action
      - node_id
      - node_name
      - status
      - stale
      - progress
      - message
      - attempts
      - created_at
      - updated_at
      - finished_at
    DetectionEvidence:
      type: object
      properties:
        code:
          type: string
        points:
          type: integer
        value:
          type: number
        limit:
          type: number
        detail:
          type: string
      required:
      - code
      - points
      - value
      - limit
    Detection:
      type: object
      properties:
        line:
          $ref: '#/components/schemas/LogLineRef'
        owner:
          $ref: '#/components/schemas/LogUserRef'
        kind:
          type: string
          enum:
          - restream
          - vod_theft
        score:
          type: integer
          minimum: 0
          maximum: 100
        status:
          type: string
          enum:
          - ok
          - flagged
          - marked
          - disabled
          - allowed
          - cleared
        evidence:
          type: array
          items:
            $ref: '#/components/schemas/DetectionEvidence'
        high_since:
          type:
          - string
          - 'null'
          format: date-time
        peak_score:
          type: integer
        updated_at:
          type: string
          format: date-time
        line_enabled:
          type: boolean
        is_restreamer:
          type: boolean
      required:
      - line
      - owner
      - kind
      - score
      - status
      - evidence
      - high_since
      - peak_score
      - updated_at
      - line_enabled
      - is_restreamer
    DetectionDetail:
      type: object
      properties:
        detection:
          $ref: '#/components/schemas/Detection'
        recent_events:
          type: array
          items:
            $ref: '#/components/schemas/LogEvent'
        recent_sessions:
          type: array
          items:
            type: object
            properties:
              content_id:
                type: integer
                format: int64
              content_kind:
                type: string
              ip:
                type: string
              asn:
                type:
                - integer
                - 'null'
                format: int64
              user_agent:
                type: string
              started_at:
                type: string
                format: date-time
              ended_at:
                type: string
                format: date-time
              bytes_out:
                type: integer
                format: int64
            required:
            - content_id
            - content_kind
            - ip
            - asn
            - user_agent
            - started_at
            - ended_at
            - bytes_out
      required:
      - detection
      - recent_events
      - recent_sessions
    DetectionSummary:
      type: object
      properties:
        restream:
          type: object
          additionalProperties:
            type: integer
            format: int64
        vod_theft:
          type: object
          additionalProperties:
            type: integer
            format: int64
      required:
      - restream
      - vod_theft
    LogNote:
      type: object
      properties:
        id:
          type: integer
          format: int64
        kind:
          type: string
          enum:
          - note
          - digest
        view:
          type: string
        title:
          type: string
        body:
          type: string
        author:
          oneOf:
          - $ref: '#/components/schemas/LogUserRef'
          - type: 'null'
        created_at:
          type: string
          format: date-time
      required:
      - id
      - kind
      - view
      - title
      - body
      - author
      - created_at
    LogsStatus:
      type: object
      properties:
        writer:
          type: object
          properties:
            queued:
              type: integer
            cap:
              type: integer
            written:
              type: integer
              format: int64
            failed:
              type: integer
              format: int64
            dropped:
              type: object
              additionalProperties:
                type: integer
                format: int64
          required:
          - queued
          - cap
          - written
          - failed
          - dropped
        partitions:
          type: array
          items:
            type: object
            properties:
              table:
                type: string
              name:
                type: string
              rows_estimate:
                type: integer
                format: int64
            required:
            - table
            - name
            - rows_estimate
        maintenance:
          oneOf:
          - type: object
            properties:
              at:
                type: string
                format: date-time
              created:
                type: array
                items:
                  type: string
              dropped:
                type: array
                items:
                  type: string
              deleted:
                type: object
                additionalProperties:
                  type: integer
                  format: int64
              error:
                type: string
            required:
            - at
            - created
            - dropped
            - deleted
          - type: 'null'
      required:
      - writer
      - partitions
      - maintenance
    LogSettings:
      type: object
      properties:
        retention_days:
          type: object
          description: 'Days per event family: client, stream, ondemand, panel, system, detect, ai.'
          additionalProperties:
            type: integer
            minimum: 1
            maximum: 3650
        audit_days:
          type: integer
          minimum: 7
          maximum: 3650
        vod_opens_per_hour:
          type: integer
          minimum: 0
          maximum: 100000
          description: Distinct movies and episodes a line may open per hour. 0 = off.
        hosting_asns:
          type: array
          items:
            type: integer
            format: int64
          description: ASNs added to the built-in datacenter list.
        restream:
          allOf:
          - type: object
            properties:
              notify_score:
                type: integer
                minimum: 1
                maximum: 100
              mark_score:
                type: integer
                minimum: 1
                maximum: 100
              auto_disable:
                type: boolean
              auto_disable_hours:
                type: integer
                minimum: 1
                maximum: 720
            required:
            - notify_score
            - mark_score
            - auto_disable
            - auto_disable_hours
          - type: object
            properties:
              continuous_hours:
                type: number
              max_concurrent:
                type: integer
              max_ips:
                type: integer
              steady_hours:
                type: number
            required:
            - continuous_hours
            - max_concurrent
            - max_ips
            - steady_hours
        theft:
          allOf:
          - type: object
            properties:
              notify_score:
                type: integer
                minimum: 1
                maximum: 100
              mark_score:
                type: integer
                minimum: 1
                maximum: 100
              auto_disable:
                type: boolean
              auto_disable_hours:
                type: integer
                minimum: 1
                maximum: 720
            required:
            - notify_score
            - mark_score
            - auto_disable
            - auto_disable_hours
          - type: object
            properties:
              per_hour:
                type: integer
              per_day:
                type: integer
              seq_run:
                type: integer
              rapid_gap_s:
                type: integer
              info_per_hour:
                type: integer
              full_lists:
                type: integer
              max_ips:
                type: integer
              parallel_opens:
                type: integer
              fast_mb:
                type: integer
              fast_mbps:
                type: number
            required:
            - per_hour
            - per_day
            - seq_run
            - rapid_gap_s
            - info_per_hour
            - full_lists
            - max_ips
            - parallel_opens
            - fast_mb
            - fast_mbps
        ai:
          type: object
          properties:
            max_output_tokens:
              type: integer
              minimum: 200
              maximum: 8000
            daily_token_budget:
              type: integer
              minimum: 1000
            digest:
              type: boolean
            digest_hour:
              type: integer
              minimum: 0
              maximum: 23
              description: UTC hour of the daily digest.
          required:
          - max_output_tokens
          - daily_token_budget
          - digest
          - digest_hour
        signers:
          type: array
          items:
            $ref: '#/components/schemas/SourceSigner'
        signer_secrets:
          type: object
          writeOnly: true
          additionalProperties:
            type: string
            minLength: 8
            maxLength: 512
          description: 'PATCH only: signer id to its HMAC key or S3 secret key. Stored encrypted, never returned.'
      required: []
    SourceSigner:
      type: object
      properties:
        id:
          type: string
          pattern: ^[a-z0-9_-]{1,32}$
        host:
          type: string
          description: Exact host, or .suffix for a domain and its subdomains.
        kind:
          type: string
          enum:
          - hmac
          - s3
        ttl_s:
          type: integer
          minimum: 30
          maximum: 86400
        template:
          type: string
          description: 'hmac: query to append, with {expires}, {sig}, {ip}, {line}.'
        message:
          type: string
          description: 'hmac: signed string, with {path}, {expires}, {ip}, {line}.'
        encoding:
          type: string
          enum:
          - hex
          - base64url
        region:
          type: string
        access_key:
          type: string
      required:
      - id
      - host
      - kind
    LogAiRequest:
      type: object
      properties:
        view:
          type: string
          minLength: 1
          maxLength: 40
          description: The Logs view the request comes from.
        question:
          type: string
          minLength: 3
          maxLength: 1000
          description: ask only.
        include_ips:
          type: boolean
          default: false
          description: Send full IP addresses instead of /24 or /48 networks.
        lang:
          type: string
          enum:
          - en
          - pt-BR
          - es
          description: 'Answer language. Default: Accept-Language.'
        detection:
          type: object
          properties:
            kind:
              type: string
              enum:
              - restream
              - vod_theft
            line_id:
              type: integer
              format: int64
          required:
          - kind
          - line_id
      required:
      - view
    TmdbSettings:
      type: object
      description: TMDB connection. This product uses the TMDB API but is not endorsed or certified by TMDB.
      properties:
        api_key_set:
          type: boolean
        api_key_hint:
          type:
          - string
          - 'null'
          description: Last 4 characters of the saved key.
        key_type:
          type:
          - string
          - 'null'
          description: 'v3: API key (sent as api_key). v4: API Read Access Token (sent as a Bearer token).'
          enum:
          - v3
          - v4
          - null
        key_checked:
          type: boolean
          description: False when the last saved key could not be checked because TMDB did not answer.
        language:
          type: string
          description: TMDB language for titles and overviews, like pt-BR. Empty follows the panel default language.
          examples:
          - pt-BR
        effective_language:
          type: string
          examples:
          - pt-BR
        auto_match:
          type: boolean
          description: Match new movies and series without a TMDB id by title and year in the background.
        min_confidence:
          type: number
          description: Automatic matches at or above this score (0 to 1) are applied; lower ones wait in the review list.
          examples:
          - 0.85
        attribution:
          type: string
          examples:
          - This product uses the TMDB API but is not endorsed or certified by TMDB.
      required:
      - api_key_set
      - api_key_hint
      - key_type
      - key_checked
      - language
      - effective_language
      - auto_match
      - min_confidence
      - attribution
    TmdbSettingsUpdate:
      type: object
      properties:
        api_key:
          type:
          - string
          - 'null'
          maxLength: 400
        language:
          type: string
          pattern: ^$|^[a-z]{2}(-[A-Z]{2})?$
        auto_match:
          type: boolean
        min_confidence:
          type: number
          minimum: 0.5
          maximum: 1
    TmdbSearchResult:
      type: object
      properties:
        tmdb_id:
          type: integer
          format: int32
          examples:
          - 603
        title:
          type: string
          examples:
          - Matrix
        original_title:
          type: string
          examples:
          - The Matrix
        year:
          type:
          - integer
          - 'null'
          format: int32
          examples:
          - 1999
        overview:
          type: string
        poster_url:
          type: string
          description: Direct TMDB image URL (w185), empty when TMDB has none.
        confidence:
          type:
          - number
          - 'null'
          description: Only in the review list, 0 to 1.
      required:
      - tmdb_id
      - title
      - original_title
      - year
      - overview
      - poster_url
    TmdbDetails:
      type: object
      description: One TMDB title mapped to Bitstream fields. Images are direct TMDB URLs (poster w500, backdrops w1280, stills w300).
      properties:
        tmdb_id:
          type: integer
          format: int32
        kind:
          type: string
          enum:
          - movie
          - series
        title:
          type: string
        original_title:
          type: string
        overview:
          type: string
        genres:
          type: array
          items:
            type: string
        cast:
          type: array
          description: Top 10 billed actors.
          items:
            type: string
        director:
          type: string
          description: Directors (movies) or creators (series), comma separated.
        release_date:
          type:
          - string
          - 'null'
          format: date
        year:
          type:
          - integer
          - 'null'
          format: int32
        runtime_min:
          type:
          - integer
          - 'null'
        rating:
          type:
          - number
          - 'null'
        country:
          type: string
        trailer:
          type: string
          description: YouTube video id.
        poster_url:
          type: string
        backdrop_urls:
          type: array
          items:
            type: string
        collection:
          type: string
        language:
          type: string
          description: Language the texts came in.
        seasons:
          type: array
          description: Series only.
          items:
            type: object
            properties:
              season_number:
                type: integer
              name:
                type: string
              overview:
                type: string
              air_date:
                type:
                - string
                - 'null'
              poster_url:
                type: string
              episode_count:
                type: integer
            required:
            - season_number
            - name
            - overview
            - air_date
            - poster_url
            - episode_count
      required:
      - tmdb_id
      - kind
      - title
      - original_title
      - overview
      - genres
      - cast
      - director
      - release_date
      - year
      - runtime_min
      - rating
      - country
      - trailer
      - poster_url
      - backdrop_urls
      - collection
      - language
    TmdbRefreshRequest:
      type: object
      properties:
        tmdb_id:
          type: integer
          format: int32
          description: Link this TMDB title before refreshing. Omit to use the saved one.
    TmdbReviewItem:
      type: object
      properties:
        kind:
          type: string
          enum:
          - movie
          - series
        id:
          type: integer
          format: int64
        name:
          type: string
        year:
          type:
          - integer
          - 'null'
          format: int32
        confidence:
          type:
          - number
          - 'null'
        candidates:
          type: array
          items:
            $ref: '#/components/schemas/TmdbSearchResult'
      required:
      - kind
      - id
      - name
      - year
      - confidence
      - candidates
    VodJob:
      type: object
      properties:
        id:
          type: integer
          format: int64
        kind:
          type: string
          enum:
          - movie
          - episode
        item_id:
          type: integer
          format: int64
        item_name:
          type: string
        action:
          type: string
          enum:
          - download
          - reprocess
        node_id:
          type: integer
          format: int64
        status:
          type: string
          enum:
          - queued
          - running
          - done
          - failed
        progress:
          type: integer
          description: 0 to 100.
        message:
          type: string
          description: Why it failed, or what changed when done.
        created_at:
          type: string
          format: date-time
        finished_at:
          type:
          - string
          - 'null'
          format: date-time
      required:
      - id
      - kind
      - item_id
      - item_name
      - action
      - node_id
      - status
      - progress
      - message
      - created_at
      - finished_at
    BouquetMembership:
      type: object
      properties:
        bouquet_ids:
          type: array
          maxItems: 1000
          items:
            type: integer
            format: int64
      required:
      - bouquet_ids
    AiExplainRequest:
      type: object
      properties:
        subject_type:
          type: string
          examples:
          - stream
          enum:
          - stream
          - node
          - connection
          - log
        subject_id:
          type: string
          description: Stream id, node id, connection session id, or stream id for logs.
          examples:
          - '101'
        node_id:
          type:
          - integer
          - 'null'
          description: For stream and log subjects, limit to one node.
          format: int64
        question:
          type:
          - string
          - 'null'
          description: Optional extra question.
          examples:
          - Why does this channel keep switching sources?
          maxLength: 1000
      required:
      - subject_type
      - subject_id
    AiExplanation:
      type: object
      properties:
        markdown:
          type: string
          examples:
          - |-
            ## What is happening
            Source 1 stops sending video every few minutes...
        provider:
          type: string
          examples:
          - anthropic
        model:
          type: string
          examples:
          - claude-sonnet-4-5
        redacted:
          type: array
          items:
            type: string
          description: Kinds of data removed before sending.
          examples:
          - - source_credentials
            - client_ips
      required:
      - markdown
      - provider
      - model
      - redacted
    AiSettings:
      type: object
      properties:
        enabled:
          type: boolean
          examples:
          - true
        provider:
          type: string
          examples:
          - anthropic
          enum:
          - anthropic
          - openai
        model:
          type: string
          examples:
          - claude-sonnet-4-5
        api_key:
          type: string
          description: Write only, stored encrypted. Required in the same request when provider or base_url changes, so a stored key never goes to a new host.
          writeOnly: true
        api_key_set:
          type: boolean
          examples:
          - true
          readOnly: true
        api_key_hint:
          type:
          - string
          - 'null'
          examples:
          - …7fQ2
          readOnly: true
        base_url:
          type:
          - string
          - 'null'
          description: Override for compatible gateways. Private addresses are refused unless the control runs with BS_FETCH_ALLOW_PRIVATE=1. Loopback and link-local are always refused.
    ApiKey:
      type: object
      description: An API key for automation. Acts as its owner, limited to its scopes.
      properties:
        id:
          type: integer
          description: Unique id.
          examples:
          - 42
          format: int64
          readOnly: true
        prefix:
          type: string
          examples:
          - a1b2c3d4
          readOnly: true
        owner:
          $ref: '#/components/schemas/UserBrief'
          readOnly: true
        last_used_at:
          type:
          - string
          - 'null'
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        last_used_ip:
          type:
          - string
          - 'null'
          readOnly: true
        revoked_at:
          type:
          - string
          - 'null'
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        created_at:
          type: string
          description: When the record was created.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        name:
          type: string
          examples:
          - Billing integration
          maxLength: 100
        scopes:
          type: array
          items:
            type: string
          description: Must be a subset of your own permissions.
          examples:
          - - lines:read
            - lines:write
          minItems: 1
        allowed_ips:
          type: array
          items:
            type: string
            examples:
            - 203.0.113.10/32
          description: Empty means any IP.
        require_signature:
          type: boolean
          description: Reject requests without a valid X-BS-Signature.
          default: false
        expires_at:
          type:
          - string
          - 'null'
          description: null means no expiry.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
      required:
      - id
      - prefix
      - owner
      - last_used_at
      - last_used_ip
      - revoked_at
      - created_at
      - name
      - scopes
    ApiKeyCreate:
      type: object
      description: Fields accepted when creating a ApiKey. Omitted optional fields take the defaults shown.
      properties:
        name:
          type: string
          examples:
          - Billing integration
          maxLength: 100
        scopes:
          type: array
          items:
            type: string
          description: Must be a subset of your own permissions.
          examples:
          - - lines:read
            - lines:write
          minItems: 1
        allowed_ips:
          type: array
          items:
            type: string
            examples:
            - 203.0.113.10/32
          description: Empty means any IP.
        require_signature:
          type: boolean
          description: Reject requests without a valid X-BS-Signature.
          default: false
        expires_at:
          type:
          - string
          - 'null'
          description: null means no expiry.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
      required:
      - name
      - scopes
    ApiKeyCreated:
      allOf:
      - $ref: '#/components/schemas/ApiKey'
      - type: object
        properties:
          key:
            type: string
            description: 'Full key, shown once: bsk_<prefix>_<secret>.'
            examples:
            - bsk_a1b2c3d4_Q2xvdWQgc2VjcmV0IGtleSBleGFtcGxl
        required:
        - key
    ApiKeyList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/ApiKey'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    ApiKeyUpdate:
      type: object
      description: Partial update of a ApiKey. Send only the fields to change.
      properties:
        name:
          type: string
          examples:
          - Billing integration
          maxLength: 100
        scopes:
          type: array
          items:
            type: string
          description: Must be a subset of your own permissions.
          examples:
          - - lines:read
            - lines:write
          minItems: 1
        allowed_ips:
          type: array
          items:
            type: string
            examples:
            - 203.0.113.10/32
          description: Empty means any IP.
        require_signature:
          type: boolean
          description: Reject requests without a valid X-BS-Signature.
          default: false
        expires_at:
          type:
          - string
          - 'null'
          description: null means no expiry.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
      minProperties: 1
    AuditEntry:
      type: object
      properties:
        id:
          type: integer
          format: int64
        at:
          type: string
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
        actor:
          $ref: '#/components/schemas/UserBrief'
        api_key_prefix:
          type:
          - string
          - 'null'
        ip:
          type:
          - string
          - 'null'
        action:
          type: string
          examples:
          - line.renew
        target_type:
          type: string
          examples:
          - line
        target_id:
          type:
          - integer
          - 'null'
          examples:
          - 812
          format: int64
        details:
          type: object
          properties: {}
          additionalProperties: true
          examples:
          - periods: 1
            credits: 1
      required:
      - id
      - at
      - action
    AuditEntryList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/AuditEntry'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    Backup:
      type: object
      properties:
        error_code:
          type: string
          description: error as a code to translate. pg_tools_missing (pg_dump not installed on the control host), interrupted (bs-control
            restarted during the backup), backup_failed (anything else, see error). Absent when nothing failed.
          enum:
          - pg_tools_missing
          - interrupted
          - backup_failed
        id:
          type: integer
          examples:
          - 12
          format: int64
        filename:
          type: string
          examples:
          - bitstream-2026-11-28T030000Z.dump.enc
        kind:
          type: string
          examples:
          - manual
          enum:
          - manual
          - scheduled
          - pre_restore
        status:
          type: string
          examples:
          - running
          enum:
          - running
          - done
          - failed
        size_bytes:
          type:
          - integer
          - 'null'
          examples:
          - 48234496
          format: int64
        sha256:
          type:
          - string
          - 'null'
          examples:
          - 9f86d0...
        error:
          type: string
          examples:
          - ''
        created_by:
          $ref: '#/components/schemas/UserBrief'
        created_at:
          type: string
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
        finished_at:
          type:
          - string
          - 'null'
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
      required:
      - id
      - filename
      - kind
      - status
      - created_at
    BackupList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Backup'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    BlockedAsn:
      type: object
      properties:
        asn:
          type: integer
          examples:
          - 16509
          minimum: 1
          format: int64
        name:
          type: string
          description: From GeoLite2 ASN.
          examples:
          - AMAZON-02
          readOnly: true
        reason:
          type: string
          examples:
          - hosting
        created_at:
          type: string
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
      required:
      - asn
    BlockedCountry:
      type: object
      properties:
        country_code:
          type: string
          examples:
          - XX
          pattern: ^[A-Z]{2}$
        reason:
          type: string
          examples:
          - ''
        created_at:
          type: string
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
      required:
      - country_code
    BlockedIp:
      type: object
      description: A blocked address or range. Applies to the panel and client APIs.
      properties:
        id:
          type: integer
          description: Unique id.
          examples:
          - 42
          format: int64
          readOnly: true
        source:
          type: string
          description: 'auto: added by brute force protection.'
          examples:
          - manual
          enum:
          - manual
          - auto
          readOnly: true
        created_at:
          type: string
          description: When the record was created.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        cidr:
          type: string
          description: Single IP or CIDR.
          examples:
          - 203.0.113.0/24
        reason:
          type: string
          examples:
          - scraping
        expires_at:
          type:
          - string
          - 'null'
          description: null is permanent.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
      required:
      - id
      - source
      - created_at
      - cidr
    BlockedIpCreate:
      type: object
      description: Fields accepted when creating a BlockedIp. Omitted optional fields take the defaults shown.
      properties:
        cidr:
          type: string
          description: Single IP or CIDR.
          examples:
          - 203.0.113.0/24
        reason:
          type: string
          examples:
          - scraping
        expires_at:
          type:
          - string
          - 'null'
          description: null is permanent.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
      required:
      - cidr
    BlockedIpList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/BlockedIp'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    BlockedUserAgent:
      type: object
      description: A refused user agent, matched case insensitively.
      properties:
        id:
          type: integer
          description: Unique id.
          examples:
          - 42
          format: int64
          readOnly: true
        created_at:
          type: string
          description: When the record was created.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        pattern:
          type: string
          examples:
          - curl/
          maxLength: 512
        match:
          type: string
          examples:
          - contains
          enum:
          - contains
          - exact
        reason:
          type: string
          examples:
          - ''
      required:
      - id
      - created_at
      - pattern
    BlockedUserAgentCreate:
      type: object
      description: Fields accepted when creating a BlockedUserAgent. Omitted optional fields take the defaults shown.
      properties:
        pattern:
          type: string
          examples:
          - curl/
          maxLength: 512
        match:
          type: string
          examples:
          - contains
          enum:
          - contains
          - exact
        reason:
          type: string
          examples:
          - ''
      required:
      - pattern
    BlockedUserAgentList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/BlockedUserAgent'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    Bouquet:
      type: object
      description: A named bundle of content given to lines and packages.
      properties:
        id:
          type: integer
          description: Unique id.
          examples:
          - 42
          format: int64
          readOnly: true
        counts:
          type: object
          properties:
            live:
              type: integer
              examples:
              - 320
              format: int32
            radio:
              type: integer
              examples:
              - 12
              format: int32
            movies:
              type: integer
              examples:
              - 1500
              format: int32
            series:
              type: integer
              examples:
              - 210
              format: int32
          readOnly: true
        created_at:
          type: string
          description: When the record was created.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        updated_at:
          type: string
          description: When the record was last changed.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        name:
          type: string
          examples:
          - Brazil Full
          maxLength: 128
        position:
          type: integer
          examples:
          - 0
          format: int32
      required:
      - id
      - counts
      - created_at
      - updated_at
      - name
    BouquetCreate:
      type: object
      description: Fields accepted when creating a Bouquet. Omitted optional fields take the defaults shown.
      properties:
        name:
          type: string
          examples:
          - Brazil Full
          maxLength: 128
        position:
          type: integer
          examples:
          - 0
          format: int32
      required:
      - name
    BouquetItems:
      type: object
      description: Ordered membership. Order decides the order and `num` clients see.
      properties:
        live:
          type: array
          items:
            type: integer
            format: int64
          description: Ordered live and created channel ids.
          examples:
          - - 101
            - 102
        radio:
          type: array
          items:
            type: integer
            format: int64
          description: Ordered radio ids.
        movies:
          type: array
          items:
            type: integer
            format: int64
          description: Ordered movie ids.
        series:
          type: array
          items:
            type: integer
            format: int64
          description: Ordered series ids.
      required:
      - live
      - radio
      - movies
      - series
    BouquetItemsPatch:
      type: object
      properties:
        add:
          type: object
          description: Ids appended at the end, skipping ones already present.
          properties:
            live:
              type: array
              items:
                type: integer
                format: int64
            radio:
              type: array
              items:
                type: integer
                format: int64
            movies:
              type: array
              items:
                type: integer
                format: int64
            series:
              type: array
              items:
                type: integer
                format: int64
        remove:
          type: object
          properties:
            live:
              type: array
              items:
                type: integer
                format: int64
            radio:
              type: array
              items:
                type: integer
                format: int64
            movies:
              type: array
              items:
                type: integer
                format: int64
            series:
              type: array
              items:
                type: integer
                format: int64
      minProperties: 1
    BouquetList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Bouquet'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    BouquetUpdate:
      type: object
      description: Partial update of a Bouquet. Send only the fields to change.
      properties:
        name:
          type: string
          examples:
          - Brazil Full
          maxLength: 128
        position:
          type: integer
          examples:
          - 0
          format: int32
      minProperties: 1
    ListOp:
      type: object
      description: Changes a list in a mass edit. `add` and `remove` change only the given ids, `replace` makes the list exactly `ids`.
      properties:
        op:
          type: string
          enum: [add, remove, replace]
        ids:
          type: array
          items:
            type: integer
            format: int64
          maxItems: 1000
      required: [op, ids]
    StreamMassEdit:
      type: object
      description: '`params` of the streams bulk `update` action. A field left out stays as it is on every stream; null clears a nullable field.
        `mode` is skipped on created channels and `category_id` on streams of another kind (listed in `failed`). The adult flag lives on categories.'
      properties:
        category_id:
          type:
          - integer
          - 'null'
          format: int64
        bouquets:
          $ref: '#/components/schemas/ListOp'
        nodes:
          $ref: '#/components/schemas/ListOp'
        enabled:
          type: boolean
        on_demand:
          type: boolean
        idle_timeout_s:
          type: integer
          minimum: 5
          maximum: 86400
        mode:
          type: string
          enum: [ffmpeg, llod, direct]
        dash_output:
          type: string
          enum: ['off', 'on', all_qualities]
        archive_enabled:
          type: boolean
        archive_days:
          type: integer
          minimum: 1
          maximum: 30
        archive_node_id:
          type:
          - integer
          - 'null'
          format: int64
        fast_detection:
          type: boolean
        priority_backup:
          type: boolean
        is_adult:
          type: boolean
        custom_sid:
          type: string
          maxLength: 128
          description: Same value on every channel. XC_VM does not require it to be unique.
        epg_channel_id:
          type:
          - integer
          - 'null'
          format: int64
          description: One guide channel for all. Null clears the guide mapping.
        epg:
          type: object
          required:
          - source_id
          - pattern
          additionalProperties: false
          description: Map each channel to the channel of this EPG source whose XMLTV id is the pattern with `{name}` and `{id}` filled in (case does not matter). A channel with no match fails with `epg_no_match` and is not changed. Cannot be combined with `epg_channel_id`.
          properties:
            source_id:
              type: integer
              format: int64
            pattern:
              type: string
              minLength: 1
              maxLength: 255
              examples:
              - '{name}.uk'
        restart:
          type: boolean
          default: false
          description: Restart running streams now when `mode` or `dash_output` changed. False lets them pick it up on their next start.
    VodMassEdit:
      type: object
      description: '`params` of the movies, series and episodes bulk `update` action. A field left out stays as it is. Movies take every field,
        series all but `container`, episodes `enabled`, `rating` and `container`. TMDB re-fetch is `POST /tmdb/refresh`.'
      properties:
        category_id:
          type:
          - integer
          - 'null'
          format: int64
        bouquets:
          $ref: '#/components/schemas/ListOp'
        enabled:
          type: boolean
        rating:
          type:
          - number
          - 'null'
          minimum: 0
          maximum: 10
        year:
          type:
          - integer
          - 'null'
          minimum: 1880
          maximum: 2200
        container:
          type: string
          pattern: ^[a-z0-9]{2,5}$
        is_adult:
          type: boolean
          description: Movies and series only.
    VodBulkUpdateRequest:
      type: object
      properties:
        ids:
          type: array
          items:
            type: integer
            format: int64
          minItems: 1
          maxItems: 1000
        action:
          type: string
          enum: [update]
        params:
          $ref: '#/components/schemas/VodMassEdit'
      required: [ids, action, params]
    ToolsItemType:
      type: string
      enum: [live, radio, created, movie, series, episode, category, bouquet, epg_source, line, reseller]
    MassDeleteTarget:
      type: object
      description: Some ids (up to 100000) or every row of the type (`all`), never both.
      properties:
        type:
          $ref: '#/components/schemas/ToolsItemType'
        ids:
          type: array
          items:
            type: integer
            format: int64
        all:
          type: boolean
      required: [type]
    MassDeletePreview:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/ToolsItemType'
        count:
          type: integer
        cascades:
          type: object
          additionalProperties:
            type: integer
            format: int64
        confirm_word:
          type: string
        backup_available:
          type: boolean
      required: [type, count, cascades, confirm_word, backup_available]
    ToolsJob:
      type: object
      properties:
        id:
          type: string
        type:
          $ref: '#/components/schemas/ToolsItemType'
        state:
          type: string
          enum: [running, done, failed]
        stage:
          type: string
          enum: [backup, stopping, deleting, done]
        total:
          type: integer
        done:
          type: integer
        deleted:
          type: integer
        skipped:
          type: array
          items:
            type: object
            properties:
              id:
                type: integer
                format: int64
              code:
                type: string
              message:
                type: string
            required: [id, code, message]
        backup_id:
          type:
          - integer
          - 'null'
          format: int64
        error:
          type: string
          description: '`backup_failed` or `internal` when state is failed.'
        started_at:
          type: string
          format: date-time
        finished_at:
          type:
          - string
          - 'null'
          format: date-time
      required: [id, type, state, stage, total, done, deleted, skipped, backup_id, error, started_at, finished_at]
    ChannelOrderItem:
      type: object
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
        kind:
          type: string
        category_id:
          type:
          - integer
          - 'null'
          format: int64
        category_name:
          type:
          - string
          - 'null'
        position:
          type: integer
        logo_url:
          type: string
      required: [id, name, kind, category_id, category_name, position, logo_url]
    BulkResult:
      type: object
      properties:
        succeeded:
          type: array
          items:
            type: integer
            format: int64
          description: Ids processed successfully.
          examples:
          - - 12
            - 13
        failed:
          type: array
          items:
            type: object
            properties:
              id:
                type: integer
                format: int64
              code:
                type: string
                examples:
                - insufficient_credits
              message:
                type: string
            required:
            - id
            - code
            - message
      required:
      - succeeded
      - failed
    Category:
      type: object
      description: A category of live channels, movies, series or radios.
      properties:
        id:
          type: integer
          description: Unique id.
          examples:
          - 42
          format: int64
          readOnly: true
        item_count:
          type: integer
          examples:
          - 48
          format: int64
          readOnly: true
        created_at:
          type: string
          description: When the record was created.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        kind:
          type: string
          description: Content kind. Created channels use live.
          examples:
          - live
          enum:
          - live
          - movie
          - series
          - radio
        name:
          type: string
          examples:
          - Sports
          maxLength: 128
        parent_id:
          type:
          - integer
          - 'null'
          format: int64
        position:
          type: integer
          description: Order within the kind.
          examples:
          - 0
          format: int32
        is_adult:
          type: boolean
          description: Adult content. Apps get is_adult 1 for its channels, movies and series and can lock them behind a PIN.
            Lines with hide_adult do not see the category at all.
      required:
      - id
      - item_count
      - created_at
      - kind
      - name
    CategoryCreate:
      type: object
      description: Fields accepted when creating a Category. Omitted optional fields take the defaults shown.
      properties:
        kind:
          type: string
          description: Content kind. Created channels use live.
          examples:
          - live
          enum:
          - live
          - movie
          - series
          - radio
        name:
          type: string
          examples:
          - Sports
          maxLength: 128
        parent_id:
          type:
          - integer
          - 'null'
          format: int64
        position:
          type: integer
          description: Order within the kind.
          examples:
          - 0
          format: int32
        is_adult:
          type: boolean
          description: Adult content. Apps get is_adult 1 for its channels, movies and series and can lock them behind a PIN.
            Lines with hide_adult do not see the category at all.
      required:
      - kind
      - name
    CategoryList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Category'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    CategoryUpdate:
      type: object
      description: Partial update of a Category. Send only the fields to change.
      properties:
        kind:
          type: string
          description: Content kind. Created channels use live.
          examples:
          - live
          enum:
          - live
          - movie
          - series
          - radio
        name:
          type: string
          examples:
          - Sports
          maxLength: 128
        parent_id:
          type:
          - integer
          - 'null'
          format: int64
        position:
          type: integer
          description: Order within the kind.
          examples:
          - 0
          format: int32
        is_adult:
          type: boolean
          description: Adult content. Apps get is_adult 1 for its channels, movies and series and can lock them behind a PIN.
            Lines with hide_adult do not see the category at all.
      minProperties: 1
    Certificate:
      type: object
      properties:
        id:
          type: integer
          format: int64
          readOnly: true
        domain:
          type: string
          examples:
          - edge1.example.com
        node_id:
          type:
          - integer
          - 'null'
          description: null for the panel domain.
          format: int64
        challenge:
          type: string
          description: dns-01 needs the Cloudflare token.
          examples:
          - http-01
          enum:
          - http-01
          - dns-01
        status:
          type: string
          examples:
          - pending
          enum:
          - pending
          - issuing
          - valid
          - expiring
          - failed
          readOnly: true
        issued_at:
          type:
          - string
          - 'null'
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        expires_at:
          type:
          - string
          - 'null'
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        last_error:
          type: string
          examples:
          - ''
          readOnly: true
        updated_at:
          type: string
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
      required:
      - domain
    GeoIPDatabase:
      type: object
      properties:
        loaded:
          type: boolean
        type:
          type:
          - string
          - 'null'
          description: database_type of the file.
          examples:
          - DBIP-Country-Lite
        build_at:
          type:
          - string
          - 'null'
          description: When the provider built this file. RFC 3339 timestamp in UTC.
          format: date-time
      required:
      - loaded
      - type
      - build_at
    GeoIPStatus:
      type: object
      properties:
        provider:
          type: string
          enum:
          - dbip
          - maxmind
          description: dbip is DB-IP Lite (free, no account, CC BY 4.0). maxmind is GeoLite2 and needs an account id and license key.
        maxmind_account_id:
          type:
          - string
          - 'null'
        maxmind_key_set:
          type: boolean
        country:
          $ref: '#/components/schemas/GeoIPDatabase'
        asn:
          $ref: '#/components/schemas/GeoIPDatabase'
        updating:
          type: boolean
        last_update_at:
          type:
          - string
          - 'null'
          description: Last successful update. RFC 3339 timestamp in UTC.
          format: date-time
        last_attempt_at:
          type:
          - string
          - 'null'
          format: date-time
        next_update_at:
          type: string
          description: Next automatic update (weekly; 6 hours after a failure).
          format: date-time
        last_error_code:
          type:
          - string
          - 'null'
          enum:
          - offline
          - auth
          - not_found
          - bad_file
          - disk
          - null
          description: Why the last attempt failed. null when it worked.
        last_error:
          type:
          - string
          - 'null'
          description: Technical detail of the failure, in English.
        attribution:
          type:
          - string
          - 'null'
          description: Credit to show next to geolocation data (DB-IP Lite license). null when not required.
          examples:
          - IP geolocation by DB-IP
        attribution_url:
          type:
          - string
          - 'null'
          examples:
          - https://db-ip.com
      required:
      - provider
      - maxmind_account_id
      - maxmind_key_set
      - country
      - asn
      - updating
      - last_update_at
      - last_attempt_at
      - next_update_at
      - last_error_code
      - last_error
      - attribution
      - attribution_url
    GeoIPLookup:
      type: object
      properties:
        ip:
          type: string
        country_code:
          type:
          - string
          - 'null'
          examples:
          - US
        asn:
          type:
          - integer
          - 'null'
          format: int64
          examples:
          - 15169
        isp:
          type:
          - string
          - 'null'
          examples:
          - Google LLC
      required:
      - ip
      - country_code
      - asn
      - isp
    DomainsPlan:
      type: object
      properties:
        admin_panel:
          type: string
          description: Host of the admin panel (bare name, no scheme).
          examples:
          - painel.minhamarca-admin.com
        admin_api:
          type: string
          description: Host of the admin API. Empty means the admin panel host (panel served by the control).
        reseller_panel:
          type: string
        client_api:
          type: string
          description: Host apps use for player_api.php, get.php and xmltv.php.
        panel_hosting:
          type: string
          enum:
          - control
          - external
          default: control
        client_api_on_admin_hosts:
          type: boolean
          default: false
        admin_proxied:
          type: boolean
          default: true
        client_proxied:
          type: boolean
          default: true
      required:
      - admin_panel
      - admin_api
      - reseller_panel
      - client_api
      - panel_hosting
      - client_api_on_admin_hosts
      - admin_proxied
      - client_proxied
    DomainIssue:
      type: object
      properties:
        code:
          type: string
          examples:
          - admin_client_same_domain
          enum:
          - admin_client_same_domain
          - reseller_on_admin_domain
          - admin_not_proxied
          - client_not_proxied
          - streaming_proxied
          - streaming_on_admin_domain
          - panel_origin_not_allowed
          - panel_url_exposes_control
        hosts:
          type: array
          items:
            type: string
      required:
      - code
      - hosts
    DomainNode:
      type: object
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
        hosts:
          type: array
          items:
            type: string
        proxied:
          type: boolean
        port:
          type: integer
      required:
      - id
      - name
      - hosts
      - proxied
      - port
    DomainsView:
      type: object
      properties:
        plan:
          $ref: '#/components/schemas/DomainsPlan'
        nodes:
          type: array
          items:
            $ref: '#/components/schemas/DomainNode'
        warnings:
          type: array
          items:
            $ref: '#/components/schemas/DomainIssue'
        spa_origins:
          type: array
          description: http.spa_origins of the control config (read only).
          items:
            type: string
      required:
      - plan
      - nodes
      - warnings
      - spa_origins
    DomainCheck:
      type: object
      properties:
        role:
          type: string
          enum:
          - admin_panel
          - admin_api
          - reseller_panel
          - client_api
          - streaming
        host:
          type: string
        node_id:
          type: integer
          format: int64
        addresses:
          type: array
          items:
            type: string
        resolves:
          type: boolean
        cloudflare:
          type: boolean
        want:
          type: string
          enum:
          - proxied
          - dns_only
        status:
          type: string
          enum:
          - ok
          - missing
          - proxy_off
          - proxy_on
      required:
      - role
      - host
      - addresses
      - resolves
      - cloudflare
      - want
      - status
    DomainDnsChange:
      type: object
      properties:
        host:
          type: string
        role:
          type: string
        result:
          type: string
          enum:
          - synced
          - skipped
        reason:
          type: string
          enum:
          - external_panel
          - outside_zone
          - no_public_ip
        proxied:
          type: boolean
      required:
      - host
      - role
      - result
      - proxied
    DomainLink:
      type: object
      properties:
        key:
          type: string
          enum:
          - admin_panel
          - reseller_panel
          - admin_api
          - client_api
          - node
        url:
          type: string
        name:
          type: string
        node_id:
          type: integer
          format: int64
      required:
      - key
      - url
    CloudflareStatus:
      type: object
      properties:
        token_set:
          type: boolean
          examples:
          - true
        token_hint:
          type:
          - string
          - 'null'
          description: Last 4 characters.
          examples:
          - …x9Qa
        zone_id:
          type:
          - string
          - 'null'
          examples:
          - 023e105f4ecef8ad9ca31a8372d0c353
        zone_name:
          type:
          - string
          - 'null'
          examples:
          - example.com
        panel_record:
          type:
          - string
          - 'null'
          examples:
          - panel.example.com
        panel_proxied:
          type: boolean
          description: Panel may be proxied (orange cloud). Node records are always DNS only.
          examples:
          - false
        auto_sync:
          type: boolean
          description: Create and update node A/AAAA records when nodes change.
          examples:
          - true
        last_sync_at:
          type:
          - string
          - 'null'
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
        last_sync_error:
          type: string
          examples:
          - ''
      required:
      - token_set
      - auto_sync
    Connection:
      type: object
      properties:
        session_id:
          type: string
          examples:
          - 01936d6e-8a3b-7c1e-9f00-1a2b3c4d5e6f
          format: uuid
        state:
          type: string
          examples:
          - pending
          enum:
          - pending
          - active
        line:
          $ref: '#/components/schemas/UserBriefLine'
        content_kind:
          type: string
          examples:
          - live
          enum:
          - live
          - radio
          - movie
          - episode
        content_id:
          type: integer
          examples:
          - 101
          format: int64
        content_name:
          type: string
          examples:
          - SporTV HD
        node_id:
          type:
          - integer
          - 'null'
          examples:
          - 1
          format: int64
        node_name:
          type:
          - string
          - 'null'
          examples:
          - edge-sp-1
        proxy_id:
          type:
          - integer
          - 'null'
          description: Proxy node the viewer came through. null when the viewer went straight to the node.
          format: int64
        proxy_name:
          type:
          - string
          - 'null'
          examples:
          - proxy-fra-1
        output:
          type: string
          examples:
          - ts
          enum:
          - ts
          - hls
          - dash
        ip:
          type:
          - string
          - 'null'
          description: Hidden (null) for resellers without can_view_connection_ips.
          examples:
          - 198.51.100.23
        country_code:
          type:
          - string
          - 'null'
          examples:
          - BR
        asn:
          type:
          - integer
          - 'null'
          examples:
          - 28573
          format: int64
        isp:
          type:
          - string
          - 'null'
          description: ASN organization from the current GeoIP database.
          examples:
          - Claro
        user_agent:
          type: string
          examples:
          - TiviMate/4.7.0
        started_at:
          type: string
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
        bytes_out:
          type: integer
          examples:
          - 1073741824
          format: int64
        bitrate_kbps:
          type: integer
          examples:
          - 4800
          format: int32
        control_ms:
          type:
          - integer
          - 'null'
          description: Control part of the open time, in ms (play request to the 302 or the proxy start). Null until the node reports it, and
            always null for older nodes.
          examples:
          - 4
          format: int64
        node_first_byte_ms:
          type:
          - integer
          - 'null'
          description: Node part of the open time, in ms (request to the first media byte written; HLS from the first playlist to the first
            segment). The player's own start time comes on top.
          examples:
          - 60
          format: int64
      required:
      - session_id
      - state
      - line
      - content_kind
      - content_id
      - output
      - started_at
    ConnectionList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Connection'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    CreatedChannel:
      type: object
      description: A channel made from movies and episodes played in a loop (ffmpeg concat, copy).
      properties:
        id:
          type: integer
          description: Unique id.
          examples:
          - 42
          format: int64
          readOnly: true
        kind:
          type: string
          const: created
          readOnly: true
        health:
          $ref: '#/components/schemas/StreamHealth'
          readOnly: true
        total_duration_s:
          type: integer
          examples:
          - 86400
          format: int64
          readOnly: true
        created_at:
          type: string
          description: When the record was created.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        updated_at:
          type: string
          description: When the record was last changed.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        name:
          type: string
          examples:
          - Sports HD
          maxLength: 255
        category_id:
          type:
          - integer
          - 'null'
          examples:
          - 4
          format: int64
        logo_url:
          type: string
          examples:
          - https://cdn.example.com/logos/sports.png
        epg_channel_id:
          type:
          - integer
          - 'null'
          description: Mapped EPG channel (see `/epg/channels`).
          examples:
          - 3021
          format: int64
        on_demand:
          type: boolean
          description: Start on first viewer, stop after idle_timeout_s without viewers.
          default: false
        idle_timeout_s:
          type: integer
          deprecated: true
          description: Stored but unused. Nodes always stop idle on demand channels after the panel setting default_idle_timeout_s.
          examples:
          - 60
          format: int32
          minimum: 5
          maximum: 86400
        ffmpeg_input_args:
          type: array
          items:
            type: string
          description: Admin only. Extra input flags from the allowlist (GET /system/ffmpeg).
          examples:
          - - -re
        ffmpeg_output_args:
          type: array
          items:
            type: string
          description: Admin only. Extra output flags from the allowlist.
        is_adult:
          type: boolean
          description: Adult channel even in a non-adult category. Lines that hide adult content do not see it. Default false.
        custom_sid:
          type: string
          description: Enigma2 service reference override.
          examples:
          - ''
        enabled:
          type: boolean
          default: true
        position:
          type: integer
          examples:
          - 0
          format: int32
        notes:
          type: string
          examples:
          - ''
        node_ids:
          type: array
          items:
            type: integer
            format: int64
          description: 'Shortcut on create: assign these nodes as roots of the server tree.'
          writeOnly: true
          examples:
          - - 1
        items:
          type: array
          items:
            $ref: '#/components/schemas/CreatedChannelItem'
          description: Ordered playlist, looped.
          minItems: 1
        shuffle:
          type: boolean
          description: Shuffle order on each loop.
          default: false
      required:
      - id
      - kind
      - health
      - total_duration_s
      - created_at
      - updated_at
      - name
      - items
    CreatedChannelCreate:
      type: object
      description: Fields accepted when creating a CreatedChannel. Omitted optional fields take the defaults shown.
      properties:
        name:
          type: string
          examples:
          - Sports HD
          maxLength: 255
        category_id:
          type:
          - integer
          - 'null'
          examples:
          - 4
          format: int64
        logo_url:
          type: string
          examples:
          - https://cdn.example.com/logos/sports.png
        epg_channel_id:
          type:
          - integer
          - 'null'
          description: Mapped EPG channel (see `/epg/channels`).
          examples:
          - 3021
          format: int64
        on_demand:
          type: boolean
          description: Start on first viewer, stop after idle_timeout_s without viewers.
          default: false
        idle_timeout_s:
          type: integer
          deprecated: true
          description: Stored but unused. Nodes always stop idle on demand channels after the panel setting default_idle_timeout_s.
          examples:
          - 60
          format: int32
          minimum: 5
          maximum: 86400
        ffmpeg_input_args:
          type: array
          items:
            type: string
          description: Admin only. Extra input flags from the allowlist (GET /system/ffmpeg).
          examples:
          - - -re
        ffmpeg_output_args:
          type: array
          items:
            type: string
          description: Admin only. Extra output flags from the allowlist.
        is_adult:
          type: boolean
          description: Adult channel even in a non-adult category. Lines that hide adult content do not see it. Default false.
        custom_sid:
          type: string
          description: Enigma2 service reference override.
          examples:
          - ''
        enabled:
          type: boolean
          default: true
        position:
          type: integer
          examples:
          - 0
          format: int32
        notes:
          type: string
          examples:
          - ''
        node_ids:
          type: array
          items:
            type: integer
            format: int64
          description: 'Shortcut on create: assign these nodes as roots of the server tree.'
          writeOnly: true
          examples:
          - - 1
        items:
          type: array
          items:
            $ref: '#/components/schemas/CreatedChannelItem'
          description: Ordered playlist, looped.
          minItems: 1
        shuffle:
          type: boolean
          description: Shuffle order on each loop.
          default: false
      required:
      - name
      - items
    CreatedChannelItem:
      type: object
      description: Exactly one of movie_id or episode_id. Items must share codec parameters (checked with ffprobe), or the channel breaks at the
        switch.
      properties:
        movie_id:
          type:
          - integer
          - 'null'
          examples:
          - 9001
          format: int64
        episode_id:
          type:
          - integer
          - 'null'
          format: int64
        title:
          type: string
          description: Resolved title.
          examples:
          - The Matrix (1999)
          readOnly: true
        duration_s:
          type:
          - integer
          - 'null'
          examples:
          - 8160
          format: int32
          readOnly: true
    CreatedChannelList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/CreatedChannel'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    CreatedChannelUpdate:
      type: object
      description: Partial update of a CreatedChannel. Send only the fields to change.
      properties:
        name:
          type: string
          examples:
          - Sports HD
          maxLength: 255
        category_id:
          type:
          - integer
          - 'null'
          examples:
          - 4
          format: int64
        logo_url:
          type: string
          examples:
          - https://cdn.example.com/logos/sports.png
        epg_channel_id:
          type:
          - integer
          - 'null'
          description: Mapped EPG channel (see `/epg/channels`).
          examples:
          - 3021
          format: int64
        on_demand:
          type: boolean
          description: Start on first viewer, stop after idle_timeout_s without viewers.
          default: false
        idle_timeout_s:
          type: integer
          deprecated: true
          description: Stored but unused. Nodes always stop idle on demand channels after the panel setting default_idle_timeout_s.
          examples:
          - 60
          format: int32
          minimum: 5
          maximum: 86400
        ffmpeg_input_args:
          type: array
          items:
            type: string
          description: Admin only. Extra input flags from the allowlist (GET /system/ffmpeg).
          examples:
          - - -re
        ffmpeg_output_args:
          type: array
          items:
            type: string
          description: Admin only. Extra output flags from the allowlist.
        is_adult:
          type: boolean
          description: Adult channel even in a non-adult category. Lines that hide adult content do not see it. Default false.
        custom_sid:
          type: string
          description: Enigma2 service reference override.
          examples:
          - ''
        enabled:
          type: boolean
          default: true
        position:
          type: integer
          examples:
          - 0
          format: int32
        notes:
          type: string
          examples:
          - ''
        node_ids:
          type: array
          items:
            type: integer
            format: int64
          description: 'Shortcut on create: assign these nodes as roots of the server tree.'
          writeOnly: true
          examples:
          - - 1
        items:
          type: array
          items:
            $ref: '#/components/schemas/CreatedChannelItem'
          description: Ordered playlist, looped.
          minItems: 1
        shuffle:
          type: boolean
          description: Shuffle order on each loop.
          default: false
      minProperties: 1
    CreditAdjust:
      type: object
      properties:
        amount:
          type: integer
          description: Positive adds credits, negative removes. For resellers this is a transfer from their own balance to a sub-reseller (or
            back, when negative).
          examples:
          - 100
          format: int64
        note:
          type: string
          description: Shown in the ledger.
          examples:
          - November payment
          maxLength: 500
      required:
      - amount
    CreditBalance:
      type: object
      properties:
        user_id:
          type: integer
          examples:
          - 5
          format: int64
        credits:
          type: integer
          examples:
          - 350
          format: int64
        actor_credits:
          type:
          - integer
          - 'null'
          description: Caller balance after a reseller transfer; null for admins.
          examples:
          - 900
          format: int64
      required:
      - user_id
      - credits
    CreditEntry:
      type: object
      properties:
        id:
          type: integer
          format: int64
        delta:
          type: integer
          examples:
          - -3
          format: int64
        balance_after:
          type: integer
          examples:
          - 347
          format: int64
        reason:
          type: string
          examples:
          - admin_adjust
          enum:
          - admin_adjust
          - transfer
          - line_create
          - line_renew
          - refund
          - subreseller_create
        actor:
          $ref: '#/components/schemas/UserBrief'
        line_id:
          type:
          - integer
          - 'null'
          format: int64
        note:
          type: string
        created_at:
          type: string
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
      required:
      - id
      - delta
      - balance_after
      - reason
      - created_at
    CreditEntryList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/CreditEntry'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    StatsSummary:
      type: object
      description: Live summary strip. Admin only fields (streams, bandwidth) are null for resellers; lines_active is null for admins.
      required:
      - generated_at
      - connections
      - online_lines
      - lines_active
      - streams_online
      - streams_offline
      - bandwidth
      properties:
        generated_at:
          type: string
          format: date-time
        connections:
          type: integer
          format: int64
          description: Live viewer sessions in scope (same as dashboard totals.connections).
        online_lines:
          type: integer
          format: int64
        lines_active:
          type:
          - integer
          - 'null'
          format: int64
          description: Resellers only. Enabled, not banned, not expired lines in the tree.
        streams_online:
          type:
          - integer
          - 'null'
          format: int64
          description: Same as dashboard totals.streams_running.
        streams_offline:
          type:
          - integer
          - 'null'
          format: int64
          description: Streams not playing (down, stalled, retrying). Same as dashboard totals.streams_error.
        bandwidth:
          type:
          - object
          - 'null'
          required:
          - rx_mbps
          - tx_mbps
          - nodes
          properties:
            rx_mbps:
              type: number
              description: Input, summed over nodes.
            tx_mbps:
              type: number
              description: Output, summed over nodes. Same as dashboard bandwidth_now.tx_mbps.
            nodes:
              type: array
              items:
                type: object
                required:
                - id
                - name
                - status
                - rx_mbps
                - tx_mbps
                properties:
                  id:
                    type: integer
                    format: int64
                  name:
                    type: string
                  status:
                    type: string
                  rx_mbps:
                    type: number
                  tx_mbps:
                    type: number
    SearchHit:
      type: object
      required:
      - id
      - title
      - subtitle
      - status
      - kind
      properties:
        id:
          type: integer
          format: int64
        title:
          type: string
          description: Username or name.
        subtitle:
          type: string
          description: 'Lines: client name. Users: email. Streams: category. Movies and series: year. May be empty.'
        status:
          type:
          - string
          - 'null'
          description: 'Lines: active, expired, disabled, banned. Others: active or disabled.'
        kind:
          type:
          - string
          - 'null'
          description: 'Streams: live, radio, created. Users: admin, reseller. Null otherwise.'
    SearchResults:
      type: object
      required:
      - lines
      - users
      - streams
      - movies
      - series
      properties:
        lines:
          type: array
          items:
            $ref: '#/components/schemas/SearchHit'
        users:
          type: array
          items:
            $ref: '#/components/schemas/SearchHit'
        streams:
          type: array
          items:
            $ref: '#/components/schemas/SearchHit'
        movies:
          type: array
          items:
            $ref: '#/components/schemas/SearchHit'
        series:
          type: array
          items:
            $ref: '#/components/schemas/SearchHit'
    Dashboard:
      type: object
      description: Everything the dashboard draws, in one call. Resellers get the same shape scoped to their tree (node and stream health fields
        are empty).
      properties:
        generated_at:
          type: string
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
        totals:
          type: object
          properties:
            lines:
              type: integer
              examples:
              - 5230
              format: int64
            lines_active:
              type: integer
              examples:
              - 4810
              format: int64
            lines_expiring_7d:
              type: integer
              examples:
              - 212
              format: int64
            lines_trial:
              type: integer
              examples:
              - 40
              format: int64
            connections:
              type: integer
              examples:
              - 2210
              format: int64
            online_lines:
              type: integer
              examples:
              - 1980
              format: int64
            streams:
              type: integer
              examples:
              - 1200
              format: int64
            streams_running:
              type: integer
              examples:
              - 860
              format: int64
            streams_error:
              type: integer
              examples:
              - 6
              format: int64
            movies:
              type: integer
              examples:
              - 14000
              format: int64
            series:
              type: integer
              examples:
              - 2100
              format: int64
            nodes_online:
              type: integer
              examples:
              - 4
              format: int32
            nodes_total:
              type: integer
              examples:
              - 5
              format: int32
            credits:
              type:
              - integer
              - 'null'
              description: Caller credits (resellers).
              examples:
              - 250
              format: int64
            open_tickets:
              type: integer
              examples:
              - 3
              format: int32
        bandwidth_now:
          type: object
          properties:
            tx_mbps:
              type: number
              examples:
              - 9800.5
            rx_mbps:
              type: number
              examples:
              - 1400.1
        connections_24h:
          type: array
          items:
            $ref: '#/components/schemas/TimePoint'
          description: 5 minute points.
        bandwidth_24h:
          type: array
          items:
            $ref: '#/components/schemas/TimePoint'
          description: tx Mbps, 5 minute points.
        nodes:
          type: array
          items:
            type: object
            properties:
              id:
                type: integer
                format: int64
              name:
                type: string
              status:
                type: string
              cpu_pct:
                type: number
              mem_pct:
                type: number
              rx_mbps:
                type: number
              tx_mbps:
                type: number
              clients:
                type: integer
                format: int32
        top_streams:
          type: array
          items:
            type: object
            properties:
              stream_id:
                type: integer
                format: int64
              name:
                type: string
              clients:
                type: integer
                format: int32
          description: Top 10 by current viewers.
        problem_streams:
          type: array
          items:
            type: object
            properties:
              stream_id:
                type: integer
                format: int64
              name:
                type: string
              color:
                type: string
                examples:
                - yellow
                enum:
                - yellow
                - red
              reason:
                type: string
                description: English explanation. Translate code and node instead.
              code:
                type: string
                description: not_playing (red) or backup (yellow, running on a backup source).
                enum:
                - not_playing
                - backup
              node:
                type: string
                description: Name of the node the code is about.
          description: Up to 20.
        countries:
          type: array
          items:
            type: object
            properties:
              country_code:
                type: string
                description: ISO 3166-1 alpha-2, or empty for viewers without a known country (local or private address, no GeoIP data).
              connections:
                type: integer
                format: int32
          description: Top 10. Adds up to totals.connections when there are 10 countries or fewer.
        recent_lines:
          type: array
          items:
            $ref: '#/components/schemas/Line'
          description: Last 5 created.
        expiring_lines:
          type: array
          items:
            $ref: '#/components/schemas/Line'
          description: Next 5 to expire within 7 days (same window as totals.lines_expiring_7d).
        alerts:
          type: array
          items:
            type: object
            properties:
              severity:
                type: string
                examples:
                - info
                enum:
                - info
                - warning
                - critical
              message:
                type: string
                description: English text for API clients. The panel shows `code` translated.
                examples:
                - Node edge-3 is offline.
              link:
                type:
                - string
                - 'null'
                examples:
                - /nodes/3
              code:
                type: string
                description: Stable alert kind.
                enum:
                - node_offline
                - streams_error
                - license_revoked
                - license_unregistered
                examples:
                - node_offline
              params:
                type: object
                description: Values for the translated text (name, count, nodes, lines).
                additionalProperties:
                  type: string
      required:
      - generated_at
      - totals
    EpgChannel:
      type: object
      properties:
        id:
          type: integer
          examples:
          - 3021
          format: int64
        epg_source_id:
          type: integer
          examples:
          - 1
          format: int64
        xmltv_id:
          type: string
          examples:
          - SporTV.br
        display_name:
          type: string
          examples:
          - SporTV HD
        icon_url:
          type: string
          examples:
          - ''
        lang:
          type: string
          examples:
          - pt
        mapped_stream_ids:
          type: array
          items:
            type: integer
            format: int64
      required:
      - id
      - epg_source_id
      - xmltv_id
      - display_name
    EpgChannelList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/EpgChannel'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    EpgMapping:
      type: object
      properties:
        stream_id:
          type: integer
          examples:
          - 101
          format: int64
        epg_channel_id:
          type:
          - integer
          - 'null'
          examples:
          - 3021
          format: int64
      required:
      - stream_id
      - epg_channel_id
    EpgMappingRow:
      type: object
      properties:
        stream_id:
          type: integer
          examples:
          - 101
          format: int64
        stream_name:
          type: string
          examples:
          - SporTV HD
        epg_channel:
          $ref: '#/components/schemas/EpgChannel'
        suggestion:
          type:
          - object
          - 'null'
          properties:
            epg_channel:
              $ref: '#/components/schemas/EpgChannel'
            score:
              type: number
              description: 0 to 1 name similarity.
              examples:
              - 0.93
    EpgProgramme:
      type: object
      properties:
        start:
          type: string
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
        end:
          type: string
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
        title:
          type: string
          examples:
          - Futebol ao vivo
        description:
          type: string
          examples:
          - ''
        lang:
          type: string
          examples:
          - pt
      required:
      - start
      - end
      - title
    EpgSource:
      type: object
      description: An XMLTV guide source.
      properties:
        id:
          type: integer
          description: Unique id.
          examples:
          - 42
          format: int64
          readOnly: true
        last_refreshed_at:
          type:
          - string
          - 'null'
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        last_status:
          type: string
          examples:
          - never
          enum:
          - never
          - ok
          - error
          - running
          readOnly: true
        last_error:
          type: string
          examples:
          - ''
          readOnly: true
        channel_count:
          type: integer
          examples:
          - 1830
          format: int32
          readOnly: true
        created_at:
          type: string
          description: When the record was created.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        name:
          type: string
          examples:
          - epg.example.org BR
        url:
          type: string
          description: XMLTV URL, plain or gzip.
          examples:
          - https://epg.example.org/br.xml.gz
        enabled:
          type: boolean
          default: true
        priority:
          type: integer
          description: Higher wins when two sources map the same stream.
          examples:
          - 0
          format: int32
        refresh_interval:
          type: string
          description: ISO 8601 duration, minimum PT15M.
          examples:
          - PT12H
        days_to_keep:
          type: integer
          examples:
          - 7
          format: int32
          minimum: 1
          maximum: 30
      required:
      - id
      - last_refreshed_at
      - last_status
      - last_error
      - channel_count
      - created_at
      - name
      - url
    EpgSourceCreate:
      type: object
      description: Fields accepted when creating a EpgSource. Omitted optional fields take the defaults shown.
      properties:
        name:
          type: string
          examples:
          - epg.example.org BR
        url:
          type: string
          description: XMLTV URL, plain or gzip.
          examples:
          - https://epg.example.org/br.xml.gz
        enabled:
          type: boolean
          default: true
        priority:
          type: integer
          description: Higher wins when two sources map the same stream.
          examples:
          - 0
          format: int32
        refresh_interval:
          type: string
          description: ISO 8601 duration, minimum PT15M.
          examples:
          - PT12H
        days_to_keep:
          type: integer
          examples:
          - 7
          format: int32
          minimum: 1
          maximum: 30
      required:
      - name
      - url
    EpgSourceList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/EpgSource'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    EpgSourceUpdate:
      type: object
      description: Partial update of a EpgSource. Send only the fields to change.
      properties:
        name:
          type: string
          examples:
          - epg.example.org BR
        url:
          type: string
          description: XMLTV URL, plain or gzip.
          examples:
          - https://epg.example.org/br.xml.gz
        enabled:
          type: boolean
          default: true
        priority:
          type: integer
          description: Higher wins when two sources map the same stream.
          examples:
          - 0
          format: int32
        refresh_interval:
          type: string
          description: ISO 8601 duration, minimum PT15M.
          examples:
          - PT12H
        days_to_keep:
          type: integer
          examples:
          - 7
          format: int32
          minimum: 1
          maximum: 30
      minProperties: 1
    Episode:
      type: object
      description: An episode. Its id is the stream id clients play.
      properties:
        id:
          type: integer
          description: Unique id.
          examples:
          - 42
          format: int64
          readOnly: true
        series_id:
          type: integer
          examples:
          - 77
          format: int64
          readOnly: true
        probe:
          type: object
          properties: {}
          additionalProperties: true
          readOnly: true
        created_at:
          type: string
          description: When the record was created.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        season_number:
          type: integer
          description: Season it belongs to. Created on the fly if missing.
          examples:
          - 1
          format: int32
        episode_number:
          type: integer
          examples:
          - 1
          format: int32
          minimum: 0
        title:
          type: string
          examples:
          - Pilot
        source_kind:
          type: string
          description: 'url: remote file proxied with Range passthrough. local: a file on a storage node.'
          examples:
          - url
          enum:
          - url
          - local
        source_url:
          type: string
          description: URL, or absolute file path on the storage node. Local paths must be inside a media folder (control and node setting media_roots, default /srv, /mnt, /media, /data, /opt/bitstream/media).
          examples:
          - https://vod.example.net/movies/matrix.mkv
        storage_node_id:
          type:
          - integer
          - 'null'
          description: Required when source_kind is local.
          format: int64
        account_id:
          type:
          - integer
          - 'null'
          description: Provider account for connection limits.
          format: int64
        container:
          type: string
          description: File extension clients use in the URL.
          examples:
          - mkv
          pattern: ^[a-z0-9]{2,5}$
        direct_source:
          type: boolean
          description: Redirect clients straight to source_url (url only). No limits or stats. URLs with user:pass@ or a query string, or tied to a provider account, are never redirected and play through a node.
          default: false
        plot:
          type: string
          examples:
          - ''
        poster_url:
          type: string
          examples:
          - ''
        air_date:
          type:
          - string
          - 'null'
          format: date
        rating:
          type:
          - number
          - 'null'
        duration_s:
          type:
          - integer
          - 'null'
          examples:
          - 3480
          format: int32
        enabled:
          type: boolean
          default: true
      required:
      - id
      - series_id
      - probe
      - created_at
      - season_number
      - episode_number
      - source_url
    EpisodeCreate:
      type: object
      description: Fields accepted when creating a Episode. Omitted optional fields take the defaults shown.
      properties:
        season_number:
          type: integer
          description: Season it belongs to. Created on the fly if missing.
          examples:
          - 1
          format: int32
        episode_number:
          type: integer
          examples:
          - 1
          format: int32
          minimum: 0
        title:
          type: string
          examples:
          - Pilot
        source_kind:
          type: string
          description: 'url: remote file proxied with Range passthrough. local: a file on a storage node.'
          examples:
          - url
          enum:
          - url
          - local
        source_url:
          type: string
          description: URL, or absolute file path on the storage node. Local paths must be inside a media folder (control and node setting media_roots, default /srv, /mnt, /media, /data, /opt/bitstream/media).
          examples:
          - https://vod.example.net/movies/matrix.mkv
        storage_node_id:
          type:
          - integer
          - 'null'
          description: Required when source_kind is local.
          format: int64
        account_id:
          type:
          - integer
          - 'null'
          description: Provider account for connection limits.
          format: int64
        container:
          type: string
          description: File extension clients use in the URL.
          examples:
          - mkv
          pattern: ^[a-z0-9]{2,5}$
        direct_source:
          type: boolean
          description: Redirect clients straight to source_url (url only). No limits or stats. URLs with user:pass@ or a query string, or tied to a provider account, are never redirected and play through a node.
          default: false
        plot:
          type: string
          examples:
          - ''
        poster_url:
          type: string
          examples:
          - ''
        air_date:
          type:
          - string
          - 'null'
          format: date
        rating:
          type:
          - number
          - 'null'
        duration_s:
          type:
          - integer
          - 'null'
          examples:
          - 3480
          format: int32
        enabled:
          type: boolean
          default: true
      required:
      - season_number
      - episode_number
      - source_url
    EpisodeList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Episode'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    EpisodeUpdate:
      type: object
      description: Partial update of a Episode. Send only the fields to change.
      properties:
        season_number:
          type: integer
          description: Season it belongs to. Created on the fly if missing.
          examples:
          - 1
          format: int32
        episode_number:
          type: integer
          examples:
          - 1
          format: int32
          minimum: 0
        title:
          type: string
          examples:
          - Pilot
        source_kind:
          type: string
          description: 'url: remote file proxied with Range passthrough. local: a file on a storage node.'
          examples:
          - url
          enum:
          - url
          - local
        source_url:
          type: string
          description: URL, or absolute file path on the storage node. Local paths must be inside a media folder (control and node setting media_roots, default /srv, /mnt, /media, /data, /opt/bitstream/media).
          examples:
          - https://vod.example.net/movies/matrix.mkv
        storage_node_id:
          type:
          - integer
          - 'null'
          description: Required when source_kind is local.
          format: int64
        account_id:
          type:
          - integer
          - 'null'
          description: Provider account for connection limits.
          format: int64
        container:
          type: string
          description: File extension clients use in the URL.
          examples:
          - mkv
          pattern: ^[a-z0-9]{2,5}$
        direct_source:
          type: boolean
          description: Redirect clients straight to source_url (url only). No limits or stats. URLs with user:pass@ or a query string, or tied to a provider account, are never redirected and play through a node.
          default: false
        plot:
          type: string
          examples:
          - ''
        poster_url:
          type: string
          examples:
          - ''
        air_date:
          type:
          - string
          - 'null'
          format: date
        rating:
          type:
          - number
          - 'null'
        duration_s:
          type:
          - integer
          - 'null'
          examples:
          - 3480
          format: int32
        enabled:
          type: boolean
          default: true
      minProperties: 1
    PanelEdge:
      type: object
      description: A panel proxy (bs-edge).
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
        status:
          type: string
          enum:
          - pending
          - online
          - offline
          - burned
        public_ip:
          type:
          - string
          - 'null'
        hostname:
          type: string
        version:
          type: string
        relay_port:
          type: integer
          description: Port where the proxy relays node channels (0 = off).
        last_seen_at:
          type:
          - string
          - 'null'
          format: date-time
        rps:
          type: number
          description: Requests per second over the last report.
        rss_bytes:
          type: integer
          format: int64
        requests_total:
          type: integer
          format: int64
        created_at:
          type: string
          format: date-time
        join_expires_at:
          type:
          - string
          - 'null'
          format: date-time
        replaced_by:
          type:
          - integer
          - 'null'
          format: int64
      required:
      - id
      - name
      - status
      - public_ip
      - hostname
      - version
      - relay_port
      - last_seen_at
      - rps
      - rss_bytes
      - requests_total
      - created_at
      - join_expires_at
      - replaced_by
    PanelEdgeCreate:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 64
        ip:
          type: string
          description: Public IP of the new proxy (optional). Needed when the firewall lockdown is on, so it can enrol.
    PanelEdgeCreated:
      type: object
      properties:
        edge:
          $ref: '#/components/schemas/PanelEdge'
        join_token:
          type: string
        install_command:
          type: string
        expires_at:
          type: string
          format: date-time
      required:
      - edge
      - join_token
      - install_command
      - expires_at
    PanelEdgeSettings:
      type: object
      properties:
        cloudflare_only:
          type: boolean
          description: Proxies accept HTTP only from Cloudflare ranges (default on).
        nodes_via_edges:
          type: boolean
          description: Nodes reach the control through the proxies.
        node_direct_fallback:
          type: boolean
          description: Nodes may still use the direct address when no proxy answers. They learn the control address while this is on.
        rate_per_ip:
          type: integer
          minimum: 1
          maximum: 10000
        burst:
          type: integer
          minimum: 1
          maximum: 100000
        max_body_mb:
          type: integer
          minimum: 1
          maximum: 4096
        dns_sync:
          type: boolean
    PanelEdgeView:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/PanelEdge'
        settings:
          allOf:
          - $ref: '#/components/schemas/PanelEdgeSettings'
          required:
          - cloudflare_only
          - nodes_via_edges
          - node_direct_fallback
          - rate_per_ip
          - burst
          - max_body_mb
          - dns_sync
        lockdown:
          type: object
          properties:
            enabled:
              type: boolean
            pending_until:
              type:
              - string
              - 'null'
              format: date-time
              description: Rollback deadline while not confirmed.
            via_edge:
              type: boolean
              description: This request came through a proxy.
          required:
          - enabled
          - pending_until
          - via_edge
        dns:
          type: object
          properties:
            record:
              type: string
            last_sync_at:
              type:
              - string
              - 'null'
              format: date-time
            last_error:
              type: string
            warnings:
              type: array
              items:
                type: string
          required:
          - record
          - last_sync_at
          - last_error
          - warnings
      required:
      - data
      - settings
      - lockdown
      - dns
    PanelEdgeDnsResult:
      type: object
      properties:
        record:
          type: string
        addresses:
          type: array
          items:
            type: string
        changes:
          type: integer
        warnings:
          type: array
          items:
            type: string
      required:
      - record
      - addresses
      - changes
      - warnings
    Error:
      type: object
      description: Every non 2xx response uses this envelope.
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Stable machine readable code in snake_case. Branch on this, not on message.
              examples:
              - validation_failed
            message:
              type: string
              description: Human readable explanation in English.
              examples:
              - Some fields are invalid.
            details:
              type: object
              description: Optional structured context. For validation errors, `fields` maps field names to problems.
              properties: {}
              additionalProperties: true
          required:
          - code
          - message
      required:
      - error
    GeoData:
      type: object
      properties:
        countries:
          type: array
          items:
            type: object
            properties:
              country_code:
                type: string
                examples:
                - BR
              connections:
                type: integer
                examples:
                - 1830
                format: int32
              lines:
                type: integer
                examples:
                - 1402
                format: int32
        points:
          type: array
          items:
            type: object
            properties:
              lat:
                type: number
                examples:
                - -23.55
              lon:
                type: number
                examples:
                - -46.63
              connections:
                type: integer
                examples:
                - 320
                format: int32
              city:
                type: string
                examples:
                - Sao Paulo
          description: Clustered city level points (GeoLite2 City). Never individual IPs.
        nodes:
          type: array
          items:
            type: object
            properties:
              node_id:
                type: integer
                format: int64
              name:
                type: string
              lat:
                type:
                - number
                - 'null'
              lon:
                type:
                - number
                - 'null'
      required:
      - countries
      - points
    HistorySession:
      type: object
      properties:
        session_id:
          type: string
          format: uuid
        line:
          $ref: '#/components/schemas/UserBriefLine'
        content_kind:
          type: string
          examples:
          - live
          enum:
          - live
          - radio
          - movie
          - episode
        content_id:
          type: integer
          format: int64
        content_name:
          type:
          - string
          - 'null'
          description: null if the content was deleted.
        node_id:
          type:
          - integer
          - 'null'
          format: int64
        proxy_id:
          type:
          - integer
          - 'null'
          description: Proxy node the viewer came through. null when the viewer went straight to the node.
          format: int64
        ip:
          type:
          - string
          - 'null'
        country_code:
          type:
          - string
          - 'null'
        asn:
          type:
          - integer
          - 'null'
          format: int64
        isp:
          type:
          - string
          - 'null'
          description: ASN organization from the current GeoIP database.
        user_agent:
          type: string
        output:
          type: string
          examples:
          - ts
          enum:
          - ts
          - hls
          - dash
        started_at:
          type: string
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
        ended_at:
          type: string
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
        duration_s:
          type: integer
          examples:
          - 3600
          format: int64
        bytes_out:
          type: integer
          format: int64
        end_reason:
          type: string
          examples:
          - client_closed
        control_ms:
          type:
          - integer
          - 'null'
          description: Control part of the open time, in ms (play request to the 302 or the proxy start). Null until the node reports it, and
            always null for older nodes.
          examples:
          - 4
          format: int64
        node_first_byte_ms:
          type:
          - integer
          - 'null'
          description: Node part of the open time, in ms (request to the first media byte written; HLS from the first playlist to the first
            segment). The player's own start time comes on top.
          examples:
          - 60
          format: int64
      required:
      - session_id
      - line
      - content_kind
      - content_id
      - started_at
      - ended_at
      - bytes_out
    HistorySessionList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/HistorySession'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    Job:
      type: object
      properties:
        id:
          type: integer
          examples:
          - 7
          format: int64
        kind:
          type: string
          description: Job kind.
          examples:
          - m3u
        status:
          type: string
          examples:
          - queued
          enum:
          - queued
          - running
          - done
          - failed
          - cancelled
        progress:
          type: object
          description: Rough progress.
          properties:
            done:
              type: integer
              examples:
              - 120
              format: int64
            total:
              type: integer
              examples:
              - 480
              format: int64
            stage:
              type: string
              examples:
              - creating_streams
        result:
          type: object
          description: 'Summary when done: counts of created, updated, skipped items and warnings.'
          properties: {}
          additionalProperties: true
        error:
          type: string
          description: Failure reason when status is failed.
          examples:
          - ''
        created_at:
          type: string
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
        started_at:
          type:
          - string
          - 'null'
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
        finished_at:
          type:
          - string
          - 'null'
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
      required:
      - id
      - kind
      - status
      - created_at
    JoinToken:
      type: object
      properties:
        id:
          type: integer
          examples:
          - 3
          format: int64
        note:
          type: string
        created_at:
          type: string
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
        expires_at:
          type: string
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
        used_at:
          type:
          - string
          - 'null'
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
        used_by_node_id:
          type:
          - integer
          - 'null'
          format: int64
        role:
          type: string
          enum:
          - node
          - proxy
        token:
          type: string
          description: Only in the create response. Contains the CA hash the node pins.
          examples:
          - bsj_1.Zm9v...sha256:4f3c...
        install_command:
          type: string
          description: Only in the create response. One line installer for the node host.
          examples:
          - sudo ./deploy/install.sh --node --join bsj1... --control https://panel.example.com:8443
      required:
      - id
      - created_at
      - expires_at
    SSHTarget:
      type: object
      properties:
        host:
          type: string
          maxLength: 253
          description: Host name or IP address of the server.
          examples:
          - 203.0.113.20
        port:
          type: integer
          format: int32
          minimum: 1
          maximum: 65535
          default: 22
      required:
      - host
    SSHHostKey:
      type: object
      properties:
        host:
          type: string
        port:
          type: string
        fingerprint:
          type: string
          description: SHA-256 fingerprint as `ssh-keygen -lf` prints it.
          examples:
          - SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8
        key_type:
          type: string
          examples:
          - ssh-ed25519
      required:
      - host
      - port
      - fingerprint
      - key_type
    SSHInstallRequest:
      type: object
      properties:
        host:
          type: string
          maxLength: 253
          description: Host name or IP address of the server.
        port:
          type: integer
          format: int32
          minimum: 1
          maximum: 65535
          default: 22
        user:
          type: string
          maxLength: 64
          examples:
          - root
        ssh_password:
          type: string
          format: password
          description: SSH password. Give this or private_key. Used once, never stored.
        private_key:
          type: string
          format: password
          maxLength: 16384
          description: SSH private key (OpenSSH or PEM). Used once, never stored.
        passphrase:
          type: string
          format: password
          description: Passphrase of private_key, when it has one.
        sudo_password:
          type: string
          format: password
          description: For a user other than root. Empty means the SSH password, or passwordless sudo with a key.
        host_key:
          type: string
          description: The fingerprint from `POST /nodes/ssh/host-key` that the admin confirmed. Any other key is refused.
        join_token:
          type: string
          format: password
          description: The join token from `POST /node-join-tokens`. Its role (node or proxy) is used.
        domain:
          type: string
          description: Public domain of the new server (`--domain`).
        password:
          type: string
          format: password
          description: The current password of the signed in panel user.
        totp_code:
          type: string
          description: TOTP or recovery code. Required when two-step sign-in is on.
      required:
      - host
      - user
      - host_key
      - join_token
      - password
    SSHInstallJob:
      type: object
      properties:
        id:
          type: string
          format: uuid
        state:
          type: string
          enum:
          - running
          - done
          - failed
        error_code:
          type: string
          description: 'Empty unless failed: host_key_mismatch, ssh_auth_failed, ssh_key_invalid, ssh_unreachable, arch_mismatch, shared_host, upload_failed, install_failed, install_timeout, ssh_failed.'
        error:
          type: string
          description: Why it failed, in English (no secrets). Show error_code translated.
        host:
          type: string
        port:
          type: integer
          format: int32
        role:
          type: string
          enum:
          - node
          - proxy
        join_token_id:
          type: integer
          format: int64
        node_id:
          type:
          - integer
          - 'null'
          format: int64
          description: The new server, once it joined.
        lines:
          type: array
          items:
            type: string
        next:
          type: integer
          format: int64
          description: Pass as `from` on the next call.
      required:
      - id
      - state
      - error_code
      - error
      - host
      - port
      - role
      - join_token_id
      - node_id
      - lines
      - next
    JoinTokenCreate:
      type: object
      properties:
        note:
          type: string
          examples:
          - edge in Frankfurt
        ttl_minutes:
          type: integer
          examples:
          - 60
          format: int32
          minimum: 5
          maximum: 1440
          default: 60
        domain:
          type: string
          description: Public domain of the new node. Added to the install command as `--domain`, so the node joins with it.
          examples:
          - edge2.example.com
        role:
          type: string
          description: proxy makes the server join as a proxy fronting proxy_backends. The install command gets `--role proxy` (no
            ffmpeg, proxy tuning).
          enum:
          - node
          - proxy
          default: node
        proxy_backends:
          type: array
          description: Required with role proxy. The nodes the new proxy fronts.
          items:
            type: integer
            format: int64
          maxItems: 200
    LicenseStatus:
      type: object
      properties:
        status:
          type: string
          description: '`unregistered` (setup skipped with BS_LICENSE_SKIP, or an older install not registered yet; nothing is blocked), `active`, or `revoked` by the platform (creating lines and streams is refused).'
          enum:
          - unregistered
          - active
          - revoked
          examples:
          - active
        panel_id:
          type: string
          format: uuid
          description: This panel's id at the license server.
        license_key:
          type: string
          description: Empty until activated.
          examples:
          - BSL-ABCDE-FGHIJ-KLMNO-PQRST
        message:
          type: string
          description: Text from the platform, for example why the key was revoked.
          examples:
          - ''
        activated_at:
          type:
          - string
          - 'null'
          format: date-time
          description: RFC 3339 timestamp in UTC.
        last_check_at:
          type:
          - string
          - 'null'
          format: date-time
          description: Last call to the license server, ok or not. RFC 3339 timestamp in UTC.
        last_check_ok:
          type:
          - boolean
          - 'null'
        last_error:
          type: string
          description: Why the last call failed. Failures never block anything.
        skipped:
          type: boolean
          description: True when the control runs with `BS_LICENSE_SKIP=1` (test labs).
      required:
      - status
      - panel_id
      - license_key
      - message
      - skipped
    Line:
      type: object
      description: A client subscription used by IPTV apps (Xtream login).
      properties:
        client_name:
          type: string
          description: Optional name of the person using the line. Used in the WhatsApp greeting and on client cards. Never sent to apps.
          maxLength: 100
          examples:
          - Maria
        client_phone:
          type: string
          description: Optional phone for WhatsApp. Stored as international digits (E.164 without +). On write, a number without a country code
            (up to 11 digits, like 21 99876-5432) gets the panel's phone_country_code; a leading + or 00 means it already has one.
          examples:
          - '5521998765432'
        id:
          type: integer
          description: Unique id.
          examples:
          - 42
          format: int64
          readOnly: true
        status:
          type: string
          description: 'Derived: banned > disabled > expired > active.'
          examples:
          - active
          enum:
          - active
          - expired
          - disabled
          - banned
          readOnly: true
        banned:
          type: boolean
          examples:
          - false
          readOnly: true
        owner:
          $ref: '#/components/schemas/UserBrief'
          readOnly: true
        active_connections:
          type: integer
          examples:
          - 1
          format: int32
          readOnly: true
        last_ip:
          description: Null for resellers without `can_view_connection_ips`.
          type:
          - string
          - 'null'
          examples:
          - 198.51.100.23
          readOnly: true
        last_activity_at:
          type:
          - string
          - 'null'
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        created_at:
          type: string
          description: When the record was created.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        updated_at:
          type: string
          description: When the record was last changed.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        username:
          type: string
          description: Login used by IPTV apps. Generated when omitted on create. Letters, digits and `._@-`.
          examples:
          - joao2291
          pattern: ^[A-Za-z0-9._@-]{3,64}$
        password:
          type: string
          description: 'Readable on purpose: the Xtream protocol puts it in every playlist URL. Generated when omitted on create.'
          examples:
          - k8Jw2pQz
          minLength: 4
          maxLength: 64
        owner_id:
          type: integer
          description: Owning user. Defaults to the caller. Must be in your tree.
          examples:
          - 5
          format: int64
        package_id:
          type:
          - integer
          - 'null'
          description: Package the line was sold with.
          examples:
          - 2
          format: int64
        exp_date:
          type:
          - string
          - 'null'
          description: Expiry. null means never. Admin only on update; resellers extend with `/renew`.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
        max_connections:
          type: integer
          examples:
          - 1
          format: int32
          minimum: 1
          maximum: 1000
        connection_policy:
          type: string
          description: 'At the limit: drop the oldest connection (same IP first, so zapping works) or refuse the new one.'
          examples:
          - kick_oldest
          enum:
          - kick_oldest
          - reject
        is_trial:
          type: boolean
          examples:
          - false
          readOnly: true
        is_restreamer:
          type: boolean
          default: false
        hide_adult:
          type: boolean
          description: Leave adult categories (is_adult) out of this line's lists, playlists and EPG, and refuse to play them.
        enabled:
          type: boolean
          default: true
        bouquet_ids:
          type: array
          items:
            type: integer
            format: int64
          description: Ordered bouquets. Defaults to the package bouquets.
          examples:
          - - 1
            - 4
        allowed_ips:
          type: array
          items:
            type: string
            examples:
            - 203.0.113.0/24
          description: CIDRs allowed to play. Empty means any.
        allowed_user_agents:
          type: array
          items:
            type: string
            examples:
            - TiviMate/4.7.0
          description: Exact user agents allowed. Empty means any.
        allowed_outputs:
          type: array
          items:
            type: string
            examples:
            - ts
            enum:
            - ts
            - m3u8
            - mpd
        forced_country:
          type:
          - string
          - 'null'
          examples:
          - BR
          pattern: ^[A-Z]{2}$
        notes:
          type: string
          description: Admin notes.
          examples:
          - ''
        reseller_notes:
          type: string
          description: Notes visible to the owner chain.
          examples:
          - Paid by pix
      required:
      - id
      - status
      - banned
      - owner
      - active_connections
      - last_ip
      - last_activity_at
      - created_at
      - updated_at
    LineBulkRequest:
      type: object
      properties:
        ids:
          type: array
          items:
            type: integer
            format: int64
          description: Ids to act on. Up to 1000.
          minItems: 1
          maxItems: 1000
          examples:
          - - 12
            - 13
            - 14
        action:
          type: string
          description: 'What to do. `enable`: Enable. `disable`: Disable and kill connections. `delete`: Delete. `renew`: `params.periods` (default
            1), `params.package_id` optional. Charged per line. `set_bouquets`: `params.bouquet_ids` replaces bouquets. `add_bouquets`: `params.bouquet_ids`
            appended. `remove_bouquets`: `params.bouquet_ids` removed. `set_max_connections`: `params.max_connections` (admin). `set_owner`: `params.owner_id`
            moves lines (must be in your tree). `set_exp_date`: `params.exp_date` (admin). `ban`: Admin. `unban`: Admin. `kill`: Kill connections.'
          examples:
          - enable
          enum:
          - enable
          - disable
          - delete
          - renew
          - set_bouquets
          - add_bouquets
          - remove_bouquets
          - set_max_connections
          - set_owner
          - set_exp_date
          - ban
          - unban
          - kill
        params:
          type: object
          description: Extra arguments for the action, documented with each action.
          properties: {}
          additionalProperties: true
      required:
      - ids
      - action
    LineCreate:
      type: object
      description: Create a line. Resellers must pass package_id; duration, cost, connections, outputs and bouquets come from the package (bouquets
        can differ only with allow_change_bouquets).
      properties:
        client_name:
          type: string
          description: Optional name of the person using the line. Used in the WhatsApp greeting and on client cards. Never sent to apps.
          maxLength: 100
          examples:
          - Maria
        client_phone:
          type: string
          description: Optional phone for WhatsApp. Stored as international digits (E.164 without +). On write, a number without a country code
            (up to 11 digits, like 21 99876-5432) gets the panel's phone_country_code; a leading + or 00 means it already has one.
          examples:
          - '5521998765432'
        username:
          type: string
          description: Login used by IPTV apps. Generated when omitted on create. Letters, digits and `._@-`.
          examples:
          - joao2291
          pattern: ^[A-Za-z0-9._@-]{3,64}$
        password:
          type: string
          description: 'Readable on purpose: the Xtream protocol puts it in every playlist URL. Generated when omitted on create.'
          examples:
          - k8Jw2pQz
          minLength: 4
          maxLength: 64
        owner_id:
          type: integer
          description: Owning user. Defaults to the caller. Must be in your tree.
          examples:
          - 5
          format: int64
        package_id:
          type: integer
          description: Package to sell. Required for resellers. Admins may omit it and set fields directly.
          examples:
          - 2
          format: int64
        max_connections:
          type: integer
          examples:
          - 1
          format: int32
          minimum: 1
          maximum: 1000
        connection_policy:
          type: string
          description: 'At the limit: drop the oldest connection (same IP first, so zapping works) or refuse the new one.'
          examples:
          - kick_oldest
          enum:
          - kick_oldest
          - reject
        is_restreamer:
          type: boolean
          default: false
        hide_adult:
          type: boolean
          description: Leave adult categories (is_adult) out of this line's lists, playlists and EPG, and refuse to play them.
        enabled:
          type: boolean
          default: true
        bouquet_ids:
          type: array
          items:
            type: integer
            format: int64
          description: Ordered bouquets. Defaults to the package bouquets.
          examples:
          - - 1
            - 4
        allowed_ips:
          type: array
          items:
            type: string
            examples:
            - 203.0.113.0/24
          description: CIDRs allowed to play. Empty means any.
        allowed_user_agents:
          type: array
          items:
            type: string
            examples:
            - TiviMate/4.7.0
          description: Exact user agents allowed. Empty means any.
        allowed_outputs:
          type: array
          items:
            type: string
            examples:
            - ts
            enum:
            - ts
            - m3u8
            - mpd
        forced_country:
          type:
          - string
          - 'null'
          examples:
          - BR
          pattern: ^[A-Z]{2}$
        notes:
          type: string
          description: Admin notes.
          examples:
          - ''
        reseller_notes:
          type: string
          description: Notes visible to the owner chain.
          examples:
          - Paid by pix
        trial:
          type: boolean
          description: Create with the package trial variant (trial_duration, trial_credits).
          default: false
        exp_date:
          type:
          - string
          - 'null'
          description: Admin only, overrides the package duration.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
    LineList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Line'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    LineRenew:
      type: object
      description: Adds periods x official_duration to max(now, exp_date) and charges periods x official_credits. A trial line becomes official.
      properties:
        package_id:
          type: integer
          description: Package to renew with. Defaults to the line package.
          examples:
          - 2
          format: int64
        periods:
          type: integer
          description: How many official periods to add.
          examples:
          - 1
          format: int32
          minimum: 1
          maximum: 24
          default: 1
    LineUpdate:
      type: object
      description: Partial update of a Line. Send only the fields to change.
      properties:
        client_name:
          type: string
          description: Optional name of the person using the line. Used in the WhatsApp greeting and on client cards. Never sent to apps.
          maxLength: 100
          examples:
          - Maria
        client_phone:
          type: string
          description: Optional phone for WhatsApp. Stored as international digits (E.164 without +). On write, a number without a country code
            (up to 11 digits, like 21 99876-5432) gets the panel's phone_country_code; a leading + or 00 means it already has one.
          examples:
          - '5521998765432'
        username:
          type: string
          description: Login used by IPTV apps. Generated when omitted on create. Letters, digits and `._@-`.
          examples:
          - joao2291
          pattern: ^[A-Za-z0-9._@-]{3,64}$
        password:
          type: string
          description: 'Readable on purpose: the Xtream protocol puts it in every playlist URL. Generated when omitted on create.'
          examples:
          - k8Jw2pQz
          minLength: 4
          maxLength: 64
        owner_id:
          type: integer
          description: Owning user. Defaults to the caller. Must be in your tree.
          examples:
          - 5
          format: int64
        package_id:
          type:
          - integer
          - 'null'
          description: Package the line was sold with.
          examples:
          - 2
          format: int64
        exp_date:
          type:
          - string
          - 'null'
          description: Expiry. null means never. Admin only on update; resellers extend with `/renew`.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
        max_connections:
          type: integer
          examples:
          - 1
          format: int32
          minimum: 1
          maximum: 1000
        connection_policy:
          type: string
          description: 'At the limit: drop the oldest connection (same IP first, so zapping works) or refuse the new one.'
          examples:
          - kick_oldest
          enum:
          - kick_oldest
          - reject
        is_trial:
          type: boolean
          examples:
          - false
          readOnly: true
        is_restreamer:
          type: boolean
          default: false
        hide_adult:
          type: boolean
          description: Leave adult categories (is_adult) out of this line's lists, playlists and EPG, and refuse to play them.
        enabled:
          type: boolean
          default: true
        bouquet_ids:
          type: array
          items:
            type: integer
            format: int64
          description: Ordered bouquets. Defaults to the package bouquets.
          examples:
          - - 1
            - 4
        allowed_ips:
          type: array
          items:
            type: string
            examples:
            - 203.0.113.0/24
          description: CIDRs allowed to play. Empty means any.
        allowed_user_agents:
          type: array
          items:
            type: string
            examples:
            - TiviMate/4.7.0
          description: Exact user agents allowed. Empty means any.
        allowed_outputs:
          type: array
          items:
            type: string
            examples:
            - ts
            enum:
            - ts
            - m3u8
            - mpd
        forced_country:
          type:
          - string
          - 'null'
          examples:
          - BR
          pattern: ^[A-Z]{2}$
        notes:
          type: string
          description: Admin notes.
          examples:
          - ''
        reseller_notes:
          type: string
          description: Notes visible to the owner chain.
          examples:
          - Paid by pix
      minProperties: 1
    HealthDiag:
      type: object
      description: The node's health check at the moment it cut a source.
      properties:
        no_media_s:
          type: number
          description: Seconds since new video last arrived.
          examples:
          - 60.2
        limit_s:
          type: number
          description: The limit in effect, 60 s (15 s with fast_detection).
          examples:
          - 60
        silent_s:
          type: number
          description: Seconds since the last byte from the source.
          examples:
          - 60.2
        bytes_10s:
          type: integer
          format: int64
          examples:
          - 0
        bytes_60s:
          type: integer
          format: int64
          examples:
          - 0
      required:
      - no_media_s
      - limit_s
      - silent_s
      - bytes_10s
      - bytes_60s
    LogEntry:
      type: object
      properties:
        at:
          type: string
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
        node_id:
          type: integer
          examples:
          - 1
          format: int64
        level:
          type: string
          examples:
          - debug
          enum:
          - debug
          - info
          - warn
          - error
        message:
          type: string
          description: Credentials in URLs are redacted.
          examples:
          - 'source 1 stalled: no PTS progress for 5s, switching to source 2'
        code:
          description: Set on a line about a health cut (no_data, frozen), with `health`. The panel shows it translated; `message`
            is the English text.
          type: string
          examples:
          - no_data
        health:
          $ref: '#/components/schemas/HealthDiag'
      required:
      - at
      - node_id
      - level
      - message
    LoginAttempt:
      type: object
      properties:
        id:
          type: integer
          format: int64
        at:
          type: string
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
        kind:
          type: string
          examples:
          - panel
          enum:
          - panel
          - line
        username:
          type: string
          examples:
          - admin
        ip:
          type: string
          examples:
          - 203.0.113.9
        country_code:
          type:
          - string
          - 'null'
        success:
          type: boolean
          examples:
          - false
        reason:
          type: string
          examples:
          - bad_password
        user_agent:
          type: string
      required:
      - id
      - at
      - kind
      - username
      - ip
      - success
    LoginAttemptList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/LoginAttempt'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    LoginRequest:
      type: object
      properties:
        username:
          type: string
          examples:
          - admin
          minLength: 1
          maxLength: 64
        password:
          type: string
          examples:
          - correct horse battery staple
          minLength: 1
          maxLength: 1024
          writeOnly: true
        totp_code:
          type: string
          description: 6 digit TOTP code, or a recovery code. Required when the user has 2FA enabled.
          examples:
          - '492817'
      required:
      - username
      - password
    M3uImportRequest:
      type: object
      description: Import a provider M3U playlist into streams, categories and logos.
      properties:
        url:
          type: string
          description: Playlist URL to fetch. Either url or content.
          examples:
          - http://provider.example.net/get.php?username=u&password=p&type=m3u_plus&output=ts
        content:
          type: string
          description: Raw M3U text, for uploads.
        kinds:
          type: array
          items:
            type: string
            examples:
            - live
            enum:
            - live
            - movie
            - series
            - radio
          description: What to import. Kind is guessed from the URL path (/movie/, /series/) and group names.
          examples:
          - - live
        create_categories:
          type: boolean
          description: Create categories from group-title.
          default: true
        category_map:
          type: object
          description: group-title to existing category id.
          properties: {}
          additionalProperties:
            type: integer
            format: int64
        bouquet_ids:
          type: array
          items:
            type: integer
            format: int64
          description: Add imported items to these bouquets.
        account_id:
          type:
          - integer
          - 'null'
          description: Link created sources to this provider account.
          format: int64
        mode:
          type: string
          examples:
          - ffmpeg
          enum:
          - ffmpeg
          - llod
          - direct
        on_demand:
          type: boolean
          default: true
        node_ids:
          type: array
          items:
            type: integer
            format: int64
          description: Assign live streams to these nodes as roots.
        match_existing:
          type: string
          description: When a stream with the same name (trimmed, case-folded) exists in the same category, also for the same
            name twice in the file. With match_tvg_id, also when one that was there before the import has the same
            tvg-id. add_source appends the new URLs after its sources as backups.
          examples:
          - skip
          enum:
          - skip
          - update_sources
          - add_source
        max_sources:
          type: integer
          description: 'Sources to keep per live or radio channel, in file order (0: all, up to 50). A URL line may list
            several URLs separated by commas or pipes; the first is the primary, the next ones are backups.'
          default: 0
          minimum: 0
          maximum: 50
        match_tvg_id:
          type: boolean
          description: Also match an existing live or radio channel by tvg-id (through its EPG channel) when no name matches.
            Off by default because quality variants (FHD, HD, SD) often share one tvg-id. Entries of the same file never
            merge by tvg-id.
          default: false
        probe:
          type: boolean
          description: Probe every source on a node before saving and drop the ones that fail. Slow on big lists. Skipped
            in dry runs and when no node is online.
          default: false
        dry_run:
          type: boolean
          description: 'Only report what would change. The job result then has preview rows (name, kind, group, action,
            sources: scheme and host of each source, in order).'
          default: false
    Me:
      type: object
      properties:
        phone_country_code:
          type: string
          description: Country calling code added to client phones typed without one (settings general.phone_country_code).
          examples:
          - '55'
        id:
          type: integer
          examples:
          - 1
          format: int64
        username:
          type: string
          examples:
          - admin
        email:
          type:
          - string
          - 'null'
          examples:
          - ops@example.com
          format: email
        role:
          type: string
          examples:
          - admin
          enum:
          - admin
          - reseller
        group:
          type: object
          properties:
            id:
              type: integer
              format: int64
            name:
              type: string
              examples:
              - Owner
            builtin:
              type:
              - string
              - 'null'
              description: Built-in role key, `owner` for the Owner. Null for custom roles and reseller groups.
              examples:
              - owner
          required:
          - id
          - name
        permissions:
          type: array
          items:
            type: string
          description: Effective permissions, same strings as API key scopes. The SPA uses this to hide what you cannot do.
          examples:
          - - lines:read
            - lines:write
        credits:
          type: integer
          description: Credit balance. Always 0 for admins, who do not spend credits.
          examples:
          - 250
          format: int64
        totp_enabled:
          type: boolean
          examples:
          - true
        totp_required:
          type: boolean
          description: Two-step sign-in is required (group `require_2fa`, or an admin with `security.require_2fa_admins`) but not turned on. Until it is, every call except `GET /me`, `/auth/logout`, `/auth/refresh`, `/auth/2fa/enroll` and `/auth/2fa/verify` answers `403 2fa_enrollment_required`. The SPA should send the user to the 2FA setup screen.
          examples:
          - false
        locale:
          type: string
          examples:
          - en
          enum:
          - en
          - pt-BR
          - es
        last_login_at:
          type:
          - string
          - 'null'
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
        setup_tour_done:
          type: boolean
          description: Whether the user finished or skipped the guided tour.
          examples:
          - false
        welcome_seen:
          type: boolean
          description: Whether the user saw or skipped the welcome screen shown once after setup.
          examples:
          - false
        share_template:
          type:
          - string
          - 'null'
          description: The user's own WhatsApp/share message for line access. Null when not set. Placeholders `{name}` `{server}` `{url}`
            `{username}` `{password}` `{m3u}` `{expires}`.
          examples:
          - "Hi {name}
User: {username}
Password: {password}
Server: {url}
Valid until {expires}"
        share_template_default:
          type:
          - string
          - 'null'
          description: Panel-wide share message (settings `general.share_template`), used when `share_template` is null. Null means the
            panel's built-in text in the user's language.
      required:
      - id
      - username
      - role
      - group
      - permissions
      - credits
      - totp_enabled
      - locale
    MeUpdate:
      type: object
      properties:
        email:
          type:
          - string
          - 'null'
          format: email
        locale:
          type: string
          examples:
          - en
          enum:
          - en
          - pt-BR
          - es
        setup_tour_done:
          type: boolean
        welcome_seen:
          type: boolean
        share_template:
          type:
          - string
          - 'null'
          maxLength: 2000
          description: Your share message. Null or empty goes back to the panel default.
      minProperties: 1
    Movie:
      type: object
      description: A VOD movie.
      properties:
        tmdb_status:
          type: string
          description: 'TMDB link. pending: waiting for the automatic match. refresh: queued for a refresh. matched: linked. review: the match was not sure, see /tmdb/review. no_match: nothing found. skipped: you chose no match.'
          enum:
          - pending
          - refresh
          - matched
          - review
          - no_match
          - skipped
          readOnly: true
        is_adult:
          type: boolean
          description: Adult even in a non-adult category. Lines that hide adult content do not see it (for series, its episodes too). Default false.
        original_name:
          type: string
          description: Original title (from TMDB).
          maxLength: 255
        collection:
          type: string
          description: TMDB collection (saga), like The Matrix Collection.
          maxLength: 255
        id:
          type: integer
          description: Unique id.
          examples:
          - 42
          format: int64
          readOnly: true
        probe:
          type: object
          description: ffprobe summary (codecs, bitrate, duration, subtitle tracks).
          properties: {}
          additionalProperties: true
          readOnly: true
        created_at:
          type: string
          description: When the record was created.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        updated_at:
          type: string
          description: When the record was last changed.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        name:
          type: string
          examples:
          - The Matrix
          maxLength: 255
        source_kind:
          type: string
          description: 'url: remote file proxied with Range passthrough. local: a file on a storage node.'
          examples:
          - url
          enum:
          - url
          - local
        source_url:
          type: string
          description: URL, or absolute file path on the storage node. Local paths must be inside a media folder (control and node setting media_roots, default /srv, /mnt, /media, /data, /opt/bitstream/media).
          examples:
          - https://vod.example.net/movies/matrix.mkv
        storage_node_id:
          type:
          - integer
          - 'null'
          description: Required when source_kind is local.
          format: int64
        account_id:
          type:
          - integer
          - 'null'
          description: Provider account for connection limits.
          format: int64
        container:
          type: string
          description: File extension clients use in the URL.
          examples:
          - mkv
          pattern: ^[a-z0-9]{2,5}$
        direct_source:
          type: boolean
          description: Redirect clients straight to source_url (url only). No limits or stats. URLs with user:pass@ or a query string, or tied to a provider account, are never redirected and play through a node.
          default: false
        poster_url:
          type: string
          examples:
          - https://image.tmdb.org/t/p/w600/matrix.jpg
        year:
          type:
          - integer
          - 'null'
          examples:
          - 1999
          format: int32
        category_id:
          type:
          - integer
          - 'null'
          examples:
          - 12
          format: int64
        plot:
          type: string
          examples:
          - A hacker learns...
        cast:
          type: string
          examples:
          - Keanu Reeves, Laurence Fishburne
        director:
          type: string
          examples:
          - Lana Wachowski, Lilly Wachowski
        genre:
          type: string
          examples:
          - Action, Science Fiction
        release_date:
          type:
          - string
          - 'null'
          examples:
          - '1999-03-31'
          format: date
        rating:
          type:
          - number
          - 'null'
          description: 0 to 10.
          examples:
          - 8.7
        tmdb_id:
          type:
          - integer
          - 'null'
          examples:
          - 603
          format: int32
        youtube_trailer:
          type: string
          description: YouTube video id.
          examples:
          - vKQi3bBA1y8
        backdrop_urls:
          type: array
          items:
            type: string
        enabled:
          type: boolean
          default: true
        position:
          type: integer
          examples:
          - 0
          format: int32
        country:
          type: string
          examples:
          - US
        duration_s:
          type:
          - integer
          - 'null'
          examples:
          - 8160
          format: int32
      required:
      - id
      - probe
      - created_at
      - updated_at
      - name
      - source_url
    MovieBulkRequest:
      type: object
      properties:
        ids:
          type: array
          items:
            type: integer
            format: int64
          description: Ids to act on. Up to 1000.
          minItems: 1
          maxItems: 1000
          examples:
          - - 12
            - 13
            - 14
        action:
          type: string
          description: 'What to do. `enable`: Enable. `disable`: Disable. `delete`: Delete. `set_category`: `params.category_id`. `add_to_bouquets`:
            `params.bouquet_ids`. `remove_from_bouquets`: `params.bouquet_ids`. `probe`: Re-run ffprobe.'
          examples:
          - enable
          enum:
          - enable
          - disable
          - delete
          - set_category
          - add_to_bouquets
          - remove_from_bouquets
          - probe
          - update
        params:
          type: object
          description: Extra arguments for the action, documented with each action.
          properties: {}
          additionalProperties: true
      required:
      - ids
      - action
    MovieCreate:
      type: object
      description: Fields accepted when creating a Movie. Omitted optional fields take the defaults shown.
      properties:
        is_adult:
          type: boolean
          description: Adult even in a non-adult category. Lines that hide adult content do not see it (for series, its episodes too). Default false.
        original_name:
          type: string
          description: Original title (from TMDB).
          maxLength: 255
        collection:
          type: string
          description: TMDB collection (saga), like The Matrix Collection.
          maxLength: 255
        name:
          type: string
          examples:
          - The Matrix
          maxLength: 255
        source_kind:
          type: string
          description: 'url: remote file proxied with Range passthrough. local: a file on a storage node.'
          examples:
          - url
          enum:
          - url
          - local
        source_url:
          type: string
          description: URL, or absolute file path on the storage node. Local paths must be inside a media folder (control and node setting media_roots, default /srv, /mnt, /media, /data, /opt/bitstream/media).
          examples:
          - https://vod.example.net/movies/matrix.mkv
        storage_node_id:
          type:
          - integer
          - 'null'
          description: Required when source_kind is local.
          format: int64
        account_id:
          type:
          - integer
          - 'null'
          description: Provider account for connection limits.
          format: int64
        container:
          type: string
          description: File extension clients use in the URL.
          examples:
          - mkv
          pattern: ^[a-z0-9]{2,5}$
        direct_source:
          type: boolean
          description: Redirect clients straight to source_url (url only). No limits or stats. URLs with user:pass@ or a query string, or tied to a provider account, are never redirected and play through a node.
          default: false
        poster_url:
          type: string
          examples:
          - https://image.tmdb.org/t/p/w600/matrix.jpg
        year:
          type:
          - integer
          - 'null'
          examples:
          - 1999
          format: int32
        category_id:
          type:
          - integer
          - 'null'
          examples:
          - 12
          format: int64
        plot:
          type: string
          examples:
          - A hacker learns...
        cast:
          type: string
          examples:
          - Keanu Reeves, Laurence Fishburne
        director:
          type: string
          examples:
          - Lana Wachowski, Lilly Wachowski
        genre:
          type: string
          examples:
          - Action, Science Fiction
        release_date:
          type:
          - string
          - 'null'
          examples:
          - '1999-03-31'
          format: date
        rating:
          type:
          - number
          - 'null'
          description: 0 to 10.
          examples:
          - 8.7
        tmdb_id:
          type:
          - integer
          - 'null'
          examples:
          - 603
          format: int32
        youtube_trailer:
          type: string
          description: YouTube video id.
          examples:
          - vKQi3bBA1y8
        backdrop_urls:
          type: array
          items:
            type: string
        enabled:
          type: boolean
          default: true
        position:
          type: integer
          examples:
          - 0
          format: int32
        country:
          type: string
          examples:
          - US
        duration_s:
          type:
          - integer
          - 'null'
          examples:
          - 8160
          format: int32
      required:
      - name
      - source_url
    MovieList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Movie'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    MovieUpdate:
      type: object
      description: Partial update of a Movie. Send only the fields to change.
      properties:
        is_adult:
          type: boolean
          description: Adult even in a non-adult category. Lines that hide adult content do not see it (for series, its episodes too). Default false.
        original_name:
          type: string
          description: Original title (from TMDB).
          maxLength: 255
        collection:
          type: string
          description: TMDB collection (saga), like The Matrix Collection.
          maxLength: 255
        name:
          type: string
          examples:
          - The Matrix
          maxLength: 255
        source_kind:
          type: string
          description: 'url: remote file proxied with Range passthrough. local: a file on a storage node.'
          examples:
          - url
          enum:
          - url
          - local
        source_url:
          type: string
          description: URL, or absolute file path on the storage node. Local paths must be inside a media folder (control and node setting media_roots, default /srv, /mnt, /media, /data, /opt/bitstream/media).
          examples:
          - https://vod.example.net/movies/matrix.mkv
        storage_node_id:
          type:
          - integer
          - 'null'
          description: Required when source_kind is local.
          format: int64
        account_id:
          type:
          - integer
          - 'null'
          description: Provider account for connection limits.
          format: int64
        container:
          type: string
          description: File extension clients use in the URL.
          examples:
          - mkv
          pattern: ^[a-z0-9]{2,5}$
        direct_source:
          type: boolean
          description: Redirect clients straight to source_url (url only). No limits or stats. URLs with user:pass@ or a query string, or tied to a provider account, are never redirected and play through a node.
          default: false
        poster_url:
          type: string
          examples:
          - https://image.tmdb.org/t/p/w600/matrix.jpg
        year:
          type:
          - integer
          - 'null'
          examples:
          - 1999
          format: int32
        category_id:
          type:
          - integer
          - 'null'
          examples:
          - 12
          format: int64
        plot:
          type: string
          examples:
          - A hacker learns...
        cast:
          type: string
          examples:
          - Keanu Reeves, Laurence Fishburne
        director:
          type: string
          examples:
          - Lana Wachowski, Lilly Wachowski
        genre:
          type: string
          examples:
          - Action, Science Fiction
        release_date:
          type:
          - string
          - 'null'
          examples:
          - '1999-03-31'
          format: date
        rating:
          type:
          - number
          - 'null'
          description: 0 to 10.
          examples:
          - 8.7
        tmdb_id:
          type:
          - integer
          - 'null'
          examples:
          - 603
          format: int32
        youtube_trailer:
          type: string
          description: YouTube video id.
          examples:
          - vKQi3bBA1y8
        backdrop_urls:
          type: array
          items:
            type: string
        enabled:
          type: boolean
          default: true
        position:
          type: integer
          examples:
          - 0
          format: int32
        country:
          type: string
          examples:
          - US
        duration_s:
          type:
          - integer
          - 'null'
          examples:
          - 8160
          format: int32
      minProperties: 1
    Node:
      type: object
      description: A streaming node (bs-node). Nodes are added by enrollment with a join token, not by POST.
      properties:
        id:
          type: integer
          description: Unique id.
          examples:
          - 42
          format: int64
          readOnly: true
        status:
          type: string
          description: online/offline come from heartbeats. Set maintenance or disabled with PATCH (field admin_status).
          examples:
          - pending
          enum:
          - pending
          - online
          - offline
          - maintenance
          - disabled
          readOnly: true
        cert_fingerprint:
          type:
          - string
          - 'null'
          description: SHA-256 of the node mTLS certificate, hex.
          examples:
          - a3f1...
          readOnly: true
        agent_version:
          type: string
          examples:
          - 1.0.0
          readOnly: true
        proto:
          type: integer
          examples:
          - 1
          format: int32
          readOnly: true
        hostname:
          type: string
          examples:
          - edge-sp-1
          readOnly: true
        cpu_cores:
          type:
          - integer
          - 'null'
          examples:
          - 8
          format: int32
          readOnly: true
        mem_bytes:
          type:
          - integer
          - 'null'
          examples:
          - 17179869184
          format: int64
          readOnly: true
        ffmpeg_versions:
          type: array
          items:
            type: string
          description: Builds found on the node.
          examples:
          - - 4.4.4
            - '7.1'
          readOnly: true
        last_seen_at:
          type:
          - string
          - 'null'
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        live:
          description: Latest stats. Null until the node sends its first report (a few seconds after it joins) and while it is offline.
          readOnly: true
          anyOf:
          - $ref: '#/components/schemas/NodeLiveStats'
          - type: 'null'
        created_at:
          type: string
          description: When the record was created.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        updated_at:
          type: string
          description: When the record was last changed.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        name:
          type: string
          examples:
          - edge-sp-1
          maxLength: 64
        public_host:
          type: string
          description: Public domain of the node for client redirects. Use a DNS only record (no Cloudflare proxy).
          examples:
          - edge1.example.com
        http_port:
          type: integer
          description: Port viewers are redirected to. The node reports it at enrollment and on every stats heartbeat (its listen port, or public_port behind NAT or a proxy), so a value set here is replaced by the node's report.
          examples:
          - 8090
          format: int32
        https_port:
          type: integer
          examples:
          - 8091
          format: int32
        internal_url:
          type: string
          description: URL other nodes use for relay, if different.
          examples:
          - https://10.0.0.11:8091
        delivery_mode:
          type: string
          description: 'redirect: 302 to the node (default). proxy: the control streams through itself; for a node on the same machine or networks
            that mishandle redirects.'
          examples:
          - redirect
          enum:
          - redirect
          - proxy
        admin_status:
          type: string
          description: 'maintenance: no new viewers, current ones stay. disabled: everything stops.'
          examples:
          - active
          enum:
          - active
          - maintenance
          - disabled
        weight:
          type: integer
          description: Load balancing weight.
          examples:
          - 100
          format: int32
          minimum: 0
          maximum: 1000
        max_clients:
          type: integer
          description: 0 is unlimited.
          examples:
          - 0
          format: int32
          minimum: 0
        ffmpeg_version:
          type: string
          description: Selected ffmpeg build, one of ffmpeg_versions. Empty picks the newest.
          examples:
          - '7.1'
        is_storage:
          type: boolean
          description: Holds local VOD files.
          default: false
        allow_internal_sources:
          type: boolean
          description: Allow sources on private networks and UDP.
          default: false
        enabled:
          type: boolean
          description: Off stops the node like admin_status disabled. On makes it active again.
        domains:
          type: array
          items:
            type: string
          description: Ordered public domains. The first one is public_host. An entry starting with `wildcard.` becomes `<line id>.` in redirects
            (one subdomain per line; needs a `*.` DNS record and certificate). IP addresses go in public_ipv4 / public_ipv6.
          examples:
          - - edge1.example.com
            - wildcard.tv.example.com
          maxItems: 20
        random_domain:
          type: boolean
          description: Redirect each viewer to a random domain of the list instead of the first one. The request host still wins when it is one of the
            domains.
        domain_proxied:
          type: boolean
          description: Create the Cloudflare records with the orange cloud. Most Cloudflare plans do not allow video through the proxy and it only
            forwards a few ports, so the default is DNS only.
        public_ipv4:
          type:
          - string
          - 'null'
          description: Public IPv4 for DNS records and IP redirects. Filled from the address the node joins from and what it reports.
          examples:
          - 203.0.113.7
        public_ipv6:
          type:
          - string
          - 'null'
          examples:
          - 2001:db8::7
        extra_http_ports:
          type: array
          items:
            type: integer
            format: int32
          description: More ports the node also serves plain HTTP on. Open them in the node firewall.
          maxItems: 10
        extra_https_ports:
          type: array
          items:
            type: integer
            format: int32
          maxItems: 10
        network_interface:
          type: string
          description: Interface whose traffic counts for bandwidth routing. Empty means all of them.
          examples:
          - eth0
        guaranteed_mbps:
          type: integer
          description: Bandwidth the provider guarantees, in Mbit/s, for balance_by guaranteed_bandwidth. 0 uses the link speed.
          format: int32
          minimum: 0
        geo_countries:
          type: array
          items:
            type: string
          description: ISO country codes for geo routing. Empty turns geo routing off for this node.
          examples:
          - - BR
            - PT
        geo_mode:
          type: string
          description: 'preferred: viewers from these countries come here first, others can still use it. fallback: others only when no other
            node has room. strict: only viewers from these countries.'
          enum:
          - preferred
          - fallback
          - strict
        isp_names:
          type: array
          items:
            type: string
          description: ISP names (matched when the viewer ISP name contains the text) or AS numbers like AS28573. Empty turns ISP routing off.
          examples:
          - - Claro
            - AS18881
        isp_mode:
          type: string
          description: Same meaning as geo_mode, for isp_names.
          enum:
          - preferred
          - fallback
          - strict
        whitelist:
          type: array
          items:
            type: string
          description: IPs or CIDRs allowed to open relays (/relay/) on the node and to read its /metrics. Empty leaves relays open (they are token
            protected). The public IPs of the other nodes are always allowed.
          examples:
          - - 10.0.0.0/8
        media_roots:
          type: array
          items:
            type: string
          description: Folders movie files may live in on this storage node. Empty uses the control media_roots. The node's own media_roots setting
            still limits what it reads.
          examples:
          - - /srv/media
        archive_path:
          type: string
          maxLength: 512
          description: Folder for TV archive recordings on this node (absolute path). Empty uses the node's archive_dir setting.
          examples:
          - /srv/archive
        archive_quota_gb:
          type: integer
          minimum: 0
          maximum: 1000000
          description: Most space the archive may use, in GB. 0 means no quota (the node still keeps 1 GiB of the disk free). Oldest
            hours are deleted first.
          format: int32
        role:
          type: string
          description: 'node runs streams and serves viewers. proxy is an edge with no ffmpeg (XC_VM proxy server): it fronts the nodes in
            proxy_backends, relays their live channels once and fans them out, and forwards movies, series and catch-up to them.'
          enum:
          - node
          - proxy
          default: node
        proxy_backends:
          type: array
          description: Proxy only. Ids of the nodes this proxy fronts (XC_VM parent_id).
          items:
            type: integer
            format: int64
          maxItems: 200
        require_proxy:
          type: boolean
          description: Viewers reach this node only through one of its proxies (XC_VM enable_proxy). Direct requests get the node's plain 404 Not Found, the same as an unknown path.
            Live, VOD, catch-up and DASH all go through the proxy. Restreamer lines skip it only when the streaming setting restreamer_bypass_proxy is on (off by default).
          default: false
        proxies:
          type: array
          readOnly: true
          description: Proxy nodes that front this node.
          items:
            type: integer
            format: int64
        notes:
          type: string
          maxLength: 4000
          examples:
          - Rack 4, provider ticket 1234
        inventory:
          description: Machine inventory the node last reported (about once a minute). Null for nodes older than this field.
          readOnly: true
          anyOf:
          - $ref: '#/components/schemas/NodeInventory'
          - type: 'null'
      required:
      - id
      - status
      - cert_fingerprint
      - agent_version
      - proto
      - hostname
      - cpu_cores
      - mem_bytes
      - ffmpeg_versions
      - last_seen_at
      - live
      - created_at
      - updated_at
    NodeInventory:
      type: object
      description: What the node reports about its machine.
      properties:
        cpu_model:
          type: string
          examples:
          - AMD EPYC 7543 32-Core Processor
        cores:
          type: integer
          format: int32
        kernel:
          type: string
          examples:
          - 6.8.0-45-generic
        distro:
          type: string
          examples:
          - Ubuntu 24.04.1 LTS
        mem_total:
          type: integer
          format: int64
        disks:
          type: array
          items:
            type: object
            properties:
              mount:
                type: string
              fs:
                type: string
              total:
                type: integer
                format: int64
              used:
                type: integer
                format: int64
            required:
            - mount
            - total
            - used
        interfaces:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              speed_mbps:
                type: integer
                format: int32
              addrs:
                type: array
                items:
                  type: string
              up:
                type: boolean
            required:
            - name
            - up
        public_ips:
          type: array
          items:
            type: string
        nofile_soft:
          type: integer
          format: int64
          description: Open files limit of bs-node (soft).
        nofile_hard:
          type: integer
          format: int64
        governor:
          type: string
          description: CPU frequency governor, empty when the machine has none (most VMs).
        governors:
          type: array
          items:
            type: string
        ffmpeg:
          type: array
          items:
            type: object
            properties:
              label:
                type: string
              version:
                type: string
              path:
                type: string
            required:
            - label
            - version
        tuning:
          $ref: '#/components/schemas/NodeTuningReport'
    NodeTuningReport:
      type: object
      properties:
        current:
          type: object
          additionalProperties:
            type: string
        recommended:
          type: object
          additionalProperties:
            type: string
        available:
          type: boolean
          description: The root helper (bs-node-tune) is installed.
        last_result:
          anyOf:
          - $ref: '#/components/schemas/NodeTuneResult'
          - type: 'null'
      required:
      - current
      - recommended
      - available
    NodeTuneResult:
      type: object
      description: Outcome of the last apply by the root helper.
      properties:
        id:
          type: string
        at:
          type: string
          format: date-time
        ok:
          type: boolean
        applied:
          type: object
          additionalProperties:
            type: string
        errors:
          type: object
          additionalProperties:
            type: string
      required:
      - at
      - ok
    NodeSystemTuning:
      type: object
      properties:
        online:
          type: boolean
        reported:
          type: boolean
          description: False until the node sends its first inventory (older bs-node, or just joined).
        available:
          type: boolean
          description: The root helper is installed, so Apply recommended can work.
        rows:
          type: array
          items:
            type: object
            properties:
              key:
                type: string
                examples:
                - net.core.somaxconn
              current:
                type:
                - string
                - 'null'
              recommended:
                type:
                - string
                - 'null'
              differs:
                type: boolean
            required:
            - key
            - current
            - recommended
            - differs
        last_result:
          anyOf:
          - $ref: '#/components/schemas/NodeTuneResult'
          - type: 'null'
        nofile_soft:
          type:
          - integer
          - 'null'
          format: int64
        nofile_hard:
          type:
          - integer
          - 'null'
          format: int64
      required:
      - online
      - reported
      - available
      - rows
      - last_result
    NodeDomainStatus:
      type: object
      properties:
        domain:
          type: string
        wildcard:
          type: boolean
        expected:
          type: array
          description: The DNS records this domain needs (create them by hand when Cloudflare is not set up).
          items:
            type: object
            properties:
              type:
                type: string
                enum:
                - A
                - AAAA
              name:
                type: string
              content:
                type: string
            required:
            - type
            - name
            - content
        resolved:
          type: array
          items:
            type: string
        dns:
          type: string
          description: 'ok: points at the node. missing: no record yet. wrong: points elsewhere. proxied: behind Cloudflare. unknown: the node
            public IP is not known yet.'
          enum:
          - ok
          - missing
          - wrong
          - proxied
          - unknown
        certificate:
          anyOf:
          - $ref: '#/components/schemas/Certificate'
          - type: 'null'
      required:
      - domain
      - wildcard
      - expected
      - resolved
      - dns
      - certificate
    NodeDomains:
      type: object
      properties:
        domains:
          type: array
          items:
            $ref: '#/components/schemas/NodeDomainStatus'
        proxied:
          type: boolean
        https_port:
          type: integer
          format: int32
        cert_pushed:
          type: boolean
          description: The node is new enough to receive certificates from the control.
        cloudflare:
          type: object
          properties:
            token_set:
              type: boolean
            zone_set:
              type: boolean
            zone_name:
              type: string
            auto_sync:
              type: boolean
            last_sync_at:
              type:
              - string
              - 'null'
              format: date-time
            last_sync_error:
              type: string
          required:
          - token_set
          - zone_set
          - zone_name
          - auto_sync
      required:
      - domains
      - proxied
      - https_port
      - cert_pushed
      - cloudflare
    NodeList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Node'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    ServiceHealth:
      type: object
      required:
      - generated_at
      - state
      - checks
      properties:
        generated_at:
          type: string
          format: date-time
        state:
          type: string
          enum:
          - ok
          - attention
          - problem
        checks:
          type: array
          items:
            $ref: '#/components/schemas/HealthCheck'
    HealthCheck:
      type: object
      required:
      - id
      - group
      - severity
      - pass
      - reason
      - fix_link
      properties:
        id:
          type: string
          description: Stable check id.
          enum:
          - admin_2fa
          - https
          - api_keys_scoped
          - license
          - backups
          - db_tls
          - redis_auth
          - nodes_on_control
          - shared_host
          - panel_edges
          - clock_sync
          - disk_free
          - node_tuning
          - ffmpeg
          - nodes_offline
        group:
          type: string
          enum:
          - security
          - data
          - infra
        severity:
          type: string
          description: How much a failure matters.
          enum:
          - critical
          - warning
          - info
        pass:
          type: boolean
        reason:
          type: string
          description: Translation key under `health.reason` (for example `backups.stale`).
          examples:
          - backups.stale
        params:
          type: object
          additionalProperties:
            type: string
          description: Values for the reason text (names, count, hours).
        fix_link:
          type:
          - string
          - 'null'
          description: A panel path (`/backups`) or a docs page prefixed with `docs:` (`docs:/guides/backups`).
    MachinePoint:
      type: object
      description: One sample. Zero values are omitted. Network in Mb/s, disk I/O in MB/s, cpu, mem and disk in percent.
      required:
      - t
      properties:
        t:
          type: string
          format: date-time
        conns:
          type: integer
          format: int32
        users:
          type: integer
          format: int32
          description: Distinct lines.
        up:
          type: integer
          format: int32
          description: Live streams running.
        down:
          type: integer
          format: int32
          description: Live streams down.
        rps:
          type: number
        rx:
          type: number
        tx:
          type: number
        cpu:
          type: number
        mem:
          type: number
        dr:
          type: number
        dw:
          type: number
        disk:
          type: number
    Machine:
      type: object
      required:
      - kind
      - id
      - name
      - online
      - status
      - uptime_s
      - link
      - metrics
      - now
      - points
      properties:
        kind:
          type: string
          enum:
          - control
          - node
          - proxy
          - edge
        id:
          type: string
          description: Node or edge id, or the control replica id.
        name:
          type: string
        online:
          type: boolean
        status:
          type: string
          examples:
          - online
        uptime_s:
          type:
          - integer
          - 'null'
          format: int64
        link:
          type:
          - string
          - 'null'
          description: Panel page of the machine.
        metrics:
          type: array
          items:
            type: string
            enum:
            - conns
            - users
            - up
            - down
            - rps
            - rx
            - tx
            - cpu
            - mem
            - dr
            - dw
            - disk
        now:
          oneOf:
          - $ref: '#/components/schemas/MachinePoint'
          - type: 'null'
        points:
          type: array
          description: One point per minute, oldest first, up to 60.
          items:
            $ref: '#/components/schemas/MachinePoint'
        roles:
          type: array
          description: Set on a node tile that also stands for the control replica on the same machine (same machine id). Example ["control", "node"].
          items:
            type: string
            enum:
            - control
            - node
            - proxy
    MachineList:
      type: object
      required:
      - generated_at
      - machines
      properties:
        generated_at:
          type: string
          format: date-time
        machines:
          type: array
          items:
            $ref: '#/components/schemas/Machine'
    ClusterStats:
      type: object
      required:
      - range
      - step_s
      - points
      properties:
        range:
          type: string
          enum:
          - 1h
          - 24h
          - 7d
        step_s:
          type: integer
          format: int32
        points:
          type: array
          items:
            type: object
            required:
            - t
            - cpu
            - mem
            properties:
              t:
                type: string
                format: date-time
              cpu:
                type: number
              mem:
                type: number
    NodeLiveStats:
      type: object
      description: Last 5 second sample from Redis. Absent when the node is offline.
      properties:
        cpu_pct:
          type: number
          examples:
          - 37.5
        mem_pct:
          type: number
          examples:
          - 41.2
        load1:
          type: number
          examples:
          - 2.1
        disk_pct:
          type: number
          examples:
          - 22
        rx_mbps:
          type: number
          examples:
          - 380.2
        tx_mbps:
          type: number
          examples:
          - 2210.7
        clients:
          type: integer
          examples:
          - 742
          format: int32
        streams_running:
          type: integer
          examples:
          - 188
          format: int32
        streams_error:
          type: integer
          examples:
          - 2
          format: int32
        uptime_s:
          type: integer
          examples:
          - 1209600
          format: int64
        users:
          type: integer
          format: int32
          description: Distinct lines watching, from the last session heartbeat.
        disk_read_mbs:
          type: number
          description: Disk read MB/s. 0 from nodes that do not report it.
        disk_write_mbs:
          type: number
          description: Disk write MB/s. 0 from nodes that do not report it.
        interfaces:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
                examples:
                - eth0
              rx_mbps:
                type: number
              tx_mbps:
                type: number
              speed_mbps:
                type:
                - integer
                - 'null'
                examples:
                - 10000
                format: int32
        archive:
          description: TV archive disk use on this node. Absent when the node records nothing.
          type: object
          properties:
            used_bytes:
              type: integer
              format: int64
            quota_bytes:
              type: integer
              format: int64
              description: 0 means no quota.
            free_bytes:
              type: integer
              format: int64
              description: Free space on the archive disk.
            total_bytes:
              type: integer
              format: int64
          required:
          - used_bytes
          - quota_bytes
          - free_bytes
          - total_bytes
        updated_at:
          type: string
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
    NodeTarget:
      type: object
      properties:
        node_ids:
          type: array
          items:
            type: integer
            format: int64
          description: Nodes to act on. Empty or omitted means every node in the tree.
    NodeUpdate:
      type: object
      description: Partial update of a Node. Send only the fields to change.
      properties:
        name:
          type: string
          examples:
          - edge-sp-1
          maxLength: 64
        public_host:
          type: string
          description: Public domain of the node for client redirects. Use a DNS only record (no Cloudflare proxy).
          examples:
          - edge1.example.com
        http_port:
          type: integer
          description: Port viewers are redirected to. The node reports it at enrollment and on every stats heartbeat (its listen port, or public_port behind NAT or a proxy), so a value set here is replaced by the node's report.
          examples:
          - 8090
          format: int32
        https_port:
          type: integer
          examples:
          - 8091
          format: int32
        internal_url:
          type: string
          description: URL other nodes use for relay, if different.
          examples:
          - https://10.0.0.11:8091
        delivery_mode:
          type: string
          description: 'redirect: 302 to the node (default). proxy: the control streams through itself; for a node on the same machine or networks
            that mishandle redirects.'
          examples:
          - redirect
          enum:
          - redirect
          - proxy
        admin_status:
          type: string
          description: 'maintenance: no new viewers, current ones stay. disabled: everything stops.'
          examples:
          - active
          enum:
          - active
          - maintenance
          - disabled
        weight:
          type: integer
          description: Load balancing weight.
          examples:
          - 100
          format: int32
          minimum: 0
          maximum: 1000
        max_clients:
          type: integer
          description: 0 is unlimited.
          examples:
          - 0
          format: int32
          minimum: 0
        ffmpeg_version:
          type: string
          description: Selected ffmpeg build, one of ffmpeg_versions. Empty picks the newest.
          examples:
          - '7.1'
        is_storage:
          type: boolean
          description: Holds local VOD files.
          default: false
        allow_internal_sources:
          type: boolean
          description: Allow sources on private networks and UDP.
          default: false
        enabled:
          type: boolean
          description: Off stops the node like admin_status disabled. On makes it active again.
        domains:
          type: array
          items:
            type: string
          description: Ordered public domains. The first one is public_host. An entry starting with `wildcard.` becomes `<line id>.` in redirects
            (one subdomain per line; needs a `*.` DNS record and certificate). IP addresses go in public_ipv4 / public_ipv6.
          examples:
          - - edge1.example.com
            - wildcard.tv.example.com
          maxItems: 20
        random_domain:
          type: boolean
          description: Redirect each viewer to a random domain of the list instead of the first one. The request host still wins when it is one of the
            domains.
        domain_proxied:
          type: boolean
          description: Create the Cloudflare records with the orange cloud. Most Cloudflare plans do not allow video through the proxy and it only
            forwards a few ports, so the default is DNS only.
        public_ipv4:
          type:
          - string
          - 'null'
          description: Public IPv4 for DNS records and IP redirects. Filled from the address the node joins from and what it reports.
          examples:
          - 203.0.113.7
        public_ipv6:
          type:
          - string
          - 'null'
          examples:
          - 2001:db8::7
        extra_http_ports:
          type: array
          items:
            type: integer
            format: int32
          description: More ports the node also serves plain HTTP on. Open them in the node firewall.
          maxItems: 10
        extra_https_ports:
          type: array
          items:
            type: integer
            format: int32
          maxItems: 10
        network_interface:
          type: string
          description: Interface whose traffic counts for bandwidth routing. Empty means all of them.
          examples:
          - eth0
        guaranteed_mbps:
          type: integer
          description: Bandwidth the provider guarantees, in Mbit/s, for balance_by guaranteed_bandwidth. 0 uses the link speed.
          format: int32
          minimum: 0
        geo_countries:
          type: array
          items:
            type: string
          description: ISO country codes for geo routing. Empty turns geo routing off for this node.
          examples:
          - - BR
            - PT
        geo_mode:
          type: string
          description: 'preferred: viewers from these countries come here first, others can still use it. fallback: others only when no other
            node has room. strict: only viewers from these countries.'
          enum:
          - preferred
          - fallback
          - strict
        isp_names:
          type: array
          items:
            type: string
          description: ISP names (matched when the viewer ISP name contains the text) or AS numbers like AS28573. Empty turns ISP routing off.
          examples:
          - - Claro
            - AS18881
        isp_mode:
          type: string
          description: Same meaning as geo_mode, for isp_names.
          enum:
          - preferred
          - fallback
          - strict
        whitelist:
          type: array
          items:
            type: string
          description: IPs or CIDRs allowed to open relays (/relay/) on the node and to read its /metrics. Empty leaves relays open (they are token
            protected). The public IPs of the other nodes are always allowed.
          examples:
          - - 10.0.0.0/8
        media_roots:
          type: array
          items:
            type: string
          description: Folders movie files may live in on this storage node. Empty uses the control media_roots. The node's own media_roots setting
            still limits what it reads.
          examples:
          - - /srv/media
        archive_path:
          type: string
          maxLength: 512
          description: Folder for TV archive recordings on this node (absolute path). Empty uses the node's archive_dir setting.
          examples:
          - /srv/archive
        archive_quota_gb:
          type: integer
          minimum: 0
          maximum: 1000000
          description: Most space the archive may use, in GB. 0 means no quota (the node still keeps 1 GiB of the disk free). Oldest
            hours are deleted first.
          format: int32
        role:
          type: string
          description: 'node runs streams and serves viewers. proxy is an edge with no ffmpeg (XC_VM proxy server): it fronts the nodes in
            proxy_backends, relays their live channels once and fans them out, and forwards movies, series and catch-up to them.'
          enum:
          - node
          - proxy
          default: node
        proxy_backends:
          type: array
          description: Proxy only. Ids of the nodes this proxy fronts (XC_VM parent_id).
          items:
            type: integer
            format: int64
          maxItems: 200
        require_proxy:
          type: boolean
          description: Viewers reach this node only through one of its proxies (XC_VM enable_proxy). Direct requests get the node's plain 404 Not Found, the same as an unknown path.
            Live, VOD, catch-up and DASH all go through the proxy. Restreamer lines skip it only when the streaming setting restreamer_bypass_proxy is on (off by default).
          default: false
        notes:
          type: string
          maxLength: 4000
          examples:
          - Rack 4, provider ticket 1234
      minProperties: 1
    Package:
      type: object
      description: 'Template a reseller sells: trial and official variants, each with duration and credit cost.'
      properties:
        id:
          type: integer
          description: Unique id.
          examples:
          - 42
          format: int64
          readOnly: true
        line_count:
          type: integer
          examples:
          - 310
          format: int64
          readOnly: true
        created_at:
          type: string
          description: When the record was created.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        updated_at:
          type: string
          description: When the record was last changed.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        name:
          type: string
          examples:
          - Full HD 1 screen
          maxLength: 128
        allow_trial:
          type: boolean
          default: false
        allow_official:
          type: boolean
          default: true
        trial_duration:
          type: string
          description: ISO 8601 duration.
          examples:
          - P1D
        trial_credits:
          type: integer
          examples:
          - 0
          format: int64
        official_duration:
          type: string
          description: ISO 8601 duration added on create and on each renewal.
          examples:
          - P1M
        official_credits:
          type: integer
          description: Credits charged per official create or renewal.
          examples:
          - 1
          format: int64
        max_connections:
          type: integer
          examples:
          - 1
          format: int32
          minimum: 1
          maximum: 1000
        allowed_outputs:
          type: array
          items:
            type: string
            examples:
            - ts
            enum:
            - ts
            - m3u8
            - mpd
          examples:
          - - ts
            - m3u8
        is_restreamer:
          type: boolean
          default: false
        forced_country:
          type:
          - string
          - 'null'
          description: ISO country code clients must connect from.
          examples:
          - BR
          pattern: ^[A-Z]{2}$
        bouquet_ids:
          type: array
          items:
            type: integer
            format: int64
          description: Ordered bouquets given to lines.
          examples:
          - - 1
            - 4
            - 7
        group_ids:
          type: array
          items:
            type: integer
            format: int64
          description: Reseller groups allowed to sell this package.
          examples:
          - - 3
      required:
      - id
      - line_count
      - created_at
      - updated_at
      - name
      - bouquet_ids
    PackageCreate:
      type: object
      description: Fields accepted when creating a Package. Omitted optional fields take the defaults shown.
      properties:
        name:
          type: string
          examples:
          - Full HD 1 screen
          maxLength: 128
        allow_trial:
          type: boolean
          default: false
        allow_official:
          type: boolean
          default: true
        trial_duration:
          type: string
          description: ISO 8601 duration.
          examples:
          - P1D
        trial_credits:
          type: integer
          examples:
          - 0
          format: int64
        official_duration:
          type: string
          description: ISO 8601 duration added on create and on each renewal.
          examples:
          - P1M
        official_credits:
          type: integer
          description: Credits charged per official create or renewal.
          examples:
          - 1
          format: int64
        max_connections:
          type: integer
          examples:
          - 1
          format: int32
          minimum: 1
          maximum: 1000
        allowed_outputs:
          type: array
          items:
            type: string
            examples:
            - ts
            enum:
            - ts
            - m3u8
            - mpd
          examples:
          - - ts
            - m3u8
        is_restreamer:
          type: boolean
          default: false
        forced_country:
          type:
          - string
          - 'null'
          description: ISO country code clients must connect from.
          examples:
          - BR
          pattern: ^[A-Z]{2}$
        bouquet_ids:
          type: array
          items:
            type: integer
            format: int64
          description: Ordered bouquets given to lines.
          examples:
          - - 1
            - 4
            - 7
        group_ids:
          type: array
          items:
            type: integer
            format: int64
          description: Reseller groups allowed to sell this package.
          examples:
          - - 3
      required:
      - name
      - bouquet_ids
    PackageList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Package'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    PackageUpdate:
      type: object
      description: Partial update of a Package. Send only the fields to change.
      properties:
        name:
          type: string
          examples:
          - Full HD 1 screen
          maxLength: 128
        allow_trial:
          type: boolean
          default: false
        allow_official:
          type: boolean
          default: true
        trial_duration:
          type: string
          description: ISO 8601 duration.
          examples:
          - P1D
        trial_credits:
          type: integer
          examples:
          - 0
          format: int64
        official_duration:
          type: string
          description: ISO 8601 duration added on create and on each renewal.
          examples:
          - P1M
        official_credits:
          type: integer
          description: Credits charged per official create or renewal.
          examples:
          - 1
          format: int64
        max_connections:
          type: integer
          examples:
          - 1
          format: int32
          minimum: 1
          maximum: 1000
        allowed_outputs:
          type: array
          items:
            type: string
            examples:
            - ts
            enum:
            - ts
            - m3u8
            - mpd
          examples:
          - - ts
            - m3u8
        is_restreamer:
          type: boolean
          default: false
        forced_country:
          type:
          - string
          - 'null'
          description: ISO country code clients must connect from.
          examples:
          - BR
          pattern: ^[A-Z]{2}$
        bouquet_ids:
          type: array
          items:
            type: integer
            format: int64
          description: Ordered bouquets given to lines.
          examples:
          - - 1
            - 4
            - 7
        group_ids:
          type: array
          items:
            type: integer
            format: int64
          description: Reseller groups allowed to sell this package.
          examples:
          - - 3
      minProperties: 1
    PageMeta:
      type: object
      properties:
        page:
          type: integer
          description: Current page.
          examples:
          - 1
          format: int32
        per_page:
          type: integer
          description: Page size.
          examples:
          - 50
          format: int32
        total:
          type: integer
          description: Total matching items.
          examples:
          - 1234
          format: int64
      required:
      - page
      - per_page
      - total
    PasswordChange:
      type: object
      properties:
        current_password:
          type: string
          writeOnly: true
        new_password:
          type: string
          minLength: 10
          maxLength: 1024
          writeOnly: true
      required:
      - current_password
      - new_password
    PlaylistLinks:
      type: object
      properties:
        server_url:
          type: string
          description: What to type in the app as server.
          examples:
          - http://tv.example.com
        username:
          type: string
          examples:
          - joao2291
        password:
          type: string
          examples:
          - k8Jw2pQz
        m3u:
          type: string
          examples:
          - http://tv.example.com/get.php?username=joao2291&password=k8Jw2pQz&type=m3u&output=ts
        m3u_plus:
          type: string
          examples:
          - http://tv.example.com/get.php?username=joao2291&password=k8Jw2pQz&type=m3u_plus&output=ts
        m3u_plus_hls:
          type: string
          examples:
          - http://tv.example.com/get.php?username=joao2291&password=k8Jw2pQz&type=m3u_plus&output=m3u8
        m3u_plus_mpd:
          type: string
          description: Playlist with DASH (.mpd) links for channels with DASH output; other channels keep TS links.
          examples:
          - http://tv.example.com/get.php?username=joao2291&password=k8Jw2pQz&type=m3u_plus&output=mpd
        xmltv:
          type: string
          examples:
          - http://tv.example.com/xmltv.php?username=joao2291&password=k8Jw2pQz
        player_api:
          type: string
          examples:
          - http://tv.example.com/player_api.php?username=joao2291&password=k8Jw2pQz
        share_text:
          type: string
          description: Ready-to-send message for chat apps (WhatsApp, Telegram) with the access details, in the requester's language.
      required:
      - server_url
      - username
      - password
      - m3u
      - m3u_plus
      - m3u_plus_hls
      - xmltv
      - player_api
    ProbeResult:
      type: object
      properties:
        ok:
          type: boolean
          examples:
          - true
        source_url_redacted:
          type: string
          examples:
          - http://provider.example.net/live/***/***/1234.ts
        format:
          type: string
          examples:
          - mpegts
        duration_ms_to_open:
          type: integer
          examples:
          - 840
          format: int32
        bitrate_kbps:
          type: integer
          examples:
          - 5200
          format: int32
        video:
          type: array
          items:
            type: object
            properties:
              codec:
                type: string
                examples:
                - h264
              profile:
                type: string
                examples:
                - High
              width:
                type: integer
                examples:
                - 1920
                format: int32
              height:
                type: integer
                examples:
                - 1080
                format: int32
              fps:
                type: number
                examples:
                - 50
              pix_fmt:
                type: string
                examples:
                - yuv420p
        audio:
          type: array
          items:
            type: object
            properties:
              codec:
                type: string
                examples:
                - aac
              channels:
                type: integer
                examples:
                - 2
                format: int32
              sample_rate:
                type: integer
                examples:
                - 48000
                format: int32
              language:
                type: string
                examples:
                - por
        subtitles:
          type: array
          items:
            type: object
            properties:
              codec:
                type: string
                examples:
                - dvb_subtitle
              language:
                type: string
                examples:
                - por
        duration_s:
          type: integer
          description: Length of a movie or episode file in seconds. Only on VOD probes.
          examples:
          - 5400
          format: int32
        llod_compatible:
          type: boolean
          description: Source is HTTP MPEG-TS, so llod mode can be used.
          examples:
          - true
        qualities:
          type: array
          description: DASH sources only. Video qualities (representations) of the manifest, in manifest order.
          items:
            type: object
            properties:
              id:
                type: string
                examples:
                - '1'
              width:
                type: integer
                format: int32
                examples:
                - 1920
              height:
                type: integer
                format: int32
                examples:
                - 1080
              bitrate_kbps:
                type: integer
                format: int32
                examples:
                - 4000
              codec:
                type: string
                examples:
                - avc1.640028
              fps:
                type: number
                examples:
                - 25
            required:
            - id
        error:
          type: string
          examples:
          - ''
        error_code:
          type: string
          description: Why the probe failed, for a translated message. `error` keeps the technical detail. encrypted_source means the
            DASH manifest has ContentProtection (DRM); encrypted sources are never decrypted and are not supported.
          enum:
          - no_source
          - no_node_online
          - probe_failed
          - encrypted_source
          examples:
          - no_node_online
      required:
      - ok
    ProcessMachine:
      type: object
      required:
      - id
      - name
      - roles
      - node_ids
      - online
      - status
      - full
      - mem_total
      - processes
      properties:
        id:
          type: string
          description: '"control" for the panel machine, else a stable machine key.'
        name:
          type: string
          description: Node names on this machine, or the control host name.
        roles:
          type: array
          items:
            type: string
            enum:
            - control
            - node
            - proxy
        node_ids:
          type: array
          items:
            type: integer
            format: int64
        online:
          type: boolean
        status:
          type: string
          examples:
          - online
        full:
          type: boolean
          description: False when the only list comes from a node too old to send every process (ffmpeg only).
        mem_total:
          type: integer
          format: int64
          description: Machine memory in bytes (0 = unknown).
        processes:
          type: array
          items:
            $ref: '#/components/schemas/HostProcess'
    HostProcess:
      type: object
      required:
      - pid
      - ppid
      - user
      - name
      - cmd
      - cpu_pct
      - mem_bytes
      - mem_pct
      - state
      - started_at
      - read_bps
      - write_bps
      - role
      - stream_id
      properties:
        pid:
          type: integer
          format: int32
        ppid:
          type: integer
          format: int32
        user:
          type: string
        name:
          type: string
        cmd:
          type: string
          description: Redacted command line, at most about 300 characters.
        cpu_pct:
          type: number
          description: 100 = one full core.
        mem_bytes:
          type: integer
          format: int64
          description: Resident memory (RSS).
        mem_pct:
          type: number
        state:
          type: string
          description: Empty when unknown.
          enum:
          - running
          - sleeping
          - disk_wait
          - zombie
          - stopped
          - idle
          - other
          - ''
        started_at:
          type:
          - string
          - 'null'
          format: date-time
        read_bps:
          type:
          - number
          - 'null'
          description: Storage bytes read per second. Null when not readable (a process of another user).
        write_bps:
          type:
          - number
          - 'null'
        role:
          type:
          - string
          - 'null'
          description: Bitstream's own processes.
          enum:
          - bs-control
          - bs-node
          - bs-edge
          - ffmpeg
          - null
        stream_id:
          type:
          - integer
          - 'null'
          format: int64
          description: ffmpeg spawned by the node for this stream.
    Process:
      type: object
      properties:
        pid:
          type: integer
          examples:
          - 31337
          format: int32
        stream_id:
          type:
          - integer
          - 'null'
          examples:
          - 101
          format: int64
        kind:
          type: string
          examples:
          - ffmpeg
          enum:
          - ffmpeg
          - ffprobe
          - llod
          - other
        cpu_pct:
          type: number
          examples:
          - 3.2
        mem_bytes:
          type: integer
          examples:
          - 48234496
          format: int64
        started_at:
          type: string
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
        args_redacted:
          type: string
          examples:
          - ffmpeg -hide_banner -i http://***@provider/... -c copy -f mpegts pipe:1
    RecoveryCodes:
      type: object
      properties:
        recovery_codes:
          type: array
          items:
            type: string
          description: Ten single use codes. Shown once.
          examples:
          - - k3p9-xq2m
            - a8d2-vv0t
      required:
      - recovery_codes
    ReorderRequest:
      type: object
      properties:
        ids:
          type: array
          items:
            type: integer
            format: int64
          description: All ids in the new order.
          minItems: 1
          examples:
          - - 5
            - 2
            - 9
      required:
      - ids
    ResellerLimits:
      type: object
      description: Rules applied to resellers in the group. Ignored for admin groups.
      properties:
        max_trials_per_day:
          type: integer
          description: 0 means trials are not allowed.
          examples:
          - 5
          format: int32
        can_create_subresellers:
          type: boolean
          examples:
          - false
        subreseller_price:
          type: integer
          description: Credits charged to create a sub-reseller.
          examples:
          - 0
          format: int64
        allow_change_bouquets:
          type: boolean
          description: May edit bouquets of a line beyond the package.
          examples:
          - false
        allow_line_restrictions:
          type: boolean
          description: May set allowed IPs, user agents and forced country on lines.
          examples:
          - true
        min_username_length:
          type: integer
          examples:
          - 6
          format: int32
        min_password_length:
          type: integer
          examples:
          - 8
          format: int32
        can_view_connection_ips:
          type: boolean
          examples:
          - true
    Season:
      type: object
      description: A season of a series.
      properties:
        id:
          type: integer
          description: Unique id.
          examples:
          - 42
          format: int64
          readOnly: true
        series_id:
          type: integer
          examples:
          - 77
          format: int64
          readOnly: true
        episode_count:
          type: integer
          examples:
          - 13
          format: int32
          readOnly: true
        season_number:
          type: integer
          description: 0 is specials.
          examples:
          - 1
          format: int32
          minimum: 0
        name:
          type: string
          examples:
          - Season 1
        overview:
          type: string
          examples:
          - ''
        air_date:
          type:
          - string
          - 'null'
          format: date
        cover_url:
          type: string
          examples:
          - ''
      required:
      - id
      - series_id
      - episode_count
      - season_number
    SeasonCreate:
      type: object
      description: Fields accepted when creating a Season. Omitted optional fields take the defaults shown.
      properties:
        season_number:
          type: integer
          description: 0 is specials.
          examples:
          - 1
          format: int32
          minimum: 0
        name:
          type: string
          examples:
          - Season 1
        overview:
          type: string
          examples:
          - ''
        air_date:
          type:
          - string
          - 'null'
          format: date
        cover_url:
          type: string
          examples:
          - ''
      required:
      - season_number
    SeasonUpdate:
      type: object
      description: Partial update of a Season. Send only the fields to change.
      properties:
        season_number:
          type: integer
          description: 0 is specials.
          examples:
          - 1
          format: int32
          minimum: 0
        name:
          type: string
          examples:
          - Season 1
        overview:
          type: string
          examples:
          - ''
        air_date:
          type:
          - string
          - 'null'
          format: date
        cover_url:
          type: string
          examples:
          - ''
      minProperties: 1
    Series:
      type: object
      description: A TV series.
      properties:
        tmdb_status:
          type: string
          description: 'TMDB link. pending: waiting for the automatic match. refresh: queued for a refresh. matched: linked. review: the match was not sure, see /tmdb/review. no_match: nothing found. skipped: you chose no match.'
          enum:
          - pending
          - refresh
          - matched
          - review
          - no_match
          - skipped
          readOnly: true
        is_adult:
          type: boolean
          description: Adult even in a non-adult category. Lines that hide adult content do not see it (for series, its episodes too). Default false.
        original_name:
          type: string
          description: Original title (from TMDB).
          maxLength: 255
        id:
          type: integer
          description: Unique id.
          examples:
          - 42
          format: int64
          readOnly: true
        season_count:
          type: integer
          examples:
          - 5
          format: int32
          readOnly: true
        episode_count:
          type: integer
          examples:
          - 62
          format: int32
          readOnly: true
        created_at:
          type: string
          description: When the record was created.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        updated_at:
          type: string
          description: When the record was last changed.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        name:
          type: string
          examples:
          - Breaking Bad
          maxLength: 255
        cover_url:
          type: string
          examples:
          - https://image.tmdb.org/t/p/w600/bb.jpg
        year:
          type:
          - integer
          - 'null'
          examples:
          - 1999
          format: int32
        category_id:
          type:
          - integer
          - 'null'
          examples:
          - 12
          format: int64
        plot:
          type: string
          examples:
          - A hacker learns...
        cast:
          type: string
          examples:
          - Keanu Reeves, Laurence Fishburne
        director:
          type: string
          examples:
          - Lana Wachowski, Lilly Wachowski
        genre:
          type: string
          examples:
          - Action, Science Fiction
        release_date:
          type:
          - string
          - 'null'
          examples:
          - '1999-03-31'
          format: date
        rating:
          type:
          - number
          - 'null'
          description: 0 to 10.
          examples:
          - 8.7
        tmdb_id:
          type:
          - integer
          - 'null'
          examples:
          - 603
          format: int32
        youtube_trailer:
          type: string
          description: YouTube video id.
          examples:
          - vKQi3bBA1y8
        backdrop_urls:
          type: array
          items:
            type: string
        enabled:
          type: boolean
          default: true
        position:
          type: integer
          examples:
          - 0
          format: int32
        episode_run_time:
          type:
          - integer
          - 'null'
          description: Minutes.
          examples:
          - 47
          format: int32
      required:
      - id
      - season_count
      - episode_count
      - created_at
      - updated_at
      - name
    SeriesCreate:
      type: object
      description: Fields accepted when creating a Series. Omitted optional fields take the defaults shown.
      properties:
        is_adult:
          type: boolean
          description: Adult even in a non-adult category. Lines that hide adult content do not see it (for series, its episodes too). Default false.
        original_name:
          type: string
          description: Original title (from TMDB).
          maxLength: 255
        name:
          type: string
          examples:
          - Breaking Bad
          maxLength: 255
        cover_url:
          type: string
          examples:
          - https://image.tmdb.org/t/p/w600/bb.jpg
        year:
          type:
          - integer
          - 'null'
          examples:
          - 1999
          format: int32
        category_id:
          type:
          - integer
          - 'null'
          examples:
          - 12
          format: int64
        plot:
          type: string
          examples:
          - A hacker learns...
        cast:
          type: string
          examples:
          - Keanu Reeves, Laurence Fishburne
        director:
          type: string
          examples:
          - Lana Wachowski, Lilly Wachowski
        genre:
          type: string
          examples:
          - Action, Science Fiction
        release_date:
          type:
          - string
          - 'null'
          examples:
          - '1999-03-31'
          format: date
        rating:
          type:
          - number
          - 'null'
          description: 0 to 10.
          examples:
          - 8.7
        tmdb_id:
          type:
          - integer
          - 'null'
          examples:
          - 603
          format: int32
        youtube_trailer:
          type: string
          description: YouTube video id.
          examples:
          - vKQi3bBA1y8
        backdrop_urls:
          type: array
          items:
            type: string
        enabled:
          type: boolean
          default: true
        position:
          type: integer
          examples:
          - 0
          format: int32
        episode_run_time:
          type:
          - integer
          - 'null'
          description: Minutes.
          examples:
          - 47
          format: int32
      required:
      - name
    SeriesList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Series'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    SeriesUpdate:
      type: object
      description: Partial update of a Series. Send only the fields to change.
      properties:
        is_adult:
          type: boolean
          description: Adult even in a non-adult category. Lines that hide adult content do not see it (for series, its episodes too). Default false.
        original_name:
          type: string
          description: Original title (from TMDB).
          maxLength: 255
        name:
          type: string
          examples:
          - Breaking Bad
          maxLength: 255
        cover_url:
          type: string
          examples:
          - https://image.tmdb.org/t/p/w600/bb.jpg
        year:
          type:
          - integer
          - 'null'
          examples:
          - 1999
          format: int32
        category_id:
          type:
          - integer
          - 'null'
          examples:
          - 12
          format: int64
        plot:
          type: string
          examples:
          - A hacker learns...
        cast:
          type: string
          examples:
          - Keanu Reeves, Laurence Fishburne
        director:
          type: string
          examples:
          - Lana Wachowski, Lilly Wachowski
        genre:
          type: string
          examples:
          - Action, Science Fiction
        release_date:
          type:
          - string
          - 'null'
          examples:
          - '1999-03-31'
          format: date
        rating:
          type:
          - number
          - 'null'
          description: 0 to 10.
          examples:
          - 8.7
        tmdb_id:
          type:
          - integer
          - 'null'
          examples:
          - 603
          format: int32
        youtube_trailer:
          type: string
          description: YouTube video id.
          examples:
          - vKQi3bBA1y8
        backdrop_urls:
          type: array
          items:
            type: string
        enabled:
          type: boolean
          default: true
        position:
          type: integer
          examples:
          - 0
          format: int32
        episode_run_time:
          type:
          - integer
          - 'null'
          description: Minutes.
          examples:
          - 47
          format: int32
      minProperties: 1
    Session:
      type: object
      properties:
        id:
          type: string
          description: Session (refresh token family) id.
          examples:
          - 01936d6e-8a3b-7c1e-9f00-1a2b3c4d5e6f
          format: uuid
        ip:
          type: string
          examples:
          - 203.0.113.7
        user_agent:
          type: string
          examples:
          - Mozilla/5.0 ...
        created_at:
          type: string
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
        last_used_at:
          type: string
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
        current:
          type: boolean
          description: True for the session making this request.
      required:
      - id
      - ip
      - user_agent
      - created_at
      - last_used_at
      - current
    Settings:
      type: object
      description: All settings by group.
      properties:
        general:
          $ref: '#/components/schemas/SettingsGeneral'
        streaming:
          $ref: '#/components/schemas/SettingsStreaming'
        client_api:
          $ref: '#/components/schemas/SettingsClientApi'
        security:
          $ref: '#/components/schemas/SettingsSecurity'
        epg:
          $ref: '#/components/schemas/SettingsEpg'
        history:
          $ref: '#/components/schemas/SettingsHistory'
        backups:
          $ref: '#/components/schemas/SettingsBackups'
        monitoring:
          $ref: '#/components/schemas/SettingsMonitoring'
      required:
      - general
      - streaming
      - client_api
      - security
      - epg
      - history
      - backups
      - monitoring
    SettingsBackups:
      type: object
      properties:
        schedule:
          type: string
          description: Cron expression, empty disables.
          examples:
          - 0 3 * * *
        keep:
          type: integer
          examples:
          - 7
          format: int32
        include_history:
          type: boolean
          examples:
          - false
      description: Settings group `backups`. Unknown keys are rejected.
    SettingsClientApi:
      type: object
      properties:
        ip_check:
          type: string
          examples:
          - prefix
          enum:
          - prefix
          - 'off'
          - exact
        trusted_proxies:
          type: array
          items:
            type: string
            examples:
            - 173.245.48.0/20
        allow_hls:
          type: boolean
          examples:
          - true
        allow_ts:
          type: boolean
          examples:
          - true
        legacy_urls:
          type: boolean
          description: Accept /u/p/id short URLs.
          examples:
          - true
        playlist_enabled:
          type: boolean
          examples:
          - true
        show_category_duplicates:
          type: boolean
          examples:
          - false
        vod_sort_newest:
          type: boolean
          examples:
          - false
        expired_video_url:
          type: string
          examples:
          - ''
        max_failed_logins_per_ip:
          type: integer
          examples:
          - 20
          format: int32
      description: Settings group `client_api`. Unknown keys are rejected.
    SettingsEpg:
      type: object
      properties:
        enabled:
          type: boolean
          examples:
          - true
        days_ahead:
          type: integer
          examples:
          - 7
          format: int32
        days_back:
          type: integer
          examples:
          - 1
          format: int32
        auto_map_new_streams:
          type: boolean
          examples:
          - true
      description: Settings group `epg`. Unknown keys are rejected.
    SettingsGeneral:
      type: object
      properties:
        phone_country_code:
          type: string
          description: Country calling code (1 to 3 digits) added to client phones typed without one, for WhatsApp links. Default 55 (Brazil).
          pattern: ^[1-9][0-9]{0,2}$
          examples:
          - '55'
        server_name:
          type: string
          examples:
          - My IPTV
        panel_url:
          type: string
          examples:
          - https://panel.example.com
        client_url:
          type: string
          description: Base URL given to apps; defaults to panel_url.
          examples:
          - http://tv.example.com
        timezone:
          type: string
          examples:
          - America/Sao_Paulo
        default_locale:
          type: string
          examples:
          - en
          enum:
          - en
          - pt-BR
          - es
        message_of_day:
          type: string
          description: Sent to apps in user_info.message.
          examples:
          - ''
        maintenance_mode:
          type: boolean
          examples:
          - false
        maintenance_message:
          type: string
          examples:
          - ''
        share_template:
          type: string
          maxLength: 2000
          description: Default WhatsApp/share message for line access, used by users without their own. Empty means the built-in text in
            each user's language. Placeholders `{name}` `{server}` `{url}` `{username}` `{password}` `{m3u}` `{expires}`.
          examples:
          - ''
      description: Settings group `general`. Unknown keys are rejected.
    SettingsHistory:
      type: object
      properties:
        retention_months:
          type: integer
          examples:
          - 6
          format: int32
        aggregate_retention_months:
          type: integer
          examples:
          - 24
          format: int32
      description: Settings group `history`. Unknown keys are rejected.
    SettingsMonitoring:
      type: object
      properties:
        metrics_enabled:
          type: boolean
          description: Expose Prometheus /metrics on the control.
          examples:
          - true
        metrics_allowed_ips:
          type: array
          items:
            type: string
            examples:
            - 10.0.0.0/8
        metrics_token_set:
          type: boolean
          description: A bearer token is required for /metrics.
          examples:
          - true
          readOnly: true
        metrics_token:
          type: string
          writeOnly: true
      description: Settings group `monitoring`. Unknown keys are rejected.
    SettingsSecurity:
      type: object
      properties:
        panel_allowed_ips:
          type: array
          items:
            type: string
          description: Empty means any.
        login_max_attempts:
          type: integer
          examples:
          - 5
          format: int32
        login_lockout_minutes:
          type: integer
          examples:
          - 15
          format: int32
        session_days:
          type: integer
          description: How long a panel login lasts without use, in days (1 to 365). Each use extends it.
          minimum: 1
          maximum: 365
          examples:
          - 30
          format: int32
        require_2fa_admins:
          type: boolean
          examples:
          - false
        login_attempts_retention_days:
          type: integer
          examples:
          - 30
          format: int32
        auto_block_bruteforce:
          type: boolean
          examples:
          - true
      description: Settings group `security`. Unknown keys are rejected.
    SettingsStreaming:
      type: object
      properties:
        default_mode:
          type: string
          examples:
          - ffmpeg
          enum:
          - ffmpeg
          - llod
          - direct
        default_on_demand:
          type: boolean
          examples:
          - true
        default_idle_timeout_s:
          type: integer
          examples:
          - 60
          format: int32
        ts_buffer_seconds:
          type: integer
          examples:
          - 6
          format: int32
        client_prebuffer_seconds:
          type: integer
          minimum: 0
          maximum: 30
          description: 'XC_VM client_prebuffer. A new live TS viewer starts on a keyframe at least this many seconds behind live and gets
            that backlog at once, so the player starts without waiting. 0: the newest keyframe. The ring of every channel keeps this plus
            about one GOP (shared by all viewers).'
          examples:
          - 4
          format: int32
        restreamer_prebuffer_seconds:
          type: integer
          minimum: 0
          maximum: 30
          description: XC_VM restreamer_prebuffer. The same for restreamer lines, small so they stay close to live.
          examples:
          - 1
          format: int32
        hls_segment_seconds:
          type: integer
          examples:
          - 4
          format: int32
        hls_window_segments:
          type: integer
          examples:
          - 4
          format: int32
        max_stream_buffer_mb:
          type: integer
          examples:
          - 32
          format: int32
        max_concurrent_starts_per_node:
          type: integer
          examples:
          - 20
          format: int32
        source_failover_seconds:
          type: integer
          examples:
          - 8
          format: int32
        primary_return_healthy_seconds:
          type: integer
          examples:
          - 30
          format: int32
        default_user_agent:
          type: string
          examples:
          - Bitstream/1.0
        default_headers:
          type: string
          description: 'Extra request headers for every source, one "Name: value" per line. A channel or source header of the same name wins.'
          examples:
          - 'Referer: https://example.com'
        balance_by:
          type: string
          description: 'How viewers are spread over nodes (XC_VM split_by). connections: fewest viewers per weight. max_clients: lowest share of
            each node max_clients. bandwidth: lowest outgoing traffic compared with the link speed. guaranteed_bandwidth: same, compared with
            guaranteed_mbps. Geo and ISP rules and full nodes are applied first.'
          enum:
          - connections
          - max_clients
          - bandwidth
          - guaranteed_bandwidth
          default: connections
        vod_speed_limit:
          type: boolean
          description: 'VOD speed limit (XC_VM vod_limit_perc and vod_bitrate_plus). After vod_limit_percent of a movie, episode or
            catch-up file, the node sends at the content bitrate plus vod_bitrate_plus percent. Restreamer lines are never limited.
            Seeks work: a range past the limit is paced from its first byte. Default false.'
          default: false
        vod_limit_percent:
          type: integer
          format: int32
          minimum: 0
          maximum: 100
          description: Percent of the file sent at full speed before the limit starts.
          default: 20
        vod_bitrate_plus:
          type: integer
          format: int32
          minimum: 0
          maximum: 1000
          description: Percent above the content bitrate allowed after the limit starts.
          default: 60
        restreamer_bypass_proxy:
          type: boolean
          description: Off by default, so restreamer lines go through the proxy like any line. When on, they play straight from a node that requires a proxy (XC_VM restreamer_bypass_proxy).
          default: false
      description: Settings group `streaming`. Unknown keys are rejected.
    SetupRequest:
      type: object
      properties:
        admin:
          type: object
          properties:
            username:
              type: string
              examples:
              - admin
              minLength: 3
              maxLength: 64
            password:
              type: string
              minLength: 10
              writeOnly: true
            email:
              type:
              - string
              - 'null'
              format: email
          required:
          - username
          - password
        server_name:
          type: string
          description: Shown to clients and in playlists.
          examples:
          - My IPTV
        panel_url:
          type: string
          description: Public URL of this panel, used in playlist links. Ignored when `cloudflare` is set (it becomes `https://<panel_domain>`); required only without it.
          examples:
          - https://panel.example.com
          format: uri
        timezone:
          type: string
          description: IANA timezone.
          examples:
          - America/Sao_Paulo
        locale:
          type: string
          examples:
          - en
          enum:
          - en
          - pt-BR
          - es
        license_email:
          type: string
          description: Optional. Sent to the license server with the activation, only when filled in.
          examples:
          - owner@example.com
        local_node:
          type: boolean
          description: Register a streaming node on this same machine (delivery_mode proxy, or redirect when `cloudflare.node_domain` is set).
          examples:
          - true
        cloudflare:
          $ref: '#/components/schemas/SetupCloudflare'
      required:
      - admin
      - server_name
      - timezone
      - cloudflare
    SetupCloudflare:
      type: object
      description: Cloudflare connection made by the setup wizard. Required to finish setup.
      properties:
        api_token:
          type: string
          writeOnly: true
          minLength: 20
          maxLength: 200
          description: API token with Zone, Zone, Read and Zone, DNS, Edit on the zone. Stored encrypted, never returned.
        zone_id:
          type: string
        panel_domain:
          type: string
          description: Full panel host inside the zone.
          examples:
          - painel.example.com
        panel_proxied:
          type: boolean
          default: true
          description: Panel record through the Cloudflare proxy.
        node_domain:
          type:
          - string
          - 'null'
          description: Optional streaming domain for the node on this server (DNS only by default).
          examples:
          - tv.example.com
        node_proxied:
          type: boolean
          default: false
          description: Cloudflare proxy for the streaming domain. Not meant for video on most Cloudflare plans.
        ipv4:
          type:
          - string
          - 'null'
          description: Public IPv4 the records point at. At least one of ipv4 and ipv6.
          examples:
          - 203.0.113.10
        ipv6:
          type:
          - string
          - 'null'
      required:
      - api_token
      - zone_id
      - panel_domain
    SetupStatus:
      type: object
      properties:
        setup_complete:
          type: boolean
          examples:
          - false
        version:
          type: string
          examples:
          - 1.0.0
        checks:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
                examples:
                - database
              ok:
                type: boolean
                examples:
                - true
              message:
                type: string
                examples:
                - PostgreSQL 16.4
            required:
            - name
            - ok
          description: Environment checks shown on the first wizard screen.
        code_required:
          type: boolean
          description: False when this request came over loopback (SSH tunnel), where no setup code is needed.
          examples:
          - true
        local_node_available:
          type: boolean
          description: The installer set up a bs-node on this host (role both). Choosing `local_node` enrolls it automatically.
          examples:
          - true
        cloudflare_required:
          type: boolean
          description: False only when the control runs with `BS_SETUP_SKIP_CLOUDFLARE=1` (test labs).
          examples:
          - true
        license_required:
          type: boolean
          description: False only when the control runs with `BS_LICENSE_SKIP=1` (test labs). When true, complete registers the panel for its free license first.
          examples:
          - true
      required:
      - setup_complete
      - version
      - checks
    SourceAccount:
      type: object
      description: An upstream provider account. Sources linked to it never exceed max_connections in total, across fallbacks, nodes and on-demand
        starts.
      properties:
        id:
          type: integer
          description: Unique id.
          examples:
          - 42
          format: int64
          readOnly: true
        in_use:
          type: integer
          description: Connections open right now. Live streams count once per node that pulls from one of the account's sources, VOD counts every playing session.
          examples:
          - 2
          format: int32
          readOnly: true
        source_count:
          type: integer
          examples:
          - 140
          format: int32
          readOnly: true
        created_at:
          type: string
          description: When the record was created.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        name:
          type: string
          examples:
          - Provider X account 1
        max_connections:
          type: integer
          description: 0 means unlimited.
          examples:
          - 2
          format: int32
          minimum: 0
        notes:
          type: string
          examples:
          - ''
      required:
      - id
      - in_use
      - source_count
      - created_at
      - name
      - max_connections
    SourceAccountCreate:
      type: object
      description: Fields accepted when creating a SourceAccount. Omitted optional fields take the defaults shown.
      properties:
        name:
          type: string
          examples:
          - Provider X account 1
        max_connections:
          type: integer
          description: 0 means unlimited.
          examples:
          - 2
          format: int32
          minimum: 0
        notes:
          type: string
          examples:
          - ''
      required:
      - name
      - max_connections
    SourceAccountList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/SourceAccount'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    SourceAccountUpdate:
      type: object
      description: Partial update of a SourceAccount. Send only the fields to change.
      properties:
        name:
          type: string
          examples:
          - Provider X account 1
        max_connections:
          type: integer
          description: 0 means unlimited.
          examples:
          - 2
          format: int32
          minimum: 0
        notes:
          type: string
          examples:
          - ''
      minProperties: 1
    DuplicateRequest:
      type: object
      description: Optional body of the duplicate operations.
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 255
          description: Name of the copy. Omitted keeps the original name.
          examples:
          - Sports HD (copy)
        enabled:
          type: boolean
          default: false
          description: Turn the copy on right away.
    Stream:
      type: object
      description: A live channel, radio station or created channel. The kind is fixed by the endpoint that created it.
      properties:
        id:
          type: integer
          description: Unique id.
          examples:
          - 42
          format: int64
          readOnly: true
        kind:
          type: string
          examples:
          - live
          enum:
          - live
          - radio
          - created
          readOnly: true
        health:
          $ref: '#/components/schemas/StreamHealth'
          readOnly: true
        created_at:
          type: string
          description: When the record was created.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        updated_at:
          type: string
          description: When the record was last changed.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        name:
          type: string
          examples:
          - Sports HD
          maxLength: 255
        category_id:
          type:
          - integer
          - 'null'
          examples:
          - 4
          format: int64
        logo_url:
          type: string
          examples:
          - https://cdn.example.com/logos/sports.png
        epg_channel_id:
          type:
          - integer
          - 'null'
          description: Mapped EPG channel (see `/epg/channels`).
          examples:
          - 3021
          format: int64
        mode:
          type: string
          description: 'ffmpeg: ffmpeg copy (default). llod: Go relay without ffmpeg, HTTP MPEG-TS sources only, fastest to open. direct: clients
            are redirected to the source, no limits or stats.'
          examples:
          - ffmpeg
          enum:
          - ffmpeg
          - llod
          - direct
        on_demand:
          type: boolean
          description: Start on first viewer, stop after idle_timeout_s without viewers.
          default: false
        idle_timeout_s:
          type: integer
          deprecated: true
          description: Stored but unused. Nodes always stop idle on demand channels after the panel setting default_idle_timeout_s.
          examples:
          - 60
          format: int32
          minimum: 5
          maximum: 86400
        ffmpeg_input_args:
          type: array
          items:
            type: string
          description: Admin only. Extra input flags from the allowlist (GET /system/ffmpeg).
          examples:
          - - -re
        ffmpeg_output_args:
          type: array
          items:
            type: string
          description: Admin only. Extra output flags from the allowlist.
        probe_size:
          type:
          - integer
          - 'null'
          description: Bytes. null uses node default.
          format: int32
        analyze_duration_ms:
          type:
          - integer
          - 'null'
          format: int32
        user_agent:
          type: string
          description: User agent sent to sources.
          examples:
          - VLC/3.0.20
        http_proxy:
          type: string
          description: Proxy for sources, http://host:port.
          examples:
          - ''
        is_adult:
          type: boolean
          description: Adult channel even in a non-adult category. Lines that hide adult content do not see it. Default false.
        custom_sid:
          type: string
          description: Enigma2 service reference override.
          examples:
          - ''
        enabled:
          type: boolean
          default: true
        position:
          type: integer
          examples:
          - 0
          format: int32
        notes:
          type: string
          examples:
          - ''
        dash_output:
          type: string
          description: 'MPEG-DASH output for this channel, on top of TS and HLS. off (default). on: packaged on the node from the same
            feed, copy only. all_qualities: every video quality of a DASH source in one manifest (a second pull from the source while
            DASH viewers watch). Lines need `mpd` in allowed_outputs.'
          examples:
          - 'off'
          enum:
          - 'off'
          - 'on'
          - all_qualities
        fast_detection:
          type: boolean
          description: Fail the source after 15 s without new video instead of 60 s, so the backup takes over sooner. For channels
            with good sources. Default false.
          examples:
          - false
        fps_restart:
          type: boolean
          description: After 10 minutes, restart the source when its frame rate falls below fps_threshold percent of the rate at
            the start (XC_VM fps_restart). Default false.
          examples:
          - false
        fps_threshold:
          type: integer
          format: int32
          minimum: 10
          maximum: 100
          description: Percent of the start frame rate for fps_restart. Default 90.
          examples:
          - 90
        audio_restart_loss:
          type: boolean
          description: Every 5 minutes, restart the source when no audio arrived for 10 s (XC_VM audio_restart_loss). Default false.
          examples:
          - false
        priority_backup:
          type: boolean
          description: While a backup source plays, go back to a better source once it works again (XC_VM priority_backup). Default
            true.
          examples:
          - true
        adaptive_variants:
          type: array
          items:
            type: integer
            format: int64
          maxItems: 10
          description: 'Adaptive HLS (XC_VM adaptive_link): live channels offered as qualities of this one, usually its sub channels.
            With at least one, `/live/U/P/{id}.m3u8` answers a master playlist (highest bitrate first) and every quality of one viewer
            shares one connection slot. Copy only, nothing is transcoded. Empty (default): one quality, as before. The channel itself
            may be listed. Not for created channels.'
          examples:
          - - 1021
            - 1022
        archive_enabled:
          type: boolean
          description: Record the channel for catch-up (TV archive). Copy only, on the archive node. Needs archive_node_id; not for
            direct channels.
        archive_days:
          type: integer
          minimum: 1
          maximum: 30
          description: Days of recording to keep (default 7). Older hours are deleted.
          format: int32
        archive_node_id:
          type:
          - integer
          - 'null'
          format: int64
          description: Node that records and serves the archive. It pulls the channel through the server tree, never from the
            source, when it does not run the channel itself.
        parent_id:
          type:
          - integer
          - 'null'
          description: Set on a sub channel (one quality of a DASH source). Deleting the parent deletes it; parent source changes
            are copied to it.
          examples:
          - null
          format: int64
          readOnly: true
        sources:
          type: array
          items:
            $ref: '#/components/schemas/StreamSource'
          description: Ordered sources. On create, at least one unless kind is created.
        node_ids:
          type: array
          items:
            type: integer
            format: int64
          description: 'Shortcut on create: assign these nodes as roots of the server tree.'
          writeOnly: true
          examples:
          - - 1
      required:
      - id
      - kind
      - health
      - created_at
      - updated_at
      - name
    StreamArchive:
      type: object
      description: TV archive of a channel, with what its archive node last reported (about every minute).
      properties:
        enabled:
          type: boolean
        days:
          type: integer
          format: int32
        node_id:
          type:
          - integer
          - 'null'
          format: int64
        node_name:
          type: string
        node_online:
          type: boolean
        recording:
          type: boolean
          description: The node is writing segments now.
        error:
          type: string
          description: Empty, or no_space, write_error, no_input.
        from:
          type:
          - string
          - 'null'
          format: date-time
          description: Oldest stored moment (UTC). Null when nothing is stored.
        to:
          type:
          - string
          - 'null'
          format: date-time
          description: Newest stored moment (UTC).
        bytes:
          type: integer
          format: int64
        timezone:
          type: string
          description: Panel timezone. Catch-up start times in client URLs are read in it.
          examples:
          - America/Sao_Paulo
      required:
      - enabled
      - days
      - node_id
      - node_name
      - node_online
      - recording
      - error
      - from
      - to
      - bytes
      - timezone
    StreamBulkRequest:
      type: object
      properties:
        ids:
          type: array
          items:
            type: integer
            format: int64
          description: Ids to act on. Up to 1000.
          minItems: 1
          maxItems: 1000
          examples:
          - - 12
            - 13
            - 14
        action:
          type: string
          description: 'What to do. `enable`: Enable. `disable`: Disable and stop. `delete`: Delete. `start`: `params.node_ids` optional. `stop`:
            `params.node_ids` optional. `restart`: restarts the input on every assigned node. `probe`: runs ffprobe on the first source, fails per id when it does not open. `set_category`: `params.category_id`. `set_mode`: `params.mode`.
            `set_on_demand`: `params.on_demand`, `params.idle_timeout_s` optional. `add_to_bouquets`: `params.bouquet_ids`. `remove_from_bouquets`:
            `params.bouquet_ids`. `assign_nodes`: `params.node_ids` added as roots. `unassign_nodes`: `params.node_ids`. `update`: mass edit, `params` is a `StreamMassEdit`.'
          examples:
          - enable
          enum:
          - enable
          - disable
          - delete
          - start
          - stop
          - restart
          - probe
          - set_category
          - set_mode
          - set_on_demand
          - add_to_bouquets
          - remove_from_bouquets
          - assign_nodes
          - unassign_nodes
          - update
        params:
          type: object
          description: Extra arguments for the action, documented with each action.
          properties: {}
          additionalProperties: true
      required:
      - ids
      - action
    StreamCreate:
      type: object
      description: Fields accepted when creating a Stream. Omitted optional fields take the defaults shown.
      properties:
        name:
          type: string
          examples:
          - Sports HD
          maxLength: 255
        category_id:
          type:
          - integer
          - 'null'
          examples:
          - 4
          format: int64
        logo_url:
          type: string
          examples:
          - https://cdn.example.com/logos/sports.png
        epg_channel_id:
          type:
          - integer
          - 'null'
          description: Mapped EPG channel (see `/epg/channels`).
          examples:
          - 3021
          format: int64
        mode:
          type: string
          description: 'ffmpeg: ffmpeg copy (default). llod: Go relay without ffmpeg, HTTP MPEG-TS sources only, fastest to open. direct: clients
            are redirected to the source, no limits or stats.'
          examples:
          - ffmpeg
          enum:
          - ffmpeg
          - llod
          - direct
        on_demand:
          type: boolean
          description: Start on first viewer, stop after idle_timeout_s without viewers.
          default: false
        idle_timeout_s:
          type: integer
          deprecated: true
          description: Stored but unused. Nodes always stop idle on demand channels after the panel setting default_idle_timeout_s.
          examples:
          - 60
          format: int32
          minimum: 5
          maximum: 86400
        ffmpeg_input_args:
          type: array
          items:
            type: string
          description: Admin only. Extra input flags from the allowlist (GET /system/ffmpeg).
          examples:
          - - -re
        ffmpeg_output_args:
          type: array
          items:
            type: string
          description: Admin only. Extra output flags from the allowlist.
        probe_size:
          type:
          - integer
          - 'null'
          description: Bytes. null uses node default.
          format: int32
        analyze_duration_ms:
          type:
          - integer
          - 'null'
          format: int32
        user_agent:
          type: string
          description: User agent sent to sources.
          examples:
          - VLC/3.0.20
        http_proxy:
          type: string
          description: Proxy for sources, http://host:port.
          examples:
          - ''
        is_adult:
          type: boolean
          description: Adult channel even in a non-adult category. Lines that hide adult content do not see it. Default false.
        custom_sid:
          type: string
          description: Enigma2 service reference override.
          examples:
          - ''
        enabled:
          type: boolean
          default: true
        position:
          type: integer
          examples:
          - 0
          format: int32
        notes:
          type: string
          examples:
          - ''
        dash_output:
          type: string
          description: 'MPEG-DASH output for this channel, on top of TS and HLS. off (default). on: packaged on the node from the same
            feed, copy only. all_qualities: every video quality of a DASH source in one manifest (a second pull from the source while
            DASH viewers watch). Lines need `mpd` in allowed_outputs.'
          examples:
          - 'off'
          enum:
          - 'off'
          - 'on'
          - all_qualities
        fast_detection:
          type: boolean
          description: Fail the source after 15 s without new video instead of 60 s, so the backup takes over sooner. For channels
            with good sources. Default false.
          examples:
          - false
        fps_restart:
          type: boolean
          description: After 10 minutes, restart the source when its frame rate falls below fps_threshold percent of the rate at
            the start (XC_VM fps_restart). Default false.
          examples:
          - false
        fps_threshold:
          type: integer
          format: int32
          minimum: 10
          maximum: 100
          description: Percent of the start frame rate for fps_restart. Default 90.
          examples:
          - 90
        audio_restart_loss:
          type: boolean
          description: Every 5 minutes, restart the source when no audio arrived for 10 s (XC_VM audio_restart_loss). Default false.
          examples:
          - false
        priority_backup:
          type: boolean
          description: While a backup source plays, go back to a better source once it works again (XC_VM priority_backup). Default
            true.
          examples:
          - true
        adaptive_variants:
          type: array
          items:
            type: integer
            format: int64
          maxItems: 10
          description: 'Adaptive HLS (XC_VM adaptive_link): live channels offered as qualities of this one, usually its sub channels.
            With at least one, `/live/U/P/{id}.m3u8` answers a master playlist (highest bitrate first) and every quality of one viewer
            shares one connection slot. Copy only, nothing is transcoded. Empty (default): one quality, as before. The channel itself
            may be listed. Not for created channels.'
          examples:
          - - 1021
            - 1022
        archive_enabled:
          type: boolean
          description: Record the channel for catch-up (TV archive). Copy only, on the archive node. Needs archive_node_id; not for
            direct channels.
        archive_days:
          type: integer
          minimum: 1
          maximum: 30
          description: Days of recording to keep (default 7). Older hours are deleted.
          format: int32
        archive_node_id:
          type:
          - integer
          - 'null'
          format: int64
          description: Node that records and serves the archive. It pulls the channel through the server tree, never from the
            source, when it does not run the channel itself.
        sources:
          type: array
          items:
            $ref: '#/components/schemas/StreamSource'
          description: Ordered sources. On create, at least one unless kind is created.
        node_ids:
          type: array
          items:
            type: integer
            format: int64
          description: 'Shortcut on create: assign these nodes as roots of the server tree.'
          writeOnly: true
          examples:
          - - 1
      required:
      - name
    StreamHealth:
      type: object
      description: Live health summary from Redis, refreshed every 5 seconds.
      properties:
        state:
          type: string
          description: Worst state across nodes. idle means on-demand and not running.
          examples:
          - running
          enum:
          - running
          - starting
          - idle
          - stopped
          - error
          - fallback
          - frozen
        color:
          type: string
          examples:
          - green
          enum:
          - green
          - yellow
          - red
          - grey
        reason:
          type: string
          description: Short explanation for yellow or red.
          examples:
          - Primary source down, running on source 2
        clients:
          type: integer
          description: Viewers across nodes.
          examples:
          - 14
          format: int32
        bitrate_kbps:
          type: integer
          examples:
          - 4800
          format: int32
      required:
      - state
      - color
      - clients
    StreamList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Stream'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    StreamNodeStats:
      type: object
      properties:
        node_id:
          type: integer
          examples:
          - 1
          format: int64
        node_name:
          type: string
          examples:
          - edge-sp-1
        state:
          type: string
          examples:
          - running
          enum:
          - running
          - starting
          - idle
          - stopped
          - error
          - fallback
          - frozen
        active_source_position:
          description: Position (0 = primary) of the source the node plays, null when it relays from a parent or is stopped.
          type:
          - integer
          - 'null'
          examples:
          - 0
          format: int32
        uptime_s:
          type: integer
          examples:
          - 86000
          format: int64
        clients:
          type: integer
          examples:
          - 9
          format: int32
        clients_hls:
          type: integer
          examples:
          - 3
          format: int32
        input_bitrate_kbps:
          type: integer
          examples:
          - 4800
          format: int32
        fps:
          type: number
          examples:
          - 50
        speed:
          type: number
          description: ffmpeg speed, 1.0 is real time.
          examples:
          - 1.0
        slow_speed:
          type: number
          description: Media speed over the last minute when it is below 0.9x (a slow source that keeps playing). Absent when the source
            keeps up.
          examples:
          - 0.82
        video_codec:
          type: string
          description: Video codec of the running program (ffmpeg name). Empty when unknown or the node is older.
          examples:
          - h264
        audio_codec:
          type: string
          description: Audio codec of the first audio track (ffmpeg name). Empty when unknown.
          examples:
          - aac
        width:
          type: integer
          description: Picture width in pixels. 0 when unknown (HEVC sizes are not read).
          examples:
          - 1920
          format: int32
        height:
          type: integer
          description: Picture height in pixels. 0 when unknown.
          examples:
          - 1080
          format: int32
        restarts_24h:
          type: integer
          examples:
          - 1
          format: int32
        last_error:
          type: string
          description: Why the stream last failed. On a backup source it says why, for example primary source failed (no data), using source 2.
          examples:
          - ''
        last_error_code:
          type: string
          description: last_error as a stable code to translate. On a backup source it is why the primary failed. Empty when there is no error or the node is too old to say.
          enum:
          - ''
          - no_data
          - frozen
          - slow
          - ended
          - refused
          - timeout
          - not_found
          - forbidden
          - http_error
          - dns
          - not_ts
          - unavailable
          examples:
          - no_data
        active_source_id:
          description: Id of the saved source the node plays (follows the source when the list is reordered). Only on /streams/{id}/stats.
          type:
          - integer
          - 'null'
          format: int64
          examples:
          - 12
        pid:
          description: ffmpeg process of the stream on this node (with cpu_pct and mem_bytes), null without one (llod, relay, stopped) or when the node is offline.
          type:
          - integer
          - 'null'
          examples:
          - 31337
          format: int32
        cpu_pct:
          type: number
          examples:
          - 1.4
        mem_bytes:
          type: integer
          examples:
          - 52428800
          format: int64
    StreamSource:
      type: object
      properties:
        id:
          type: integer
          examples:
          - 880
          format: int64
          readOnly: true
        position:
          type: integer
          description: 0 is the primary source.
          examples:
          - 0
          format: int32
          readOnly: true
        url:
          type: string
          description: Input URL. http(s), hls, rtmp, rtsp, udp (udp and private addresses only if the node allows internal sources). Stored in
            clear but redacted in logs.
          examples:
          - http://provider.example.net/live/u/p/1234.ts
          maxLength: 2048
        account_id:
          type:
          - integer
          - 'null'
          description: Provider account whose connection limit this source uses.
          examples:
          - 3
          format: int64
        headers:
          type: object
          description: Extra HTTP headers.
          properties: {}
          additionalProperties:
            type: string
          examples:
          - Referer: https://provider.example.net/
        enabled:
          type: boolean
          default: true
        variant:
          type: string
          description: DASH sources only. Representation id (quality) to pull, from the probe `qualities`. Empty pulls the best
            quality.
          examples:
          - ''
          maxLength: 128
        last_status:
          type: string
          examples:
          - unknown
          enum:
          - unknown
          - ok
          - error
          readOnly: true
        last_checked_at:
          type:
          - string
          - 'null'
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        last_error:
          type: string
          examples:
          - ''
          readOnly: true
      required:
      - url
    StreamTree:
      type: object
      description: Server tree of a stream. Every parent must be in the list; cycles are refused with `400 tree_cycle`.
      properties:
        stream_id:
          type: integer
          examples:
          - 101
          format: int64
          readOnly: true
        nodes:
          type: array
          items:
            $ref: '#/components/schemas/TreeNode'
      required:
      - nodes
    StreamUpdate:
      type: object
      description: Partial update of a Stream. Send only the fields to change.
      properties:
        name:
          type: string
          examples:
          - Sports HD
          maxLength: 255
        category_id:
          type:
          - integer
          - 'null'
          examples:
          - 4
          format: int64
        logo_url:
          type: string
          examples:
          - https://cdn.example.com/logos/sports.png
        epg_channel_id:
          type:
          - integer
          - 'null'
          description: Mapped EPG channel (see `/epg/channels`).
          examples:
          - 3021
          format: int64
        mode:
          type: string
          description: 'ffmpeg: ffmpeg copy (default). llod: Go relay without ffmpeg, HTTP MPEG-TS sources only, fastest to open. direct: clients
            are redirected to the source, no limits or stats.'
          examples:
          - ffmpeg
          enum:
          - ffmpeg
          - llod
          - direct
        on_demand:
          type: boolean
          description: Start on first viewer, stop after idle_timeout_s without viewers.
          default: false
        idle_timeout_s:
          type: integer
          deprecated: true
          description: Stored but unused. Nodes always stop idle on demand channels after the panel setting default_idle_timeout_s.
          examples:
          - 60
          format: int32
          minimum: 5
          maximum: 86400
        ffmpeg_input_args:
          type: array
          items:
            type: string
          description: Admin only. Extra input flags from the allowlist (GET /system/ffmpeg).
          examples:
          - - -re
        ffmpeg_output_args:
          type: array
          items:
            type: string
          description: Admin only. Extra output flags from the allowlist.
        probe_size:
          type:
          - integer
          - 'null'
          description: Bytes. null uses node default.
          format: int32
        analyze_duration_ms:
          type:
          - integer
          - 'null'
          format: int32
        user_agent:
          type: string
          description: User agent sent to sources.
          examples:
          - VLC/3.0.20
        http_proxy:
          type: string
          description: Proxy for sources, http://host:port.
          examples:
          - ''
        is_adult:
          type: boolean
          description: Adult channel even in a non-adult category. Lines that hide adult content do not see it. Default false.
        custom_sid:
          type: string
          description: Enigma2 service reference override.
          examples:
          - ''
        enabled:
          type: boolean
          default: true
        position:
          type: integer
          examples:
          - 0
          format: int32
        notes:
          type: string
          examples:
          - ''
        dash_output:
          type: string
          description: 'MPEG-DASH output for this channel, on top of TS and HLS. off (default). on: packaged on the node from the same
            feed, copy only. all_qualities: every video quality of a DASH source in one manifest (a second pull from the source while
            DASH viewers watch). Lines need `mpd` in allowed_outputs.'
          examples:
          - 'off'
          enum:
          - 'off'
          - 'on'
          - all_qualities
        fast_detection:
          type: boolean
          description: Fail the source after 15 s without new video instead of 60 s, so the backup takes over sooner. For channels
            with good sources. Default false.
          examples:
          - false
        fps_restart:
          type: boolean
          description: After 10 minutes, restart the source when its frame rate falls below fps_threshold percent of the rate at
            the start (XC_VM fps_restart). Default false.
          examples:
          - false
        fps_threshold:
          type: integer
          format: int32
          minimum: 10
          maximum: 100
          description: Percent of the start frame rate for fps_restart. Default 90.
          examples:
          - 90
        audio_restart_loss:
          type: boolean
          description: Every 5 minutes, restart the source when no audio arrived for 10 s (XC_VM audio_restart_loss). Default false.
          examples:
          - false
        priority_backup:
          type: boolean
          description: While a backup source plays, go back to a better source once it works again (XC_VM priority_backup). Default
            true.
          examples:
          - true
        adaptive_variants:
          type:
          - array
          - 'null'
          items:
            type: integer
            format: int64
          maxItems: 10
          description: 'Adaptive HLS (XC_VM adaptive_link): live channels offered as qualities of this one, usually its sub channels.
            With at least one, `/live/U/P/{id}.m3u8` answers a master playlist (highest bitrate first) and every quality of one viewer
            shares one connection slot. Copy only, nothing is transcoded. Empty (default): one quality, as before. The channel itself
            may be listed. Not for created channels.'
          examples:
          - - 1021
            - 1022
        archive_enabled:
          type: boolean
          description: Record the channel for catch-up (TV archive). Copy only, on the archive node. Needs archive_node_id; not for
            direct channels.
        archive_days:
          type: integer
          minimum: 1
          maximum: 30
          description: Days of recording to keep (default 7). Older hours are deleted.
          format: int32
        archive_node_id:
          type:
          - integer
          - 'null'
          format: int64
          description: Node that records and serves the archive. It pulls the channel through the server tree, never from the
            source, when it does not run the channel itself.
        sources:
          type: array
          items:
            $ref: '#/components/schemas/StreamSource'
          description: Ordered sources. On create, at least one unless kind is created.
        node_ids:
          type: array
          items:
            type: integer
            format: int64
          description: 'Shortcut on create: assign these nodes as roots of the server tree.'
          writeOnly: true
          examples:
          - - 1
      minProperties: 1
    Ticket:
      type: object
      description: A support ticket between a reseller and its parent or admins.
      properties:
        id:
          type: integer
          description: Unique id.
          examples:
          - 42
          format: int64
          readOnly: true
        user:
          $ref: '#/components/schemas/UserBrief'
          readOnly: true
        unread:
          type: integer
          examples:
          - 1
          format: int32
          readOnly: true
        messages:
          type: array
          items:
            $ref: '#/components/schemas/TicketMessage'
          description: Only in the single ticket response.
          readOnly: true
        created_at:
          type: string
          description: When the record was created.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        updated_at:
          type: string
          description: When the record was last changed.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        subject:
          type: string
          examples:
          - Channel 101 down
          maxLength: 200
        priority:
          type: string
          examples:
          - normal
          enum:
          - normal
          - low
          - high
        status:
          type: string
          description: Set by the panel on create (open).
          examples:
          - open
          enum:
          - open
          - answered
          - closed
        body:
          type: string
          description: First message, on create only.
          writeOnly: true
      required:
      - id
      - user
      - unread
      - messages
      - created_at
      - updated_at
      - subject
      - body
    TicketCreate:
      type: object
      description: Fields accepted when creating a Ticket. Omitted optional fields take the defaults shown.
      properties:
        subject:
          type: string
          examples:
          - Channel 101 down
          maxLength: 200
        priority:
          type: string
          examples:
          - normal
          enum:
          - normal
          - low
          - high
        status:
          type: string
          description: Set by the panel on create (open).
          examples:
          - open
          enum:
          - open
          - answered
          - closed
        body:
          type: string
          description: First message, on create only.
          writeOnly: true
      required:
      - subject
      - body
    TicketList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Ticket'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    TicketMessage:
      type: object
      properties:
        id:
          type: integer
          format: int64
          readOnly: true
        author:
          $ref: '#/components/schemas/UserBrief'
          readOnly: true
        body:
          type: string
          examples:
          - My lines cannot open channel 101.
          minLength: 1
          maxLength: 20000
        created_at:
          type: string
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        read_at:
          type:
          - string
          - 'null'
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
      required:
      - body
    TicketUpdate:
      type: object
      description: Partial update of a Ticket. Send only the fields to change.
      properties:
        subject:
          type: string
          examples:
          - Channel 101 down
          maxLength: 200
        priority:
          type: string
          examples:
          - normal
          enum:
          - normal
          - low
          - high
        status:
          type: string
          description: Set by the panel on create (open).
          examples:
          - open
          enum:
          - open
          - answered
          - closed
        body:
          type: string
          description: First message, on create only.
          writeOnly: true
      minProperties: 1
    TimePoint:
      type: object
      properties:
        t:
          type: string
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
        v:
          type: number
      required:
      - t
      - v
    TimeSeries:
      type: object
      properties:
        name:
          type: string
          examples:
          - tx_mbps
        points:
          type: array
          items:
            $ref: '#/components/schemas/TimePoint'
      required:
      - name
      - points
    TokenResponse:
      type: object
      properties:
        access_token:
          type: string
          description: 'EdDSA (Ed25519) JWT. Send as `Authorization: Bearer <token>`.'
          examples:
          - eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9...
        token_type:
          type: string
          examples:
          - Bearer
          const: Bearer
        expires_in:
          type: integer
          description: Seconds until the access token expires.
          examples:
          - 900
          format: int32
        user:
          $ref: '#/components/schemas/Me'
      required:
      - access_token
      - token_type
      - expires_in
      - user
    TotpCode:
      type: object
      properties:
        code:
          type: string
          description: Current 6 digit code.
          examples:
          - '492817'
          pattern: ^[0-9]{6}$
      required:
      - code
    TotpDisable:
      type: object
      properties:
        password:
          type: string
          writeOnly: true
        code:
          type: string
          description: Current TOTP code or a recovery code.
      required:
      - password
      - code
    TotpEnrollment:
      type: object
      properties:
        secret:
          type: string
          description: Base32 secret. Shown once; also encoded in otpauth_url.
          examples:
          - JBSWY3DPEHPK3PXP
        otpauth_url:
          type: string
          description: URL for authenticator apps (render as QR code).
          examples:
          - otpauth://totp/Bitstream:admin?secret=JBSWY3DPEHPK3PXP&issuer=Bitstream
      required:
      - secret
      - otpauth_url
    TreeNode:
      type: object
      properties:
        node_id:
          type: integer
          examples:
          - 2
          format: int64
        parent_node_id:
          type:
          - integer
          - 'null'
          description: 'null: pulls from the sources. Otherwise relays from that node.'
          examples:
          - 1
          format: int64
        may_pull_source:
          type: boolean
          description: If all ancestors fail, pull from the sources directly.
          default: false
        desired_state:
          type: string
          examples:
          - running
          enum:
          - running
          - stopped
        node_name:
          type: string
          examples:
          - edge-sp-1
          readOnly: true
        status:
          type: string
          examples:
          - running
          enum:
          - running
          - starting
          - idle
          - stopped
          - error
          readOnly: true
      required:
      - node_id
    TuningSuggestion:
      type: object
      properties:
        id:
          type: string
          description: Stable rule id.
          examples:
          - cpu_high_ffmpeg
        severity:
          type: string
          examples:
          - info
          enum:
          - info
          - warning
          - critical
        title:
          type: string
          examples:
          - CPU above 85% for the last hour
        detail:
          type: string
          description: Markdown with the evidence and what to do.
          examples:
          - Switch the 40 HTTP TS streams listed below to `llod` mode...
        action:
          type:
          - object
          - 'null'
          description: Optional API call that applies the suggestion.
          properties:
            method:
              type: string
              examples:
              - POST
            path:
              type: string
              examples:
              - /api/v1/streams/bulk
            body:
              type: object
              properties: {}
              additionalProperties: true
      required:
      - id
      - severity
      - title
      - detail
    User:
      type: object
      description: 'A panel user: admin or reseller. Resellers form a tree; a reseller sees itself and its descendants only.'
      properties:
        id:
          type: integer
          description: Unique id.
          examples:
          - 42
          format: int64
          readOnly: true
        credits:
          type: integer
          description: Credit balance.
          examples:
          - 250
          format: int64
          readOnly: true
        totp_enabled:
          type: boolean
          readOnly: true
        line_count:
          type: integer
          description: Lines owned directly.
          examples:
          - 87
          format: int64
          readOnly: true
        last_login_at:
          type:
          - string
          - 'null'
          description: RFC 3339 timestamp in UTC.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        last_login_ip:
          type:
          - string
          - 'null'
          examples:
          - 203.0.113.7
          readOnly: true
        created_at:
          type: string
          description: When the record was created.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        updated_at:
          type: string
          description: When the record was last changed.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        username:
          type: string
          examples:
          - reseller_ana
          minLength: 3
          maxLength: 64
        password:
          type: string
          description: Write only. Minimum 10 characters.
          minLength: 10
          maxLength: 1024
          writeOnly: true
        email:
          type:
          - string
          - 'null'
          examples:
          - ana@example.com
          format: email
        role:
          type: string
          description: Resellers can only create resellers.
          examples:
          - reseller
          enum:
          - reseller
          - admin
        group_id:
          type: integer
          description: User group, which sets permissions and limits.
          examples:
          - 3
          format: int64
        parent_id:
          type:
          - integer
          - 'null'
          description: Parent reseller. Defaults to the caller for resellers; null for top level.
          examples:
          - 5
          format: int64
        enabled:
          type: boolean
          default: true
        locale:
          type: string
          examples:
          - en
          enum:
          - en
          - pt-BR
          - es
        notes:
          type: string
          description: Private notes, visible to the parent chain and admins. Empty on a reseller's own record.
          examples:
          - ''
      required:
      - id
      - credits
      - totp_enabled
      - line_count
      - last_login_at
      - last_login_ip
      - created_at
      - updated_at
      - username
      - password
      - role
      - group_id
    UserBrief:
      type: object
      properties:
        id:
          type: integer
          examples:
          - 1
          format: int64
        username:
          type: string
          examples:
          - admin
        role:
          type: string
          examples:
          - admin
          enum:
          - admin
          - reseller
      required:
      - id
      - username
      - role
    UserBriefLine:
      type: object
      properties:
        id:
          type: integer
          examples:
          - 812
          format: int64
        username:
          type: string
          examples:
          - joao2291
        owner_id:
          type: integer
          examples:
          - 5
          format: int64
      required:
      - id
      - username
    UserCreate:
      type: object
      description: Fields accepted when creating a User. Omitted optional fields take the defaults shown.
      properties:
        username:
          type: string
          examples:
          - reseller_ana
          minLength: 3
          maxLength: 64
        password:
          type: string
          description: Write only. Minimum 10 characters.
          minLength: 10
          maxLength: 1024
          writeOnly: true
        email:
          type:
          - string
          - 'null'
          examples:
          - ana@example.com
          format: email
        role:
          type: string
          description: Resellers can only create resellers.
          examples:
          - reseller
          enum:
          - reseller
          - admin
        group_id:
          type: integer
          description: User group, which sets permissions and limits.
          examples:
          - 3
          format: int64
        parent_id:
          type:
          - integer
          - 'null'
          description: Parent reseller. Defaults to the caller for resellers; null for top level.
          examples:
          - 5
          format: int64
        enabled:
          type: boolean
          default: true
        locale:
          type: string
          examples:
          - en
          enum:
          - en
          - pt-BR
          - es
        notes:
          type: string
          description: Private notes, visible to the parent chain and admins.
          examples:
          - ''
      required:
      - username
      - password
      - role
      - group_id
    UserGroup:
      type: object
      description: Permission group for panel users.
      properties:
        id:
          type: integer
          description: Unique id.
          examples:
          - 42
          format: int64
          readOnly: true
        member_count:
          type: integer
          examples:
          - 12
          format: int64
          readOnly: true
        created_at:
          type: string
          description: When the record was created.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        updated_at:
          type: string
          description: When the record was last changed.
          examples:
          - '2026-11-28T14:30:00Z'
          format: date-time
          readOnly: true
        name:
          type: string
          examples:
          - Gold resellers
          maxLength: 64
        role:
          type: string
          description: Which kind of user the group is for.
          examples:
          - reseller
          enum:
          - reseller
          - admin
        permissions:
          type: array
          items:
            type: string
          description: Permission strings. See `GET /system/permissions`.
          examples:
          - - lines:read
            - lines:write
            - connections:read
        require_2fa:
          type: boolean
          default: false
        limits:
          $ref: '#/components/schemas/ResellerLimits'
        description:
          type: string
          description: What the role is for.
          maxLength: 500
          examples:
          - Helps clients with lines and tickets.
        builtin:
          type:
          - string
          - 'null'
          description: Built-in role key. `owner` cannot be changed; other built-ins cannot be renamed or deleted.
          enum:
          - owner
          - administrator
          - support
          - finance
          - content
          - operations
          - null
          readOnly: true
      required:
      - id
      - member_count
      - created_at
      - updated_at
      - name
      - role
    UserGroupCreate:
      type: object
      description: Fields accepted when creating a UserGroup. Omitted optional fields take the defaults shown.
      properties:
        name:
          type: string
          examples:
          - Gold resellers
          maxLength: 64
        role:
          type: string
          description: Which kind of user the group is for.
          examples:
          - reseller
          enum:
          - reseller
          - admin
        permissions:
          type: array
          items:
            type: string
          description: Permission strings. See `GET /system/permissions`.
          examples:
          - - lines:read
            - lines:write
            - connections:read
        require_2fa:
          type: boolean
          default: false
        limits:
          $ref: '#/components/schemas/ResellerLimits'
        description:
          type: string
          description: What the role is for.
          maxLength: 500
      required:
      - name
      - role
    UserGroupList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/UserGroup'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    UserGroupUpdate:
      type: object
      description: Partial update of a UserGroup. Send only the fields to change.
      properties:
        name:
          type: string
          examples:
          - Gold resellers
          maxLength: 64
        role:
          type: string
          description: Which kind of user the group is for.
          examples:
          - reseller
          enum:
          - reseller
          - admin
        permissions:
          type: array
          items:
            type: string
          description: Permission strings. See `GET /system/permissions`.
          examples:
          - - lines:read
            - lines:write
            - connections:read
        require_2fa:
          type: boolean
          default: false
        limits:
          $ref: '#/components/schemas/ResellerLimits'
        description:
          type: string
          description: What the role is for.
          maxLength: 500
      minProperties: 1
    RoleCreate:
      type: object
      description: A staff role. Permissions must be ones you hold; sensitive ones need the Owner or `roles:delegate`.
      properties:
        name:
          type: string
          maxLength: 64
          examples:
          - Night support
        description:
          type: string
          description: What the role is for.
          maxLength: 500
        permissions:
          type: array
          items:
            type: string
          description: Permission strings. See `GET /system/permissions`.
          examples:
          - - lines:read
            - tickets:read
        require_2fa:
          type: boolean
          default: false
      required:
      - name
    RoleUpdate:
      type: object
      description: Partial update of a role. Send only the fields to change.
      properties:
        name:
          type: string
          maxLength: 64
        description:
          type: string
          description: What the role is for.
          maxLength: 500
        permissions:
          type: array
          items:
            type: string
        require_2fa:
          type: boolean
      minProperties: 1
    RoleClone:
      type: object
      properties:
        name:
          type: string
          maxLength: 64
          examples:
          - Support (copy)
      required:
      - name
    UserList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/User'
        meta:
          $ref: '#/components/schemas/PageMeta'
      required:
      - data
      - meta
    UserUpdate:
      type: object
      description: Partial update of a User. Send only the fields to change.
      properties:
        username:
          type: string
          examples:
          - reseller_ana
          minLength: 3
          maxLength: 64
        password:
          type: string
          description: Write only. Minimum 10 characters.
          minLength: 10
          maxLength: 1024
          writeOnly: true
        email:
          type:
          - string
          - 'null'
          examples:
          - ana@example.com
          format: email
        role:
          type: string
          description: Resellers can only create resellers.
          examples:
          - reseller
          enum:
          - reseller
          - admin
        group_id:
          type: integer
          description: User group, which sets permissions and limits.
          examples:
          - 3
          format: int64
        parent_id:
          type:
          - integer
          - 'null'
          description: Parent reseller. Defaults to the caller for resellers; null for top level.
          examples:
          - 5
          format: int64
        enabled:
          type: boolean
          default: true
        locale:
          type: string
          examples:
          - en
          enum:
          - en
          - pt-BR
          - es
        notes:
          type: string
          description: Private notes, visible to the parent chain and admins.
          examples:
          - ''
      minProperties: 1
    XcvmImportRequest:
      type: object
      description: Migrate from an XC_VM (or Xtream UI) MySQL database. Reseller passwords cannot be migrated (different hashing); resellers get
        a reset link.
      properties:
        host:
          type: string
          examples:
          - 10.0.0.5
        port:
          type: integer
          examples:
          - 3306
          format: int32
        database:
          type: string
          examples:
          - xc_vm
        username:
          type: string
          examples:
          - readonly
        password:
          type: string
          description: Kept encrypted only for the job lifetime.
          writeOnly: true
        include:
          type: array
          items:
            type: string
            examples:
            - users
            enum:
            - users
            - groups
            - packages
            - lines
            - bouquets
            - categories
            - streams
            - movies
            - series
            - epg
            - blocklists
          examples:
          - - users
            - packages
            - lines
            - bouquets
            - categories
            - streams
        keep_ids:
          type: boolean
          description: Keep XC_VM stream and line ids so existing app favourites and playlists keep working. Needs an empty catalogue.
          default: true
        dry_run:
          type: boolean
          default: false
      required:
      - host
      - database
      - username
      - password
      - include
    ModuleFilterHook:
      type: object
      properties:
        name:
          type: string
          enum:
          - playlist
          - player_api
          - play.authorize
        fail_closed:
          type: boolean
          description: When the module fails, refuse instead of skipping it.
        timeout_ms:
          type: integer
      required:
      - name
      - fail_closed
      - timeout_ms
    ModuleJob:
      type: object
      properties:
        name:
          type: string
        cron:
          type: string
      required:
      - name
      - cron
    ModuleManifestInfo:
      type: object
      description: What the package says about itself.
      properties:
        id:
          type: string
          pattern: ^[a-z][a-z0-9_]{1,31}$
        name:
          type: string
        version:
          type: string
        description:
          type: string
        author:
          type: string
        license:
          type: string
        bitstream:
          type: string
          description: Supported Bitstream versions (semver range).
        permissions:
          type: array
          items:
            type: string
          description: Admin API scopes plus `client_routes`.
        filters:
          type: array
          items:
            $ref: '#/components/schemas/ModuleFilterHook'
        events:
          type: array
          items:
            type: string
        jobs:
          type: array
          items:
            $ref: '#/components/schemas/ModuleJob'
        has_backend:
          type: boolean
        has_ui:
          type: boolean
        settings_schema:
          type: object
          additionalProperties: true
          description: JSON Schema of the settings form.
        i18n:
          type: object
          additionalProperties:
            type: object
            additionalProperties: true
          description: Module strings per locale (en, pt-BR, es).
        signed:
          type: boolean
        publisher:
          type:
          - string
          - 'null'
          description: Name of the trusted key that signed it.
      required:
      - id
      - name
      - version
      - description
      - author
      - license
      - bitstream
      - permissions
      - filters
      - events
      - jobs
      - has_backend
      - has_ui
      - settings_schema
      - i18n
      - signed
      - publisher
    Module:
      allOf:
      - $ref: '#/components/schemas/ModuleManifestInfo'
      - type: object
        properties:
          enabled:
            type: boolean
          state:
            type: string
            enum:
            - running
            - starting
            - stopped
            - crashed
            - disabled
            - safe_mode
            description: '`stopped` when an enabled module is not loaded (between restarts). A module without a backend part is `running` once loaded.'
          disabled_reason:
            type: string
            description: Empty, or why it was turned off automatically (`crashed`, `timeouts`, `errors`).
          last_error:
            type: string
          settings:
            type: object
            additionalProperties: true
          installed_at:
            type: string
            format: date-time
          updated_at:
            type: string
            format: date-time
        required:
        - enabled
        - state
        - disabled_reason
        - last_error
        - settings
        - installed_at
        - updated_at
    ModuleReview:
      allOf:
      - $ref: '#/components/schemas/ModuleManifestInfo'
      - type: object
        properties:
          installed_version:
            type:
            - string
            - 'null'
            description: Set when this would upgrade an installed module.
          problems:
            type: array
            description: Codes that block the install (unsigned, untrusted_key, bad_signature, incompatible, downgrade, already_installed, no_backend_for_platform).
            items:
              type: string
          warnings:
            type: array
            description: Codes worth a look (unsigned_developer_mode, client_routes, fail_closed).
            items:
              type: string
        required:
        - installed_version
        - problems
        - warnings
    ModuleTrustedKey:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 60
        key:
          type: string
          description: Base64 ed25519 public key (32 bytes).
      required:
      - name
      - key
    ModulesConfig:
      type: object
      properties:
        safe_mode:
          type: boolean
          description: Panel switch.
        safe_mode_env:
          type: boolean
          description: BS_MODULES_SAFE_MODE=1 is set; the panel switch cannot turn it off.
        developer_mode:
          type: boolean
          description: Allows unsigned packages.
        trusted_keys:
          type: array
          items:
            $ref: '#/components/schemas/ModuleTrustedKey'
      required:
      - safe_mode
      - safe_mode_env
      - developer_mode
      - trusted_keys
    ModuleUI:
      type: object
      properties:
        id:
          type: string
        version:
          type: string
        url:
          type: string
          description: Path of the bundle, relative to the panel origin.
        integrity:
          type: string
          description: Subresource Integrity value (sha256-...).
        permissions:
          type: array
          items:
            type: string
        settings:
          type: object
          additionalProperties: true
        i18n:
          type: object
          additionalProperties:
            type: object
            additionalProperties: true
      required:
      - id
      - version
      - url
      - integrity
      - permissions
      - settings
      - i18n
    ModuleHookStats:
      type: object
      properties:
        calls:
          type: integer
        errors:
          type: integer
        timeouts:
          type: integer
        p95_ms:
          type: number
      required:
      - calls
      - errors
      - timeouts
      - p95_ms
    ModuleHealth:
      type: object
      properties:
        state:
          type: string
        pid:
          type: integer
        started_at:
          type:
          - string
          - 'null'
          format: date-time
        restarts:
          type: integer
        consecutive_failures:
          type: integer
        last_error:
          type: string
        last_error_at:
          type:
          - string
          - 'null'
          format: date-time
        total:
          $ref: '#/components/schemas/ModuleHookStats'
        hooks:
          type: object
          description: Per call kind (`filter:playlist`, `event`, `http`, `job:<name>`).
          additionalProperties:
            $ref: '#/components/schemas/ModuleHookStats'
      required:
      - state
      - pid
      - started_at
      - restarts
      - consecutive_failures
      - last_error
      - last_error_at
      - total
      - hooks
    ModuleLogLine:
      type: object
      properties:
        at:
          type: string
          format: date-time
        level:
          type: string
          enum:
          - debug
          - info
          - warn
          - error
        msg:
          type: string
      required:
      - at
      - level
      - msg
