Pacejet
  • API
  • Tools
  • Monitoring Pacejet API Webhook Subscriptions

Monitoring Pacejet API Webhook Subscriptions

Monitoring Pacejet API Webhook Subscriptions

Pacejet uses webhook subscriptions to push shipment events back to your ERP in real time — when a shipment is confirmed, a quote is updated, or a void is processed, Pacejet calls the URL registered for that event. If a subscription goes inactive, those callbacks stop silently, and your ERP stops receiving updates without any visible error.

This article explains how to set up a lightweight monitoring script that checks your webhook subscriptions on a schedule and alerts you if any are no longer active. The script runs on Windows, requires no third-party services, and takes about 15 minutes to configure. While this example uses a simple Windows balloon notification method, the notification could easily be extended to send an email, Teams notification, or other type of notification.

Prerequisites

  • Windows 10 or Windows 11

  • Python 3.9 or later — download from python.org. During installation, check Add Python to PATH.

  • Your Pacejet location name and API license key — available from your Pacejet administrator or the Pacejet location settings page.

  • Administrator access on the Windows machine where the script will run (required for Task Scheduler setup).


Step 1: Install the Python dependency

Open PowerShell or Command Prompt and run:

py -m pip install requests

Note: If py is not recognized, try python instead. If neither works, Python may not be installed or may not be on your PATH. Re-run the Python installer and confirm the Add Python to PATH option is checked.


Step 2: Download and configure the script

  1. Download pacejet_webhook_monitor.py from the attachment on this page and save it to a folder on your computer. A dedicated folder such as C:\pacejet-scripts\monitors is recommended.
    pacejet_webhook_monitor.py

  2. Open the file in any text editor (Notepad, VS Code, etc.) and update the two configuration lines near the top:

Note: Replace the placeholder values below with your actual Pacejet location name and API license key before running the script.

  1. Set PACEJET_LOCATION to your Pacejet location name — for example, "MyCompany".

  2. Set PACEJET_LICENSE_KEY to the API license key for that location.

  3. Save the file.


Step 3: Test the script manually

Before scheduling, confirm the script runs correctly from the command line.

  1. Open PowerShell and navigate to the folder where you saved the script:

cd "C:\pacejet-scripts\monitors"
  1. Run the script:

py pacejet_webhook_monitor.py
  1. If all subscriptions are active, the script exits silently with no output. This is the expected behavior for a healthy location.

  2. To confirm the alert notification works, temporarily change line 68 in the script from:

problems = [s for s in subscriptions if s.get("status", "").lower() != "active"]

to:

problems = [s for s in subscriptions if s.get("status", "").lower() != "never_match"]
  1. Run the script again. A Windows notification should appear in the bottom-right corner of your screen listing the affected subscriptions.

  2. Change line 68 back to != "active" and save before continuing.

Tip: The notification appears via the Windows system tray (balloon notification). If you do not see it, check that notifications are enabled in Settings > System > Notifications.


Step 4: Schedule the script with Windows Task Scheduler

The following PowerShell commands create a scheduled task that runs the monitor every hour. Run these in a PowerShell window opened as Administrator (right-click PowerShell in the Start menu and select Run as administrator).

Warning: Replace the script path in the command below with the actual path where you saved the script on your machine. The path must match exactly, including any spaces in folder names.

  1. In the Administrator PowerShell window, run all three lines together:

$action = New-ScheduledTaskAction -Execute "C:\Users\YourName\AppData\Local\Programs\Python\Launcher\py.exe" -Argument '"C:\pacejet-scripts\monitors\pacejet_webhook_monitor.py"'
$trigger = New-ScheduledTaskTrigger -RepetitionInterval (New-TimeSpan -Hours 1) -Once -At (Get-Date)
Register-ScheduledTask -TaskName "Pacejet Webhook Monitor" -Action $action -Trigger $trigger -RunLevel Highest

Note: To find the correct path to py.exe on your machine, run where.exe py in PowerShell and use the path it returns.

  1. Verify the task was created successfully:

Get-ScheduledTask -TaskName "Pacejet Webhook Monitor"
  1. Run the task immediately to confirm it works end to end:

Start-ScheduledTask -TaskName "Pacejet Webhook Monitor"
  1. Check the result of the last run:

Get-ScheduledTask -TaskName "Pacejet Webhook Monitor" | Get-ScheduledTaskInfo

A LastTaskResult of 0 means the script ran successfully and found no problems.


How alerts work

When the script detects one or more subscriptions that are not active, it displays a Windows balloon notification in the system tray showing the location name and the affected subscription event names. The notification appears in the bottom-right corner of the screen and stays visible for approximately 10 seconds.

The script also prints full details to the console output, including the subscription ID, event name, current status, and the last-modified date and user. If you redirect console output to a log file in your Task Scheduler configuration, this information is preserved for later review.

Note: Windows balloon notifications only appear when a user is actively logged in to the machine. If the scheduled task runs while the machine is locked or no user is logged on, the notification will not be displayed. The script will still execute and log its output.


Troubleshooting

Symptom

Resolution

Script exits with [ERROR] Could not reach Pacejet API

Verify the machine has internet access and that shipapi.pacejet.cc is not blocked by a firewall or proxy.

Script exits with [ERROR] Unexpected response format

The license key or location name is incorrect. Double-check both values in the configuration section of the script against your Pacejet location settings.

Scheduled task shows LastTaskResult 2147942402

The path to py.exe in the task action is incorrect. Run where.exe py in PowerShell to find the correct path, then delete and recreate the task.

No Windows notification appears during testing

Confirm notifications are not silenced by Focus Assist. Check Settings > System > Notifications & actions and ensure notifications are turned on.

ModuleNotFoundError: No module named 'requests'

Run py -m pip install requests in PowerShell and try again.

Back to top