Skip to content

Automations

The Automations module enables users to extend the system with custom workflows. It allows running custom business logic, integrating with external systems, and scheduling automated tasks to improve efficiency and reduce manual work.

Use Cases:

  • Run AI-powered data analysis and generate insights.
  • Send automated email notifications based on specific triggers.
  • Generate and export reports on a scheduled basis.
  • Prepare PDF documents and attach them to the system.
  • Integrate with third-party services for data synchronization.
  • Perform data cleanup and maintenance tasks automatically.
  • Run custom scripts to process data and update records in the system.

Examples:

  • Pull exchange rates from an external API and update the system.
  • Retrieve emails from an external mail server.
  • Optimize video files within the system.
  • Validate VAT numbers using the VIES service, generate a PDF confirmation, and attach to the system.

Prerequisites

  • Python installed in c:\Python
  • Python libs pip install requests pyodbc uuid logging

Configuration

  • secrets:jetquery_var_automation_appname - name of the app authorized to run automations default erp
  • secrets:jetquery_var_automation_python - optional - location of python default c:\\Python\\python.exe
  • Automations are stored in the /automations directory of the application.
  • Automation names must follow the format: A001-YourAutomationName.
  • Only a single app instance is authorized to run automations.

Environment Variables

  • Automation scripts read environment variables starting with JETQUERY_.

Warning : environment variables are visible in a scope of the machine level (system environment) IIS/Kestrel. After restarting iis from gui or recycle it will not be visible iisreset is required

Batchfile
setx /M JETQUERY_TOKEN_app.platformaerp.com "12345-secret-value"
iisreset    # reset required

Predefined:

  • JETQUERY_TOKEN – Represents the API token for authentication, reads from Environment variables JETQUERY_TOKEN_+ JETQUERY_HOST (e.g., JETQUERY_TOKEN_app.platformaerp.com) token must match host/tenant other tokens are ignored
  • JETQUERY_HOST – Represents the host URL or tenant ID. example app.platformaerp.com !WARNING! without scheme https:// or http://
  • JETQUERY_DSN – Represents the database connection string.
    • If not provided, it is generated automatically, e.g.: SERVER=192.1.1.1;DATABASE=ERP;UID=platforma;PWD=password;Trusted_Connection=no;
    • The driver must be added in the script, for example:
      DRIVER={SQL Server};
  • JETQUERY_FILES – Path to the local tenant files.
  • JETQUERY_ARCHIVE – Path to the local tenant temporary archive, which is cleaned automatically according to the data retention policy.
  • JETQUERY_.... All environment variables starting with JETQUERY_

automation.json

Stored in app directory automations\

JSON
[
  {
    "name": "A001-run-kursy",
    "type": "python",
    "description": "Automatyzacja pobierania kursów walut NBP",
    "acl": "erp_administrator",
    "cron": "* * * * *"
  },
  {
    "name": "A002-tools-minimal",
    "type": "win-x64",
    "description": "Testowy skrypt nie wykonuje czynności zwraca komunikat error,success i random exit code 0-1",
    "acl": "erp_administrator",
    "cron": "* * * * *"
  }
]

API

Test automations using A000-run-test.

RUN Automation as a JOB

Starts an automation and returns a job ID for status polling.

Request (works with GET/POST):

options:

  • cron (optional queryparameter) - cron expression to schedule the automation, if not provided runs immediately
  • args (optional queryparameter) - additional arguments to pass to the script, for example: ?args=arg1,arg2
HTTP
POST {{host}}/api/core/automations/run/A000-run-test
Authorization: Token {{token}}

Response:

JSON
{
  "success": true,
  "message": "",
  "requestID": "",
  "executed_at": "2026-05-31T12:21:30Z",
  "data": {
    "jobid": "45711",
    "jobstatus": "/api/core/automations/status/45711"
  }
}
Field Type Description
data.jobid string Job identifier, use to poll status
data.jobstatus string Relative URL for the status endpoint

SCHEDULE Automation RUN

HTTP
POST {{host}}/api/core/automations/run/A000-run-test?cron=0 9 * * 1-5
Authorization: Token {{token}}

Exmaples of cron expressions:

  • * * * * * - every minute
  • 0 * * * * - every hour at minute 0
  • 0 0 * * * - every day at midnight
  • */5 * * * * - every 5 minutes
  • 0 9 * * 1-5 - 09:00 Monday–Friday

EXEC Automation immediately and wait for the result

Starts an automation and wait for the result, not recommended for long running tasks, use for testing and debugging only.

Request (works with GET/POST): options:

  • cron (optional queryparameter) - cron expression to schedule the automation, if not provided runs immediately
  • args (optional queryparameter) - additional arguments to pass to the script, for example: ?args=--action arg2 --action2 test

POST http://localhost/api/core/automations/exec/A020-run-hanel?args=--action

HTTP
POST  http://localhost/api/core/automations/exec/A002-tools-minimal?args=--wait 5 --status 1
Authorization: Token {{token}}

Response:

JSON
{
  "success": true,
  "message": "",
  "requestID": "",
  "executed_at": "2026-05-31T12:21:30Z",
  "data": {
    "jobid": "45711",
    "jobstatus": "/api/core/automations/status/45711"
  }
}

STATUS of the job

Returns the current state of a running or completed automation job.

Request:

HTTP
GET {{host}}/api/core/automations/status/{jobid}
Authorization: Token {{token}}

Response:

JSON
{
  "success": true,
  "message": "",
  "requestID": "",
  "executed_at": "2026-05-31T13:13:18Z",
  "data": {
    "jobid": "45722",
    "jobstate": "Succeeded",
    "exitCode": "2",
    "stdout": "",
    "stderr": "..."
  }
}
Field Type Description
data.jobstate string Pending, Running, Succeeded, or Failed
data.exitCode string Process exit code returned by the automation script
data.stdout string Standard output from the script
data.stderr string Standard error output from the script

BROWSE Automations

Lists all available automations. Requires role sys_administrator.

Request:

HTTP
GET {{host}}/api/core/automations/browse
Authorization: Token {{token}}

Other endpoints

HTTP
POST /api/core/automations/run/{{automationName}}?cron={{cron}}
DELETE /api/core/automations/del/{{automationName}}

Testing in local environment

SETUP ENVIRONMENT VARIABLES

Run cmd as administrator

Batchfile
1
2
3
4
5
6
7
echo %JETQUERY_TOKEN%
echo %JETQUERY_HOST%

setx JETQUERY_TOKEN "MyValue"
setx JETQUERY_HOST "https://app.platformaerp.com"
:: połączenie z bazą danych
setx JETQUERY_DSN "your_dsn_value" 

A002-tools-minimal - Basic dotnet template

you can find it in tests\test-files\A002-tools-minimal.cs

args:

  • --status [0/1/2] default 0
    • 0 = Success
    • 1 = General failure (write to stderr)
    • 2 = Incorrect usage / file not found (write to stderr)
  • --wait [s] default 5
  • --msg [string] default: write all env vars and args as JSON to stdout