shiftlabs Start free
Menu Deploy and triggers

Deploy and triggers

Deploy a workflow with one call and start runs from a trigger URL.

Deploy and trigger

The deploy body is the workflow's source, up to 512 KiB. Send TypeScript as is, or Python with content-type: text/x-python. A workflow of several files or npm packages is sent as JSON with content-type: application/json: {"entry", "files"}, where files maps each file's path, such as lib/money.ts, to its text, and entry names the workflow's file among them; the language follows its extension. That body may be 1 MiB with up to 100 files, and shiftlabs deploy builds it for you. Workflow names are lowercase letters, digits and hyphens, up to 63 characters. A file that holds a PEM private key is refused before anything is built, with 400 {"error": "private key in source", "detail", "hint"}: detail names the file and the line the key starts on, such as src/a.ts:12: a PEM private key starts here, or the line alone for a deploy of one source, and never repeats the key. Keep the key in a secret marked readable: reveal() returns it, and step.exec takes it as { secret: "NAME" }. Each deploy is scanned. Blocked code is refused with the reason, and warnings are returned in warnings. The code is then loaded once, with no network, which reads its payload schema. Code that fails to load fails the deploy with 400: for Python, a syntax error or an import that is not installed, with the traceback. A deploy with new Python packages or npm packages returns 202 with a deployId while they install. To ship several workflows together, see Releases.

shellcurl
# Deploy (developer or admin key).
# Answers {"versionHash", "sizeBytes", "warnings"}.
curl -X PUT https://api.shiftlabs.org/v1/workflows/refund-check \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" \
  --data-binary @refund-check.ts

# The same for Python.
curl -X PUT https://api.shiftlabs.org/v1/workflows/refund-check \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" \
  -H "content-type: text/x-python" \
  --data-binary @refund_check.py

# Several files: the workflow's file, the files it imports, package.json and
# package-lock.json.
# upload.json: {"entry": "workflows/invoice-check.ts", "files": {
#   "workflows/invoice-check.ts": "…", "lib/money.ts": "…", "package.json": "…",
#   "package-lock.json": "…"}}
curl -X PUT https://api.shiftlabs.org/v1/workflows/invoice-check \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" \
  -H "content-type: application/json" \
  --data-binary @upload.json

# Create a trigger. Answers 201 {"triggerId", "url", "signingScheme"}.
curl -X POST https://api.shiftlabs.org/v1/triggers \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" \
  -H "content-type: application/json" \
  -d '{"workflow": "refund-check"}'

# Start a run from any webhook sender. Answers 202 {"runId"}; sent again with
# the same Idempotency-Key within 7 days, it answers 200
# {"duplicate": true, "runId"} and starts nothing.
curl -X POST https://hooks.shiftlabs.org/t/<triggerId> \
  -H "content-type: application/json" \
  -H "idempotency-key: ch_123" \
  -d '{"id": "ch_123"}'

# Follow it.
curl https://api.shiftlabs.org/v1/runs/<runId>/timeline \
  -H "authorization: Bearer $SHIFTLABS_API_KEY"

A trigger id is 128 random bits. Without signing, anyone with the URL can start a run. Rotate it with POST /v1/triggers/:id/rotate or revoke it with DELETE. To require signed deliveries, create the trigger with "signing": {"scheme": …}. Timestamped signatures must be within 5 minutes. A webhook body is capped at 1 MiB, and so is its payload as JSON: a JSON body counts without its whitespace, and a text body as a JSON string, where quotes, backslashes and control characters take 2 to 6 bytes each. Past either, a delivery returns 413 {"error": "payload too large"} and starts no run.

A delivery the trigger has seen in the last 7 days returns 200 {"duplicate": true, "runId"} with the run the first delivery started, and starts no second run. If the first attempt got a 5xx, a retry within 45 minutes starts its run, unless the run has already started. Seen means the same shiftlabs or github signature, the same Stripe event id (on an adapter trigger, the same stripe signature), or, on any trigger, the same Idempotency-Key header, which any sender can set (1 to 255 visible ASCII characters). GitHub signs the body but not X-GitHub-Delivery, so the same body under another delivery id is the same delivery, and two GitHub events with identical bodies count as one. GitHub signs no timestamp, so after 7 days a copy of an old github delivery starts a run again; rotating the trigger URL or changing its secret stops that.

When the workflow has a payload schema, a delivery whose payload fails it gets 400 {"error": "payload does not match the schema", "detail"}, with each problem on a line of detail. It starts no run and counts toward no quota. A retry of a delivery that already started a run is still a duplicate, even after a deploy changed the schema. On a trigger with an adapter, which maps the body before that check, a retry the adapter can no longer map after its config changed gets 422 instead. Checking the payload may take 2 seconds: past that, the delivery returns 503 {"error": "temporarily unavailable"} with a detail and Retry-After: 5, and starts no run. Run now and a release's schedule payloads are checked the same way.

A keyed workflow's trigger can take an event: each delivery is then that event, sent to its payload's key as POST /v1/workflows/:workflow/events/:name sends one. The key's open run gets it, or the delivery opens a run as before, which gets it too; a delivery to an open run returns 200 {"runId", "started": false}, and its log reads sent to the key's open run. See Events to a key.

When the workspace's storage is briefly unavailable, a delivery returns 503 {"error": "temporarily unavailable"} with Retry-After: 1. Webhook senders that retry on 5xx deliver later. See Rate limits.

Revisions · refund-check

2
RevHashDeployed
B currentf7e852362026-10-20
A1d9a281e2026-10-20

Runs keep the hash they started on. Redeploying a known hash keeps its letter.

Signing schemes
SchemeSecretHeader checked
shiftlabsGenerated and returned once, as signingSecret.Shiftlabs-Signature: t=<unix seconds>,v1=<hex>, where v1 is HMAC-SHA256 of <t>.<body>.
stripeYour Stripe endpoint secret, 8–256 characters.Stripe-Signature
githubYour GitHub webhook secret, 8–256 characters.X-Hub-Signature-256; X-GitHub-Delivery is optional
Routes
RouteMethodMinimum role
/v1/triggers [{id, workflow, signing_scheme, created_at, name, description, event, adapter, url}]; viewers get masked ids and no urlGETviewer
/v1/triggers {"workflow", "signing"?: {"scheme", "secret"?}, "name"?, "description"?, "event"?, "adapter"?: {"kind", "config"}}; 201 {triggerId, url, signingScheme, signingSecret?, name, description, event, adapter}POSTdeveloper
/v1/triggers/:id {"signing"?: {"scheme", "secret"?} | null, "name"?, "description"?, "event"?: name | null, "adapter"?: {"kind", "config"} | null}, at least one; the URL staysPATCHdeveloper
/v1/triggers/:id/rotate a new id and URL with the same signing, name, event, adapter and delivery log: {triggerId, url, revoked}; the old URL stops workingPOSTdeveloper
/v1/triggers/:id {"revoked": id}; its delivery log goes tooDELETEdeveloper

Check code before you deploy

POST /v1/workflows/:workflow/validate takes the body a deploy takes and checks it as a deploy does: it bundles the code, scans it and loads it once, with no network. It deploys nothing, builds no packages and leaves the current version as it is. It answers 200 with what it found, so an editor can check code as you type.

shellcurl
# Developer or admin key. Answers {"ok", "loadChecked", "errors", "warnings"}.
curl -X POST https://api.shiftlabs.org/v1/workflows/refund-check/validate \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" \
  --data-binary @refund-check.ts
  • errors

    What a deploy would refuse, each with its stage: bundle, scan or load. message is the error a deploy returns, with its detail; a scan error names the rule the code scan blocks, or says a file holds a private key. Where the error points into your files, as a TypeScript syntax error, a Python traceback or a private key's first line does, path is the file and line the line; a check of one source has line alone. ok is true when there are none.

  • loadChecked

    false when the code wasn't loaded, which is not an error: a check builds no packages, so code whose Python packages or npm packages haven't been built isn't loaded, and a bundle or scan error stops before the load. Packages built already, for an earlier deploy of the same ones, are loaded as a deploy loads them.

  • warnings

    Each has a kind and a detail. secret_names: a secret the code reads that isn't set, has no hosts or isn't scoped to the workflow, as a deploy warns. quota: your plan's limit on workflows, or on new versions per 24 hours, would refuse a deploy now, and until when.

  • A workspace can check code 20 times a minute, apart from its deploys. Past that, a check gets 429 with Retry-After: 60. See Rate limits.
  • A load that takes more than 60 seconds returns 503 {"error": "temporarily unavailable"} with a detail and Retry-After: 30, as a deploy does.
  • When shiftlabs briefly can't reach the workspace's storage, a check returns 503 {"error": "temporarily unavailable"} with Retry-After: 1 and no hint: a check saves nothing, so it's safe to send again.
  • The body's limits and refusals are a deploy's: 413 past 512 KiB of source or 1 MiB of files, 400 for files of the wrong shape, and 409 for a workflow name in the trash.

Delivery log

Each trigger keeps its last 100 deliveries for 7 days, refused ones included. Developers and admins see them on the Triggers screen, under the trigger, or with GET /v1/triggers/:id/deliveries. A trigger can have a name of up to 100 characters and a description of up to 500, which the Triggers screen and a run's Started by show.

shellcurl
# A trigger's deliveries, newest first. bodies=1 adds each kept body.
# Answers {"deliveries": [{"id", "received_at", "status", "outcome", "error", "detail",
# "run_id", "size", "headers", "body_cut", "body"}], "nextBefore"}.
curl "https://api.shiftlabs.org/v1/triggers/<triggerId>/deliveries?bodies=1" \
  -H "authorization: Bearer $SHIFTLABS_API_KEY"

# Deliver a kept delivery again. Answers 202 {"runId", "delivery"}.
curl -X POST https://api.shiftlabs.org/v1/triggers/<triggerId>/deliveries/<id>/replay \
  -H "authorization: Bearer $SHIFTLABS_API_KEY"

# Send a test event with your own body ({} without one).
curl -X POST https://api.shiftlabs.org/v1/triggers/<triggerId>/test \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" \
  -H "content-type: application/json" \
  -d '{"id": "evt_test"}'
  • What a delivery shows

    When it came, the status it was answered and its outcome: started, duplicate or refused. A refusal's error is the one the sender got, such as invalid signature, invalid JSON, payload does not match the schema, payload too large or quota exceeded, and detail says more: why the signature failed, the schema's problems, the limit. Then the run it started, its size, its headers and its body.

  • Headers

    As sent, with signatures, authorization, cookies, tokens and API keys shown as [redacted].

  • Body

    The first 16 KiB, kept for a delivery whose signature passed or whose trigger has no signing; body_cut says when it is longer. A delivery refused at or before its signature check keeps none. Reading bodies needs run.payload and is written to the audit log as payload_view.

  • Not in the log

    A delivery to an unknown or revoked URL, a body over 1 MiB, one refused by the rate limits, and one to a suspended workspace. A workspace logs at most 100 refused deliveries every 10 seconds; past that, refusals are answered but not logged.

  • Kept

    100 a trigger, 10,000 a workspace, 7 days. Revoking a trigger deletes its log; rotating it keeps the log under the new URL.

  • Replay

    Delivers a kept body again, through the checks a delivery gets now, all but the signature: JSON, the trigger's adapter, the payload schema, size, your limits. A delivery whose body isn't kept whole gets 409 {"error": "body not kept"}.

  • Send test

    Delivers the body you send, with its content-type, the same way. Without one it sends {}.

  • Both

    Start a run of the trigger's workflow, count toward your runs, and are logged with who sent them. An Idempotency-Key makes a retry answer 200 {"duplicate": true, "runId"} instead of starting another run.

Routes
RouteMethodMinimum role
/v1/triggers/:id/deliveries ?limit=&before=&bodies=1; {deliveries, nextBefore}, newest first, 50 a page (limit up to 100); bodies=1 needs run.payloadGETdeveloper
/v1/triggers/:id/deliveries/:delivery/replay 202 {runId, delivery}; 409 when the body isn't kept wholePOSTdeveloper
/v1/triggers/:id/test the body to send, {} without one; 202 {runId, delivery}POSTdeveloper

Generic adapter

A trigger with an adapter starts each run with an event made from the delivery rather than with its body, so alerts from any monitoring tool reach your workflow in one shape: where they came from, their type, a dedup key, a severity, a status (triggered or resolved), a subject, and the body itself as raw. The generic adapter reads those fields from any JSON body, at the paths you configure.

shellcurl
# Create a trigger whose deliveries are signed as GitHub signs its webhooks, with
# your secret, and become events. Answers 201 {"triggerId", "url", "signingScheme",
# "name", "description", "event", "adapter"}.
curl -X POST https://api.shiftlabs.org/v1/triggers \
  -H "authorization: Bearer $SHIFTLABS_API_KEY" \
  -H "content-type: application/json" \
  -d '{"workflow": "on-call", "signing": {"secret": "<your secret>"},
    "adapter": {"kind": "generic", "config": {"source": "grafana",
      "paths": {"dedupKey": "$.groupKey", "subject": "$.title",
        "severity": "$.commonLabels.severity", "status": "$.status"},
      "severities": {"page": "critical", "ticket": "warning"},
      "resolved": ["resolved"]}}}'

# Send an alert. X-Hub-Signature-256 is the hex HMAC-SHA256 of the body.
body='{"groupKey": "disk/db-1", "title": "Disk full on db-1", "status": "firing", "commonLabels": {"severity": "page"}}'
curl -X POST https://hooks.shiftlabs.org/t/<triggerId> \
  -H "content-type: application/json" \
  -H "x-hub-signature-256: sha256=$(printf '%s' "$body" | openssl dgst -sha256 -hmac '<your secret>' | awk '{print $NF}')" \
  -d "$body"

# The run's payload:
# {"source": "grafana", "type": "alert", "dedupKey": "disk/db-1", "severity": "critical",
#  "status": "triggered", "subject": "Disk full on db-1", "raw": {"groupKey": "disk/db-1", …}}
  • paths

    Where each field is in the body. dedupKey and subject are required; type, severity and status are optional. A path is $ followed by .name, ['name'] or [index] segments, such as $.alerts[0].labels.alertname, with at most 16 segments and 256 characters. Wildcards, filters and slices are refused with 400.

  • source and type

    source is the config's own, up to 64 characters, or generic. type is the value at paths.type, or alert.

  • dedupKey and subject

    The values at their paths: a string, or a number's or boolean's text exactly as sent, every digit of a long integer kept. A delivery without one gets 422 {"error": "body does not match the adapter", "detail"}, where detail names the path.

  • severity

    The value at paths.severity, looked up in severities, which maps each value your sender uses to critical, error, warning, info or unknown. A value it doesn't list is unknown. paths.severity and severities come together; without them every event is unknown.

  • status

    resolved when the value at paths.status is one of the resolved list's, exactly as sent, and triggered otherwise. paths.status and resolved come together; without them every event is triggered.

  • An adapter trigger must be signed: one created or changed without signing gets 400 {"error": "adapter triggers need signing"}. Created without a signing.scheme, it is github; shiftlabs and stripe also work (see the signing schemes). github checks X-Hub-Signature-256: sha256=<hex HMAC-SHA256 of the body>; an X-GitHub-Delivery header is optional. A delivery whose signature is missing or wrong gets 401 {"error": "invalid signature"}.
  • A body that isn't JSON gets 400 {"error": "adapter needs a JSON body"}, whatever its content-type. Refused deliveries start no run and are in the delivery log, as is each body as it was sent.
  • The workflow's payload schema checks the event, not the body, and the 1 MiB cap counts the event, raw included.
  • PATCH /v1/triggers/:id with adapter changes the config and leaves the signing secret as it is. "adapter": null makes it a plain trigger again, still signed, after which signing can be removed. Replays and test events go through the adapter as it is now.
  • A delivery is deduplicated by its signature, under every scheme, or by its Idempotency-Key; never by dedupKey, which is in the event for your workflow to use, nor by a stripe body's id, which here usually names the alert: its firing and its resolve are two deliveries.
  • With github, the signature covers the body alone, so the same body within 7 days is the same delivery, whatever its X-GitHub-Delivery or Idempotency-Key: an alert whose body has no timestamp or other field that changes can't fire again within 7 days. Put a timestamp in the body, or sign with shiftlabs or stripe, whose signatures cover one. With those two, each signing is a new delivery, so send the same Idempotency-Key with every retry of one.
  • In the dashboard, New trigger's Adapter picks a kind and takes its config as JSON, checked with the API's messages before it is sent, and Signature check then offers only the schemes that adapter lists. The Triggers list tags adapter triggers, and a trigger's page shows the kind and config; its Edit adapter changes or clears them and leaves the signing as it is. MCP's and the helper's create_trigger take an adapter too.