openapi: 3.1.0
info:
  title: Fret API
  version: 1.0.0
  description: |
    Everything the interface does goes through this JSON API, which you can use from scripts, home
    automation or your own tools. The [command line](/use/command-line/) uses it too.

    - **Format**: JSON in and out, dates in RFC 3339 (`2026-11-12T14:02:00Z`), sizes in bytes (`-1`
      when unknown), speeds in bytes per second.
    - **Vocabulary**: the API uses the technical words. A shipment is a `package`, a parcel a `file`,
      the dock the `queue`, a carrier a `hoster`, a forwarder a `debrid` (see the
      [glossary](/reference/glossary/)).
    - **Parcels** are identified by their numeric `id` or by their number: `/files/42` and
      `/files/FR-0042` are the same parcel.
    - **Credentials**: an API token in `Authorization: Bearer fret_…`, created in **Settings › API
      tokens**, or the session cookie of the interface. With `FRET_AUTH=none`, none. Without valid
      credentials, private operations answer `401 unauthorized`.
    - **Cross-site requests**: requests that change something and come from another website (browser
      header `Sec-Fetch-Site: cross-site`) are refused. Scripts and command-line tools are not affected.

    ## Errors

    An error answers with an HTTP status and a body:

    ```json
    { "error": { "code": "invalid_state", "message": "action not possible in the file's current state" } }
    ```

    The `code` is stable and meant for programs; the `message` is plain English, for humans.

    | Code | Status | Meaning |
    | --- | --- | --- |
    | `bad_json`, `invalid_input`, `invalid_name`, `invalid_settings` | 400 | The request is malformed or a value is out of bounds |
    | `unknown_plugin` | 400 | No carrier or forwarder by this name |
    | `weak_password` | 400 | Password shorter than 8 characters |
    | `unauthorized` | 401 | Sign-in or token required |
    | `bad_credentials` | 401 | Wrong password |
    | `not_found` | 404 | No such resource, or no such API route |
    | `invalid_state` | 409 | Not possible in the current state of the parcel or shipment |
    | `not_storable` | 409 | The shipment still has parcels that are not delivered |
    | `setup_required` | 409 | No password set yet |
    | `already_set_up` | 409 | The password is already set |
    | `auth_disabled` | 409 | Not available with `FRET_AUTH=none` |
    | `too_large` | 413 | Request body too large |
    | `too_many_attempts` | 429 | Too many sign-in attempts, wait a minute |
    | `internal` | 500 | Unexpected error, see the logs |

    ## Live events

    [`GET /events`](/api/dock/get-events/) is a
    [Server-Sent Events](https://html.spec.whatwg.org/multipage/server-sent-events.html) stream: the
    interface uses it to update the dock live.

    ```sh
    curl -N -H "Authorization: Bearer $TOKEN" http://localhost:8080/api/v1/events
    ```

    The first event is `hello` (`{"version": "1.0.0"}`). Every other event comes under its type, with a
    JSON envelope `{id, type, at, data}`:

    | Event | `data` | When |
    | --- | --- | --- |
    | `queue.state` | [`QueueState`](/api/schemas/queue-state/) | Settings, open/closed state, gauge, active transfers |
    | `queue.reordered` | `{}` | The order of the shipments changed: reload `/queue` |
    | `package.updated` | [`Package`](/api/schemas/package/) | A shipment was created or changed |
    | `package.removed` | `{id}` | A shipment was deleted |
    | `package.stored` | `{id}` | A shipment left the dock for the warehouse |
    | `file.updated` | [`File`](/api/schemas/file/) | A parcel changed status or information |
    | `file.removed` | `{id, packageId}` | A parcel was deleted |
    | `progress` | [`Progress`](/api/schemas/progress/) | Progress of the running transfers, 4 times per second |

    A `: ping` comment every 25 seconds keeps the connection open, and `retry: 3000` asks the client to
    reconnect after 3 seconds if it drops. Events are not replayed: after a reconnection, read `/queue`
    again.
  license:
    name: AGPL-3.0-only
    identifier: AGPL-3.0-only
servers:
  - url: /api/v1
security:
  - session: []
  - token: []
tags:
  - name: access
    x-displayName: Access
    description: First run, sign-in, sessions and API tokens.
  - name: dock
    x-displayName: The dock
    description: The state of the dock and its live event stream.
  - name: shipments
    x-displayName: Shipments
    description: Create, reorder, hold and delete shipments (`package`).
  - name: parcels
    x-displayName: Parcels
    description: One parcel (`file`) with its segments and tracking history.
  - name: warehouse
    x-displayName: Warehouse
    description: Store delivered shipments, search the register, read the stock.
  - name: carriers
    x-displayName: Carriers and accounts
    description: Carriers, forwarders, their accounts and the check of links.
  - name: settings
    x-displayName: Settings
    description: Dock, unpacking and collection settings.

paths:
  /health:
    get:
      operationId: getHealth
      tags: [access]
      summary: Server health
      security: []
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  status: { type: string, const: ok }
                  version: { type: string }

  /auth/state:
    get:
      operationId: getAuthState
      tags: [access]
      summary: Authentication state
      security: []
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema: { $ref: "#/components/schemas/AuthState" }

  /auth/setup:
    post:
      operationId: postAuthSetup
      tags: [access]
      summary: "First run: sets the password and opens a session"
      security: []
      requestBody: { $ref: "#/components/requestBodies/Password" }
      responses:
        "201": { $ref: "#/components/responses/AuthState" }
        "400": { $ref: "#/components/responses/Error" }
        "409": { $ref: "#/components/responses/Error" }

  /auth/login:
    post:
      operationId: postAuthLogin
      tags: [access]
      summary: Sign in (5 attempts, then 1 per minute and per IP address)
      security: []
      requestBody: { $ref: "#/components/requestBodies/Password" }
      responses:
        "200": { $ref: "#/components/responses/AuthState" }
        "401": { $ref: "#/components/responses/Error" }
        "429": { $ref: "#/components/responses/Error" }

  /auth/logout:
    post:
      operationId: postAuthLogout
      tags: [access]
      summary: Sign out
      security: []
      responses:
        "204": { description: "Session closed" }

  /auth/password:
    post:
      operationId: postAuthPassword
      tags: [access]
      summary: Changes the password and closes every session
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [current, next]
              properties:
                current: { type: string }
                next: { type: string, minLength: 8 }
      responses:
        "204": { description: "Password changed" }
        "400": { $ref: "#/components/responses/Error" }
        "401": { $ref: "#/components/responses/Error" }

  /tokens:
    get:
      operationId: getTokens
      tags: [access]
      summary: API tokens
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  tokens: { type: array, items: { $ref: "#/components/schemas/ApiToken" } }
    post:
      operationId: postTokens
      tags: [access]
      summary: Creates a token (its value is only returned here)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [name]
              properties:
                name: { type: string, maxLength: 60 }
      responses:
        "201":
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  token: { $ref: "#/components/schemas/ApiToken" }
                  secret: { type: string, example: fret_q_lsMtbKa-… }

  /tokens/{id}:
    delete:
      operationId: deleteTokensById
      tags: [access]
      summary: Revokes a token
      parameters: [{ $ref: "#/components/parameters/Id" }]
      responses:
        "204": { description: "Revoked" }
        "404": { $ref: "#/components/responses/Error" }

  /events:
    get:
      operationId: getEvents
      tags: [dock]
      summary: Event stream (Server-Sent Events)
      description: |
        First event `hello` ({version}), then each event under its type, with as data
        `{id, type, at, data}`:

        | Type | data |
        | --- | --- |
        | `queue.state` | QueueState |
        | `queue.reordered` | {} (reload the dock) |
        | `package.updated` | Package |
        | `package.removed` | {id} |
        | `package.stored` | {id} (the shipment left the dock for the warehouse) |
        | `file.updated` | File |
        | `file.removed` | {id, packageId} |
        | `progress` | Progress (4 times per second during transfers) |

        A `: ping` comment every 25 s keeps the connection open.
      responses:
        "200":
          description: Event stream
          content:
            text/event-stream:
              schema: { type: string }

  /queue:
    get:
      operationId: getQueue
      tags: [dock]
      summary: Full state of the dock
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  state: { $ref: "#/components/schemas/QueueState" }
                  packages: { type: array, items: { $ref: "#/components/schemas/Package" } }

  /packages:
    post:
      operationId: postPackages
      tags: [shipments]
      summary: New shipment
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [links]
              properties:
                links:
                  type: array
                  description: http(s) links; an entry may hold several, separated by whitespace.
                  items: { type: string }
                name: { type: string, maxLength: 120, description: "Empty: the file name for a single link; a shipment of several links stays unnamed" }
                dir: { type: string, description: "Warehouse subfolder (without \"..\")" }
                priority: { $ref: "#/components/schemas/Priority" }
                password: { type: string, description: "Protected links and archives" }
      responses:
        "201":
          description: Created
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Package" }
        "400": { $ref: "#/components/responses/Error" }

  /packages/{id}:
    parameters: [{ $ref: "#/components/parameters/Id" }]
    patch:
      operationId: patchPackagesById
      tags: [shipments]
      summary: Renames, changes the priority of or moves a shipment
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name: { type: string }
                priority: { $ref: "#/components/schemas/Priority" }
                position: { type: integer, minimum: 0, description: "New place at the dock" }
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Package" }
        "404": { $ref: "#/components/responses/Error" }
    delete:
      operationId: deletePackagesById
      tags: [shipments]
      summary: Deletes a shipment (delivered files stay in the warehouse unless files=true)
      parameters:
        - name: files
          in: query
          description: >-
            true also deletes what the shipment put in the warehouse: its delivered parcels and what
            their unpacking placed (parcels "already in the warehouse" belong to another shipment and are
            kept); folders left empty are removed. Refused (409) while a parcel is moving.
          schema: { type: boolean }
      responses:
        "204": { description: "Deleted" }
        "409": { $ref: "#/components/responses/Error" }

  /packages/{id}/store:
    post:
      operationId: postPackagesStore
      tags: [warehouse]
      summary: Stores a delivered shipment in the warehouse now
      description: Every parcel must be delivered or already in the warehouse; otherwise 409 not_storable.
      parameters: [{ $ref: "#/components/parameters/Id" }]
      responses:
        "204": { description: "Stored (or already stored)" }
        "404": { $ref: "#/components/responses/Error" }
        "409": { $ref: "#/components/responses/Error" }

  /warehouse:
    get:
      operationId: getWarehouse
      tags: [warehouse]
      summary: Register of the stored shipments, most recent first
      parameters:
        - { name: q, in: query, schema: { type: string }, description: "Searched in shipment names, parcel names and links; a parcel number (FR-0042) also matches" }
        - { name: carrier, in: query, schema: { type: string }, description: "Carrier name (plugin), e.g. mega" }
        - { name: period, in: query, schema: { type: string, enum: [7d, 30d, all] }, description: "Stored within; all by default" }
        - { name: offset, in: query, schema: { type: integer, minimum: 0 } }
        - { name: limit, in: query, schema: { type: integer, minimum: 1, maximum: 100, default: 25 } }
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  total: { type: integer, description: "Matching shipments, all pages" }
                  packages: { type: array, items: { $ref: "#/components/schemas/Package" } }
        "400": { $ref: "#/components/responses/Error" }
  /warehouse/stock:
    get:
      operationId: getWarehouseStock
      tags: [warehouse]
      summary: State of the warehouse (disk, stock, this week, heaviest folders)
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Stock" }
  /warehouse/store:
    post:
      operationId: postWarehouseStore
      tags: [warehouse]
      summary: Stores every delivered shipment now
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  stored: { type: integer, description: "Shipments that left the dock" }

  /packages/{id}/pause:
    post:
      operationId: postPackagesPause
      tags: [shipments]
      summary: Holds every parcel of the shipment
      parameters: [{ $ref: "#/components/parameters/Id" }]
      responses: { "204": { description: "OK" } }
  /packages/{id}/resume:
    post:
      operationId: postPackagesResume
      tags: [shipments]
      summary: Releases the held parcels of the shipment
      parameters: [{ $ref: "#/components/parameters/Id" }]
      responses: { "204": { description: "OK" } }
  /packages/{id}/confirm:
    post:
      operationId: postPackagesConfirm
      tags: [shipments]
      summary: Ships a collected shipment awaiting confirmation
      parameters: [{ $ref: "#/components/parameters/Id" }]
      responses: { "204": { description: "OK" } }
  /packages/{id}/unpack:
    post:
      operationId: postPackagesUnpack
      tags: [shipments]
      summary: Unpacks again, with an optional new password
      parameters: [{ $ref: "#/components/parameters/Id" }]
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                password: { type: string }
      responses:
        "202": { description: "Unpacking restarted" }

  /files/{id}:
    parameters: [{ $ref: "#/components/parameters/FileId" }]
    get:
      operationId: getFilesById
      tags: [parcels]
      summary: Parcel detail (shipment, segments, history)
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema: { $ref: "#/components/schemas/FileDetail" }
        "404": { $ref: "#/components/responses/Error" }
    delete:
      operationId: deleteFilesById
      tags: [parcels]
      summary: Removes a parcel (deletes the partial file; a delivered parcel stays in the warehouse)
      responses:
        "204": { description: "Deleted" }

  /files/{id}/pause:
    post:
      operationId: postFilesPause
      tags: [parcels]
      summary: Holds a parcel (a running transfer keeps its progress)
      parameters: [{ $ref: "#/components/parameters/FileId" }]
      responses:
        "200": { $ref: "#/components/responses/File" }
        "409": { $ref: "#/components/responses/Error" }
  /files/{id}/resume:
    post:
      operationId: postFilesResume
      tags: [parcels]
      summary: Releases a parcel or sends it back to the dock
      parameters: [{ $ref: "#/components/parameters/FileId" }]
      responses:
        "200": { $ref: "#/components/responses/File" }
        "409": { $ref: "#/components/responses/Error" }

  /links/check:
    post:
      operationId: postLinksCheck
      tags: [carriers]
      summary: Checks the availability of links (100 at most)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                links: { type: array, items: { type: string } }
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  results: { type: array, items: { $ref: "#/components/schemas/CheckResult" } }

  /carriers:
    get:
      operationId: getCarriers
      tags: [carriers]
      summary: Carriers and forwarders, with their accounts
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  debrids: { type: array, items: { $ref: "#/components/schemas/Carrier" } }
                  hosters: { type: array, items: { $ref: "#/components/schemas/Carrier" } }

  /accounts:
    post:
      operationId: postAccounts
      tags: [carriers]
      summary: Adds an account (checked right away)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [plugin, apiKey]
              properties:
                plugin: { type: string, examples: [alldebrid, realdebrid, 1fichier, rapidgator] }
                label: { type: string }
                login:
                  type: string
                  description: "User name, for services whose credentials are login_password or login_key"
                apiKey: { type: string, writeOnly: true, description: "API key, token, premium key or password" }
      responses:
        "201": { $ref: "#/components/responses/Account" }
        "400": { $ref: "#/components/responses/Error" }

  /accounts/{id}:
    parameters: [{ $ref: "#/components/parameters/Id" }]
    patch:
      operationId: patchAccountsById
      tags: [carriers]
      summary: Edits an account (a new key is checked)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                label: { type: string }
                enabled: { type: boolean }
                login: { type: string, description: "New user name (sent with apiKey)" }
                apiKey: { type: string, writeOnly: true }
      responses:
        "200": { $ref: "#/components/responses/Account" }
    delete:
      operationId: deleteAccountsById
      tags: [carriers]
      summary: Deletes an account
      responses:
        "204": { description: "Deleted" }

  /accounts/{id}/check:
    post:
      operationId: postAccountsCheck
      tags: [carriers]
      summary: Checks an account with the service
      parameters: [{ $ref: "#/components/parameters/Id" }]
      responses:
        "200": { $ref: "#/components/responses/Account" }

  /settings/queue:
    get:
      operationId: getSettingsQueue
      tags: [settings]
      summary: Dock settings
      responses:
        "200": { $ref: "#/components/responses/QueueSettings" }
    put:
      operationId: putSettingsQueue
      tags: [settings]
      summary: Edits the dock settings (missing fields unchanged)
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/QueueSettings" }
      responses:
        "200": { $ref: "#/components/responses/QueueSettings" }
        "400": { $ref: "#/components/responses/Error" }

  /settings/unpack:
    get:
      operationId: getSettingsUnpack
      tags: [settings]
      summary: Unpacking settings
      responses:
        "200": { $ref: "#/components/responses/UnpackSettings" }
    put:
      operationId: putSettingsUnpack
      tags: [settings]
      summary: Edits the unpacking settings
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/UnpackSettings" }
      responses:
        "200": { $ref: "#/components/responses/UnpackSettings" }

  /settings/collect:
    get:
      operationId: getSettingsCollect
      tags: [settings]
      summary: Click'n'Load collection settings
      responses:
        "200": { $ref: "#/components/responses/CollectSettings" }
    put:
      operationId: putSettingsCollect
      tags: [settings]
      summary: Edits the collection settings
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/CollectSettings" }
      responses:
        "200": { $ref: "#/components/responses/CollectSettings" }

components:
  securitySchemes:
    session:
      type: apiKey
      in: cookie
      name: fret_session
    token:
      type: http
      scheme: bearer
      description: Token created in Settings › API tokens

  parameters:
    Id:
      name: id
      in: path
      required: true
      schema: { type: integer }
    FileId:
      name: id
      in: path
      required: true
      description: Numeric id or parcel number (FR-0042)
      schema: { type: string, examples: ["42", FR-0042] }

  requestBodies:
    Password:
      required: true
      content:
        application/json:
          schema:
            type: object
            required: [password]
            properties:
              password: { type: string }

  responses:
    Error:
      description: Error
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: object
                properties:
                  code: { type: string, examples: [not_found, invalid_state, bad_credentials] }
                  message: { type: string }
    AuthState:
      description: OK
      content:
        application/json:
          schema: { $ref: "#/components/schemas/AuthState" }
    File:
      description: Parcel
      content:
        application/json:
          schema: { $ref: "#/components/schemas/File" }
    Account:
      description: Account
      content:
        application/json:
          schema: { $ref: "#/components/schemas/Account" }
    QueueSettings:
      description: Dock settings
      content:
        application/json:
          schema: { $ref: "#/components/schemas/QueueSettings" }
    UnpackSettings:
      description: Unpacking settings
      content:
        application/json:
          schema: { $ref: "#/components/schemas/UnpackSettings" }
    CollectSettings:
      description: Collection settings
      content:
        application/json:
          schema: { $ref: "#/components/schemas/CollectSettings" }

  schemas:
    AuthState:
      type: object
      properties:
        mode: { type: string, enum: [password, none] }
        setupRequired: { type: boolean }
        authenticated: { type: boolean }

    ApiToken:
      type: object
      properties:
        id: { type: integer }
        name: { type: string }
        prefix: { type: string, description: "Start of the token, to recognise it" }
        createdAt: { type: string, format: date-time }
        lastUsedAt: { type: [string, "null"], format: date-time }

    Status:
      type: string
      description: "Parcel status, see [Statuses](/reference/statuses/)"
      enum: [queued, resolving, waiting, downloading, retrying, paused, verifying, extracting, finished, offline, corrupted, duplicate]

    Priority:
      type: string
      enum: [express, standard, night]

    File:
      type: object
      properties:
        id: { type: integer }
        number: { type: string, examples: [FR-0042] }
        packageId: { type: integer }
        url: { type: string }
        name: { type: string }
        subdir:
          type: string
          description: "Place in a consignment's folder tree, inside the shipment's warehouse folder; empty at its root"
        size: { type: integer, description: "-1 when unknown" }
        received: { type: integer }
        speed: { type: integer, description: "bytes/s" }
        hoster: { type: string }
        debrid: { type: string }
        status: { $ref: "#/components/schemas/Status" }
        error: { type: string }
        attempts: { type: integer }
        waitUntil: { type: [string, "null"], format: date-time }
        unpacked: { type: boolean }
        unpackError: { type: string }
        createdAt: { type: string, format: date-time }
        updatedAt: { type: string, format: date-time }

    Package:
      type: object
      properties:
        id: { type: integer }
        name: { type: string, description: "Empty for an unnamed shipment of several parcels: the client words it (\"Shipment of 3 parcels\")" }
        dir: { type: string }
        priority: { $ref: "#/components/schemas/Priority" }
        position: { type: integer }
        held: { type: boolean, description: "Collected, awaiting confirmation" }
        source: { type: string, examples: ["", collect] }
        createdAt: { type: string, format: date-time }
        storedAt:
          type: [string, "null"]
          format: date-time
          description: Stored in the warehouse; null while on the dock
        files: { type: array, items: { $ref: "#/components/schemas/File" } }

    Stock:
      type: object
      properties:
        root: { type: string, description: "Warehouse folder (FRET_DOWNLOAD_DIR)" }
        disk:
          type: [object, "null"]
          description: Null when the system cannot tell
          properties:
            free: { type: integer, description: "bytes available" }
            total: { type: integer }
        stored: { $ref: "#/components/schemas/StockCount" }
        week: { $ref: "#/components/schemas/StockCount", description: "Delivered over the last 7 days" }
        dirs:
          type: array
          description: Heaviest warehouse folders (8 at most)
          items:
            type: object
            properties:
              dir: { type: string, description: "\"\" = warehouse root" }
              shipments: { type: integer }
              bytes: { type: integer }

    StockCount:
      type: object
      properties:
        shipments: { type: integer }
        parcels: { type: integer }
        bytes: { type: integer }

    FileDetail:
      type: object
      properties:
        file: { $ref: "#/components/schemas/File" }
        package: { $ref: "#/components/schemas/Package", description: "The shipment, with all its parcels" }
        segments:
          type: array
          items:
            type: object
            properties:
              index: { type: integer }
              start: { type: integer }
              end: { type: integer }
              received: { type: integer }
        history:
          type: array
          items:
            type: object
            properties:
              status: { $ref: "#/components/schemas/Status" }
              code: { type: string, description: "Translation key (`history.<code>`)" }
              args: { type: object, additionalProperties: { type: string } }
              message: { type: string, description: "English fallback text" }
              at: { type: string, format: date-time }

    ScheduleWindow:
      type: object
      properties:
        days: { type: array, items: { type: integer, minimum: 1, maximum: 7 }, description: "ISO weekdays: 1 = Monday … 7 = Sunday" }
        start: { type: string, examples: ["01:00"] }
        end: { type: string, examples: ["07:00"] }
        action: { type: string, enum: [close, limit, night] }
        speedLimit: { type: integer, description: "bytes/s (limit action)" }

    QueueSettings:
      type: object
      properties:
        open: { type: boolean }
        slots: { type: integer, minimum: 1, maximum: 20 }
        speedLimit: { type: integer, description: "bytes/s, 0 = unlimited" }
        segments: { type: integer, minimum: 1, maximum: 16 }
        schedule: { type: array, items: { $ref: "#/components/schemas/ScheduleWindow" } }
        storeAfter:
          type: integer
          minimum: 0
          maximum: 720
          description: Hours before a delivered shipment is stored in the warehouse; 0 = never (24 by default)

    QueueState:
      type: object
      properties:
        settings: { $ref: "#/components/schemas/QueueSettings" }
        effective:
          type: object
          description: Settings in force, dock hours included
          properties:
            open: { type: boolean }
            speedLimit: { type: integer }
            night: { type: boolean }
            scheduled: { type: boolean }
        active: { type: integer, description: "Busy doors" }
        speed: { type: integer, description: "Total speed, bytes/s" }

    Progress:
      type: object
      properties:
        speed: { type: integer }
        files:
          type: array
          items:
            type: object
            properties:
              id: { type: integer }
              received: { type: integer }
              size: { type: integer }
              speed: { type: integer }

    CheckResult:
      type: object
      properties:
        url: { type: string }
        hoster: { type: string }
        name: { type: string }
        size: { type: integer }
        online: { type: string, enum: [online, offline, unknown] }
        note: { type: string }

    Account:
      type: object
      properties:
        id: { type: integer }
        kind: { type: string, enum: [hoster, debrid] }
        plugin: { type: string }
        label: { type: string }
        enabled: { type: boolean }
        status: { type: string, enum: [unknown, ok, free, expired, invalid, error] }
        premium: { type: boolean }
        username: { type: string }
        detail: { type: string }
        error: { type: string }
        expiresAt: { type: [string, "null"], format: date-time }
        checkedAt: { type: [string, "null"], format: date-time }
        keyHint: { type: string, description: "Last 4 characters of the key (not for passwords)" }
        login: { type: string, description: "User name, for services that take one" }

    Carrier:
      type: object
      properties:
        name: { type: string }
        title: { type: string }
        domains: { type: array, items: { type: string } }
        freeSlots: { type: integer }
        hosts: { type: integer, description: "Supported domains (forwarder)" }
        credentials:
          type: string
          enum: [key, login_password, login_key, none]
          description: "What an account is made of; none = public links only"
        folders: { type: boolean, description: "Carrier: also opens folder links (consignments)" }
        accounts: { type: array, items: { $ref: "#/components/schemas/Account" } }

    UnpackSettings:
      type: object
      properties:
        auto: { type: boolean }
        deleteArchives: { type: boolean }
        passwords: { type: array, items: { type: string } }

    CollectSettings:
      type: object
      properties:
        enabled: { type: boolean }
        confirm: { type: boolean }
        addr: { type: string, readOnly: true }
