---
title: "Request work from server"
method: POST
path: "/api/daemons/{id}/request-work"
tags: ["Daemons", "internal"]
---

# Request work from server

`POST /api/daemons/{id}/request-work`

Internal endpoint for daemons to poll for pending discovery sessions.
Also updates heartbeat and returns any pending cancellation requests.
Returns tuple of (next_session, should_cancel).

## Path parameters

- `id` string, uuid, required

## Request body

- DaemonStatus — Lightweight daemon status for polling responses.
  - `capabilities` LegacyCapabilities — Legacy inbound-only capabilities blob. Pre-0.15 daemons report their interfaced subnets as bare `subnet_id`s in this `capabilities` object (they predate the `interfaced_subnets: Vec<Subnet>` heartbeat channel). It is deserialize-only: the server never stores it, never echoes it in `DaemonResponse`, and it has no `SqlValue` variant. Reported ids are routed into the `daemon_interfaced_subnets` junction (existence-filtered) so legacy daemons keep reporting interfaced subnets. ≥0.15 daemons send the `Vec<Subnet>` channel instead and leave this empty.
    - `interfaced_subnet_ids` string[], required — Subnets the daemon has an interface on, as reported by older daemons.
  - `interfaced_subnets` Subnet[] — Subnets detected from daemon's network ip_addresses. Server resolves these via SubnetService::create (create-or-match by CIDR) to get real IDs. v0.15.0+ daemons populate this; pre-v0.15.0 daemons leave it empty.
    - `cidr` string, required — Subnet in CIDR notation, IPv4 or IPv6.
    - `description` string, nullable — Free-text notes about the subnet.
    - `name` string, required — Human-facing name for this subnet.
    - `network_id` string, uuid, required — The network this entity belongs to.
    - `source` union, required
      - object
        - `type` 'Manual', required
      - object
        - `type` 'System', required
      - object
        - `type` 'Discovery', required
      - object
        - `details` MatchDetails, required
          - `confidence` 'NotApplicable' | 'Low' | 'Medium' | 'High' | 'Certain', required
          - `reason` union, required — Match reason - either a simple reason string or a container with nested reasons
            - object
              - …
            - object
              - …
        - `type` 'DiscoveryWithMatch', required
      - object
        - `type` 'Unknown', required
    - `subnet_type` 'Internet' | 'Remote' | 'Gateway' | 'VpnTunnel' | 'Dmz' | 'Lan' | 'WiFi' | 'IoT' | 'Guest' | 'DockerBridge' | 'PodmanBridge' | 'MacVlan' | 'IpVlan' | 'Management' | 'Storage' | 'Loopback' | 'Unknown', required
    - `tags` string[], required — Tags assigned to this entity.
    - `virtualization_service_id` string, uuid, nullable, required — The container runtime service that owns this bridge network. Load-bearing for dedup: the same CIDR on two different Docker daemons is two distinct subnets, so bridge rows only merge when this matches as well as the CIDR and network. A foreign key rather than a field inside a JSONB blob because a stale value here is precisely what made a scan add a duplicate bridge row every time (GH #650) — now it cannot be written at all.
    - `created_at` string, date-time, required — When this record was first created.
    - `first_discovery_id` string, uuid, nullable — The discovery that first observed this entity.
    - `id` string, uuid, required — Server-assigned unique identifier.
    - `last_discovery_id` string, uuid, nullable — The most recent discovery that observed this entity.
    - `last_seen_at` string, date-time — When a discovery last observed this entity.
    - `lineage_id` string, uuid, nullable — Stable identifier shared by every revision of the same entity across its history.
    - `updated_at` string, date-time, required — When this record was last modified.
    - `valid_from` string, date-time — Start of the interval this revision was current for (SCD2 history).
    - `valid_to` string, date-time, nullable — End of the interval this revision was current for. `null` while it is the live revision.
  - `mode` 'server_poll' | 'daemon_poll', required — Daemon operating mode that determines the communication pattern. - **DaemonPoll** (formerly "Pull"): Daemon makes outbound connections to the server. The daemon registers itself and polls for work. Best for daemons behind NAT/firewall. - **ServerPoll** (formerly "Push"): Server makes connections to the daemon. Server polls daemon for status and discovery results. Best for DMZ deployments where daemon cannot make outbound connections.
  - `name` string, required — Name the daemon reports for itself.
  - `ready_for_work` boolean — Whether the daemon can accept a new discovery session. Both DaemonPoll and ServerPoll use this to avoid dispatching work to a busy daemon.
  - `url` string, nullable — URL is not used by server - kept for backwards compat. Server never updates daemon URL from status (URL is set during provisioning).
  - `version` string, nullable — Daemon software version (semver format)

## Response `200`

Work request processed - returns (Option<Value>, bool)

## Other responses

- `404` — Daemon not found

---

[API](https://skmtc.net/scanopy/apis/scanopy-api.md) · [All operations](https://skmtc.net/scanopy/apis/scanopy-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/scanopy/scanopy-api/versions/28e466341947/schema)
