Docs

Getting started with the API

What ITFlow's API can do, how to get a key, and your first calls with curl and PowerShell.

ITFlow's API lets other systems read and write ITFlow over HTTPS:

  • An RMM raises a ticket when an alert fires, then resolves it when the alert clears.
  • A phone system looks up who's calling.
  • A script keeps assets in step with what your RMM sees.
  • A report pulls the month's time from every technician.

Each API key acts as one of your agents. It can do what that agent's role allows, for the clients they can see, and everything it does is in the audit log under their name. See Keys and permissions.

Make a key

In ITFlow, go to Admin > API Keys and click New API Key. Give it a name that says what uses it, a date it expires, and the agent it acts as. Copy the API key before you close the window, because it isn't shown again.

Give each system that uses the API an agent of its own, with only the access it needs. Then its calls are easy to pick out, and you can switch one off without breaking the others.

Your first call

Every endpoint is a PHP file under api/v1/ on your ITFlow, named for the kind of record and what it does with it, such as clients/read.php or tickets/create.php.

To list your clients, send a GET request with the key as api_key. With curl:

curl -G https://itflow.example.com/api/v1/clients/read.php \
  --data-urlencode "api_key=YOUR_API_KEY" \
  --data-urlencode "limit=2"

Or with PowerShell:

$base = 'https://itflow.example.com/api/v1'
$key  = 'YOUR_API_KEY'

$r = Invoke-RestMethod -Uri "$base/clients/read.php?api_key=$key&limit=2"
$r.data | Select-Object client_id, client_name

ITFlow answers with JSON:

{
  "success": "True",
  "count": 2,
  "data": [
    { "client_id": "1", "client_name": "Ravenwood Dental Group", "client_rate": "145.00" },
    { "client_id": "2", "client_name": "Kestrel Precision Manufacturing", "client_rate": "155.00" }
  ]
}

Each record comes back with all its fields. The examples in these pages show only some of them.

Make a change

To create, change or remove something, send a POST request with a JSON body. The key goes in the body, with the record's fields. To raise a ticket for client 1:

curl -X POST https://itflow.example.com/api/v1/tickets/create.php \
  -H "Content-Type: application/json" \
  -d '{"api_key": "YOUR_API_KEY", "client_id": 1, "ticket_subject": "Backup job failed on RDG-SRV-01", "ticket_priority": "High"}'
$body = @{
    api_key         = $key
    client_id       = 1
    ticket_subject  = 'Backup job failed on RDG-SRV-01'
    ticket_priority = 'High'
} | ConvertTo-Json

$r = Invoke-RestMethod -Method Post -Uri "$base/tickets/create.php" -ContentType 'application/json' -Body $body
$r.data[0].insert_id
{ "success": "True", "count": "1", "data": [ { "insert_id": 1880 } ] }

insert_id is the new ticket's ticket_id.

Watch out

success is the text "True" or "False", not true or false. In PowerShell, JavaScript and Python, the text "False" counts as true when you test it on its own. Compare it instead, with $r.success -eq 'True' or r["success"] == "True".

Next

↑↓ to pickEnter to open