Skip to main content

Sync Swif Devices into Snipe-IT

Overview

Swif provides a sample integration script, SwifToSnipe, that syncs devices from Swif into Snipe-IT as hardware assets.

The integration uses Swif’s public device API to retrieve device inventory data, then creates or updates matching assets in Snipe-IT. Devices are matched by serial number, which makes the script safe to rerun without creating duplicate assets. The script can also optionally check out assets to the device owner’s email address if that user already exists in Snipe-IT. (GitHub)


What This Integration Does

The SwifToSnipe script can:

  • Pull device inventory from Swif

  • Create or update Snipe-IT hardware assets

  • Match existing Snipe-IT assets by device serial number

  • Create categories, manufacturers, and models as needed

  • Optionally check out devices to owners based on the Swif owner email

  • Run in dry-run mode before making changes

The script is idempotent, meaning it can be run multiple times safely because assets are matched by serial number instead of blindly recreated. (GitHub)


Before You Begin

You need:

  • Python 3.9 or later

  • pip

  • Access to a Swif organization API token

  • Access to a Snipe-IT API token

  • Your Snipe-IT instance URL

  • Permission in Snipe-IT to create or update assets, models, manufacturers, and categories

The SwifToSnipe repository requires Python 3.9+, the Python requests package, a Swif organization API token, and a Snipe-IT API token. (GitHub)


Step 1: Get Your Swif API Token

In Swif, go to your organization settings and retrieve your API token.

Swif’s public device API uses a bearer token in the Authorization header:

Authorization: Bearer {TOKEN}

The device API endpoint used by the script is:

https://api.swifteam.com/restful/organization/devices

Swif’s public API returns device inventory data such as device name, OS version, model, serial number, owner information, MDM device information, and encryption status. (help.swif.ai)


Step 2: Get Your Snipe-IT API Token

In Snipe-IT:

  1. Log in as an administrator.

  2. Go to Manage API Keys.

  3. Create or copy an API token.

  4. Store the token securely.

The script uses this token to create and update hardware assets in Snipe-IT.


Step 3: Clone the SwifToSnipe Repository

On the machine where you want to run the sync:

git clone https://github.com/swifteaminc/SwifToSnipe.git cd SwifToSnipe

Step 4: Install Requirements

Install the Python dependency:

pip install -r requirements.txt

The base script currently requires the requests Python package. (GitHub)


Step 5: Configure the Integration

Copy the example configuration file:

cp settings.conf.example settings.conf

Open settings.conf and configure your Snipe-IT URL:

[snipe-it] 
url = https://your-snipe-instance.com
defaultStatus = 2

[swif]
base_url = https://api.swifteam.com
windows_category = Windows

You can store API tokens in settings.conf, but environment variables are recommended so secrets are not saved in the repository or committed by mistake. The example configuration specifically recommends using environment variables for SNIPE_APIKEY and SWIF_API_TOKEN. (GitHub)

Set the tokens:

export SNIPE_APIKEY="<snipe-it-api-token>" 
export SWIF_API_TOKEN="<swif-org-api-token>"

Optional:

export SNIPE_URL="https://your-snipe-instance.com" 
export SWIF_BASE="https://api.swifteam.com"

Step 6: Run a Dry Run First

Before writing anything to Snipe-IT, run the script in dry-run mode:

python swif_sync.py --dryrun -v

Dry-run mode previews what would be created or updated without making changes. (GitHub)

Review the output carefully and confirm that:

  • Devices are being read from Swif

  • Serial numbers are correct

  • Asset names look correct

  • Models and manufacturers are mapped as expected

  • Owner emails match users in Snipe-IT, if you plan to check out assets


Step 7: Run the Sync

To create or update assets in Snipe-IT:

python swif_sync.py

To also check out assets to the Swif owner email:

python swif_sync.py -u

The -u option checks out the asset to the owner only if the matching user already exists in Snipe-IT. The tool does not create Snipe-IT users. (GitHub)


Field Mapping

The integration maps Swif device fields into Snipe-IT hardware fields as follows:

Snipe-IT field

Swif field

Serial number

deviceInfo.serialNumber

Asset name

deviceInfo.deviceName

Manufacturer

deviceInfo.productName

Model

osQueryDeviceInfo.hardware.modelSpec.fullName

Checkout user

owner.emails[0]

If the detailed model is unavailable, the script falls back to a combination of manufacturer and deviceInfo.modelName. (GitHub)


What Gets Created in Snipe-IT

When the script runs, it can:

  • Ensure the asset category exists

  • Ensure the manufacturer exists

  • Ensure the model exists

  • Create a new hardware asset if no asset exists for the serial number

  • Update an existing hardware asset if the serial number already exists

  • Assign an asset tag using the format:

SWIF-<serial>

The default category is Windows, but it can be configured in settings.conf. (GitHub)


Run on a Schedule

To keep Snipe-IT continuously updated, run the script on a schedule using cron, a scheduled job, or CI.

Example cron entry to run every day at 2:00 AM:

0 2 * * * cd /opt/SwifToSnipe && /usr/bin/python3 swif_sync.py -u >> /var/log/swif-to-snipe.log 2>&1

The SwifToSnipe repository recommends running the script on a schedule such as cron or CI for continuous sync. (GitHub)


Security Notes

  • Store API tokens securely.

  • Prefer environment variables over storing secrets in settings.conf.

  • Do not commit settings.conf with real credentials.

  • Run --dryrun before the first real sync.

  • Use a Snipe-IT API token with only the permissions required for asset sync.

The Swif device API exposes inventory and compliance-related fields such as encryption status, MDM ID, firewall/AV flags, and password-lockout policy. It does not expose device unlock PINs or BitLocker recovery keys. (GitHub)


Troubleshooting

Missing config error

If the script reports missing configuration, confirm the following values are set:

echo "$SNIPE_APIKEY" 
echo "$SWIF_API_TOKEN"
echo "$SNIPE_URL"

You can also confirm that settings.conf exists and contains your Snipe-IT URL.


Swif devices are not returned

Check:

  • The Swif API token is correct

  • The token belongs to the correct Swif organization

  • The API base URL is correct:

Global: https://api.swifteam.com
EU: https://api.eu.swifteam.com
  • The machine running the script can reach the Swif API


Snipe-IT assets are not created

Check:

  • The Snipe-IT API token is valid

  • The token has permission to create assets, models, manufacturers, and categories

  • The configured defaultStatus exists in your Snipe-IT instance

  • You are not running with --dryrun


Assets are not checked out to users

The -u option only checks out assets to users that already exist in Snipe-IT.

If an asset is not checked out:

  • Confirm the Swif device has an owner email

  • Confirm the same email exists in Snipe-IT

  • Confirm the Snipe-IT user is active


Duplicate assets appear in Snipe-IT

The script matches assets by serial number.

If duplicates appear:

  • Check whether the existing Snipe-IT asset has the correct serial number

  • Confirm there are no leading or trailing spaces in serial numbers

  • Merge or clean duplicate assets in Snipe-IT before running the sync again


Summary

Use the SwifToSnipe integration when you want Snipe-IT to reflect your Swif-managed device inventory.

Recommended workflow:

  1. Create Swif and Snipe-IT API tokens.

  2. Configure the script.

  3. Run a dry run.

  4. Review the output.

  5. Run the real sync.

  6. Schedule the script for ongoing updates.

Did this answer your question?