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

# Cancel an owned maintenance job before execution starts

> Uses the same tenant, entitlement, server and requesting-owner scope as the job read: the authority to withdraw a queued job is the person who owns the server and requested the job, and the person's agent acts with it. No delegated maintenance origin is needed, since cancelling only withdraws work that has not reached the server. Cancellation and execution claim use the same queued-state compare-and-set. Repeating a successful cancellation returns its receipt; a claimed or finished job returns maintenance_not_cancellable. Cancelling never claims to stop a command that has already reached the server.



## OpenAPI

````yaml /homelab/reference/api/openapi.yaml post /api/v1/servers/{serverId}/actions/{jobId}/cancel
openapi: 3.1.0
info:
  title: kombify-Homelab API
  description: >
    REST API for kombify-Homelab -- the hybrid cloud control plane for homelabs.


    kombify-Homelab manages infrastructure through a spec-driven architecture:

    validate YAML specs via CUE, generate OpenTofu configurations, and manage

    nodes through a gRPC agent protocol.


    ## Authentication


    Authenticated endpoints accept an OIDC/JWKS bearer token or an API key

    where documented. Self-hosted Homelab defaults to Pocket ID as identity

    provider. SaaS routes enter through the edge with Auth0 as the platform

    identity provider. PocketBase session exchange remains legacy migration

    compatibility only.


    ## Response Format


    **Success:** `{ "data": <object>, "meta": { "total": int, "page": int,
    "per_page": int } }`


    **Error:** `{ "error": { "code": "<ERROR_CODE>", "message": "...",
    "details": <any> } }`


    ## Pagination


    List endpoints accept `page` (default: 1) and `per_page` (default: 20, max:
    100) query parameters.
  version: 1.0.0
  contact:
    name: kombify
    url: https://kombify.io
  license:
    name: Apache-2.0 AND GPL-3.0
    url: https://github.com/kombifyio/Homelab/blob/main/LICENSE
servers:
  - url: https://api.kombify.io/v1/homelab
    description: >-
      Production canonical (via Cloudflare edge gateway, strip-prefix). Clients
      MUST use this projection. The Gateway strips /v1/homelab and re-adds
      /api/v1 at the origin, so it resolves the /api/v1/* paths below cleanly.
  - url: http://localhost:5260
    description: Local development
  - url: https://homelab.kombify.io
    description: Production (direct, no Gateway prefix)
  - url: https://api.kombify.io/v1/orchestrator
    description: >-
      Legacy StackKit-Orchestrator projection of the same origin. RETAINED for
      backward compatibility with existing consumers only. Do NOT use for mobile
      or new clients: combined with the /api/v1/* paths it double-resolves
      (yielding /v1/orchestrator/api/v1/...). Prefer /v1/homelab.
security:
  - bearerAuth: []
tags:
  - name: Health
    description: Health checks and service info (no auth required)
  - name: Instance
    description: Local instance identity and enrollment metadata
  - name: Stacks
    description: Stack lifecycle management (create, provision, deploy, destroy)
  - name: Stacks - Specs
    description: Access persisted specification chain (intent, requirements, unified)
  - name: Stacks - Import/Export
    description: Import and export StackKits stack-spec.yaml configurations
  - name: Stacks - Drift
    description: Infrastructure drift detection and resolution
  - name: Unifier
    description: Spec validation, analysis, unification, and IaC generation pipeline
  - name: StackKits
    description: Infrastructure template catalog
  - name: Add-ons
    description: Add-on detection and registry
  - name: Workers
    description: Worker node registration and management
  - name: Servers
    description: Canonical server lifecycle, connection, and health state
  - name: Inventory
    description: >-
      Owner-scoped sanitized server and service read models for UI, API, and MCP
      clients
  - name: Agents
    description: Connected gRPC agent management and commands
  - name: Jobs
    description: Background job monitoring and SSE streaming
  - name: Discovery
    description: Network device discovery and SSH testing
  - name: Features
    description: Feature flags (read-only; managed centrally via the kombify Admin API)
  - name: Monthly Runtime
    description: Provider-free user API for subscription-backed stack runtime control
  - name: Runtime
    description: Recent runtime/deploy logs (job/deploy progress + container tail)
  - name: Wallet
    description: >-
      Redacted recovery-item wallet with biometric/platform-reauth-gated reveal.
      List responses strip secret/totp; reveal requires a fresh trusted-reauth
      HMAC proof (5-minute window) and is audited server-side.
  - name: Trust
    description: Pairing tokens for worker enrollment
  - name: Client Binding
    description: >-
      Short-lived HTTPS pairing for a second client and normal OIDC account
      handoff
  - name: Tunnel
    description: Cloudflare tunnel management for NAT traversal
  - name: Backups
    description: Database backup management (admin only)
  - name: Auth
    description: Authentication mode and SSO configuration
  - name: Metrics
    description: Prometheus-compatible instance metrics for admin/infra scrapers
  - name: Internal
    description: >-
      Internal SaaS-only APIs, including servicecall-protected executor
      contracts
paths:
  /api/v1/servers/{serverId}/actions/{jobId}/cancel:
    post:
      tags:
        - Servers
        - Jobs
      summary: Cancel an owned maintenance job before execution starts
      description: >-
        Uses the same tenant, entitlement, server and requesting-owner scope as
        the job read: the authority to withdraw a queued job is the person who
        owns the server and requested the job, and the person's agent acts with
        it. No delegated maintenance origin is needed, since cancelling only
        withdraws work that has not reached the server. Cancellation and
        execution claim use the same queued-state compare-and-set. Repeating a
        successful cancellation returns its receipt; a claimed or finished job
        returns maintenance_not_cancellable. Cancelling never claims to stop a
        command that has already reached the server.
      operationId: cancelServerMaintenanceJob
      parameters:
        - $ref: '#/components/parameters/serverId'
        - name: jobId
          in: path
          required: true
          schema:
            type: string
            maxLength: 128
      responses:
        '200':
          description: Cancelled job, including an exact cancellation replay
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/ServerMaintenanceJob'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
components:
  parameters:
    serverId:
      name: serverId
      in: path
      required: true
      description: Canonical server runtime ID
      schema:
        type: string
  schemas:
    ServerMaintenanceJob:
      type: object
      required:
        - job_id
        - server_id
        - action
        - state
        - status
        - result
        - created_at
        - updated_at
      properties:
        job_id:
          type: string
        server_id:
          type: string
        action:
          type: string
          enum:
            - os_update_plan
            - os_update
            - reboot
        state:
          type: string
          enum:
            - queued
            - running
            - waiting
            - awaiting_node_return
            - completed
            - failed
            - cancelled
          description: >-
            Ledger state. A reboot waiting for its node to come back is the
            state `awaiting_node_return` (never `waiting`). `waiting` is only an
            OS update whose install unit outlived the CLI's wait (`reason_code`
            apply_still_running); it is polled until it completes or fails.
        status:
          type: string
          enum:
            - queued
            - running
            - completed
            - failed
            - cancelled
          description: >-
            Coarse status of the POST receipt; waiting and awaiting_node_return
            report running.
        reason_code:
          type: string
          description: >-
            Stable code of the last transition, for example node_returned,
            apply_still_running, apply_finished_after_wait, or the failure code
            (apply_partial when the install unit ended with packages of the
            approved plan still at their approved starting versions; the result
            then lists them in `not_installed`).
        plan_digest:
          type: string
          pattern: ^sha256:[0-9a-f]{64}$
        impact_snapshot_digest:
          type: string
          pattern: ^sha256:[0-9a-f]{64}$
        failure:
          type: object
          description: Present when state is failed or cancelled.
          required:
            - code
            - retryable
            - user_guidance
          properties:
            code:
              type: string
              description: >-
                Runner reasons (node_did_not_return, reboot_abandoned,
                deadline_exceeded, server_removed, dispatch_failed,
                dispatch_interrupted for a command no agent received,
                apply_partial) or the stackkit.host-maintenance/v1 refusal and
                failure codes; a host code that is not a bounded snake_case
                token is host_command_failed.
            retryable:
              type: boolean
            user_guidance:
              type: object
              required:
                - title
                - body
                - next_steps
              properties:
                title:
                  type: string
                body:
                  type: string
                next_steps:
                  type: array
                  items:
                    type: string
        result:
          $ref: '#/components/schemas/ServerMaintenanceResult'
        reboot:
          type: object
          description: Reboot jobs, once the node acknowledged the reboot.
          required:
            - boot_id_changed
          properties:
            scheduled_at:
              type: string
              format: date-time
            return_deadline:
              type: string
              format: date-time
              description: Present while awaiting_node_return.
            boot_id_changed:
              type: boolean
              description: The node reports a boot id other than the one before the reboot.
        deadline_at:
          type: string
          format: date-time
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        completed_at:
          type: string
          format: date-time
    ResponseMeta:
      type: object
      properties:
        total:
          type: integer
        page:
          type: integer
        per_page:
          type: integer
        managed_runtime_inventory_complete:
          type: boolean
          description: >-
            True only when the managed RuntimeLease authority was configured and
            read successfully for this inventory response.
        worker_inventory_sha256:
          type: string
          pattern: ^[0-9a-f]{64}$
          description: >-
            Stable digest of the complete worker identity, attachment,
            freshness, and managed RuntimeLease authority snapshot used for
            pagination.
        managed_runtime_active_lease_ids:
          type: array
          items:
            type: string
          description: >-
            Canonically sorted IDs of visible managed RuntimeLeases classified
            as active for inventory and cleanup. This visibility projection is
            not capacity reservation or release authority.
        managed_runtime_inactive_lease_ids:
          type: array
          items:
            type: string
          description: >-
            Canonically sorted IDs of visible managed RuntimeLeases classified
            as cancelled or archived for inventory and cleanup. Inactive state
            does not prove provider absence or release managed-server capacity.
        managed_runtime_lease_generation_digests:
          type: array
          items:
            type: object
            required:
              - lease_id
              - resource_generation_digest
            properties:
              lease_id:
                type: string
              resource_generation_digest:
                type: string
                pattern: ^[0-9a-f]{64}$
          description: >-
            Canonically sorted opaque bindings from each visible managed
            RuntimeLease ID to its exact provider-resource generation. Missing
            coverage makes destructive inventory proof invalid while leaving
            ordinary dashboard inventory readable.
        managed_runtime_duplicate_lease_ids:
          type: array
          items:
            type: string
          description: >-
            Managed RuntimeLease IDs represented by multiple persisted worker
            rows before UI projection deduplication; must be empty for
            destructive inventory proof.
        managed_runtime_attachment_conflict_lease_ids:
          type: array
          items:
            type: string
          description: >-
            Canonically sorted caller-visible managed RuntimeLease IDs with a
            conflicting tenant-wide worker attachment; must be empty for
            destructive inventory proof and never exposes foreign private lease
            or worker details.
    ServerMaintenanceResult:
      type: object
      description: >-
        Plan fields for os_update_plan, apply fields for os_update, empty for
        reboot. Lists are bounded: at most 200 packages (packages_truncated says
        whether the list was cut; the counts stay exact), 50 held names and 20
        dpkg problems, each string at most 256 characters.
      properties:
        plan_digest:
          type: string
        pending_count:
          type: integer
          minimum: 0
        security_count:
          type: integer
          minimum: 0
        reboot_likely:
          type: boolean
        hold_scope:
          type: string
        held:
          type: array
          maxItems: 50
          items:
            type: string
        dpkg_problems:
          type: array
          maxItems: 20
          items:
            type: string
        packages:
          type: array
          maxItems: 200
          items:
            type: object
            required:
              - name
              - from
              - to
              - security
            properties:
              name:
                type: string
              from:
                type: string
              to:
                type: string
              security:
                type: boolean
        packages_truncated:
          type: boolean
        outcome:
          type: string
          enum:
            - applied
            - noop
            - failed
            - running
            - partial
        reboot_required:
          type: boolean
        unit:
          type: string
        changed:
          type: integer
          minimum: 0
        remaining_pending_count:
          type: integer
          minimum: 0
        plan_digest_after:
          type: string
        not_installed:
          type: array
          maxItems: 50
          description: >-
            apply_partial only; approved packages still at their approved
            starting versions.
          items:
            type: string
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              enum:
                - INTERNAL_ERROR
                - NOT_FOUND
                - BAD_REQUEST
                - UNAUTHORIZED
                - FORBIDDEN
                - CONFLICT
                - VALIDATION_ERROR
                - RATE_LIMITED
                - SERVICE_UNAVAILABLE
                - METHOD_NOT_ALLOWED
            message:
              type: string
            details:
              description: Additional error context (validation errors, etc.)
  responses:
    Unauthorized:
      description: Authentication required
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Forbidden:
      description: Insufficient permissions
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Conflict:
      description: Request conflicts with existing state
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ServiceUnavailable:
      description: Required control-plane persistence or dependency is unavailable
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        OIDC/JWKS bearer token. Self-hosted defaults to Pocket ID; SaaS uses
        Auth0 through the edge. PocketBase JWT is legacy migration compatibility
        only.

````

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