Your first automationLesson 8 of 8

Call it from another system

An API endpoint lets any other system — a backend, a spreadsheet macro, a CI job — run your published script with one HTTP request and get its output back as JSON. In this last lesson of the track you turn the endpoint on for daily-report, create a token, call it, and find the call on the Runs page.

What you will learn
  • Turn an endpoint on from the editor’s Triggers tab
  • Create a token and keep it safe
  • Call the endpoint synchronously and asynchronously
  • Protect it with a calls-per-minute limit

One script, one URL

Each script or flow can have one endpoint. It lives in the item’s Triggers tab — the same place as its schedules and events — and the project’s API page lists every endpoint of the project. Like every trigger, the endpoint runs the published version, always the latest one: there is no API version to choose and nothing to re-point after a publish.

docs-demoCodehello.pySavePublish
hello.py
1def main(name: str = "world"):2    print(f"saying hello to {name}")3    return {"message": f"Hello, {name}!"}
Triggers1
APIOpen in API page
Another system starts this script with an HTTP request — copy the URL or the curl below.
POST/exec/p_58e3011e/hello
ModeSyncAuthBearerLimit60/minStatus
Call itSyncAsync
1curl -X POST "$WAISO_URL/exec/p_58e3011e/hello" \2  -H "Authorization: Bearer $WAISO_TOKEN" \3  -H "Content-Type: application/json" \4  -d '{"name":"world"}'
SchedulesOpen in Schedules
morning_helloWeekdays at 08:00Active
Add schedule
Events
Run this script when something happens elsewhere: an e-mail arrives, a database row changes, an MQTT message comes in.Add event trigger
Limits
The Triggers tab: the API card with its URL and a ready-to-copy curl, then schedules, events and limits.

The address is POST /exec/<project-id>/<path> on your Waiso address (on a self-hosted install, on the API’s public address). The project id is the project’s permanent id, not its name, so renaming the project never breaks a caller. The path defaults to the script’s folder path and name — daily-report here.

Turn it on and call it

  1. Turn on the endpoint

    Open daily-report and the Triggers tab. The API card says Not on the API yet; press Turn on endpoint. It starts as POST, synchronous, protected by a token, with inputs read from the JSON body. Configure changes any of that. (The publish toast’s Turn on endpoint does the same.)

  2. Create a token

    Under Call it, follow Create token: the API page’s settings open with a new token for this endpoint. Choose how long it lasts and press Generate token. Copy your token — it will not be shown again. Store it in your caller’s secrets as WAISO_TOKEN.

  3. Call it

    Press Copy curl on the Triggers tab — it carries your real address and project id — and run it in a terminal with WAISO_TOKEN set. The body below sends passing = 90.

  4. Find the call

    Open Runs: the new row says Triggered by API, with the token that was used. The API page counts the call in the endpoint’s usage.

Shellcall-daily-report.sh
curl -X POST "https://<your-waiso-address>/exec/<project-id>/daily-report" \
  -H "Authorization: Bearer $WAISO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"passing":90}'
Expected outputSuccessHTTP 200 — the run’s output is in "output"
{
  "runId": "7c0e5b9a-…",
  "status": "success",
  "flowRunId": null,
  "output": {
    "total": 3,
    "average": 85,
    "passed": 1
  },
  "error": null,
  "errorCode": null,
  "durationMs": 38,
  "totalMs": 112
}

Synchronous or asynchronous

A synchronous endpoint waits for the run and answers with its output — best for anything that finishes in a few seconds. It waits up to 30 seconds; after that it answers 504 with "status": "timeout" and the run keeps going. An asynchronous endpoint answers at once with 202 and a runId; the caller then polls /exec/<project-id>/runs/<runId> until the status is final.

Endpoints PrivateOnly scripts that have been published from the editor appear here.
Settings
Search endpoints…Ctrl KAll 8Active 3Inactive 5All typesScriptsFlowsScraper
hello/helloMethodPOSTModeSyncAuthBearerStatus
report/daily-reportMethodPOSTModeAsyncAuthBearerStatus
campaign/campaignMethodPOSTModeAsyncAuthBearerStatus
greetNot configuredMethod—Mode—Auth—Status
counterNot configuredMethod—Mode—Auth—Status
approvalNot configuredMethod—Mode—Auth—Status
The API page lists every endpoint of the project with its method, mode, auth and an on/off switch.
Shellcall-async.sh
curl -X POST "https://<your-waiso-address>/exec/<project-id>/daily-report" \
  -H "Authorization: Bearer $WAISO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"passing":90}'
# → 202 {"runId": "…"}; then poll until it finishes:
curl "https://<your-waiso-address>/exec/<project-id>/runs/$RUN_ID" \
  -H "Authorization: Bearer $WAISO_TOKEN"
HTTP statusMeans
200The run succeeded; read output.
202Async call accepted (or a flow waiting for an approval); poll with the runId.
401Token missing, invalid, revoked, expired or not allowed for this endpoint; code says which.
422Your script ran and failed (it raised, timed out or was cancelled); errorCode says which. Retrying the same call fails the same way.
429Over the calls-per-minute limit; no run started.
503The platform lost the run (no worker available); worth retrying.

Tokens and limits

  • A token calls only the endpoints it lists — a new endpoint needs the token edited to include it. Prefer one token per caller, scoped to what it calls, so revoking one never breaks the others.
  • Calls per minute (Triggers → Limits): callers over it get 429 with a Retry-After header and {"code": "rate_limited", "retryAfter": …}; no run starts and nothing is charged.
  • Runs at the same time: extra runs wait in the queue instead of failing. Both are empty by default — then only your plan’s limit applies.
8 / 8