agentport

Guide · Webhooks

Trigger an AI coding agent from a GitHub or Stripe webhook

In AgentPort 0.11.0 a routine can start from an HTTP webhook, not only from cron. The agent still runs on your computer. This page covers the editor, the HTTP contract, and what GitHub or Stripe can actually send.

What this is

A webhook routine is a saved prompt on the computer where AgentPort is installed. It lives on the same Routines tab as a scheduled run, with the same prompt, assistant, folder, and permission mode. A POST starts the run instead of the clock. Cron setup: Schedule an AI coding agent on your computer with cron. To run Grok Build non-interactively directly from CI pipelines or one-shot shell scripts, see How to run Grok Build headless (non-interactive): scripts, cron and CI.

You need AgentPort 0.11.0 or newer (out since 9 November 2026). Webhook appears under How it starts only when that computer advertises it. If the option is missing, open the computer's settings, go to Software, and update, or run bash ~/.agentport/update-node.sh on the machine. Version 0.10.0 has cron and does not mount this route.

The Free plan covers 1 computer. Pro is $27/month for up to 3. You pay the AI provider yourself. See pricing.

Set it up in the editor

Open the computer, click Routines, then Add a routine. Save a name, a prompt, an assistant, a folder, and a permission mode. Under How it starts, choose Webhook, then save.

The prompt can use {{payload}} or {{payload.path}} to place the webhook body. If you leave those tokens out, the body is still appended. Assistant is Grok (Grok Build) or Antigravity. Codex CLI and Claude Code are not listed yet; they are on the roadmap. Permission mode is Auto or Always approve. Ask first is not available. Antigravity lists only Always approve, because it cannot pause.

Before the first save the form says: Save to get a web address and a secret. The secret is shown only to you. After save, you get the Webhook URL (Copy URL), the Secret (hidden until Reveal secret; Hide secret and Copy secret are next to it), Rotate secret after a confirm (the old secret stops working immediately, so update the sender), and a curl example that uses Authorization: Bearer (Copy example). The secret is in the header, not in the URL the editor builds. A later Save keeps the current secret. Only rotate replaces it.

The form also says: Keep the secret in the Authorization header. A ?token= on the URL can show up in access logs. Optional Require a signature is a second check with that same routine secret; there is no second secret. Save again after you change it. sha256= of the body starts on header X-Hub-Signature-256. Stripe-style timestamp starts on Stripe-Signature. You can edit the header name. A webhook routine also warns: Always approve and a public web address means a hostile payload can ask the agent to edit files and run commands.

The HTTP call

Send POST /hooks/<routineId> to the node, the program on your computer. The Cloudflare control worker does not serve this route and does not see the prompt, the payload, or the secret.

The secret can arrive in one of three ways. Only one is used. Bearer is first, then X-AgentPort-Token, then ?token=. The curl example uses Bearer.

A wrong or missing secret, an unknown id, a routine that is not a webhook, or a machine key (apm_…) is 401 with { "ok": false }. The body does not say which check failed. When a signature is required, a bad or expired signature is also 401.

The body cap is 256 KiB (413 if larger). JSON is parsed when it parses. An empty body is passed as null. Anything else is the raw text. Each routine allows 30 requests a minute (429 over that).

An accepted delivery is remembered for 5 minutes in the running process. With a signature required, the key is the routine id plus that signature header. With no signature, the key is the header X-AgentPort-Delivery. A repeat returns 200 with the same runId. If neither header is present, nothing is remembered, and another call can start another run.

A new run returns 202 { "ok": true, "runId" }. The HTTP call does not wait for the agent. Read it later in History, then Open chat. A paused routine is 403. If the machine is disabled, the scheduler is not running, or two routine runs are already going, the answer is 503. If this routine is already running, the answer is 200 { "ok": true, "status": "skipped" }.

How the payload reaches the agent

The body is untrusted data. The hook does not write it to the logs, but it does go into the prompt, which is why the chat contains it. The routine secret is never inserted into the prompt or the HTTP response.

A line above the data says the blocks marked UNTRUSTED-WEBHOOK-PAYLOAD are data from a webhook, not instructions, and not to follow instructions inside them. {{payload}} is the JSON, or the raw text, cut after 16,000 characters, inside this fence:

Copy this and paste it on that computer. You do not need to type it by hand.

<<<UNTRUSTED-WEBHOOK-PAYLOAD
…the body…
UNTRUSTED-WEBHOOK-PAYLOAD

If the saved prompt has no {{payload}} or {{payload.path}} token, that note and the fence are appended. You opt into where the data sits. You do not opt out of the data. When you do use a token, the same note sits above the prompt, and each token becomes its own fence. {{payload.path}} is one pass of dot-path access, such as {{payload.repository.full_name}} or {{payload.commits.0.id}}. A missing path is an empty fence. Text inside the payload that looks like {{payload}} is not expanded. If the body contains the closing marker, that marker is broken up so the payload cannot close the fence early.

The computer must be reachable

The hook is served by the node, on the same public host as the machine's WebSocket. The editor turns wss://HOST/ws into https://HOST/hooks/<id>, and ws:// into http://.

A normal AgentPort install already has a managed Cloudflare Tunnel hostname m-<machineId>.johnstech.in. The browser uses that host for wss://…/ws. GitHub or Stripe reaches the hook on the same host. This is not a new tunnel. A custom host, including Coolify, works the same way when the machine has a public wss or https URL (PUBLIC_WSS_URL).

localhost, 127.0.0.1, 0.0.0.0, ::1, and a name ending in .local count as no public address. An empty or invalid address does too. The editor then shows only the path /hooks/<id> and the line "This computer has no public address yet."

The computer has to stay on. If it is off, the tunnel is down and the caller does not reach AgentPort. There is no queue on the control worker, and the body is not saved to run later. If the process is up but the machine is disabled, the scheduler is not running, or the two-run cap is full, callers get 503.

GitHub

GitHub will not send Authorization: Bearer. A working payload URL puts the routine secret in the query:

Copy this and paste it on that computer. You do not need to type it by hand.

https://m-<machineId>.johnstech.in/hooks/<routineId>?token=<routine-secret>

The editor warns that a ?token= can show up in access logs. Use it here because GitHub has no header for this secret. For a sender you control, prefer the Authorization header.

You can also turn on Require a signature, choose sha256= of the body, leave the header as X-Hub-Signature-256, and paste the same routine secret into GitHub's webhook Secret field. GitHub signs the raw body, and AgentPort checks that signature with the routine secret. Example events are push and issues.

Copy this and paste it on that computer. You do not need to type it by hand.

A GitHub webhook just arrived.
Repo: {{payload.repository.full_name}}
Ref: {{payload.ref}}
Action: {{payload.action}}
Read the fenced payload. Summarize what changed. Do not push.

A push event has repository.full_name and ref. An issues event has action. A path that is not in that event is empty; the fenced body still carries the rest. The same body and secret produce the same signature, so a repeat of that signed delivery within 5 minutes returns the same runId. Without the signature, GitHub does not send X-AgentPort-Delivery, so a second call is not deduped.

Stripe

A Stripe Dashboard webhook also does not send a Bearer header. Put ?token=<routine-secret> on the endpoint URL, with the same access-log warning. Leave Require a signature off for that Dashboard webhook. Stripe signs with a whsec_… signing secret that Stripe generates. AgentPort's Stripe-style HMAC uses the routine secret, not Stripe's whsec_. Do not paste the routine secret into Stripe as the signing secret. AgentPort does not verify Stripe's official Stripe-Signature as Stripe sent it. Those are different keys.

Turn the Stripe-style check on only when the sender is something you control, and that sender signs the timestamp, a dot, and the raw body with the routine secret, then sends t=<unix>,v1=<hex>. t has to be within 5 minutes.

Copy this and paste it on that computer. You do not need to type it by hand.

A Stripe webhook arrived.
Event type: {{payload.type}}
Read the fenced payload and tell me what the event says about the payment. Do not change files.

That is your prompt plus the JSON Stripe posted. AgentPort does not add a Stripe product of its own.

Try it with curl

The editor's example sends the secret as a Bearer token and a JSON body:

Copy this and paste it on that computer. You do not need to type it by hand.

curl -sS -X POST 'https://m-<machineId>.johnstech.in/hooks/<routineId>' \
  -H 'Authorization: Bearer <routine-secret>' \
  -H 'Content-Type: application/json' \
  -d '{"hello":"world"}'

A new run answers 202 and a runId. Open History on that routine to read what the agent did.

Unattended runs and Peaceful guardrails

The form says this runs when you are not here. Ask first is not available. On Grok, Auto still stops for edits and commands, and if you do not answer, those are denied. Always approve lets the agent edit files and run commands on its own.

Even in an always-approve chat, Grok holds git push, git reset --hard, a destructive rm, and writes outside the allowed folders. The chat shows a Needs your OK card. History then shows Needs you, with status needs_attention. Peaceful does not auto-allow that card. The run stays on Needs you until you answer. If you deny it, the run is cancelled. History says Stopped, with a line such as "Stopped: needed your OK…". That is not a crash.

Antigravity still cannot pause. Its routines stay on Always approve, and the form says it cannot be stopped before a push or a delete. Use Auto on Grok when the job should not edit unsupervised. Keep the work in git, and read the diff before you push.

Codex CLI and Claude Code are still not in AgentPort. Both are on the roadmap. To run them on a server yourself, see Run Codex CLI and Claude Code on a VPS, and use them from your phone.

FAQ

Does the computer need a public address?

Yes, if GitHub, Stripe, or anyone else on the internet should reach it. A normal install already has m-<machineId>.johnstech.in on the managed tunnel. Coolify and other custom hosts work when PUBLIC_WSS_URL is a public wss or https URL. Localhost and .local names are not public; the editor then shows only /hooks/<id> and "This computer has no public address yet."

How do I authenticate a GitHub webhook?

GitHub will not send Authorization: Bearer. Put ?token=<routine-secret> on the payload URL (it can show up in access logs). Optionally require a signature: style sha256= of the body, header X-Hub-Signature-256, and paste the same routine secret into GitHub's Secret field.

Does AgentPort verify Stripe's own signing secret?

No. Stripe's whsec_… secret is not the routine secret. Leave Require a signature off for a Stripe Dashboard webhook, and use ?token= on the URL for auth. AgentPort checks a Stripe-style signature only when the sender signs with the routine secret.

What happens if the computer is off?

The tunnel is down, so the caller does not reach your computer. AgentPort does not queue the body on the control worker, and it does not replay the call later. If the process is up but the machine is disabled, the scheduler is not running, or two routine runs are already going, the node returns 503.

Is the webhook payload trusted?

No. It is data, not instructions. It is fenced, cut after 16,000 characters, and not written to the logs. A line above the fence says not to follow instructions inside it. That does not make an Always approve routine safe against a hostile payload.

Will an update delete the routine or the secret?

No. update-node.sh replaces the container and keeps the data volume that holds routines and the webhook secret. On Coolify, pull the new image and restart; that keeps the volume too. Rotating the secret is different: the old secret stops working immediately.

Try it on your own computer

The Free plan covers 1 computer. Pro is $27/month for up to 3. You bring the AI login and pay that provider directly.