API Script Library - edmozley/freeitsm GitHub Wiki
๐ API script library
(5.7.0) System โ API โ Scripts is a library of ready-made scripts that use the REST API to do real jobs: export open tickets, turn monitoring alerts into tickets, sync people from an HR spreadsheet, import assets, migrate a knowledge base, and more. Every script comes in PowerShell and Python, and every one is heavily commented, so it teaches you the API while it works and you can change it for your own install.
๐ช Using one
-
Find it. Search by what you want to do, or filter by module, by Read only / Changes data, and by level (Starter, Intermediate, Advanced).
-
Check what it needs. Each script lists the endpoints it calls and the exact permissions the key needs.
-
Make a key under System โ API โ Keys with just those permissions. A key that can do only what the script needs is the safe way to run anything.
-
Copy or Download the script, and read it - the comments say what each part does.
-
Run it on your own computer, pointing it at your FreeITSM:
powershell -ExecutionPolicy Bypass -File .\export-open-tickets-csv.ps1 -Url https://helpdesk.example.compython export-open-tickets-csv.py --url https://helpdesk.example.com
๐ก Start with Check your API key. It needs no permissions, proves the key reaches your FreeITSM, and lists what the key is allowed to do.
๐งฉ Scripts that join modules together (5.9.0)
Eleven scripts show what the API can do when you combine modules:
| Script | What it does | Changes data |
|---|---|---|
| Monday morning briefing | One HTML page for the week: open tickets by priority with the SLAs breached or at risk, the week's changes, open incidents, today's morning checks, background jobs that need attention, contracts ending soon | no |
| Workflow failures report | Each workflow's failed runs over the last week, its failure rate and its latest error | no |
| What the knowledge base does not answer | Words that keep coming up in closed tickets' subjects with no published article - articles worth writing | no |
| Draw a network diagram from the CMDB | Follows a CI's relationships and draws them as a Network Mapper diagram; run again, it adds only what is new | yes |
| Send this PC's inventory | Reads the computer it runs on - disks, network adapters, installed software, OS - and updates its asset | yes |
| Domain health sweep | Checks every domain; one ticket per domain with problems, or a note on the ticket already open for it | yes |
| Red morning checks to the status page | Failed morning checks declare (and, when green again, resolve) an incident on the status page | yes |
| Announce approved changes as planned maintenance | Approved changes starting soon appear on the status page | yes |
| Change freeze clash check | Changes scheduled inside a change freeze on the calendar, with one comment on each | yes |
| Spot repeat incidents | Finds tickets that keep coming back - the same CI, or the same words - and opens a problem with them linked | yes |
| Plan a hardware refresh project | Ageing and out-of-warranty assets become a project with budget lines, risks and stages | yes |
๐ Where the key goes
Never in the script. Every script reads it from the FREEITSM_API_KEY environment variable, or from a file - api-key.txt beside the script unless you pass -KeyFile / --key-file. Keep that file out of source control and readable only by you. The address can likewise come from FREEITSM_URL instead of -Url / --url.
๐ Scripts that change data preview first
A script marked Changes data only shows what it would do until you add -Apply (PowerShell) or --apply (Python). Run it once without, read the list, then run it again with. Many are also safe to run twice: they check what already exists before creating anything.
๐ What you need
- PowerShell: Windows PowerShell 5.1 (built into Windows) or PowerShell 7 on any system.
- Python: 3.8 or later. Nothing to install - the Python scripts use only Python's built-in libraries, so they also run on locked-down servers where
pip installis not allowed.
๐ Why they are safe to trust
- They ship with FreeITSM as files, reviewed in the public repository and updated with each release. They are not stored in the database, so nothing done inside FreeITSM - not even by an administrator, or by someone who broke in - can change what a script does. Decided with Ed, 19 November 2026: people run these with admin keys on their own machines, so a script must carry the same trust as the code itself.
- The page only shows them. Nothing runs on the server; downloads are plain text.
- Every script was run against a test install before it shipped, and an automatic check fails the build if a script calls an endpoint that does not exist, uses a permission it does not declare, carries a key, or writes without a preview mode.
Only system administrators can open System โ API, and so the Scripts tab.
How it works and how to add a script: API script library - Developer Guide. The design and decisions: API script library - design.
Related: REST API ยท REST API: Knowledge