openapi: 3.0.3
info:
  title: GameServerKings API
  version: 1.0.0
  description: API for ordering and managing game servers and dedicated servers.
servers:
  - url: https://api.gameserverkings.com

security:
  - BearerAuth: []

components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

  schemas:
    Payment:
      type: object
      required: [provider, currency]
      properties:
        provider:
          type: string
          enum: [stripe, paypal, default, account_credit]
          description: >
            Payment source for the order.
            `stripe`/`paypal` charge the supplied `method` or `intent`.
            `default` resolves the user's stored default payment method server-side.
            `account_credit` pays the order entirely from the user's account credit
            balance in `currency` and requires no `method`/`intent`; the order is
            rejected with 402 if the balance does not fully cover the total. In all
            cases available account credit is applied first and only the remainder
            (if any) is charged to the gateway.
        currency:
          type: string
        method:
          type: string
          nullable: true
        intent:
          type: string
          nullable: true

    Period:
      type: integer
      enum: [1, 3, 6, 12]
      description: Billing period in months

    GameResourceTier:
      type: object
      description: >
        One rung of a game's compute, memory or storage ladder. It is `amount`,
        not `id`, that `POST /order/shared` takes for that category.
      properties:
        id:
          type: integer
          description: ResourceOption id
        name:
          type: string
          description: Display label, e.g. `4 GB`
        amount:
          type: integer
          description: >
            Hundredths of a vCore for compute, megabytes for memory and storage.
            This is the value to send as `compute` / `memory` / `storage` when
            ordering.
        price:
          type: integer
          description: >
            Price in USD cents per month, with this game's price override
            applied where it has one.

    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        message:
          type: string
        error:
          type: string

    StripePaymentMethod:
      type: object
      description: >
        A Stripe PaymentMethod object as returned by the Stripe API. Only the
        commonly used fields are documented; the object is passed through, so
        other Stripe-provided properties may also be present.
      properties:
        id:
          type: string
          example: pm_1Nxxxxxxxxxxxxxx
        type:
          type: string
          enum: [card, us_bank_account, sepa_debit]
        card:
          type: object
          nullable: true
          properties:
            brand:
              type: string
            last4:
              type: string
            exp_month:
              type: integer
            exp_year:
              type: integer
        us_bank_account:
          type: object
          nullable: true
          properties:
            bank_name:
              type: string
            last4:
              type: string
        sepa_debit:
          type: object
          nullable: true
          properties:
            last4:
              type: string

    PaypalPaymentMethod:
      type: object
      properties:
        id:
          type: integer
        token:
          type: string
          description: Vault token identifying the saved PayPal method
        type:
          type: string
        payerId:
          type: string
          nullable: true
        email:
          type: string
          nullable: true
        name:
          type: string
          nullable: true
        lastUsedAt:
          type: string
          format: date-time
          nullable: true
        active:
          type: boolean
        expiresAt:
          type: string
          format: date-time
          nullable: true

    CosmicRule:
      type: object
      required: [src_ip, dst_port, protocol, rule]
      properties:
        src_ip:
          type: string
        dst_port:
          type: string
        protocol:
          type: string
        rule:
          type: string

    Attack:
      type: object
      description: >
        A single mitigated DDoS attack event recorded against one IP address.
        `startedAt`/`endedAt` may be null while an event is still open or if
        its timing was not captured. `pps` and `mbps` are the peak observed
        packet rate and throughput for the event.
      properties:
        id:
          type: integer
        eventId:
          type: string
          description: Upstream mitigation event identifier
        address:
          type: string
          description: The attacked IPv4 address
        pps:
          type: integer
          description: Peak packets per second
        mbps:
          type: number
          description: Peak throughput in megabits per second
        startedAt:
          type: string
          format: date-time
          nullable: true
        endedAt:
          type: string
          format: date-time
          nullable: true

    FirewallMetricsBucket:
      type: object
      description: >
        One time bucket of aggregated firewall/filter traffic for an IP.
        Throughput fields (`*_bps`) are in bits per second and packet-rate
        fields (`*_pps`) are in packets per second, each averaged over the
        bucket and summed across mitigation nodes. `all` is total observed
        traffic, `pass` is what the filter forwarded, and `drop` is what the
        filter discarded.
      properties:
        time_bucket:
          type: string
          format: date-time
          description: Start of the bucket (UTC), aligned to the requested bucket size
        all_bps:
          type: number
          description: Total throughput in bits per second
        all_pps:
          type: number
          description: Total packet rate in packets per second
        pass_bps:
          type: number
          description: Passed (forwarded) throughput in bits per second
        pass_pps:
          type: number
          description: Passed (forwarded) packet rate in packets per second
        drop_bps:
          type: number
          description: Dropped throughput in bits per second
        drop_pps:
          type: number
          description: Dropped packet rate in packets per second

    Billable:
      type: object
      description: >
        A subscription that groups one or more services and drives recurring
        billing. Payment-method and analytics identifiers are omitted.
      properties:
        id:
          type: integer
        userId:
          type: integer
          nullable: true
        status:
          type: string
          description: Billable lifecycle status (e.g. ACTIVE, PENDING, CANCELLED, FAILED)
        start:
          type: string
          format: date-time
        end:
          type: string
          format: date-time
          nullable: true
        periodStart:
          type: string
          format: date-time
        periodEnd:
          type: string
          format: date-time
        gateway:
          type: string
          description: Billing gateway (e.g. INTERNAL, STRIPE, PAYPAL, FASTSPRING)
        periodUnit:
          type: string
          description: Recurring interval unit (e.g. MONTH)
        periodLength:
          type: integer
          description: Number of period units per billing cycle
        autoRenew:
          type: boolean
        cancelRequestedAt:
          type: string
          format: date-time
          nullable: true
          description: Set when the subscription is scheduled to cancel at period end
        price:
          type: integer
          description: Recurring price per cycle in the billable's currency (integer cents)
        currency:
          type: string
        taxExempt:
          type: boolean
        referredByAffiliateId:
          type: integer
          nullable: true

    Service:
      type: object
      description: >
        A billing service — one billable line item bound to a provisioned
        resource (a game server or dedicated machine) via `resourceType` +
        `resourceId`. Carries per-service price and cancellation state, with the
        parent billable (subscription) nested.
      properties:
        id:
          type: integer
        resourceType:
          type: string
          enum: [SHARED, DEDICATED, IPV4, OTHER]
        resourceId:
          type: integer
        price:
          type: integer
          nullable: true
          description: Per-service recurring price in the parent billable's currency (integer cents), or null
        description:
          type: string
          nullable: true
        billableId:
          type: integer
          nullable: true
          description: Parent subscription (billable) ID, or null if unattached
        billable:
          nullable: true
          description: The parent subscription this service belongs to, or null if unattached
          allOf:
            - $ref: '#/components/schemas/Billable'
        deliveredAt:
          type: string
          format: date-time
          nullable: true
        suspendedAt:
          type: string
          format: date-time
          nullable: true
        cancelRequestedAt:
          type: string
          format: date-time
          nullable: true
          description: Set when this service is scheduled to cancel at the billable's period end
        canceledAt:
          type: string
          format: date-time
          nullable: true
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time

    Invoice:
      type: object
      description: An invoice issued against a billable. All amounts are in the invoice's currency (integer cents).
      properties:
        id:
          type: integer
        userId:
          type: integer
          nullable: true
        billableId:
          type: integer
          nullable: true
        status:
          type: string
          description: Invoice lifecycle status (e.g. DRAFT, FINALIZED, PAID, PARTIALLY_PAID, OVERDUE, VOID)
        type:
          type: string
          description: Invoice type (e.g. INITIAL, RECURRING, ONE_TIME)
        subtotal:
          type: integer
          description: Sum of line items before tax
        taxTotal:
          type: integer
        total:
          type: integer
          description: subtotal + tax − credits
        amountPaid:
          type: integer
        currency:
          type: string
        periodStart:
          type: string
          format: date-time
          nullable: true
        periodEnd:
          type: string
          format: date-time
          nullable: true
        issuedAt:
          type: string
          format: date-time
          nullable: true
        dueAt:
          type: string
          format: date-time
          nullable: true
        paidAt:
          type: string
          format: date-time
          nullable: true
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    PanelServer:
      type: object
      description: >
        A game server as the Pterodactyl panel sees it, reduced to the fields
        the customer panel needs. Panel-internal values (numeric ids,
        `external_id`, subuser relationships) are stripped before the response
        leaves this API.
      properties:
        identifier:
          type: string
          description: Short panel identifier — the `{id}` used throughout these paths
          example: a1b2c3d4
        uuid:
          type: string
          format: uuid
          description: Full server UUID, as quoted to support
        name:
          type: string
        node:
          type: string
          description: Display name of the node hosting the server
        is_node_under_maintenance:
          type: boolean
        sftp_details:
          type: object
          properties:
            ip:
              type: string
            port:
              type: integer
        description:
          type: string
        limits:
          type: object
          description: >
            Hard resource limits. `memory`, `swap` and `disk` are in MB, `cpu`
            is a percentage of one core, and `0` means unlimited.
          properties:
            memory:
              type: integer
            swap:
              type: integer
            disk:
              type: integer
            io:
              type: integer
            cpu:
              type: integer
            threads:
              type: string
              nullable: true
        invocation:
          type: string
          description: Rendered startup command
        docker_image:
          type: string
        egg_features:
          type: array
          nullable: true
          description: >
            Feature hooks the egg opts into (e.g. `eula`, `gsl_token`,
            `java_version`), which the panel uses to decide which prompts to
            show when the console reports a matching error.
          items:
            type: string
        feature_limits:
          type: object
          description: >
            Per-server caps on the panel features below. `0` disables that
            feature for the server entirely.
          properties:
            databases:
              type: integer
            allocations:
              type: integer
            backups:
              type: integer
        status:
          type: string
          nullable: true
          description: >
            Non-null only while the server is in a transitional or blocked
            state (e.g. `installing`, `install_failed`, `suspended`).
        is_suspended:
          type: boolean
        is_installing:
          type: boolean
        is_transferring:
          type: boolean

    ServerResources:
      type: object
      description: >
        A point-in-time utilisation sample from Wings. The same numbers stream
        continuously over the websocket, so this is mainly for the first paint
        before the socket connects.
      properties:
        current_state:
          type: string
          enum: [running, starting, stopping, offline]
        is_suspended:
          type: boolean
        resources:
          type: object
          properties:
            memory_bytes:
              type: integer
            cpu_absolute:
              type: number
              description: CPU use as a percentage, where 100 is one full core
            disk_bytes:
              type: integer
            network_rx_bytes:
              type: integer
            network_tx_bytes:
              type: integer
            uptime:
              type: integer
              description: Milliseconds since the container started

    ServerActivityEntry:
      type: object
      description: >
        One entry from the server's activity log. The originating IP address is
        deliberately not returned.
      properties:
        id:
          type: string
        event:
          type: string
          description: Dotted event key, e.g. `server:power.start`
        description:
          type: string
          nullable: true
        properties:
          type: object
          description: Event-specific metadata, shape varies by `event`
        has_additional_metadata:
          type: boolean
        timestamp:
          type: string
          format: date-time

    ServerFile:
      type: object
      description: One entry in a server directory listing.
      properties:
        name:
          type: string
        mode:
          type: string
          description: Symbolic mode, e.g. `-rw-r--r--`
        mode_bits:
          type: string
          description: Octal mode, e.g. `644`
        size:
          type: integer
        is_file:
          type: boolean
        is_symlink:
          type: boolean
        mimetype:
          type: string
        created_at:
          type: string
          format: date-time
        modified_at:
          type: string
          format: date-time

    ServerDatabase:
      type: object
      description: >
        A MySQL database belonging to the server. `password` is present only on
        the responses that mint one — creation and rotation — never on the list.
      properties:
        id:
          type: string
        host:
          type: object
          properties:
            address:
              type: string
            port:
              type: integer
        name:
          type: string
        username:
          type: string
        connections_from:
          type: string
          description: Host mask the database user may connect from, e.g. `%`
        max_connections:
          type: integer
        password:
          type: string
          description: Returned only when the database is created or its password rotated

    ServerAllocation:
      type: object
      description: An IP/port pair assigned to the server.
      properties:
        id:
          type: integer
        ip:
          type: string
        ip_alias:
          type: string
          nullable: true
        port:
          type: integer
        notes:
          type: string
          nullable: true
        is_default:
          type: boolean
          description: True for the primary allocation, which cannot be removed

    ServerBackup:
      type: object
      properties:
        uuid:
          type: string
          format: uuid
        name:
          type: string
        ignored_files:
          type: array
          items:
            type: string
        sha256_hash:
          type: string
          nullable: true
        bytes:
          type: integer
        created_at:
          type: string
          format: date-time
        completed_at:
          type: string
          format: date-time
          nullable: true
          description: Null while the backup is still being taken
        is_successful:
          type: boolean
        is_locked:
          type: boolean
          description: Locked backups are exempt from rotation and cannot be deleted

    ServerSchedule:
      type: object
      description: >
        A cron schedule on the server. The five cron fields are supplied
        separately when creating or updating one and come back joined as `cron`.
      properties:
        id:
          type: integer
        name:
          type: string
        cron:
          type: object
          properties:
            day_of_week:
              type: string
            day_of_month:
              type: string
            month:
              type: string
            hour:
              type: string
            minute:
              type: string
        is_active:
          type: boolean
        is_processing:
          type: boolean
        only_when_online:
          type: boolean
          description: Skip the run entirely when the server is offline
        last_run_at:
          type: string
          format: date-time
          nullable: true
        next_run_at:
          type: string
          format: date-time
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    ServerScheduleTask:
      type: object
      description: One step of a schedule, run `time_offset` seconds after the previous step.
      properties:
        id:
          type: integer
        sequence_id:
          type: integer
        action:
          type: string
          enum: [command, power, backup]
        payload:
          type: string
          description: >
            The console command for `command`, the power signal for `power`,
            and the ignored-files list for `backup`.
        time_offset:
          type: integer
          description: Seconds to wait after the preceding task before running this one
        is_queued:
          type: boolean
        continue_on_failure:
          type: boolean
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    StartupVariable:
      type: object
      description: >
        One egg variable exposed on the startup tab. `rules` are the panel's own
        Laravel validation rules and are forwarded so a client can render the
        right input (`in:easy,normal,hard` becomes a select, `boolean` a switch).
      properties:
        name:
          type: string
        description:
          type: string
        env_variable:
          type: string
          description: The environment variable name — this is the `key` to send when updating
        default_value:
          type: string
        server_value:
          type: string
          nullable: true
        is_editable:
          type: boolean
          description: >
            False for variables the egg locks. Updating one is rejected by the
            panel with a 500 from this API.
        rules:
          type: string

    PanelPaginationMeta:
      type: object
      description: Pterodactyl's pagination block, forwarded unchanged.
      properties:
        pagination:
          type: object
          properties:
            total:
              type: integer
            count:
              type: integer
            per_page:
              type: integer
            current_page:
              type: integer
            total_pages:
              type: integer

    Ticket:
      type: object
      properties:
        id:
          type: integer
        subject:
          type: string
        department:
          type: string
          description: The department the ticket was filed under, e.g. `technical`, `billing` or `sales`.
        status:
          type: string
          enum: [OPEN, IN_PROGRESS, WAITING_ON_USER, RESOLVED, CLOSED]
        priority:
          type: string
          enum: [LOW, NORMAL, HIGH, URGENT]
        userId:
          type: integer
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time

    TicketReply:
      type: object
      properties:
        id:
          type: integer
        message:
          type: string
        ticketId:
          type: integer
        userId:
          type: integer
        createdAt:
          type: string
          format: date-time

    TicketAttachmentUpload:
      type: object
      description: >
        A file already uploaded through `POST /tickets/upload`. Pass the object
        back unchanged in the `attachments` array when creating a ticket or
        replying to one.
      required: [key, fileName, mimeType, size]
      properties:
        key:
          type: string
          description: Storage key returned by the upload call.
        fileName:
          type: string
        mimeType:
          type: string
        size:
          type: integer
          description: Size in bytes.

    RateLimitError:
      type: object
      properties:
        success:
          type: boolean
          example: false
        message:
          type: string
          example: Too many requests. Please slow down and try again.
        retryAfterSeconds:
          type: integer
          description: Seconds to wait before retrying. Also sent as the `Retry-After` header.

    IpMoveRequest:
      type: object
      properties:
        id:
          type: integer
        kind:
          type: string
          enum: [MOVE, RELEASE]
          description: >
            MOVE puts the IPs on `targetServerId`. RELEASE takes them off their
            server and back to our pool, and has no target server.
        status:
          type: string
          enum: [PENDING, COMPLETED, REJECTED, CANCELLED]
        subnetId:
          type: integer
          nullable: true
          description: Null when the request was for IPs already on your servers.
        subnetCidr:
          type: string
          nullable: true
          example: 62.68.68.0/24
        targetServerId:
          type: integer
          nullable: true
          description: Null for a release.
        targetServerName:
          type: string
          nullable: true
          description: The destination server's name when the request was made. Null for a release.
        note:
          type: string
          nullable: true
        rejectionReason:
          type: string
          nullable: true
          description: Set when our team rejected the request.
        createdAt:
          type: string
          format: date-time
        resolvedAt:
          type: string
          format: date-time
          nullable: true
          description: When the request was completed, rejected or cancelled.
        items:
          type: array
          description: The IPs in the request, with the server each was on when the request was made.
          items:
            type: object
            properties:
              ip:
                type: string
              fromServerId:
                type: integer
                nullable: true
                description: Null when the IP was not on any server.
              fromServerName:
                type: string
                nullable: true

    IpMoveRequestConflict:
      type: object
      properties:
        success:
          type: boolean
          example: false
        message:
          type: string
          example: Some IPs are already in a pending request
        conflicts:
          type: array
          items:
            type: object
            properties:
              ip:
                type: string
              requestId:
                type: integer
                description: The pending request that already includes this IP.

    Ipv4Request:
      type: object
      properties:
        id:
          type: integer
        status:
          type: string
          enum: [AWAITING_PAYMENT, PAID, COMPLETED, REJECTED, CANCELLED]
          description: >
            `AWAITING_PAYMENT` until the invoice is paid, then `PAID` while our
            team adds the addresses.
        source:
          type: string
          enum: [CUSTOMER, ORDER]
          description: >
            `ORDER` when the addresses were ordered with the machine; its
            invoice is the order's, and it can't be cancelled on its own.
        machineId:
          type: integer
          nullable: true
        serverName:
          type: string
          description: The machine's name when the request was made.
        count:
          type: integer
        reason:
          type: string
        amount:
          type: integer
          description: Invoice amount before tax, in cents of `currency`.
        currency:
          type: string
          example: USD
        invoiceId:
          type: integer
          nullable: true
        rejectionReason:
          type: string
          nullable: true
          description: Set when our team rejected the request.
        createdAt:
          type: string
          format: date-time
        paidAt:
          type: string
          format: date-time
          nullable: true
        resolvedAt:
          type: string
          format: date-time
          nullable: true
          description: When the request was completed, rejected or cancelled.

    Ipv4RequestQuote:
      type: object
      properties:
        count:
          type: integer
        unitPrice:
          type: integer
          description: Price of one address for a full billing period, in cents of `currency`.
        subtotal:
          type: integer
        taxAmount:
          type: integer
        total:
          type: integer
        currency:
          type: string
        periodUnit:
          type: string
          enum: [MONTH, YEAR]
        periodLength:
          type: integer

  parameters:
    ServerIdentifier:
      name: id
      in: path
      required: true
      description: Pterodactyl short identifier (8 hex characters)
      schema:
        type: string
        pattern: '^[a-f0-9]{8}$'

  responses:
    ServerNotFound:
      description: >
        Server not found, not owned by the caller, or the identifier is not a
        valid panel short identifier. All three are deliberately the same
        response so panel identifiers cannot be enumerated.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ServerProxyError:
      description: The panel or Wings rejected the request, or was unreachable
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'

paths:
  /order/shared:
    post:
      summary: Order a shared game server
      description: >
        Provisions a shared game server for the configured game, resources, and
        billing period, charging the selected payment method. Account credits are
        applied automatically and a fully credit-covered order is settled without
        a charge.


        Supply `billableId` to add the server to a subscription the caller
        already has instead of opening a new one, so both renew on a single
        invoice. The term, term discount and currency then come from that
        subscription and `period` is ignored. A subscription billed in advance is
        charged only for the part of the current period still ahead, as a
        prorated invoice due immediately; one billed in arrears is charged
        nothing at order time — the server is provisioned straight away and
        appears on that subscription's next invoice, prorated from the moment it
        actually went live.


        Authenticating with a TEST-mode API key runs the full validation and
        pricing path but does not create any order records, charge payment, or
        provision; the response includes `test: true` alongside a `pricing`
        breakdown instead of the created resource IDs.
      tags: [Orders]
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [game, memory, storage, compute, location, period]
              properties:
                game:
                  type: integer
                  minimum: 1
                variant:
                  type: integer
                  minimum: 1
                  description: Optional Pterodactyl egg/variant to provision instead of the game default
                memory:
                  type: integer
                  minimum: 1
                storage:
                  type: integer
                  minimum: 1
                compute:
                  type: integer
                  minimum: 1
                location:
                  type: string
                dedicatedIp:
                  type: boolean
                  default: false
                period:
                  allOf:
                    - $ref: '#/components/schemas/Period'
                  description: >
                    Billing period in months. Ignored when `billableId` is
                    supplied: an order joining an existing subscription takes
                    that subscription's term, not one of its own.
                billableId:
                  type: integer
                  minimum: 1
                  description: >
                    Optional. Add this server to an existing subscription
                    belonging to the caller instead of creating a new one. The
                    subscription must be active, not scheduled to cancel, and not
                    billed by an external gateway (`400`); an id that does not
                    exist or belongs to someone else returns `404`.


                    `period` is ignored and `coupon` is rejected — the term, term
                    discount and currency come from the subscription, and its own
                    recurring coupon (if any) is applied to the prorated charge
                    instead.
                expectedAmount:
                  type: integer
                  minimum: 0
                  description: >
                    Optional pre-tax, pre-coupon, pre-credit amount in USD cents
                    that the client expects to be charged. When provided, the
                    server compares it against its own re-priced total and aborts
                    with 409 if they differ. Omit to skip the drift check.


                    With `billableId` this is instead the PRORATED amount in the
                    subscription's currency — `0` when that subscription is billed
                    in arrears — because that is what the customer is being asked
                    to pay.
                coupon:
                  type: string
                  description: >
                    Rejected with 400 when `billableId` is also supplied. The
                    subscription's own recurring coupon applies there instead.
                payment:
                  allOf:
                    - $ref: '#/components/schemas/Payment'
                  description: >
                    Required for every order except one that attaches to a
                    subscription billed in arrears, which charges nothing at order
                    time and so needs no payment method. When `billableId` is
                    supplied, `currency` must match the subscription's currency.
      responses:
        '200':
          description: >
            Order processed successfully (live keys) or validated (TEST keys).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  test:
                    type: boolean
                    description: Present and true only when called with a TEST-mode API key
                  message:
                    type: string
                    description: Present only for TEST-mode responses
                  serverId:
                    type: integer
                    description: Created server ID (live keys only)
                  billableId:
                    type: integer
                    description: >
                      The subscription the server is billed on (live keys only) —
                      the newly created one, or the `billableId` that was supplied.
                  invoiceId:
                    type: integer
                    nullable: true
                    description: >
                      Created invoice ID (live keys only). `null` when nothing was
                      billed at order time, which is the normal outcome of attaching
                      to a subscription billed in arrears.
                  serviceId:
                    type: integer
                    description: Created service ID (live keys only)
                  chargedNow:
                    type: integer
                    description: >
                      Amount charged at order time, in minor units of `currency`.
                      Returned only for `billableId` orders, where it is the
                      prorated remainder of the current period — `0` in arrears.
                  currency:
                    type: string
                    description: >
                      Currency of `chargedNow`, taken from the subscription.
                      Returned only for `billableId` orders.
                  billInArrears:
                    type: boolean
                    description: >
                      Whether the target subscription bills after the fact.
                      Returned only for TEST-mode `billableId` responses.
                  pricing:
                    type: object
                    description: Pricing breakdown in minor currency units; present only for TEST-mode responses
                    properties:
                      currency:
                        type: string
                      subtotal:
                        type: integer
                      tax:
                        type: integer
                      credit:
                        type: integer
                      total:
                        type: integer
                      servicePeriodPrice:
                        type: integer
                        description: >
                          Full-term price of the new server in the subscription's
                          currency — what it adds to the renewal from the next
                          period on. `billableId` orders only.
                      prorationFactor:
                        type: number
                        description: >
                          Share of the current period still ahead, which
                          `servicePeriodPrice` is scaled by to reach `subtotal`.
                          `1` on an arrears subscription, which charges nothing
                          now. `billableId` orders only.
                      discount:
                        type: integer
                        description: >
                          Discount from the subscription's own recurring coupon,
                          applied to the prorated amount. `billableId` orders only.
        '400':
          description: >
            Invalid input, invalid coupon, or payment info not valid. For
            `billableId` orders also: the subscription is not active, is
            scheduled to cancel, is billed by an external gateway, is not billed
            through a payment gateway at all, a `coupon` was supplied alongside
            it, or `payment` is missing or in a different currency than the
            subscription.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '402':
          description: >
            Payment failed, or (for `account_credit`) the account credit balance
            does not fully cover the order total. No charges were made.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: >
            The supplied `billableId` does not exist or does not belong to the
            caller.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: >
            The re-priced total did not match the supplied `expectedAmount`
            (pricing changed since the page was loaded).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /order/dedicated:
    post:
      summary: Order a dedicated server
      description: >
        Provisions a dedicated server for the configured type, disks, uplink, and
        billing period, charging the selected payment method. Account credits are
        applied automatically.


        Authenticating with a TEST-mode API key runs the full validation and
        pricing path but does not enqueue provisioning, charge payment, or persist
        anything; the response includes `test: true` alongside a `pricing`
        breakdown instead of the created resource IDs.
      tags: [Orders]
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [type, memory, disks, uplink, location, period, payment]
              properties:
                type:
                  type: integer
                  minimum: 1
                memory:
                  type: integer
                  minimum: 1
                disks:
                  type: array
                  minItems: 1
                  description: >
                    Disk selection for the build. Each entry references a storage
                    configurable-option by `optionId` and how many of that disk to
                    include via `quantity`.
                  items:
                    type: object
                    required: [optionId, quantity]
                    properties:
                      optionId:
                        type: integer
                        minimum: 1
                      quantity:
                        type: integer
                        minimum: 1
                uplink:
                  type: integer
                  minimum: 1
                location:
                  type: string
                templateId:
                  type: integer
                  minimum: 1
                rootPassword:
                  type: string
                  minLength: 8
                  maxLength: 128
                machineId:
                  type: integer
                  minimum: 1
                  description: >
                    Optional. Target a specific machine that is listed at a
                    reduced price override. The server validates that the
                    machine still matches the requested type, location, and
                    options (including disk quantities) and that its override is
                    strictly lower than the normal type+options price before
                    applying it. If the machine has been claimed or no longer
                    qualifies by the time the order is processed, the request
                    fails with 409 — it will not silently fall back to a
                    different machine.
                period:
                  $ref: '#/components/schemas/Period'
                expectedAmount:
                  type: integer
                  minimum: 0
                  description: >
                    Optional pre-tax, pre-coupon, pre-credit amount in USD cents
                    that the client expects to be charged for the configured
                    selection. When provided, the server compares it against its
                    own re-priced total and aborts with 409 if they differ
                    (protecting against stale pricing in the browser). Omit to
                    skip the drift check entirely — useful for API-driven
                    clients that trust the server's pricing.
                coupon:
                  type: string
                payment:
                  $ref: '#/components/schemas/Payment'
      responses:
        '200':
          description: >
            Order processed successfully (live keys) or validated (TEST keys).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  test:
                    type: boolean
                    description: Present and true only when called with a TEST-mode API key
                  message:
                    type: string
                    description: Present only for TEST-mode responses
                  orderId:
                    type: integer
                    description: Created invoice ID (live keys only). Alias of `invoiceId`, kept for backwards compatibility.
                  machineId:
                    type: integer
                    description: Assigned machine ID (live keys only)
                  billableId:
                    type: integer
                    description: Created billable ID (live keys only)
                  invoiceId:
                    type: integer
                    description: Created invoice ID (live keys only)
                  serviceId:
                    type: integer
                    description: Created service ID (live keys only)
                  pricing:
                    type: object
                    description: Pricing breakdown in minor currency units; present only for TEST-mode responses
                    properties:
                      currency:
                        type: string
                      subtotal:
                        type: integer
                      tax:
                        type: integer
                      credit:
                        type: integer
                      total:
                        type: integer
        '400':
          description: Invalid input or payment info
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '402':
          description: >
            Payment failed, or (for `account_credit`) the account credit balance
            does not fully cover the order total. No charges were made.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: >
            Specified `machineId` is no longer available, doesn't match the
            requested configuration, or its price override no longer beats
            the normal type+options price.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: >
            Provisioning service temporarily unavailable; the order was not
            placed. Safe to retry.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /game/{idOrSlug}/configuration:
    get:
      summary: Get a game's shared-server configuration options
      description: >
        Everything `POST /order/shared` will accept for one game: the compute,
        memory and storage tiers with this game's prices, the orderable game
        versions, the locations, the term discounts and the dedicated-IP price.
        The shared-server counterpart to `/dedicated/types` and
        `/dedicated/locations`.


        It is built from the same data as the public order page and priced the
        same way, so a configuration assembled from this response costs what the
        order page would charge for it.


        `idOrSlug` takes either the numeric game id or the slug from the game's
        public URL (`/games/<slug>`), so no id lookup is needed to call it.


        All prices are in USD cents per month. Within `compute`, `memory` and
        `storage` it is `amount` — not `id` — that the order endpoint expects for
        that category. `defaults` restates the tier amounts and version id the
        order page opens on, so it can be submitted as-is.


        Cached for 10 minutes, and cleared immediately when the game is edited.
      tags: [Game Servers]
      security: []
      parameters:
        - name: idOrSlug
          in: path
          required: true
          schema:
            type: string
          description: Numeric game id, or the game's slug (e.g. `rust`)
      responses:
        '200':
          description: The game's orderable configuration
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      game:
                        type: object
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                          slug:
                            type: string
                          comingSoon:
                            type: boolean
                            description: >
                              Announced but not yet orderable. The game is still
                              described here so it can be listed, but
                              `POST /order/shared` rejects it.
                          orderable:
                            type: boolean
                            description: >
                              False when the game is coming soon, or has no
                              available version configured.
                      currency:
                        type: string
                        description: Currency every price in this payload is quoted in
                        example: USD
                      compute:
                        type: array
                        description: Compute tiers, smallest first
                        items:
                          $ref: '#/components/schemas/GameResourceTier'
                      memory:
                        type: array
                        description: Memory tiers, smallest first
                        items:
                          $ref: '#/components/schemas/GameResourceTier'
                      storage:
                        type: array
                        description: Storage tiers, smallest first
                        items:
                          $ref: '#/components/schemas/GameResourceTier'
                      variants:
                        type: array
                        description: >
                          The orderable versions of the game — e.g. Vanilla,
                          Paper, Forge for Minecraft. Pass an `id` as `variant`
                          when ordering; omitting it takes `defaults.variant`.
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                              description: Slug-like key, unique per game, e.g. `paper`
                            displayName:
                              type: string
                            description:
                              type: string
                              nullable: true
                            featured:
                              type: boolean
                      locations:
                        type: array
                        description: Data centers this game can be deployed to
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                              description: Pass as `location` when ordering
                            name:
                              type: string
                            code:
                              type: string
                            region:
                              type: string
                            city:
                              type: string
                            country:
                              type: string
                      defaults:
                        type: object
                        description: >
                          The configuration the order page opens on, given as the
                          values `POST /order/shared` takes. A category is null
                          only when the game has no tiers in it at all.
                        properties:
                          compute:
                            type: integer
                            nullable: true
                          memory:
                            type: integer
                            nullable: true
                          storage:
                            type: integer
                            nullable: true
                          variant:
                            type: integer
                            nullable: true
                      dedicatedIp:
                        type: object
                        description: Cost of the optional `dedicatedIp` add-on
                        properties:
                          monthlyPrice:
                            type: integer
                            description: USD cents per month
                      billingPeriods:
                        type: array
                        description: >
                          The terms `period` accepts and the discount each earns.
                          A term is charged `monthly price x months x (1 - rate)`,
                          so twelve months at a rate of 0.1667 is ten months' pay.
                        items:
                          type: object
                          properties:
                            months:
                              type: integer
                            rate:
                              type: number
                              description: Discount as a fraction of the undiscounted term
        '404':
          description: No game with that id or slug, or the game is not publicly listed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /shared:
    get:
      summary: List your game servers
      description: >
        Returns all of the authenticated user's game servers (excluding deleted
        ones), each including its game and location, ordered by most recently
        created.
      tags: [Game Servers]
      security:
        - BearerAuth: []
      responses:
        '200':
          description: List of the user's game servers
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  total:
                    type: integer
                    description: Number of game servers returned
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        status:
                          type: string
                          description: Server lifecycle status
                        gameId:
                          type: integer
                        variantId:
                          type: integer
                          nullable: true
                        ip:
                          type: string
                          nullable: true
                        port:
                          type: integer
                          nullable: true
                        dedicatedIp:
                          type: boolean
                        createdAt:
                          type: string
                          format: date-time
                        game:
                          type: object
                          description: The game this server runs
                          properties:
                            id:
                              type: integer
                            name:
                              type: string
                        location:
                          type: object
                          properties:
                            id:
                              type: string
                            name:
                              type: string
                            code:
                              type: string
                            region:
                              type: string
                            city:
                              type: string
                            country:
                              type: string
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /shared/{id}:
    get:
      summary: Get a game server by ID
      description: >
        Returns details for a specific game server owned by the authenticated
        user, including its game, location, active plan(s), variant, the
        associated billing service (with its parent billable nested, if any),
        and the server's Pterodactyl UUID.
      tags: [Game Servers]
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: Server ID
      responses:
        '200':
          description: Game server details
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      status:
                        type: string
                        description: Server lifecycle status
                      gameId:
                        type: integer
                      variantId:
                        type: integer
                        nullable: true
                      ip:
                        type: string
                        nullable: true
                      port:
                        type: integer
                        nullable: true
                      dedicatedIp:
                        type: boolean
                      createdAt:
                        type: string
                        format: date-time
                      game:
                        type: object
                        description: The game this server runs
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      location:
                        type: object
                        properties:
                          id:
                            type: string
                          name:
                            type: string
                          code:
                            type: string
                          region:
                            type: string
                          city:
                            type: string
                          country:
                            type: string
                      variant:
                        type: object
                        nullable: true
                        description: The Pterodactyl egg/variant this server was provisioned against, or null
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      plans:
                        type: array
                        description: Active (non-cancelled) plan(s) attached to this server
                        items:
                          type: object
                      service:
                        nullable: true
                        description: >
                          The billing service associated with this server (with its
                          parent billable nested), or null if the server has no billing
                          entry.
                        allOf:
                          - $ref: '#/components/schemas/Service'
                      pterodactylUuid:
                        type: string
                        format: uuid
                        nullable: true
                        description: >
                          The server's full Pterodactyl UUID (not the 8-character short
                          identifier the panel's client API uses in its URLs). Null if the
                          server has not been provisioned yet, or if the panel could not
                          be reached.
        '400':
          description: Invalid server ID
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Server not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /shared/{id}/configuration:
    post:
      summary: Change a shared server's plan
      description: >
        Changes the compute/memory/storage tiers (and optional dedicated IP) of
        an existing shared game server, re-pricing the billable and charging the
        prorated difference for upgrades. Downgrades and same-price changes are
        applied without a charge. A configuration change cannot be started while
        another is pending, and is unavailable for subscription-style billables
        (FastSpring, internal, or Stripe/PayPal subscriptions).


        Authenticating with a TEST-mode API key runs the full validation and
        proration/pricing path but does not swap plans, create an invoice,
        charge, or re-provision; the response includes `test: true` alongside
        the computed `proration`, `delta`, and `taxAmount`.
      tags: [Game Servers]
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: Shared server ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [compute, memory, storage]
              properties:
                compute:
                  type: integer
                  minimum: 1
                  description: Target compute tier amount
                memory:
                  type: integer
                  minimum: 1
                  description: Target memory tier amount
                storage:
                  type: integer
                  minimum: 1
                  description: Target storage tier amount
                dedicatedIp:
                  type: boolean
                  description: Optional. Add or remove a dedicated IP as part of the change; defaults to the server's current setting.
      responses:
        '200':
          description: >
            Configuration change applied (live keys) or validated (TEST keys).
            All amounts are in minor currency units (e.g. USD cents).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  test:
                    type: boolean
                    description: Present and true only when called with a TEST-mode API key
                  message:
                    type: string
                    description: Present only for TEST-mode responses
                  proration:
                    type: number
                    description: Fraction of the current billing period remaining, applied to the price difference
                  delta:
                    type: integer
                    description: Prorated pre-tax price difference; positive for an upgrade, zero or negative otherwise
                  taxAmount:
                    type: integer
                    description: Tax charged on the delta (only for upgrades)
                  totalDelta:
                    type: integer
                    description: delta + taxAmount; present only for TEST-mode responses
                  currency:
                    type: string
                    description: Billable currency; present only for TEST-mode responses
        '400':
          description: >
            Invalid plan options, missing billable, unsupported subscription
            gateway, or payment validation failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Server or active plan not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: A configuration change is already pending for this server
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /server/{id}:
    get:
      summary: Get a game server's panel detail
      description: >
        Returns the panel's view of one game server — limits, feature limits,
        SFTP details, current lifecycle flags and the egg features that drive
        the console prompts.

        Every `/server/{id}/*` route is a proxy onto the Pterodactyl client API
        using a shared, admin-equivalent panel key, so access is gated first:
        the caller must have a linked panel account and be the panel-side owner
        of this server. Ownership is checked against the panel, not against our
        billing records, so managed-dedicated servers and anything else hosted
        for the customer work the same way. Anything that fails the check
        returns 404 rather than 403.

        Responses are field-filtered on the way out. The shared key sees more
        than a customer should, so each route carries an explicit allowlist and
        drops everything else.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      responses:
        '200':
          description: Server detail
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  server:
                    $ref: '#/components/schemas/PanelServer'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'
    delete:
      summary: Delete a game server
      description: >
        Deletes the server from the panel and releases the allocations it held.

        Deliberately narrow: this is allowed only for servers running on a node
        that backs a managed dedicated machine the caller owns — their own
        hardware, their own capacity. Shared hosting and anything else we bill
        for is refused with 403, because tearing those down belongs to
        cancellation rather than a button, and a server still attached to an
        uncancelled service is refused with 409.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      responses:
        '204':
          description: Server deleted
        '403':
          description: The server does not sit on a dedicated machine the caller owns
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '409':
          description: The server is billed — cancel the subscription instead
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/resources:
    get:
      summary: Get current resource utilisation
      description: >
        A single utilisation sample and the server's current power state. The
        same figures stream continuously over the console websocket, so this is
        for the first paint before that socket connects.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      responses:
        '200':
          description: Current utilisation
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  resources:
                    $ref: '#/components/schemas/ServerResources'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/websocket:
    get:
      summary: Mint a console websocket token
      description: >
        Returns a short-lived Wings token and the socket URL to open with it.
        The token carries the caller's permissions for this server and expires
        on its own, so a client is expected to call this again when Wings sends
        a `token expiring` event or the socket closes with an auth error.

        Only the token and socket URL are returned; the rest of the panel's
        response is dropped.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      responses:
        '200':
          description: Websocket credentials
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  token:
                    type: string
                  socket:
                    type: string
                    description: wss:// URL for the node's console socket
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/command:
    post:
      summary: Send a console command
      description: >
        Writes one line to the running server's console. The server must be
        running — Wings rejects the command otherwise. Output is not returned
        here; it arrives on the console websocket.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [command]
              properties:
                command:
                  type: string
                  minLength: 1
                  maxLength: 1024
      responses:
        '204':
          description: Command sent
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/power:
    post:
      summary: Send a power signal
      description: >
        Starts, stops, restarts or kills the server. `kill` terminates the
        container immediately and can corrupt a save in progress, so treat it
        as a last resort after `stop` has been given time to finish.

        The signal is accepted asynchronously — the resulting state change
        arrives on the console websocket, not in this response.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [signal]
              properties:
                signal:
                  type: string
                  enum: [start, stop, restart, kill]
      responses:
        '204':
          description: Signal sent
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/activity:
    get:
      summary: List server activity
      description: >
        The server's audit trail as the panel records it — power signals, file
        writes, subuser changes and so on, newest first. The originating IP
        address the panel stores against each entry is not forwarded.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
        - name: page
          in: query
          required: false
          description: 1-based page number
          schema:
            type: integer
            minimum: 1
            maximum: 1000
            default: 1
      responses:
        '200':
          description: Activity entries
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/ServerActivityEntry'
                  meta:
                    $ref: '#/components/schemas/PanelPaginationMeta'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/files/list:
    get:
      summary: List a directory
      description: >
        Lists one directory in the server's data volume. Paths are relative to
        the server root — `/` is the root itself. Directories are returned with
        `is_file: false`; there is no recursion.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
        - name: directory
          in: query
          required: true
          description: Directory path relative to the server root
          schema:
            type: string
            minLength: 1
            maxLength: 2048
          example: /plugins
      responses:
        '200':
          description: Directory contents
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/ServerFile'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/files/contents:
    get:
      summary: Read a file
      description: >
        Returns the file's raw bytes as `text/plain`, not JSON — this is the
        editor's read path. Large files and binaries are better fetched through
        the signed download URL instead.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
        - name: file
          in: query
          required: true
          description: File path relative to the server root
          schema:
            type: string
            minLength: 1
            maxLength: 2048
          example: /server.properties
      responses:
        '200':
          description: File contents
          content:
            text/plain:
              schema:
                type: string
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/files/write:
    post:
      summary: Write a file
      description: >
        Overwrites the file at `file` with the raw request body, creating it if
        it does not exist. The body is sent as `text/plain`, not JSON, and the
        target path is a query parameter rather than part of the body.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
        - name: file
          in: query
          required: true
          description: File path relative to the server root
          schema:
            type: string
            minLength: 1
            maxLength: 2048
      requestBody:
        required: true
        content:
          text/plain:
            schema:
              type: string
              description: The complete new contents of the file
      responses:
        '204':
          description: File written
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/files/download:
    get:
      summary: Get a signed download URL for a file
      description: >
        Mints a short-lived URL pointing straight at the node, which the client
        then fetches directly. The file itself never passes through this API.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
        - name: file
          in: query
          required: true
          description: File path relative to the server root
          schema:
            type: string
            minLength: 1
            maxLength: 2048
      responses:
        '200':
          description: Signed URL
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  url:
                    type: string
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/files/upload:
    get:
      summary: Get a signed upload URL
      description: >
        Mints a short-lived URL the client POSTs a multipart form to, uploading
        straight to the node. Append `?directory=<path>` to the returned URL to
        choose the destination directory. Uploads do not pass through this API.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      responses:
        '200':
          description: Signed URL
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  url:
                    type: string
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/files/rename:
    put:
      summary: Rename or move files
      description: >
        Renames each `from` to its `to`, both relative to `root`. Moving a file
        elsewhere is the same operation with a `to` that walks out of `root`.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [root, files]
              properties:
                root:
                  type: string
                  description: Directory the paths below are relative to
                  minLength: 1
                  maxLength: 2048
                files:
                  type: array
                  minItems: 1
                  maxItems: 500
                  items:
                    type: object
                    required: [from, to]
                    properties:
                      from:
                        type: string
                      to:
                        type: string
      responses:
        '204':
          description: Renamed
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/files/copy:
    post:
      summary: Duplicate a file
      description: >
        Copies the file at `location` alongside itself, with the panel choosing
        the copy's name. There is no destination parameter — rename afterwards
        to place it elsewhere.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [location]
              properties:
                location:
                  type: string
                  description: Path of the file to copy, relative to the server root
                  minLength: 1
                  maxLength: 2048
      responses:
        '204':
          description: Copied
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/files/create-folder:
    post:
      summary: Create a folder
      description: Creates `name` inside `root`. Intermediate directories are created as needed.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [root, name]
              properties:
                root:
                  type: string
                  minLength: 1
                  maxLength: 2048
                name:
                  type: string
                  minLength: 1
                  maxLength: 255
      responses:
        '204':
          description: Folder created
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/files/delete:
    post:
      summary: Delete files
      description: >
        Deletes each entry in `files` from `root`. Directories are removed
        recursively, and deletion is not recoverable — there is no trash.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [root, files]
              properties:
                root:
                  type: string
                  minLength: 1
                  maxLength: 2048
                files:
                  type: array
                  minItems: 1
                  maxItems: 1000
                  items:
                    type: string
      responses:
        '204':
          description: Deleted
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/files/compress:
    post:
      summary: Compress files into an archive
      description: >
        Packs the named entries in `root` into a `.tar.gz` written to the same
        directory, and returns the created archive's file object so a client can
        point the user at it. Large archives take a while; the panel returns
        once the archive exists.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [root, files]
              properties:
                root:
                  type: string
                  minLength: 1
                  maxLength: 2048
                files:
                  type: array
                  minItems: 1
                  maxItems: 1000
                  items:
                    type: string
      responses:
        '200':
          description: The archive that was created
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  file:
                    $ref: '#/components/schemas/ServerFile'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/files/decompress:
    post:
      summary: Extract an archive
      description: >
        Extracts `file` in place inside `root`, overwriting anything already
        there with the same name.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [root, file]
              properties:
                root:
                  type: string
                  minLength: 1
                  maxLength: 2048
                file:
                  type: string
                  minLength: 1
                  maxLength: 2048
      responses:
        '204':
          description: Extracted
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/files/chmod:
    post:
      summary: Change file permissions
      description: >
        Sets the mode of each entry in `files`, relative to `root`. Modes are
        octal strings such as `644` or `0755`.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [root, files]
              properties:
                root:
                  type: string
                  minLength: 1
                  maxLength: 2048
                files:
                  type: array
                  minItems: 1
                  maxItems: 1000
                  items:
                    type: object
                    required: [file, mode]
                    properties:
                      file:
                        type: string
                      mode:
                        type: string
                        pattern: '^[0-7]{3,4}$'
                        example: '644'
      responses:
        '204':
          description: Permissions changed
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/files/pull:
    post:
      summary: Download a remote file onto the server
      description: >
        Has the node fetch `url` into `directory` itself, so the file never
        passes through the browser. By default the transfer runs in the
        background and this returns as soon as the node has accepted it; set
        `foreground` to make the node hold the request until the download
        finishes.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [url, directory]
              properties:
                url:
                  type: string
                  format: uri
                  maxLength: 2048
                directory:
                  type: string
                  description: Destination directory relative to the server root
                  minLength: 1
                  maxLength: 2048
                filename:
                  type: string
                  description: Name to save as; defaults to the name in the URL
                  minLength: 1
                  maxLength: 255
                use_header:
                  type: boolean
                  default: true
                  description: Take the filename from the response's Content-Disposition header
                foreground:
                  type: boolean
                  default: false
                  description: Wait for the download to complete before responding
      responses:
        '204':
          description: Download accepted (or completed, when `foreground` is set)
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/databases:
    get:
      summary: List the server's databases
      description: >
        Lists the MySQL databases attached to the server. Passwords are never
        included here — they are returned only by the create and rotate
        endpoints, at the moment they are minted.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      responses:
        '200':
          description: Databases
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/ServerDatabase'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'
    post:
      summary: Create a database
      description: >
        Creates a database and a user for it, and returns the generated
        password — the only time it is shown in full. The panel prefixes the
        supplied name, so the created database's `name` will not match
        `database` verbatim.

        Refused by the panel once the server is at its `feature_limits.databases`
        cap, which is `0` on plans without databases.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [database, remote]
              properties:
                database:
                  type: string
                  description: Database name, before the panel's prefix
                  minLength: 1
                  maxLength: 48
                remote:
                  type: string
                  description: Host mask the database user may connect from
                  minLength: 1
                  maxLength: 64
                  example: '%'
      responses:
        '200':
          description: The created database, including its password
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  database:
                    $ref: '#/components/schemas/ServerDatabase'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/databases/{databaseId}:
    delete:
      summary: Delete a database
      description: Drops the database and its user. The data is not recoverable.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
        - name: databaseId
          in: path
          required: true
          description: The database's panel id, as returned by the list endpoint
          schema:
            type: string
      responses:
        '204':
          description: Database deleted
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/databases/{databaseId}/rotate-password:
    post:
      summary: Rotate a database password
      description: >
        Generates a new password for the database user and returns it. The old
        password stops working immediately, so anything connecting with it —
        the game server's own config included — has to be updated.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
        - name: databaseId
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: The database, with its new password
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  database:
                    $ref: '#/components/schemas/ServerDatabase'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/network/allocations:
    get:
      summary: List the server's allocations
      description: >
        The IP/port pairs assigned to the server. Exactly one is the primary
        (`is_default`), which is the address players connect to.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      responses:
        '200':
          description: Allocations
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/ServerAllocation'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'
    post:
      summary: Assign an additional allocation
      description: >
        Takes the next free port on the node and assigns it to the server. There
        is no way to request a specific port. Refused by the panel once the
        server is at its `feature_limits.allocations` cap.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      responses:
        '200':
          description: The newly assigned allocation
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  allocation:
                    $ref: '#/components/schemas/ServerAllocation'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/network/allocations/rules:
    get:
      summary: List Cosmic firewall rules per allocation
      description: >
        Returns the Cosmic firewall rules that apply to each of the game
        server's allocations, keyed by the allocation id returned from
        `/server/{id}/network/allocations`.

        Rules are resolved per unique allocation IP and then filtered to those
        whose `dst_port` matches that allocation's own port, so on a shared
        protected IP the response only ever contains rules for the IP/port
        pairs this server actually holds — never another customer's.

        If rules for one IP cannot be fetched, that IP degrades to an empty
        rule list rather than failing the whole response, so an allocation may
        legitimately map to `[]`.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      responses:
        '200':
          description: Rules grouped by allocation id
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  rules:
                    type: object
                    description: >
                      Map of allocation id to the rules targeting that
                      allocation's port. Every allocation on the server is
                      present as a key, with an empty array when no rules apply.
                    additionalProperties:
                      type: array
                      items:
                        $ref: '#/components/schemas/CosmicRule'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/network/allocations/{allocationId}:
    post:
      summary: Set an allocation's note
      description: Replaces the free-text note shown against the allocation. Send an empty string to clear it.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
        - name: allocationId
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [notes]
              properties:
                notes:
                  type: string
                  maxLength: 256
      responses:
        '200':
          description: The updated allocation
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  allocation:
                    $ref: '#/components/schemas/ServerAllocation'
        '400':
          description: Validation error, or a non-integer allocation id
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'
    delete:
      summary: Release an allocation
      description: >
        Returns the port to the node's free pool. The primary allocation cannot
        be released — make another one primary first.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
        - name: allocationId
          in: path
          required: true
          schema:
            type: integer
      responses:
        '204':
          description: Allocation released
        '400':
          description: Non-integer allocation id
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/network/allocations/{allocationId}/primary:
    post:
      summary: Make an allocation primary
      description: >
        Promotes the allocation to the server's primary address. The change
        takes effect on the next start, since the running process is already
        bound to the old one.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
        - name: allocationId
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: The allocation, now primary
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  allocation:
                    $ref: '#/components/schemas/ServerAllocation'
        '400':
          description: Non-integer allocation id
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/backups:
    get:
      summary: List backups
      description: >
        Backups are returned newest first. One with a null `completed_at` is
        still being taken; the console websocket announces the completion.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
        - name: page
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 1000
            default: 1
      responses:
        '200':
          description: Backups
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/ServerBackup'
                  meta:
                    $ref: '#/components/schemas/PanelPaginationMeta'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'
    post:
      summary: Create a backup
      description: >
        Starts a backup and returns it immediately, before it has finished —
        `completed_at` is null until the node reports it done.

        Two limits apply and both come from the panel. The server's
        `feature_limits.backups` caps how many may exist at once (`0` disables
        backups entirely), and the panel throttles how often they may be taken.
        A throttled request comes back as a 429 carrying the panel's own reason,
        which is safe to show the user verbatim.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: Defaults to a timestamped name chosen by the panel
                  minLength: 1
                  maxLength: 191
                ignored:
                  type: string
                  description: Newline-separated glob patterns to exclude, in .gitignore syntax
                  maxLength: 2048
                is_locked:
                  type: boolean
                  description: Create the backup already locked against rotation and deletion
      responses:
        '200':
          description: The backup that was started
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  backup:
                    $ref: '#/components/schemas/ServerBackup'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '429':
          description: >
            The panel's backup rate limit was hit. `message` carries the panel's
            own explanation of the limit where it gave one.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/backups/{uuid}:
    get:
      summary: Get one backup
      description: Returns a single backup, chiefly to poll whether it has finished.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
        - name: uuid
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: The backup
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  backup:
                    $ref: '#/components/schemas/ServerBackup'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'
    delete:
      summary: Delete a backup
      description: Permanently removes the backup. A locked backup must be unlocked first.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
        - name: uuid
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '204':
          description: Backup deleted
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/backups/{uuid}/download:
    get:
      summary: Get a signed backup download URL
      description: >
        Mints a short-lived URL pointing at the node holding the archive. The
        archive is not proxied through this API.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
        - name: uuid
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: Signed URL
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  url:
                    type: string
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/backups/{uuid}/lock:
    post:
      summary: Toggle a backup's lock
      description: >
        Flips `is_locked` — this is a toggle, not a set, so the response is the
        authority on which way it went. A locked backup is exempt from rotation
        and cannot be deleted.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
        - name: uuid
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: The backup, with its new lock state
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  backup:
                    $ref: '#/components/schemas/ServerBackup'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/backups/{uuid}/restore:
    post:
      summary: Restore a backup
      description: >
        Restores the archive over the server's files. The server is stopped for
        the duration and the console websocket refuses connections until the
        node reports the restore finished, so a client should expect the socket
        to drop and reconnect afterwards.

        `truncate` decides what happens to files that exist now: true wipes the
        volume first, so the result is exactly the backup; false unpacks over
        the top, leaving anything the backup does not contain in place.

        Like backup creation, this is throttled by the panel and a throttled
        request comes back as a 429 carrying the panel's reason.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
        - name: uuid
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [truncate]
              properties:
                truncate:
                  type: boolean
                  description: Delete the server's existing files before unpacking
      responses:
        '204':
          description: Restore started
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '429':
          description: Too many restore requests; `message` carries the panel's reason
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/schedules:
    get:
      summary: List schedules
      description: >
        The server's cron schedules. Tasks are not included here — fetch a
        single schedule for those.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      responses:
        '200':
          description: Schedules
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/ServerSchedule'
                  meta:
                    $ref: '#/components/schemas/PanelPaginationMeta'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'
    post:
      summary: Create a schedule
      description: >
        Creates an empty schedule — a schedule with no tasks does nothing, so
        follow this with at least one task. The five cron fields are supplied
        separately and take standard cron syntax including `*`, ranges and
        steps; they come back joined under `cron`.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [name, minute, hour, day_of_week, day_of_month, month, is_active, only_when_online]
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 191
                minute:
                  type: string
                  example: '0'
                hour:
                  type: string
                  example: '*/6'
                day_of_week:
                  type: string
                  example: '*'
                day_of_month:
                  type: string
                  example: '*'
                month:
                  type: string
                  example: '*'
                is_active:
                  type: boolean
                only_when_online:
                  type: boolean
                  description: Skip the run entirely when the server is offline
      responses:
        '200':
          description: The created schedule
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  schedule:
                    $ref: '#/components/schemas/ServerSchedule'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/schedules/{scheduleId}:
    get:
      summary: Get a schedule and its tasks
      description: >
        Returns the schedule together with its tasks in `sequence_id` order.
        This is the only route that returns tasks.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
        - name: scheduleId
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Schedule and tasks
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  schedule:
                    $ref: '#/components/schemas/ServerSchedule'
                  tasks:
                    type: array
                    items:
                      $ref: '#/components/schemas/ServerScheduleTask'
        '400':
          description: Non-integer schedule id
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'
    post:
      summary: Update a schedule
      description: >
        Updates the schedule. POST, not PATCH, because that is what the panel
        exposes. Fields may be sent individually, but note that the panel
        rebuilds the cron expression from whatever it is given — send all five
        cron fields together when changing the timing.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
        - name: scheduleId
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: Any subset of the create body's fields
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 191
                minute:
                  type: string
                hour:
                  type: string
                day_of_week:
                  type: string
                day_of_month:
                  type: string
                month:
                  type: string
                is_active:
                  type: boolean
                only_when_online:
                  type: boolean
      responses:
        '200':
          description: The updated schedule
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  schedule:
                    $ref: '#/components/schemas/ServerSchedule'
        '400':
          description: Validation error, or a non-integer schedule id
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'
    delete:
      summary: Delete a schedule
      description: Deletes the schedule and every task on it.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
        - name: scheduleId
          in: path
          required: true
          schema:
            type: integer
      responses:
        '204':
          description: Schedule deleted
        '400':
          description: Non-integer schedule id
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/schedules/{scheduleId}/execute:
    post:
      summary: Run a schedule now
      description: >
        Queues the schedule's tasks immediately, without waiting for its cron
        time and without altering the next scheduled run. Works even when the
        schedule is inactive.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
        - name: scheduleId
          in: path
          required: true
          schema:
            type: integer
      responses:
        '204':
          description: Schedule queued
        '400':
          description: Non-integer schedule id
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/schedules/{scheduleId}/tasks:
    post:
      summary: Add a task to a schedule
      description: >
        Appends a step to the schedule. `payload` is interpreted by `action`:
        the console command for `command`, the power signal (`start`, `stop`,
        `restart`, `kill`) for `power`, and the ignored-files list for `backup`.

        `time_offset` is how long to wait after the preceding task before this
        one runs, which is why the first task in a schedule normally uses `0`.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
        - name: scheduleId
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [action, payload, time_offset]
              properties:
                action:
                  type: string
                  enum: [command, power, backup]
                payload:
                  type: string
                  maxLength: 2048
                time_offset:
                  type: integer
                  minimum: 0
                  maximum: 900
                  description: Seconds to wait after the preceding task
                sequence_id:
                  type: integer
                  minimum: 1
                  description: Position in the schedule; defaults to the end
                continue_on_failure:
                  type: boolean
                  description: Run the remaining tasks even if this one fails
      responses:
        '200':
          description: The created task
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  task:
                    $ref: '#/components/schemas/ServerScheduleTask'
        '400':
          description: Validation error, or a non-integer schedule id
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/schedules/{scheduleId}/tasks/{taskId}:
    post:
      summary: Update a schedule task
      description: Updates any subset of the task's fields. POST, not PATCH, matching the panel.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
        - name: scheduleId
          in: path
          required: true
          schema:
            type: integer
        - name: taskId
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: Any subset of the create body's fields
              properties:
                action:
                  type: string
                  enum: [command, power, backup]
                payload:
                  type: string
                  maxLength: 2048
                time_offset:
                  type: integer
                  minimum: 0
                  maximum: 900
                sequence_id:
                  type: integer
                  minimum: 1
                continue_on_failure:
                  type: boolean
      responses:
        '200':
          description: The updated task
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  task:
                    $ref: '#/components/schemas/ServerScheduleTask'
        '400':
          description: Validation error, or a non-integer id
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'
    delete:
      summary: Delete a schedule task
      description: Removes one step from the schedule. The remaining tasks keep their order.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
        - name: scheduleId
          in: path
          required: true
          schema:
            type: integer
        - name: taskId
          in: path
          required: true
          schema:
            type: integer
      responses:
        '204':
          description: Task deleted
        '400':
          description: Non-integer id
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/startup:
    get:
      summary: List startup variables
      description: >
        The egg's configurable variables with their current values, plus the
        rendered and raw startup commands and the Docker images the egg offers.

        `meta.docker_image` is the image the server is actually running, which
        the panel's startup endpoint does not report — it is read from the
        server detail and merged in here so a client can mark the current
        choice in `meta.docker_images`.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      responses:
        '200':
          description: Variables and startup metadata
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  variables:
                    type: array
                    items:
                      $ref: '#/components/schemas/StartupVariable'
                  meta:
                    type: object
                    properties:
                      startup_command:
                        type: string
                        description: The startup command with variables substituted
                      raw_startup_command:
                        type: string
                        description: The command as the egg defines it, with placeholders intact
                      docker_images:
                        type: object
                        description: Map of display label to image tag
                        additionalProperties:
                          type: string
                      docker_image:
                        type: string
                        description: The image this server currently runs
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/startup/variable:
    put:
      summary: Set a startup variable
      description: >
        Sets one variable's value. `key` is the variable's `env_variable`, not
        its display name. The new value takes effect on the next start, and the
        panel refuses variables the egg marks `is_editable: false`.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [key, value]
              properties:
                key:
                  type: string
                  description: The variable's `env_variable`
                  minLength: 1
                  maxLength: 191
                value:
                  type: string
                  maxLength: 2048
      responses:
        '200':
          description: The updated variable
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  variable:
                    $ref: '#/components/schemas/StartupVariable'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/settings/rename:
    post:
      summary: Rename the server
      description: Changes the server's display name in the panel. Nothing about the running server changes.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [name]
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 191
      responses:
        '204':
          description: Server renamed
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/settings/reinstall:
    post:
      summary: Reinstall the server
      description: >
        Re-runs the egg's install script against the existing volume. The server
        is stopped for the duration and `is_installing` stays true until it
        finishes; the console websocket reports progress.

        The install script may overwrite files it owns, so this is destructive
        for some eggs. Take a backup first.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      responses:
        '204':
          description: Reinstall started
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /server/{id}/settings/docker-image:
    put:
      summary: Set the server's Docker image
      description: >
        Switches the server to one of the images its egg offers — the keys of
        `meta.docker_images` from the startup endpoint. Commonly this is how a
        Java version is changed. The new image is used from the next start.
      tags: [Server Control]
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ServerIdentifier'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [docker_image]
              properties:
                docker_image:
                  type: string
                  minLength: 1
                  maxLength: 2048
      responses:
        '204':
          description: Image set
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          $ref: '#/components/responses/ServerNotFound'
        '500':
          $ref: '#/components/responses/ServerProxyError'

  /dedicated/template-groups:
    get:
      summary: List OS template groups and their templates
      description: >
        Returns all template groups, each with its nested OS templates
        (id, profile id, and version). Response is cached for 1h.
      tags: [Dedicated]
      security: []
      responses:
        '200':
          description: List of template groups
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        name:
                          type: string
                        image:
                          type: string
                        type:
                          type: string
                          enum: [LINUX, WINDOWS, UNIX, OTHER]
                        templates:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                              profileId:
                                type: integer
                              version:
                                type: string
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /dedicated/types:
    get:
      summary: List available dedicated server types
      description: >
        Always returns each type's configurable options alongside the type
        metadata. Response is cached for 1h.
      tags: [Dedicated]
      security: []
      responses:
        '200':
          description: List of dedicated server types
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        key:
                          type: string
                        name:
                          type: string
                        cpuModel:
                          type: string
                          nullable: true
                        description:
                          type: string
                          nullable: true
                        basePrice:
                          type: integer
                          description: Base price in cents
                        options:
                          type: array
                          description: >
                            The type's configurable options with per-type
                            override pricing and the joined option / category
                            metadata.
                          items:
                            type: object
                            properties:
                              optionId:
                                type: integer
                              priceOverride:
                                type: integer
                                nullable: true
                              additionalPriceOverride:
                                type: integer
                                nullable: true
                              option:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                                  priceDelta:
                                    type: integer
                                  additionalPriceDelta:
                                    type: integer
                                    nullable: true
                                  category:
                                    type: object
                                    properties:
                                      id:
                                        type: integer
                                      key:
                                        type: string
                                      name:
                                        type: string
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /dedicated/locations:
    get:
      summary: List available locations
      tags: [Dedicated]
      security: []
      responses:
        '200':
          description: List of locations
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        name:
                          type: string
                        code:
                          type: string
                        region:
                          type: string
                        city:
                          type: string
                        country:
                          type: string
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /dedicated/benchmarks:
    get:
      summary: List benchmark scores for available dedicated types
      description: >
        Returns benchmark categories, the dedicated types that have at least
        one score recorded, and the per (type, category) scores joining them.
        Only types currently marked `available` are included.
      tags: [Dedicated]
      security: []
      responses:
        '200':
          description: Benchmark catalog
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      categories:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            key:
                              type: string
                            name:
                              type: string
                            unit:
                              type: string
                              nullable: true
                            sortOrder:
                              type: integer
                      types:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: integer
                            key:
                              type: string
                            name:
                              type: string
                      scores:
                        type: array
                        items:
                          type: object
                          properties:
                            typeId:
                              type: integer
                            categoryId:
                              type: integer
                            score:
                              type: number
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /dedicated/inventory:
    get:
      summary: List dedicated server inventory
      tags: [Dedicated]
      security: []
      parameters:
        - name: search
          in: query
          schema:
            type: string
          description: Search by name or CPU model
        - name: key
          in: query
          schema:
            type: string
          description: Filter by type key
        - name: locationId
          in: query
          schema:
            type: string
          description: Filter by location ID
        - name: minPrice
          in: query
          schema:
            type: integer
            minimum: 0
          description: Minimum base price filter
        - name: maxPrice
          in: query
          schema:
            type: integer
            minimum: 0
          description: Maximum base price filter
        - name: sortBy
          in: query
          schema:
            type: string
            enum: [name, basePrice, createdAt]
            default: name
        - name: sortOrder
          in: query
          schema:
            type: string
            enum: [asc, desc]
            default: asc
        - name: options
          in: query
          required: false
          schema:
            type: string
          description: >
            Pass `true` (or `1`) to embed each type's configurable options on
            the response (same shape as /dedicated/types). Per-machine option
            selections are always included on every machine entry regardless
            of this flag.
      responses:
        '200':
          description: Inventory list
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        key:
                          type: string
                        name:
                          type: string
                        cpuModel:
                          type: string
                        description:
                          type: string
                        basePrice:
                          type: integer
                        resellerDiscount:
                          type: integer
                          description: >
                            Per-month discount in cents applied to this type's
                            base price when ordering as a reseller. Only present
                            on the response when the request is authenticated
                            (Bearer token or session) as a reseller account.
                        startingPrice:
                          type: integer
                          description: >
                            Lowest effective monthly price in cents available
                            for this type. Equal to base + cheapest option per
                            category, unless a machine-level priceOverride beats
                            that total — in which case the override wins.
                        hasStock:
                          type: boolean
                          description: >
                            True when at least one unassigned AVAILABLE machine
                            exists for this type (matching the location filter
                            if one was supplied).
                        availableCount:
                          type: integer
                          description: >
                            Number of individual AVAILABLE, unassigned machines
                            backing this type (pre-deduplication). Each entry in
                            `machines` may represent multiple of these — see
                            `machines[].count`.
                        options:
                          type: array
                          description: >
                            Only present when `options=true` is supplied.
                            Lists the type's configurable options with
                            per-type override pricing and the joined option /
                            category metadata.
                          items:
                            type: object
                            properties:
                              optionId:
                                type: integer
                              priceOverride:
                                type: integer
                                nullable: true
                              additionalPriceOverride:
                                type: integer
                                nullable: true
                              option:
                                type: object
                                properties:
                                  id:
                                    type: integer
                                  name:
                                    type: string
                                  priceDelta:
                                    type: integer
                                  additionalPriceDelta:
                                    type: integer
                                    nullable: true
                                  category:
                                    type: object
                                    properties:
                                      id:
                                        type: integer
                                      key:
                                        type: string
                                      name:
                                        type: string
                        machines:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: integer
                                description: >
                                  Pass this back as `machineId` on POST
                                  `/order/dedicated` to claim this specific
                                  machine at its override price.
                              location:
                                type: string
                              locationCode:
                                type: string
                              specs:
                                type: object
                                additionalProperties:
                                  type: string
                              monthlyPrice:
                                type: integer
                                description: >
                                  Effective monthly price in cents. Equals
                                  `normalPrice` unless a machine-level override
                                  beats it, in which case it matches the
                                  override.
                              normalPrice:
                                type: integer
                                description: >
                                  Monthly price in cents computed from the type
                                  base + selected options, ignoring any
                                  machine-level override.
                              usedOverride:
                                type: boolean
                                description: >
                                  True when `monthlyPrice` reflects a
                                  machine-level price override rather than the
                                  normal type+options total.
                              count:
                                type: integer
                                description: >
                                  Number of machines available with this exact
                                  location + options configuration.
                              options:
                                type: array
                                description: >
                                  This machine's option selections with
                                  quantities and the joined option / category
                                  metadata. Always reflects the
                                  lowest-priced machine in the dedup group.
                                items:
                                  type: object
                                  properties:
                                    optionId:
                                      type: integer
                                    quantity:
                                      type: integer
                                    option:
                                      type: object
                                      properties:
                                        id:
                                          type: integer
                                        name:
                                          type: string
                                        priceDelta:
                                          type: integer
                                        additionalPriceDelta:
                                          type: integer
                                          nullable: true
                                        category:
                                          type: object
                                          properties:
                                            id:
                                              type: integer
                                            key:
                                              type: string
                                            name:
                                              type: string
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /dedicated:
    get:
      summary: List your dedicated servers
      description: >
        Returns all active dedicated servers owned by the authenticated user,
        each including its type and location, ordered by most recently assigned.
      tags: [Dedicated]
      security:
        - BearerAuth: []
      responses:
        '200':
          description: List of the user's dedicated servers
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  total:
                    type: integer
                    description: Number of dedicated servers returned
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        serverName:
                          type: string
                        status:
                          type: string
                        ipv4:
                          type: array
                          items:
                            type: string
                        assignedAt:
                          type: string
                          format: date-time
                          nullable: true
                        type:
                          type: object
                          properties:
                            id:
                              type: integer
                            key:
                              type: string
                            name:
                              type: string
                            cpuModel:
                              type: string
                            basePrice:
                              type: integer
                        location:
                          type: object
                          properties:
                            id:
                              type: string
                            name:
                              type: string
                            code:
                              type: string
                            region:
                              type: string
                            city:
                              type: string
                            country:
                              type: string
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /dedicated/{id}:
    get:
      summary: Get a dedicated server by ID
      description: Returns details for a specific dedicated server owned by the authenticated user, including type, location, options, and the associated billing service (if any).
      tags: [Dedicated]
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: Machine ID
      responses:
        '200':
          description: Machine details
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                      status:
                        type: string
                      ipv4:
                        type: array
                        items:
                          type: string
                      assignedAt:
                        type: string
                        format: date-time
                      type:
                        type: object
                        properties:
                          id:
                            type: integer
                          key:
                            type: string
                          name:
                            type: string
                          cpuModel:
                            type: string
                          basePrice:
                            type: integer
                      location:
                        type: object
                        properties:
                          id:
                            type: string
                          name:
                            type: string
                          code:
                            type: string
                          region:
                            type: string
                          city:
                            type: string
                          country:
                            type: string
                      options:
                        type: array
                        items:
                          type: object
                      service:
                        nullable: true
                        description: >
                          The billing service associated with this machine (with its
                          parent billable nested), or null if the machine has no billing
                          entry (e.g. admin-created machines).
                        allOf:
                          - $ref: '#/components/schemas/Service'
        '404':
          description: Machine not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /dedicated/{id}/power:
    get:
      summary: Get a dedicated server's power status
      description: Returns the current power state of a dedicated server owned by the authenticated user, sourced from TenantOS.
      tags: [Dedicated]
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: Machine ID
      responses:
        '200':
          description: Power status
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    description: Power status payload as returned by TenantOS.
        '400':
          description: Invalid machine ID
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Machine not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: Machine is not yet provisioned
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /dedicated/{id}/power/on:
    post:
      summary: Power on a dedicated server
      description: Requests a power-on for a dedicated server owned by the authenticated user via TenantOS.
      tags: [Dedicated]
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: Machine ID
      responses:
        '200':
          description: Power on requested
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
                  data:
                    description: Result payload as returned by TenantOS.
        '400':
          description: Invalid machine ID
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Machine not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: Machine is not yet provisioned
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /dedicated/{id}/power/off:
    post:
      summary: Power off a dedicated server
      description: Requests a power-off for a dedicated server owned by the authenticated user via TenantOS.
      tags: [Dedicated]
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: Machine ID
      responses:
        '200':
          description: Power off requested
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
                  data:
                    description: Result payload as returned by TenantOS.
        '400':
          description: Invalid machine ID
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Machine not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: Machine is not yet provisioned
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /dedicated/{id}/upgrade-request:
    post:
      summary: Request a hardware upgrade
      description: >
        Opens a sales support ticket asking for more memory, extra drives or a
        faster uplink on a dedicated machine owned by the authenticated user.
        Only upgrades the machine's type offers are accepted. The drive layout may
        be changed within the type's caps as long as total storage doesn't go
        down; drives that come out are wiped. Nothing is charged and nothing about the machine or its billing
        changes: the ticket carries the requested spec and a price estimate, and
        staff confirm the final price there. Test-mode API keys get the
        validation result and estimate without a ticket being opened.
      tags: [Dedicated]
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: Machine ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [memoryOptionId, uplinkOptionId, disks]
              properties:
                memoryOptionId:
                  type: integer
                  nullable: true
                  description: Memory option to upgrade to, or null to keep the current memory.
                uplinkOptionId:
                  type: integer
                  nullable: true
                  description: Uplink option to upgrade to, or null to keep the current uplink.
                disks:
                  type: array
                  minItems: 1
                  maxItems: 32
                  description: >
                    The full drive layout wanted, one row per drive model. Send the
                    machine's current layout to leave its drives unchanged.
                  items:
                    type: object
                    required: [optionId, quantity]
                    properties:
                      optionId:
                        type: integer
                      quantity:
                        type: integer
                        minimum: 1
                notes:
                  type: string
                  maxLength: 2000
                preferredWindow:
                  type: string
                  maxLength: 500
                  description: When the customer would prefer the maintenance window.
      responses:
        '200':
          description: Ticket opened (or, for a test-mode key, the request validated)
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
                  test:
                    type: boolean
                  data:
                    type: object
                    properties:
                      ticketId:
                        type: integer
                      changes:
                        type: array
                        description: Test mode only. What would change.
                        items:
                          type: object
                          properties:
                            category:
                              type: string
                            from:
                              type: string
                              nullable: true
                            to:
                              type: string
                      wiped:
                        type: array
                        description: Test mode only. Drives that would come out of the machine.
                        items:
                          type: object
                          properties:
                            name:
                              type: string
                            quantity:
                              type: integer
                      estimate:
                        type: object
                        nullable: true
                        description: >
                          Test mode only. Estimated increase per billing period and
                          one-time setup fee, in the subscription's currency (cents).
                          Null for rented machines and periods that can't be priced.
                        properties:
                          periodIncrease:
                            type: integer
                          setupFee:
                            type: integer
                      currency:
                        type: string
        '400':
          description: Not eligible, or an upgrade the machine's type doesn't offer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Machine not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /dedicated/{id}/reinstall:
    post:
      summary: Reinstall a dedicated server
      description: >
        Starts a reinstallation of a dedicated server owned by the authenticated
        user using the given OS template profile id. The profile id must map to a
        configured template; arbitrary TenantOS profiles are rejected.
      tags: [Dedicated]
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: Machine ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [profileId, rootPassword]
              properties:
                profileId:
                  type: integer
                  description: TenantOS template profile id (must belong to a configured template).
                rootPassword:
                  type: string
                  minLength: 8
                  description: >
                    Root password for the freshly installed OS. Required by TenantOS on
                    every reinstallation.
      responses:
        '200':
          description: Reinstallation started
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
                  data:
                    description: Result payload as returned by TenantOS.
        '400':
          description: Invalid machine ID or template profile
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Machine not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: Machine is not yet provisioned
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /ip-move-requests:
    post:
      summary: Request an IP move to one of your servers
      description: |
        Asks our team to move IPs onto one of your TenantOS servers. The
        destination server must belong to your TenantOS account. The move is
        not made automatically: the request is verified, then sent to our team,
        who carry it out.

        There are two modes:

        - **With `subnetId`:** the subnet must belong to your TenantOS account,
          and every IP must be a usable address inside it (not its network,
          gateway or broadcast address). IPs may be unassigned or on any server.
        - **Without `subnetId`:** every IP must currently be on one of your
          TenantOS servers. Use this to move IPs between your own machines,
          including IPs from subnets you don't own.

        The response lists where each IP currently sits. IPs already on the
        destination server are skipped. An IP can only be in one pending request
        at a time; cancel the earlier request to change it. Track the request
        with `GET /ip-move-requests/{id}`. You are emailed when our team
        completes or rejects it.
      tags: [Dedicated]
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [ips, targetServerId]
              properties:
                subnetId:
                  type: integer
                  description: >
                    TenantOS subnet ID of a subnet you own, as shown in the TenantOS
                    IP manager. Omit it to move IPs that are already on your servers.
                  example: 5882
                ips:
                  type: array
                  minItems: 1
                  maxItems: 32
                  description: IPv4 addresses to move. Duplicates are ignored.
                  items:
                    type: string
                    format: ipv4
                  example: ['62.68.68.20']
                targetServerId:
                  type: integer
                  description: TenantOS server ID of the server to move the IPs onto.
                  example: 5734
                note:
                  type: string
                  maxLength: 500
                  description: Optional message for our team.
      responses:
        '202':
          description: Request verified and sent to our team
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: Your request has been sent to our team
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Request ID, for `GET /ip-move-requests/{id}`.
                      status:
                        type: string
                        example: PENDING
                      subnet:
                        type: object
                        nullable: true
                        description: The subnet from the request; null when `subnetId` was omitted.
                        properties:
                          id:
                            type: integer
                          cidr:
                            type: string
                            example: 62.68.68.0/24
                      targetServer:
                        type: object
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      moves:
                        type: array
                        description: IPs included in the request, with the server each is currently on.
                        items:
                          type: object
                          properties:
                            ip:
                              type: string
                            currentServer:
                              type: object
                              nullable: true
                              description: Null when the IP is not assigned to any server.
                              properties:
                                id:
                                  type: integer
                                name:
                                  type: string
                      skipped:
                        type: array
                        description: IPs already on the destination server.
                        items:
                          type: string
        '400':
          description: >
            Invalid request body, a non-IPv4 subnet, or IPs that are outside the
            subnet or reserved. For IP problems, `errors` lists each offending
            IP with a reason.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  message:
                    type: string
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        ip:
                          type: string
                        reason:
                          type: string
        '403':
          description: >
            Your account has no TenantOS user, the subnet or destination server
            does not belong to it, or (without `subnetId`) some IPs are not on
            one of your servers. In the last case `errors` lists each one.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  message:
                    type: string
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        ip:
                          type: string
                        reason:
                          type: string
        '404':
          description: Subnet or destination server not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: >
            Some IPs are already in a pending request (`conflicts` lists them), or
            every IP is already on the destination server so there is nothing to
            move (`skipped` lists them).
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/IpMoveRequestConflict'
                  - type: object
                    properties:
                      success:
                        type: boolean
                        example: false
                      message:
                        type: string
                      skipped:
                        type: array
                        items:
                          type: string
        '429':
          description: Too many requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitError'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '502':
          description: TenantOS could not be reached to verify the request; try again
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
    get:
      summary: List your IP move and release requests
      description: Returns your IP move and release requests, newest first.
      tags: [Dedicated]
      security:
        - BearerAuth: []
      parameters:
        - name: status
          in: query
          required: false
          schema:
            type: string
            enum: [PENDING, COMPLETED, REJECTED, CANCELLED]
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
        - name: count
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 20
      responses:
        '200':
          description: Your requests
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      $ref: '#/components/schemas/IpMoveRequest'
                  pagination:
                    type: object
                    properties:
                      offset:
                        type: integer
                      count:
                        type: integer
                      total:
                        type: integer
                      hasNext:
                        type: boolean
                      hasPrev:
                        type: boolean
        '400':
          description: Invalid query parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /ip-move-requests/release:
    post:
      summary: Request an IP release from one of your servers
      description: |
        Asks our team to take IPs off one of your TenantOS servers and return
        them to our pool, for example so you stop paying for them. The release
        is not made automatically: the request is verified, then sent to our
        team, who carry it out.

        - Every IP must currently be on one of your TenantOS servers, and all
          of them on the same server.
        - A server's primary IP cannot be released.
        - Billing for any paid additional IPs stops from your next renewal, with
          no refund for the current period. Our team adjusts it when they
          complete the request.
        - A released IP may be given to another customer. Set
          `acknowledgeIrreversible` to `true` to confirm you understand this.

        An IP can only be in one pending request (move or release) at a time.
        Track and cancel the request with the other `/ip-move-requests`
        operations; it is returned with `kind: RELEASE`. You are emailed when
        our team completes or rejects it.
      tags: [Dedicated]
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [ips, acknowledgeIrreversible]
              properties:
                ips:
                  type: array
                  minItems: 1
                  maxItems: 32
                  description: IPv4 addresses to release. Duplicates are ignored.
                  items:
                    type: string
                    format: ipv4
                  example: ['62.68.68.20']
                acknowledgeIrreversible:
                  type: boolean
                  enum: [true]
                  description: Must be `true`. Released IPs may go to another customer.
                note:
                  type: string
                  maxLength: 500
                  description: Optional message for our team.
      responses:
        '202':
          description: Request verified and sent to our team
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: Your request has been sent to our team
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: Request ID, for `GET /ip-move-requests/{id}`.
                      kind:
                        type: string
                        example: RELEASE
                      status:
                        type: string
                        example: PENDING
                      sourceServer:
                        type: object
                        description: The server the IPs are being released from.
                        properties:
                          id:
                            type: integer
                          name:
                            type: string
                      ips:
                        type: array
                        items:
                          type: string
        '400':
          description: >
            Invalid request body, IPs on more than one server, or a primary IP.
            For IP problems, `errors` lists each offending IP with a reason.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  message:
                    type: string
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        ip:
                          type: string
                        reason:
                          type: string
        '403':
          description: >
            Your account has no TenantOS user, or some IPs are not on one of
            your servers (`errors` lists each one).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  message:
                    type: string
                  errors:
                    type: array
                    items:
                      type: object
                      properties:
                        ip:
                          type: string
                        reason:
                          type: string
        '409':
          description: Some IPs are already in a pending request (`conflicts` lists them).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IpMoveRequestConflict'
        '429':
          description: Too many requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitError'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '502':
          description: TenantOS could not be reached to verify the request; try again
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /ip-move-requests/{id}:
    get:
      summary: Get an IP move request
      description: Returns one of your IP move requests, including its status and any rejection reason.
      tags: [Dedicated]
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: Request ID
      responses:
        '200':
          description: The request
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/IpMoveRequest'
        '404':
          description: Request not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /ip-move-requests/{id}/cancel:
    post:
      summary: Cancel a pending IP move or release request
      description: >
        Cancels one of your requests while it is still pending, which frees its
        IPs for a new request. Requests our team has already completed or
        rejected cannot be cancelled.
      tags: [Dedicated]
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: Request ID
      responses:
        '200':
          description: Request cancelled
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
        '404':
          description: Request not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: The request is no longer pending
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Too many requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitError'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /ipv4-requests:
    post:
      summary: Buy additional IPv4 addresses for a machine
      description: |
        Orders more IPv4 addresses for one of your active dedicated machines.
        Each address costs $5 per month. You are charged for one full billing
        period of your machine's subscription, with the same term discount as
        the subscription, in its currency, plus any sales tax. Your next renewal
        then includes the addresses.

        Account credit is applied first, then your subscription's payment
        method is charged. Subscriptions paid by bank transfer or crypto are
        never charged automatically. If nothing is charged, or the charge
        fails, the request is kept with status `AWAITING_PAYMENT`, and you can
        pay its invoice from the client area or cancel the request. Once paid,
        our team adds the addresses and emails you.

        A machine can have only one open request (awaiting payment or paid) at
        a time. Subscriptions billed in arrears, through an external
        subscription gateway, or invoiced manually can't order online; contact
        support instead.

        Test-mode API keys return the quote without creating a request or
        charging anything.
      tags: [Dedicated]
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [machineId, count, reason]
              properties:
                machineId:
                  type: integer
                  description: ID of your machine, as returned by `GET /dedicated`.
                  example: 195
                count:
                  type: integer
                  minimum: 1
                  maximum: 64
                  description: How many additional IPv4 addresses you want.
                  example: 4
                reason:
                  type: string
                  minLength: 1
                  maxLength: 1000
                  description: What the addresses are for. Our team needs this to justify the allocation.
      responses:
        '200':
          description: Test-mode keys only. The quote, with nothing created or charged.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  test:
                    type: boolean
                    example: true
                  message:
                    type: string
                  data:
                    $ref: '#/components/schemas/Ipv4RequestQuote'
        '202':
          description: >
            Request created. `data.paid` says whether payment was taken; when it
            is false, pay invoice `data.invoiceId` to send the request to our team.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                  data:
                    allOf:
                      - $ref: '#/components/schemas/Ipv4Request'
                      - type: object
                        properties:
                          paid:
                            type: boolean
                          quote:
                            $ref: '#/components/schemas/Ipv4RequestQuote'
        '400':
          description: >
            Invalid request body, no active subscription for the machine, a
            subscription that can't order online, no payment method, or a
            payment method that failed validation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Machine not found, not yours, or not active
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: The machine already has an open request
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  message:
                    type: string
                    example: This machine already has an open IPv4 request
                  requestId:
                    type: integer
                    nullable: true
                    description: The open request's ID.
        '429':
          description: Too many requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitError'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
    get:
      summary: List your IPv4 requests
      description: Returns your additional IPv4 requests, newest first.
      tags: [Dedicated]
      security:
        - BearerAuth: []
      parameters:
        - name: status
          in: query
          required: false
          schema:
            type: string
            enum: [AWAITING_PAYMENT, PAID, COMPLETED, REJECTED, CANCELLED]
        - name: machineId
          in: query
          required: false
          schema:
            type: integer
          description: Only requests for this machine.
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
        - name: count
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 20
      responses:
        '200':
          description: Your requests
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      $ref: '#/components/schemas/Ipv4Request'
                  pagination:
                    type: object
                    properties:
                      offset:
                        type: integer
                      count:
                        type: integer
                      total:
                        type: integer
                      hasNext:
                        type: boolean
                      hasPrev:
                        type: boolean
        '400':
          description: Invalid query parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /ipv4-requests/{id}:
    get:
      summary: Get an IPv4 request
      description: Returns one of your additional IPv4 requests, including its status and any rejection reason.
      tags: [Dedicated]
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: Request ID
      responses:
        '200':
          description: The request
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/Ipv4Request'
        '404':
          description: Request not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /ipv4-requests/{id}/cancel:
    post:
      summary: Cancel an unpaid IPv4 request
      description: >
        Cancels one of your requests while it is still awaiting payment. Its
        invoice is voided and any account credit applied to it is returned.
        Paid requests can't be cancelled; open a support ticket instead.
      tags: [Dedicated]
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: Request ID
      responses:
        '200':
          description: Request cancelled
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
        '404':
          description: Request not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: The request is no longer awaiting payment, a payment for it is still processing, or it was ordered with the machine
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Too many requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitError'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /firewall/profiles:
    get:
      summary: List firewall profiles
      tags: [Firewall]
      security:
        - BearerAuth: []
      responses:
        '200':
          description: List of profiles
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /firewall/{ip}:
    get:
      summary: Get firewall rules for an IP
      tags: [Firewall]
      security:
        - BearerAuth: []
      parameters:
        - name: ip
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Rules for the IP
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
                  rules:
                    type: array
                    items:
                      $ref: '#/components/schemas/CosmicRule'
        '400':
          description: IP not owned by user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
    post:
      summary: Update firewall rules for an IP
      description: >
        Replaces the firewall rules for the IP with the supplied set. An empty
        array clears all rules for the IP. The response returns the canonical
        rules after the update.
      tags: [Firewall]
      security:
        - BearerAuth: []
      parameters:
        - name: ip
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: array
              items:
                $ref: '#/components/schemas/CosmicRule'
      responses:
        '200':
          description: Rules updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
                  rules:
                    type: array
                    items:
                      $ref: '#/components/schemas/CosmicRule'
        '400':
          description: IP not owned by user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /firewall/attacks:
    get:
      summary: Get DDoS attack history across the account
      description: >
        Returns the paginated history of mitigated DDoS attack events recorded
        against the authenticated user's IPs, newest first.


        When `addresses` is omitted, results span every IP the user owns — those
        bound to their machines plus any attached directly to their account.
        When `addresses` is supplied, results are restricted to those IPs; if
        any requested address is not assigned to the user, the request is
        rejected with 400.


        History on a machine-bound IP starts when that machine was assigned to
        the account: attacks absorbed by the address under a previous tenant are
        not returned. IPs attached directly to the user account carry no such
        cutoff and return their full history.
      tags: [Firewall]
      security:
        - BearerAuth: []
      parameters:
        - name: addresses
          in: query
          required: false
          schema:
            type: array
            items:
              type: string
          style: form
          explode: true
          description: >
            One or more IPv4 addresses to filter by. Repeat the parameter
            (`?addresses=a&addresses=b`) or pass a comma-separated list
            (`?addresses=a,b`). Omit to aggregate across the whole account.
        - name: count
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 20
          description: Number of attack records to return (page size)
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of attack records to skip (for pagination)
      responses:
        '200':
          description: Attack history for the IP
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
                  attacks:
                    type: array
                    items:
                      $ref: '#/components/schemas/Attack'
                  total:
                    type: integer
                    description: Total number of matching attack records (ignores paging)
        '400':
          description: A requested address is not assigned to the user, or invalid query parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /firewall/metrics:
    get:
      summary: Get firewall traffic metrics for several IPs at once
      description: >
        Returns the same time-bucketed filter metrics as
        `/firewall/{ip}/metrics`, for many addresses in a single request, keyed
        by address.


        Intended for a live fleet view. Polling the per-address route for every
        address costs one request and one rate-limit token each per refresh, for
        data that is a single windowed scan of the same table; this route is one
        of each however many addresses are involved.


        Every requested address must belong to the authenticated user. A single
        address that does not is rejected with 400 rather than being omitted, so
        a typo surfaces as an error instead of as an address that looks quiet.


        An address the caller owns but which saw no traffic in the window is
        present in the response with an empty array, so "quiet" is
        distinguishable from "not reported".


        Rate limited on the same buckets as the per-address route.
      tags: [Firewall]
      security:
        - BearerAuth: []
      parameters:
        - name: addresses
          in: query
          required: false
          schema:
            type: array
            items:
              type: string
          style: form
          explode: true
          description: >
            One or more IPv4 addresses. Repeat the parameter
            (`?addresses=a&addresses=b`) or pass a comma-separated list
            (`?addresses=a,b`). Omit to report every address on every active
            machine the user owns, which saves a fleet client a prior call to
            `/dedicated`. At most 256 addresses.
        - name: seconds
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 3600
            default: 60
          description: Length of the look-back window in seconds (how far back to query)
        - name: bucket
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 3600
            default: 1
          description: Bucket size in seconds; each returned entry aggregates this many seconds
      responses:
        '200':
          description: Time-bucketed traffic metrics, keyed by address
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
                  data:
                    type: object
                    description: >
                      Each key is one of the requested IPv4 addresses; each value
                      is that address's buckets, oldest to newest.
                    additionalProperties:
                      type: array
                      items:
                        $ref: '#/components/schemas/FirewallMetricsBucket'
        '400':
          description: >
            One or more addresses are not assigned to the user, more than 256
            were requested, or the query parameters are invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: >
            Rate limit exceeded. Retry after the number of seconds given in the
            `Retry-After` response header.
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before retrying
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /firewall/{ip}/metrics:
    get:
      summary: Get firewall traffic metrics for an IP
      description: >
        Returns time-bucketed firewall/filter traffic metrics for one of the
        authenticated user's IPs, powering the live throughput and packet-rate
        charts in the client area. Data is aggregated per bucket and summed
        across mitigation nodes, ordered oldest to newest.


        This endpoint is rate limited per user (a token bucket of 20 requests
        refilling at 10/s) and globally; when exhausted it responds with 429 and
        a `Retry-After` header (seconds).


        To follow several addresses at once, prefer `GET /firewall/metrics`,
        which returns them all in one request and one token.
      tags: [Firewall]
      security:
        - BearerAuth: []
      parameters:
        - name: ip
          in: path
          required: true
          schema:
            type: string
          description: An IPv4 address assigned to one of your machines or your account
        - name: seconds
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 3600
            default: 60
          description: Length of the look-back window in seconds (how far back to query)
        - name: bucket
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 3600
            default: 1
          description: Bucket size in seconds; each returned entry aggregates this many seconds
      responses:
        '200':
          description: Time-bucketed traffic metrics for the IP
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/FirewallMetricsBucket'
        '400':
          description: IP not owned by user, or invalid query parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: >
            Rate limit exceeded. Retry after the number of seconds given in the
            `Retry-After` response header.
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before retrying
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /billing/invoices:
    get:
      summary: List invoices
      description: >
        Returns the authenticated user's invoices, newest first, with pagination.
        Each entry includes billing status, totals, and the parent billable ID.
      tags: [Billing]
      security:
        - BearerAuth: []
      parameters:
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            default: 0
            minimum: 0
          description: Number of invoices to skip
        - name: count
          in: query
          required: false
          schema:
            type: integer
            default: 20
            minimum: 1
            maximum: 100
          description: Page size (capped at 100)
      responses:
        '200':
          description: Paginated list of invoices
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        type:
                          type: string
                          description: Invoice type
                        status:
                          type: string
                          description: Invoice lifecycle status
                        total:
                          type: integer
                          description: Invoice total in minor currency units
                        amountPaid:
                          type: integer
                          description: Amount already paid, in minor currency units
                        currency:
                          type: string
                        issuedAt:
                          type: string
                          format: date-time
                          nullable: true
                        dueAt:
                          type: string
                          format: date-time
                          nullable: true
                        createdAt:
                          type: string
                          format: date-time
                        billable:
                          type: object
                          nullable: true
                          properties:
                            id:
                              type: integer
                  pagination:
                    type: object
                    properties:
                      offset:
                        type: integer
                      count:
                        type: integer
                      total:
                        type: integer
                      hasNext:
                        type: boolean
                      hasPrev:
                        type: boolean
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /billing/invoices/pay:
    post:
      summary: Pay one or more invoices
      description: >
        Pays one or more invoices in a single request. Pass a single ID in
        `invoiceIds` to pay one invoice, or multiple IDs to bulk-pay. All invoices
        must belong to the authenticated user and be in a payable status
        (`FINALIZED`, `PARTIALLY_PAID`, `UNPAID`, or `OVERDUE`).


        Account credits are applied first; any invoice fully covered by credits is
        settled without a charge. If a balance remains, `gateway` and `methodId`
        are required, and the remaining invoices are charged — one payment is
        created per currency group across the paid invoices.
      tags: [Billing]
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [invoiceIds]
              properties:
                invoiceIds:
                  type: array
                  minItems: 1
                  items:
                    type: integer
                    minimum: 1
                  description: IDs of the invoices to pay (one for single, many for bulk)
                gateway:
                  type: string
                  enum: [STRIPE, PAYPAL]
                  description: Required when a balance remains after credits are applied
                methodId:
                  type: string
                  description: >
                    Saved payment method identifier for the gateway. Use `CAPTURE`
                    for one-shot flows (e.g. iDEAL/PayPal one-time); such methods
                    are ignored by `setDefaultMethod` since they can't recur.
                intent:
                  type: string
                  description: Optional gateway payment intent reference
                setDefaultMethod:
                  type: boolean
                  default: false
                  description: >
                    Opt-in: also store the charged method as the renewal default on
                    the subscription(s) behind the paid invoices.
      responses:
        '200':
          description: Payment processed (or all invoices covered by credits)
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
                    example: Payment processed
                  data:
                    type: object
                    properties:
                      creditsApplied:
                        type: integer
                        description: Total account credits applied, in minor currency units
                      fullyPaidByCredits:
                        type: array
                        items:
                          type: integer
                        description: IDs of invoices fully settled by credits alone
                      payments:
                        type: array
                        description: One payment per currency group; empty when everything was covered by credits
                        items:
                          type: object
                          properties:
                            currency:
                              type: string
                            paymentId:
                              type: integer
                            status:
                              type: string
                              description: Gateway charge status (e.g. succeeded, pending, failed)
                            gatewayRef:
                              type: string
                            invoiceIds:
                              type: array
                              items:
                                type: integer
                            amount:
                              type: integer
                              description: Charged amount for this currency group, in minor currency units
        '400':
          description: One or more invoices not payable, or a payment method is required for the remaining balance
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: One or more invoices not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /billing/billables/{id}:
    get:
      summary: Get a billable (subscription) by ID
      description: >
        Returns a single subscription owned by the authenticated user, with its
        services and invoices (newest first) nested. Payment-method and analytics
        identifiers are omitted. For lightweight order-confirmation polling, use
        `/billing/order-status/{billableId}` instead.
      tags: [Billing]
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: Billable subscription ID
      responses:
        '200':
          description: Subscription details
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    allOf:
                      - $ref: '#/components/schemas/Billable'
                      - type: object
                        properties:
                          services:
                            type: array
                            items:
                              $ref: '#/components/schemas/Service'
                          invoices:
                            type: array
                            description: Invoices for this subscription, newest first
                            items:
                              $ref: '#/components/schemas/Invoice'
        '400':
          description: Invalid billable ID
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Subscription not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /billing/billables/{id}/cancel:
    post:
      summary: Cancel a subscription
      description: >
        Cancels a billable subscription. If `immediate` is true or the billing period has already ended,
        the subscription is cancelled immediately and associated resources are terminated. Otherwise,
        the cancellation is scheduled for the end of the current billing period.
      tags: [Billing]
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: Billable subscription ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                immediate:
                  type: boolean
                  default: false
                  description: If true, cancel immediately instead of at end of period
      responses:
        '200':
          description: Cancellation processed
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                        example: Subscription cancelled immediately
                      refund:
                        type: object
                        nullable: true
                        description: >
                          Refund outcome for the immediate cancellation, or null
                          when nothing was refunded (e.g. outside the money-back
                          window).
                        properties:
                          gatewayRefunded:
                            type: integer
                            description: Amount refunded to the payment gateway, in minor currency units
                          creditRestored:
                            type: integer
                            description: Amount restored as account credit, in minor currency units
                          currency:
                            type: string
                          failed:
                            type: boolean
                            description: True if the gateway refund was attempted but failed
                  - type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                        example: Subscription will be cancelled on March 22, 2026
                      cancelDate:
                        type: string
                        format: date-time
        '400':
          description: Already cancelled or cancellation already scheduled
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Subscription not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /billing/billables/{id}/undo-cancel:
    post:
      summary: Undo a scheduled cancellation
      description: >
        Reverses a cancellation that was scheduled for the end of the current billing period,
        keeping the subscription active. Only works while the subscription is still `ACTIVE`,
        has a pending cancellation, and the current billing period has not yet ended.
      tags: [Billing]
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: Billable subscription ID
      responses:
        '200':
          description: Cancellation reversed
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
                    example: Cancellation has been reversed
        '400':
          description: >
            Invalid subscription ID, no pending cancellation to undo, or the billing period
            has already ended
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Subscription not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /billing/billables/{id}/services/{serviceId}/cancel:
    post:
      summary: Cancel a single service on a subscription
      description: >
        Cancels one service on a multi-service subscription, leaving the
        subscription and its remaining services active. If `immediate` is true
        the service is dropped from billing at once, its resource is torn down
        and the subscription's recurring price is recomputed; no refund is
        issued for the removed service. Otherwise the service is flagged to end
        at the subscription's current `periodEnd` and keeps running until then.


        Only available on self-billed subscriptions (gateway `INTERNAL`,
        `STRIPE` or `PAYPAL`) that have more than one active service. `IPV4`
        services are released by support rather than through this endpoint.
      tags: [Billing]
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: Billable subscription ID
        - name: serviceId
          in: path
          required: true
          schema:
            type: integer
          description: ID of the service on that subscription
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                immediate:
                  type: boolean
                  default: false
                  description: >
                    If true, cancel the service now and tear down its resource
                    instead of at the end of the current billing period
      responses:
        '200':
          description: Service cancellation processed
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                        example: DEDICATED #4821 cancelled
                  - type: object
                    properties:
                      success:
                        type: boolean
                      message:
                        type: string
                        example: DEDICATED #4821 will be cancelled on March 22, 2026
                      cancelDate:
                        type: string
                        format: date-time
                        description: The subscription's `periodEnd`, when the service will end
        '400':
          description: >
            Invalid subscription or service ID; the subscription's gateway does
            not support per-service cancellation; the service is already
            cancelled; the service is an `IPV4` address (contact support); it is
            the only active service on the subscription (cancel the whole
            subscription instead); or, for an end-of-period cancellation, the
            service is already scheduled to cancel or the billing period has
            already ended.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Subscription not found, or the service is not on this subscription
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /billing/billables/{id}/services/{serviceId}/undo-cancel:
    post:
      summary: Undo a scheduled service cancellation
      description: >
        Clears a service's pending end-of-period cancellation, keeping it on the
        subscription. Only works while the service has a `cancelRequestedAt` set,
        has not already been cancelled, and the subscription's current billing
        period has not yet ended. A service cancelled immediately cannot be
        restored this way.
      tags: [Billing]
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
          description: Billable subscription ID
        - name: serviceId
          in: path
          required: true
          schema:
            type: integer
          description: ID of the service on that subscription
      responses:
        '200':
          description: Service cancellation reversed
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
                    example: Service cancellation reversed
        '400':
          description: >
            Invalid subscription or service ID, no pending cancellation to undo
            for this service, or the billing period has already ended
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Subscription not found, or the service is not on this subscription
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /billing/order-status/{billableId}:
    get:
      summary: Get order status
      description: >
        Returns the current status of a billable order, its most recent
        invoice, and the provisioning status of each resource it covers.
        Intended for polling an order confirmation page until payment settles
        and the resources finish provisioning. Only the authenticated user's
        own billables are accessible.
      tags: [Billing]
      security:
        - BearerAuth: []
      parameters:
        - name: billableId
          in: path
          required: true
          schema:
            type: integer
          description: Billable ID
      responses:
        '200':
          description: Order status
          content:
            application/json:
              schema:
                type: object
                properties:
                  billable:
                    type: object
                    properties:
                      status:
                        type: string
                        description: Billable lifecycle status
                  invoice:
                    type: object
                    nullable: true
                    description: Most recent invoice for the billable, or null if none exists
                    properties:
                      status:
                        type: string
                        description: Invoice status
                      paidAt:
                        type: string
                        format: date-time
                        nullable: true
                  services:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        resourceType:
                          type: string
                          enum: [SHARED, DEDICATED]
                        resourceId:
                          type: integer
                        resourceStatus:
                          type: string
                          nullable: true
                          description: Live status of the underlying server (SHARED) or machine (DEDICATED), or null if not yet created
                        deliveredAt:
                          type: string
                          format: date-time
                          nullable: true
        '400':
          description: Invalid billable ID
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Billable not found or not owned by the authenticated user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /stripe/methods:
    get:
      summary: List saved Stripe payment methods
      description: >
        Returns the authenticated user's saved Stripe payment methods (card,
        US bank account/ACH, and SEPA debit) along with their default method.
        Results are cached per Stripe customer for 10 minutes; the `cached`
        flag indicates whether this response was served from cache. Items are
        raw Stripe PaymentMethod objects, so additional Stripe-provided fields
        may be present beyond those documented here.
      tags: [Billing]
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Saved Stripe payment methods
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
                  paymentMethods:
                    type: array
                    items:
                      $ref: '#/components/schemas/StripePaymentMethod'
                  defaultPaymentMethod:
                    allOf:
                      - $ref: '#/components/schemas/StripePaymentMethod'
                    nullable: true
                    description: The customer's default payment method, or null if none is set
                  cached:
                    type: boolean
                    description: Whether the result was served from the Redis cache
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /paypal/methods:
    get:
      summary: List saved PayPal payment methods
      description: >
        Returns the authenticated user's vaulted PayPal payment methods along
        with their default method. The default is only populated when PayPal is
        the user's default billing gateway; otherwise it is null.
      tags: [Billing]
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Saved PayPal payment methods
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
                  methods:
                    type: array
                    items:
                      $ref: '#/components/schemas/PaypalPaymentMethod'
                  default:
                    allOf:
                      - $ref: '#/components/schemas/PaypalPaymentMethod'
                    nullable: true
                    description: The user's default PayPal method, or null if PayPal is not their default gateway
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /firewall/cache/{cacheType}/{ip}:
    get:
      summary: Get cache ports for a cache type and IP
      tags: [Firewall]
      security:
        - BearerAuth: []
      parameters:
        - name: cacheType
          in: path
          required: true
          schema:
            type: string
            enum: [steam_a2s, raknet, samp, fivem]
          description: >
            Game cache type identifier (underscored, e.g. `steam_a2s`). An
            unrecognized value is rejected with a 400.
        - name: ip
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Cache ports data
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
        '400':
          description: Invalid cache type, or IP not owned by user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
    post:
      summary: Add cache ports for a cache type and IP
      tags: [Firewall]
      security:
        - BearerAuth: []
      parameters:
        - name: cacheType
          in: path
          required: true
          schema:
            type: string
            enum: [steam_a2s, raknet, samp, fivem]
          description: >
            Game cache type identifier (underscored, e.g. `steam_a2s`). An
            unrecognized value is rejected with a 400.
        - name: ip
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [ports]
              properties:
                ports:
                  type: array
                  items:
                    type: integer
      responses:
        '200':
          description: Cache ports added
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
        '400':
          description: Invalid cache type, or IP not owned by user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /firewall/cache/{cacheType}/{ip}/ports:
    delete:
      summary: Delete specific cache ports
      tags: [Firewall]
      security:
        - BearerAuth: []
      parameters:
        - name: cacheType
          in: path
          required: true
          schema:
            type: string
            enum: [steam_a2s, raknet, samp, fivem]
          description: >
            Game cache type identifier (underscored, e.g. `steam_a2s`). An
            unrecognized value is rejected with a 400.
        - name: ip
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [ports]
              properties:
                ports:
                  type: array
                  items:
                    type: integer
      responses:
        '200':
          description: Cache ports deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
        '400':
          description: Invalid cache type, or IP not owned by user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /firewall/cache/{cacheType}/{ip}/all:
    delete:
      summary: Delete all cache ports for a cache type and IP
      tags: [Firewall]
      security:
        - BearerAuth: []
      parameters:
        - name: cacheType
          in: path
          required: true
          schema:
            type: string
            enum: [steam_a2s, raknet, samp, fivem]
          description: >
            Game cache type identifier (underscored, e.g. `steam_a2s`). An
            unrecognized value is rejected with a 400.
        - name: ip
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: All cache ports deleted for type
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
        '400':
          description: Invalid cache type, or IP not owned by user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /firewall/cache/{ip}:
    delete:
      summary: Delete all cache data for an IP
      tags: [Firewall]
      security:
        - BearerAuth: []
      parameters:
        - name: ip
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: All cache deleted for IP
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
        '400':
          description: IP not owned by user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /tickets/upload:
    post:
      summary: Upload a ticket attachment
      description: >
        Uploads one file to attach to a ticket or reply. Send one file per
        request as `multipart/form-data` under the `file` field; each file may
        be at most 95 MB. The returned `attachment` object is what you pass in
        the `attachments` array of `POST /tickets` or
        `POST /tickets/{ticketId}/reply`. Keep the combined size of all
        attachments on a single ticket or reply under 250 MB.
      tags: [Support]
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required: [file]
              properties:
                file:
                  type: string
                  format: binary
      responses:
        '200':
          description: File uploaded
          content:
            application/json:
              schema:
                type: object
                properties:
                  attachment:
                    $ref: '#/components/schemas/TicketAttachmentUpload'
        '400':
          description: No file was provided, or the file exceeds the 95 MB limit
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /tickets:
    post:
      summary: Open a support ticket
      description: >
        Opens a new support ticket with `message` as its first reply. To
        include files, upload each one with `POST /tickets/upload` first and
        pass the returned objects in `attachments`. Limited to a burst of 10
        tickets, refilling at one ticket every 30 seconds.
      tags: [Support]
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [subject, department, message]
              properties:
                subject:
                  type: string
                department:
                  type: string
                  description: One of `technical`, `billing` or `sales`.
                  example: technical
                message:
                  type: string
                attachments:
                  type: array
                  items:
                    $ref: '#/components/schemas/TicketAttachmentUpload'
      responses:
        '200':
          description: Ticket opened
          content:
            application/json:
              schema:
                type: object
                properties:
                  ticket:
                    $ref: '#/components/schemas/Ticket'
        '400':
          description: "`subject`, `department` or `message` is missing"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Too many tickets opened in a short period
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitError'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /tickets/{ticketId}/reply:
    post:
      summary: Reply to a support ticket
      description: >
        Adds a reply to one of your tickets. Replying sets the ticket's status
        back to `OPEN`, including a ticket that was resolved or closed. Files
        are attached the same way as when opening a ticket. Limited to a burst
        of 30 replies across all your tickets (refilling at one every 10
        seconds) and 15 replies on any single ticket (refilling at one every
        20 seconds).
      tags: [Support]
      security:
        - BearerAuth: []
      parameters:
        - name: ticketId
          in: path
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [message]
              properties:
                message:
                  type: string
                attachments:
                  type: array
                  items:
                    $ref: '#/components/schemas/TicketAttachmentUpload'
      responses:
        '200':
          description: Reply added
          content:
            application/json:
              schema:
                type: object
                properties:
                  reply:
                    $ref: '#/components/schemas/TicketReply'
        '400':
          description: "`message` is missing"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: The ticket belongs to another user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Ticket not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Too many replies in a short period
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitError'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /tickets/attachments/{attachmentId}:
    get:
      summary: Get a download link for a ticket attachment
      description: >
        Returns a signed URL for downloading an attachment on one of your
        tickets. The URL expires after one hour.
      tags: [Support]
      security:
        - BearerAuth: []
      parameters:
        - name: attachmentId
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Signed download URL
          content:
            application/json:
              schema:
                type: object
                properties:
                  downloadUrl:
                    type: string
                    description: Signed URL, valid for one hour.
                  fileName:
                    type: string
                  mimeType:
                    type: string
                  size:
                    type: integer
                    description: Size in bytes.
        '403':
          description: The attachment belongs to another user's ticket
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Attachment not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
