Returning results
Collected data reaches inventory through one endpoint, POST /api/v1/inventory/collected-facts. It applies per-field ownership rules instead of overwriting whole objects, so a collector cannot erase values an operator maintains by hand.
Who may call it
The endpoint accepts only a playbook run's job token. The token must be active, not revoked and not expired, and it is scoped to one run, run group, connection target and inventory source. A personal API token is refused with 403; run identity is never inferred from a host name.
Piping's system collectors are built for this path. Copying a built-in playbook into a project produces an ordinary playbook and does not grant the run-token capability of the original.
Reading the run token
A run receives two values for API access: PIPING_API_URL (the API base URL) and PIPING_RUN_TOKENS_FILE, a private controller file with mode 0600. The file is a JSON object that maps each run ID in the launch to its sandbox token.
Select the token for the current host's run by piping_run_id. Never print it, store it in the project, pass it as an argument or put it in extra vars:
- name: Read this run's API token
ansible.builtin.set_fact:
piping_run_token: >-
{{ (lookup('ansible.builtin.file',
lookup('ansible.builtin.env', 'PIPING_RUN_TOKENS_FILE')) | from_json)[piping_run_id] }}
delegate_to: localhost
no_log: true
The token is bound to its run, group, connection target and inventory source. Reusing another run's entry from the same file is refused by that binding.
Request identity
inventory_kind (device or virtual_machine) and inventory_id select the object. run_id, run_group_id and connection_target_id must match the run that owns the token. target_name is a label for diagnostics only: a host name never selects, creates or classifies an object.
A managed launch exposes piping_run_id, piping_target_id, piping_source_kind and piping_source_id as host variables. Read the accepted dispatch group identifier from the reserved PIPING_RUN_GROUP_ID environment variable. Launch parameters and secret references cannot override that value, PIPING_API_URL or PIPING_RUN_TOKENS_FILE.
A request must reference an object that already exists. The endpoint does not create inventory objects from a playbook.
What is written
write_policy is a group-level switch. A group flag set to false is skipped with a recorded reason. Within an allowed group:
| Rule | Effect |
|---|---|
| Manual override | A value an operator changed by hand is protected from a later observation |
| Provenance | Each written field records its source and observed_at |
| Stale | An observation older than the stored one does not replace it |
| Missing | An absent, empty or sentinel value leaves the stored value unchanged; it never clears it |
| Units | Device fields, VM resources and virtual disks keep the units of their model columns |
Only fields the model supports are written. Virtual machine resource totals and virtual disks map to virtual-machine fields and disk rows; device CPU, memory and disk totals have no column and are not written. Unsupported values are ignored, not stored in a new universal field.
Partial results
The response reports every group independently as applied, skipped or error, with a stable reason token. Groups are applied under savepoints, so one failing group does not roll back the others.
A skipped or failed group is not evidence that the host lacks the value. A partial collection stays partial: it must not be reported as a complete observation, and it must not write zeros to stand in for unknown capacity.
Repeating a request
Writes are matched by the model's identity keys: platform by slug or name, device type by manufacturer and model, interfaces by object and name, IP addresses by address, MAC addresses by address, virtual disks by machine and name. Repeating the same observation updates the matching row instead of creating a duplicate. A second run of the same collector is therefore safe to retry.
Token lifecycle
A revoked, expired or out-of-scope token is rejected for the whole request. The endpoint does not accept the request and drop the write: a caller that ignores the error must not treat the data as delivered.
Tokens are registered for log scrubbing. Never print the Authorization header, the run-token file or a request body containing a token into run output.
Example
The request body below shows the shape. Identifiers are placeholders, and the token is supplied by the run, never written in the playbook.
{
"run_group_id": "00000000-0000-4000-8000-000000000003",
"run_id": "00000000-0000-4000-8000-000000000002",
"connection_target_id": "00000000-0000-4000-8000-000000000004",
"inventory_kind": "virtual_machine",
"inventory_id": "00000000-0000-4000-8000-000000000001",
"observed_at": "2026-01-01T00:00:00Z",
"write_policy": {
"write_platform": true,
"write_resources": true,
"write_interfaces": true,
"write_ip_addresses": true,
"write_virtual_disks": true
},
"platform": { "name": "Debian 12" },
"hardware": { "cpu_count": 4, "memory_mb": 8192, "disk_mb": 65536 },
"interfaces": [
{ "name": "eth0", "enabled": true, "addresses": ["192.0.2.10/24"], "mac": "02:00:00:00:00:01" }
],
"virtual_disks": [{ "name": "/", "size_mb": 65536 }]
}
The versioned field matrix and the exact write groups live beside the product code; this page is a guide, not a second contract. The endpoint itself is listed in the REST API reference.