Assets
Sending devices from inventory tools
Keep the asset register up to date from PowerShell, Intune, Ansible or osquery, with an integration token and one API endpoint.
Inventory scripts and tools can add and update assets through one endpoint, so the register keeps up with what's actually on the network.
Tokens
An organisation admin makes a token on the Integrations tab of the admin pages → New token. Name it after what will use it ("Intune sync", "Lab inventory script") so you can revoke it on its own later.
- The token is shown once. Fettledesk keeps only a hash of it.
- It works only for sending devices (
POST /api/v1/ingest/assets). It can't read tickets or sign in. - It acts as the admin who made it, and history shows changes under their name. It stops working if it's revoked, or if that person is deactivated or is no longer an admin.
- Admins see when each token was last used. Making and revoking tokens is in the audit log.
Send it as a bearer token:
POST /api/v1/ingest/assets
Authorization: Bearer fdk_…
Content-Type: application/json
The request
{
"assets": [
{
"serialNumber": "5CG1234XYZ",
"hostname": "NG-LT-0412",
"name": "NG-LT-0412",
"type": "Laptop",
"model": "Altura Book 14 G3",
"assignee": "[email protected]",
"attributes": { "Operating system": "Windows 11", "Memory": 16 }
}
],
"dryRun": false
}
Up to 500 devices per request. Every field is optional:
| Field | Notes |
|---|---|
tag | The asset's tag, if the tool knows it. Matched first. |
serialNumber | Matched second. |
hostname | Matched third. Stored in the type's Hostname field, when it has one. |
name, type | Needed for a device that matches nothing. type is an asset type's name. |
status | On order, In stock, In use, In repair, Lost or Retired. |
model, location, costCentre, notes | Text. |
assignee | An email, or a name only one person has. null unassigns. |
purchased, warrantyEnds, expires | Dates like 2026-10-19. null clears. |
attributes | By the label the asset type uses, such as Memory or Operating system. |
A field you leave out is left as it is. An empty string or null clears it. Choice fields need one of the type's options (for laptops: Windows 11, Windows 10, macOS, ChromeOS, Linux or Other), in any case.
Matching
Each device is matched to an existing asset by tag, then serial number, then hostname, ignoring case.
- A device that matches nothing is added, with the next tag for its type.
- If a serial number or hostname matches two assets, that device is reported as an error: send its tag instead.
- A device listed twice in one request is an error the second time.
Valid devices are saved even when others in the same request have errors, so one bad record doesn't hold up a whole sync. Set "dryRun": true to see what would happen without saving anything.
The response
{
"results": [
{ "index": 0, "tag": "LT-0412", "action": "update", "changes": ["Memory: 8 → 16"], "errors": [] },
{ "index": 1, "tag": null, "action": "error", "changes": [], "errors": ["New assets need a type."] }
],
"counts": { "create": 0, "update": 1, "unchanged": 0, "error": 1 }
}
index is the device's position in your request. action is create, update, unchanged or error. A request that's wrong as a whole, such as one with over 500 devices, gets a 400 with a description of the problem instead.
Examples
PowerShell on each Windows device
Run it as a scheduled task, at sign-in or daily:
$token = 'fdk_…'
$os = (Get-CimInstance Win32_OperatingSystem).Caption
$bios = Get-CimInstance Win32_BIOS
$system = Get-CimInstance Win32_ComputerSystem
$device = @{
serialNumber = $bios.SerialNumber
hostname = $env:COMPUTERNAME
name = $env:COMPUTERNAME
type = if ($system.PCSystemType -eq 2) { 'Laptop' } else { 'Desktop' }
model = "$($system.Manufacturer) $($system.Model)"
attributes = @{
'Operating system' = if ($os -match 'Windows 11') { 'Windows 11' } elseif ($os -match 'Windows 10') { 'Windows 10' } else { 'Other' }
'Memory' = [math]::Round($system.TotalPhysicalMemory / 1GB)
}
}
$body = @{ assets = @($device) } | ConvertTo-Json -Depth 5
Invoke-RestMethod -Method Post -Uri 'https://desk.example.org/api/v1/ingest/assets' `
-Headers @{ Authorization = "Bearer $token" } -ContentType 'application/json' -Body $body
Intune, through Microsoft Graph
Run it from one machine with the Microsoft Graph PowerShell SDK and the DeviceManagementManagedDevices.Read.All permission. It sends devices 500 at a time:
Connect-MgGraph -Scopes 'DeviceManagementManagedDevices.Read.All'
$devices = Get-MgDeviceManagementManagedDevice -All | Where-Object operatingSystem -eq 'Windows'
$assets = foreach ($d in $devices) {
@{
serialNumber = $d.SerialNumber
hostname = $d.DeviceName
name = $d.DeviceName
type = 'Laptop'
model = "$($d.Manufacturer) $($d.Model)"
assignee = $d.UserPrincipalName
}
}
for ($i = 0; $i -lt $assets.Count; $i += 500) {
$batch = $assets[$i..([math]::Min($i + 499, $assets.Count - 1))]
$body = @{ assets = @($batch) } | ConvertTo-Json -Depth 5
Invoke-RestMethod -Method Post -Uri 'https://desk.example.org/api/v1/ingest/assets' `
-Headers @{ Authorization = 'Bearer fdk_…' } -ContentType 'application/json' -Body $body
}
An assignee that matches nobody in Fettledesk is reported as an error for that device. Add the person first, or leave assignee out.
Ansible
- name: Report to Fettledesk
ansible.builtin.uri:
url: https://desk.example.org/api/v1/ingest/assets
method: POST
headers:
Authorization: 'Bearer {{ fettledesk_token }}'
body_format: json
body:
assets:
- serialNumber: "{{ ansible_facts['product_serial'] }}"
hostname: "{{ ansible_facts['hostname'] }}"
name: "{{ ansible_facts['hostname'] }}"
type: Server
model: "{{ ansible_facts['system_vendor'] }} {{ ansible_facts['product_name'] }}"
attributes:
Operating system: "{{ ansible_facts['distribution'] }} {{ ansible_facts['distribution_version'] }}"
CPU cores: "{{ ansible_facts['processor_vcpus'] }}"
delegate_to: localhost
osquery
osqueryi --json "SELECT hardware_serial AS serialNumber, computer_name AS hostname,
computer_name AS name, hardware_model AS model, 'Desktop' AS type FROM system_info" |
jq '{assets: .}' |
curl -sS -X POST https://desk.example.org/api/v1/ingest/assets \
-H "Authorization: Bearer $FETTLEDESK_TOKEN" -H 'Content-Type: application/json' -d @-
Keeping tokens safe
- Keep tokens where your tool keeps secrets (an Intune script's protected settings, Ansible Vault, an environment variable), not in a shared folder.
- Use one token per tool, so revoking one doesn't stop the others.
- Revoke a token when the person who made it leaves. It stops working anyway once their account is deactivated.