REST API
Multi-step services
A service is one to ten steps that your own servers (its collectors) run in order. The same service can be built in the console, by an AI assistant (the recipe) and through the calls on this page. The step reference lists every step type, assertion and limit, and the guide explains how a service behaves. A service is one service on your price list, whatever its steps.
| Call | Scope | Answers |
|---|---|---|
POST /v1/services |
services.edit |
201, the service |
PUT /v1/services/{service_uuid} |
services.edit |
200, the service, a new live version |
POST /v1/services/{service_uuid}/duplicate |
services.edit |
201, a paused copy |
POST /v1/services/import |
services.edit |
200, the step a cURL command or OpenAPI operation makes; saves nothing |
POST /v1/services/test-runs |
services.edit |
202, a test of a definition not saved |
POST /v1/services/{service_uuid}/test-runs |
services.edit |
202, a test of a saved service’s definition as sent |
GET /v1/service-test-runs/{test_uuid} |
services.view |
200, the test and, once it ended, each step’s result |
GET /v1/services/{service_uuid}/runs |
services.view |
200, a page of runs |
GET /v1/services/{service_uuid}/runs/{run_uuid} |
services.view |
200, one run with its steps |
GET /v1/services/{service_uuid}/versions |
services.view |
200, a page of versions |
GET /v1/services/{service_uuid}/versions/{version_uuid} |
services.view |
200, one version’s steps |
A definition with Parameters also needs the services.parameters scope and permission. Every write takes an optional
Idempotency-Key.
Create a service
Section titled “Create a service”The body names the service, its steps and the servers that run it. Credentials are references to Parameters, never values:
curl -X POST -H "Authorization: Bearer $WT15_API_KEY" -H "Content-Type: application/json" \ https://rest.watchtower15.com/v1/services -d '{ "name": "Orders journey", "collectors": { "selection": "servers", "servers": ["'"$SERVER_UUID"'"] }, "parameters": [{ "name": "api_key", "source": { "type": "file", "path": "/etc/app/api-key" }, "format": "raw" }], "variables": [{ "name": "run", "generator": "alphanumeric", "length": 8 }], "steps": [ { "name": "Create the order", "type": "http", "request": { "method": "POST", "url": "https://orders.example.com/v1/orders", "body_type": "json", "headers": { "Authorization": "Bearer {{param.api_key}}" }, "body": "{\"ref\":\"check-{{var.run}}\"}" }, "assertions": [{ "target": "status", "operator": "in", "value": [201] }], "extract": [{ "name": "order_id", "from": "body", "parse": "jsonpath", "expression": "$.data.id" }] }, { "name": "Read it back", "type": "http", "request": { "method": "GET", "url": "https://orders.example.com/v1/orders/{{order_id}}", "headers": { "Authorization": "Bearer {{param.api_key}}" } }, "assertions": [{ "target": "status", "operator": "is", "value": 200 }] }, { "name": "Delete it", "type": "http", "request": { "method": "DELETE", "url": "https://orders.example.com/v1/orders/{{order_id}}", "headers": { "Authorization": "Bearer {{param.api_key}}" } }, "assertions": [{ "target": "status", "operator": "is", "value": 204 }] } ] }'The answer holds the service with its steps, each with a uuid that stays the same across edits, its live_version and its run budget. A step’s
headers, body, query, cookies, payload and credentials are never returned.
Change a service
Section titled “Change a service”PUT is a full replacement: send every field again. To keep a step, send it with its uuid and leave out its headers, body, query and auth: they
are write-only and are kept as saved. null clears one. A step whose host changes must send them again: a change of host that leaves them out is refused
with a 422, so that a stored secret is never sent to a new destination unasked. Every save is a new version, live at once.
Test before you save
Section titled “Test before you save”A test runs the definition once, on one of the service’s collectors, and sends each step’s real request. It saves nothing, opens no incident and is
not billed. Send the body of a create to test a draft, or the body of an update to POST /v1/services/{service_uuid}/test-runs to test a saved
service with edits that are not saved yet (each kept step with its uuid, its write-only parts left out and used as saved).
curl -X POST -H "Authorization: Bearer $WT15_API_KEY" -H "Content-Type: application/json" \ https://rest.watchtower15.com/v1/services/test-runs -d @draft.jsonThe call answers 202 with the test’s uuid and status waiting. Read it with GET /v1/service-test-runs/{test_uuid} until status is one of the three
end states: passed, failed or no_answer (no collector picked it up in time). waiting and picked_up mean it is in flight. A test is kept for an hour.
Once it ended, run.steps holds each step’s status, reason, attempts, duration_ms, the numbers it observed, the outcome of each assertion and extraction, and
its response_shape: the structure of what the step received, the keys, types and lengths of a JSON body and the header names, never a value. Use it to
write the next step’s JSON path.
Read runs and versions
Section titled “Read runs and versions”curl -H "Authorization: Bearer $WT15_API_KEY" \ "https://rest.watchtower15.com/v1/services/$SERVICE_UUID/runs?period=1d&status=failed"A run has its status (passed, failed, budget_exceeded or refused), reason, duration_ms against budget_ms, version and version_uuid, the
collector, and the failed_step_uuid with its failed_reason. The window is period or from and to, as everywhere (times and windows).
Every run of the last 30 days is kept; older ones only if they mattered (retention is recent or history, and meta.history_only_before says where the
list stops holding every run). GET …/runs/{run_uuid} adds each step’s outcome. A run names numbers and reasons; the only text a server chose is a step’s evidence.
Step evidence
Section titled “Step evidence”A step of GET /v1/services/{service_uuid}/runs/{run_uuid} and of GET /v1/service-test-runs/{test_uuid} carries evidence, evidence_dropped and evidence_hidden. evidence is what the step’s server answered at its last attempt, with every value the run used masked on your collector as its {{reference}}; it needs the scope service_evidence.view (and the owner’s permission). Without it evidence is null and evidence_hidden is true. evidence_dropped says why a step has none: switched_off, run_cap, pool or invalid. A run’s evidence is kept as long as the run; a test run’s an hour.
evidence is one object whose keys depend on the step type; every type has attempt, of and answered (false when the last attempt got no answer: then only those and, for http, request):
| Type | Keys |
|---|---|
http |
request (method and URL without its query, at most 2,064 bytes), version, status, headers (a list of {name, value, withheld}, at most 64, names lower-cased), headers_omitted, body (the first 8,192 bytes of a text body), body_bytes, body_kept (whole, first_8kb, binary, not_read, step_cap, run_cap), body_decompressed |
grpc |
code (0 to 16), message, reply (JSON, at most 8,192 bytes), reply_kept, reply_bytes, trailers (names only), trailers_omitted |
websocket |
status, message (the first one), message_kept, message_bytes |
tcp, udp |
reply (at most 512 bytes read: text, or hex with each masked value as its reference), reply_encoding (text or hex), reply_bytes |
dns |
records (at most 50 of {type, name, ttl, data, data_bytes}), records_omitted |
tls |
subject, issuer, names, names_omitted, not_before, not_after, protocol, cipher |
smtp |
lines (at most 50, each at most 512 bytes), lines_omitted |
A secret too short to mask (under 4 characters) adds withheld_reason: short_value and withholds every text and list. A step’s evidence is at most 16,384 bytes and a run’s 98,304: past them the body is cut shorter, then dropped, then lists from the end, and a step that no longer fits is null with evidence_dropped: run_cap.
A step body takes keep_evidence (boolean, on by default): the step’s own switch. A request that leaves it out keeps the stored value of the step with that uuid; a wait or icmp step keeps none.
GET …/versions lists the saved versions, newest first; one version holds the steps as they were, so two reads show what a save changed.
Import a step
Section titled “Import a step”POST /v1/services/import reads a pasted cURL command, or one operation of an OpenAPI document, and answers the step it makes, without saving it:
curl -X POST -H "Authorization: Bearer $WT15_API_KEY" -H "Content-Type: application/json" \ https://rest.watchtower15.com/v1/services/import \ -d '{"source":"curl","source_text":"curl -X POST https://orders.example.com/v1/orders -H \"Authorization: Bearer $TOKEN\""}'The answer has step, parameters_needed (each credential as a {{param.name}} reference and where it is used) and unread_flags. Send the step in a create or an
update, and supply the Parameters it needs. A document is pasted, never fetched: a url is refused.
In an SDK
Section titled “In an SDK”Every published SDK has a method for each call on this page.