Snipe-IT Integration
Roles in the integration
The integration follows a unidirectional authority model:
| System | Authority for |
|---|---|
| Snipe-IT | Physical assets (models, assets, locations, checkout/check-in) |
| MakerLab API | Projects, requisitions, assignments, user roles, status history |
The MakerLab does not attempt to replicate or replace Snipe-IT. It reads asset state from Snipe-IT and writes reservation status changes back to it.
Configuration
The API connects to Snipe-IT using two environment variables:
# Internal Docker network URL (never browser-facing)
SNIPEIT_BASE_URL=http://snipeit
# API token generated from the Snipe-IT admin interface
SNIPEIT_API_TOKEN=eyJ0eXAiOiJKV1QiLCJhbG...
# Public browser-facing Snipe-IT URL (used for sidebar links and redirect)
SNIPEIT_PUBLIC_URL=https://deti-makerlab.ua.pt/new/snipe-it
# Snipe-IT status label ID for "Reserved" status
SNIPEIT_RESERVED_STATUS_ID=4
The SNIPEIT_BASE_URL uses the Docker internal service name snipeit — it is not accessible from outside the Docker network. This is the URL used for backend-to-Snipe-IT API calls only.
Initial setup
Snipe-IT requires one-time initialization on first deployment. The automated bootstrap script handles this:
./infra/docker/bootstrap-snipeit.sh
The script:
- Waits for Snipe-IT to fully initialize.
- Creates the first admin user.
- Registers the personal access client.
- Generates an API token.
- Writes the token to
apps/api/.env. - Restarts the API container.
If the script fails, the Snipe-IT API token can be generated manually through the Snipe-IT web interface. See core/docs/SNIPEIT.md for the manual procedure.
Snipe-IT status labels
Before the system can operate, the following status labels must be configured in Snipe-IT (Settings → Status Labels):
| Label name | Status type | Notes |
|---|---|---|
Available | Deployable | Rename from the default "Ready to Deploy" |
Reserved | Deployable | Create new; note the numeric ID for SNIPEIT_RESERVED_STATUS_ID |
Checked Out | Deployable | Create new |
Catalog sync
Equipment models are synced from Snipe-IT into the local equipment_models table on demand:
POST /api/equipment/catalog/sync
This endpoint queries /api/v1/models from Snipe-IT and upserts local EquipmentModel records. It also queries assets and populates the equipment table.
Equipment catalog data displayed to users comes from the local database (fast, no Snipe-IT round-trip required per page load).
Reservation flow (approval)
When a technician approves a requisition:
- The local
equipment_requeststatus moves toreserved. - The API calls Snipe-IT's asset update endpoint to set the asset's status label to
Reserved(identified bySNIPEIT_RESERVED_STATUS_ID). - A notification is sent to project members.
PATCH /api/v1/hardware/{snipeit_asset_id}
Body: { "status_id": SNIPEIT_RESERVED_STATUS_ID }
Checkout and check-in detection (activity log polling)
Physical checkout and check-in are performed by the technician directly in the Snipe-IT interface. The MakerLab detects these events by polling the Snipe-IT activity log:
POST /api/requisitions/sync-snipeit
This endpoint:
- Fetches the latest activity log from Snipe-IT (up to 200 entries via
/api/v1/reports/activity). - For each
checkoutaction: if the asset corresponds to a local request inreservedstatus, updates the request tochecked_outand recordschecked_out_at. - For each
checkin fromaction: if the asset corresponds to a local request inchecked_outstatus, updates the request toreturnedand recordsreturned_at. - Records all transitions in
status_history.
Technician provisioning in Snipe-IT
When a lab_technician user accesses Snipe-IT for the first time, the API auto-provisions them as a Snipe-IT admin user:
# auth/router.py → /auth/snipeit/verify
_create_snipeit_user(user.name, user.email)
This ensures every verified technician has a corresponding Snipe-IT account and can perform checkout operations in the Snipe-IT interface.
ID mapping
| MakerLab entity | Snipe-IT reference |
|---|---|
equipment_models.snipeit_model_id | Snipe-IT model ID |
equipment.snipeit_asset_id | Snipe-IT asset ID |
equipment_request.snipeit_asset_id | Snipe-IT asset ID being requested |
These foreign references allow the API to look up and update specific Snipe-IT records without maintaining a full local copy of Snipe-IT data.
Limitations
- Polling, not webhooks. Checkout and check-in detection depend on polling the Snipe-IT activity log. There is no real-time push mechanism. Run
sync-snipeitperiodically or on demand. - Status label IDs are environment-specific. The
SNIPEIT_RESERVED_STATUS_IDmust be set to match the actual numeric ID in the deployed Snipe-IT instance. - Snipe-IT is not automatically backed up by the MakerLab. Snipe-IT's MariaDB data requires a separate backup. See Backups and Restore.
- SSL verification. When using the public Snipe-IT URL from external scripts (outside Docker), SSL verification may need to be disabled if self-signed certificates are in use. Inside Docker, the internal
http://snipeitURL is used and does not require SSL.