> ## 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.

# Link an existing Home Assistant instance read-only

> Probes a Home Assistant instance from a local executor with the long-lived access token held in the Wallet item `token_wallet_item_id` (a kombify Wallet item assigned to Homelab, or a built-in wallet API key or OAuth token item whose URL names this instance; resolved inside Homelab, never answered) and records a read-only observed service. This contract accepts no token. The token is used for this probe only and is never stored in the registry row. Self-hosted installs only (503 `lan_executor_unavailable` otherwise). The call is idempotent: an already linked instance returns `existing: true` without a new probe.



## OpenAPI

````yaml /homelab/reference/api/openapi.yaml post /api/v1/registry/services/home-assistant/import
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/registry/services/home-assistant/import:
    post:
      tags:
        - Services
      summary: Link an existing Home Assistant instance read-only
      description: >-
        Probes a Home Assistant instance from a local executor with the
        long-lived access token held in the Wallet item `token_wallet_item_id`
        (a kombify Wallet item assigned to Homelab, or a built-in wallet API key
        or OAuth token item whose URL names this instance; resolved inside
        Homelab, never answered) and records a read-only observed service. This
        contract accepts no token. The token is used for this probe only and is
        never stored in the registry row. Self-hosted installs only (503
        `lan_executor_unavailable` otherwise). The call is idempotent: an
        already linked instance returns `existing: true` without a new probe.
      operationId: importHomeAssistantService
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
                - stack_id
                - server_id
                - url
                - token_wallet_item_id
                - installation_method
              properties:
                stack_id:
                  type: string
                  minLength: 1
                server_id:
                  type: string
                  minLength: 1
                url:
                  type: string
                  description: Local Home Assistant endpoint.
                token_wallet_item_id:
                  type: string
                  minLength: 1
                  description: >-
                    Wallet item holding the Home Assistant long-lived access
                    token.
                installation_method:
                  type: string
                  enum:
                    - haos
                    - container
      responses:
        '200':
          description: The linked service and the observation made
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    required:
                      - service
                    properties:
                      service:
                        $ref: '#/components/schemas/RegistryService'
                      existing:
                        type: boolean
                      observation:
                        type: object
                      management_scope:
                        type: string
                        enum:
                          - observed
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '502':
          description: The Home Assistant probe failed (`home_assistant_probe_failed`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
components:
  schemas:
    RegistryService:
      type: object
      required:
        - id
        - name
        - display_name
        - kit_deployment_id
        - server_id
        - allowed_actions
        - inventory_revision
        - desired_state
        - observed_state
        - version
        - catalog
        - mutation_lock
      properties:
        id:
          type: string
        name:
          type: string
        display_name:
          type: string
        application_key:
          type: string
        application_name:
          type: string
        type:
          type: string
        status:
          type: string
        health_state:
          type: string
        observed_at:
          type: string
          format: date-time
        management_state:
          type: string
          enum:
            - managed
            - observed
        kit_deployment_id:
          type: string
        stack_name:
          type: string
        server_id:
          type: string
          description: Canonical server id, or empty when placement is unknown.
        server_name:
          type: string
        environment_class:
          type: string
        port:
          type: integer
        url:
          type: string
        move:
          type: object
          description: >-
            Present only when this one application can be moved now with POST
            /api/v1/stacks/{kit_deployment_id}/relocations (engine native,
            workloads [workload_ref]); absent otherwise.
          required:
            - workload_ref
            - source_agent_id
            - destinations
          properties:
            workload_ref:
              type: string
            source_agent_id:
              type: string
            destinations:
              type: array
              minItems: 1
              items:
                type: object
                required:
                  - kit_deployment_id
                  - server_id
                  - agent_id
                properties:
                  kit_deployment_id:
                    type: string
                  server_id:
                    type: string
                  agent_id:
                    type: string
        allowed_actions: 7235e014-2208-4d41-980d-cc6543ead34e
        inventory_revision:
          type: integer
          format: int64
        desired_state:
          type: string
        observed_state:
          type: string
        version:
          oneOf:
            - 636f5f68-84c1-4d2f-a5b2-7178285e9e05
            - type: 'null'
        catalog: 18ce8b32-29dc-4568-b0f8-5a46473784bb
        mutation_lock: d8e3ffc3-fbe1-49ac-8731-552b9213a46f
        provenance: 5f223e48-a70e-4418-9842-e3702edda23e
        action_guard: c4360be4-f537-4dcc-9a1d-ef88d9f2507c
    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.
    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:
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    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'
    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.