# How do I start a job from a webhook?

Get a secret URL. Whenever another service calls it – GitHub on a push, a form, your e-shop on a new order – a job starts and gets what was sent as files.

> **Paid plans.** Schedules and webhooks are available on paid plans and to accounts that have topped up at least US$15 in total (or the same in EUR or CZK). Until then the API answers `403 feature_disabled`.

## Steps

1. **Create a trigger with a webhook** and the job it should start, with a time limit and a price limit.
2. **Copy the webhook URL.** It is shown only once – keep it like a password.
3. **Paste the URL into the other service.** Each `POST` to it starts one run.
4. **Read the data in the job** from `input/webhook.body` (the body) and `input/webhook.json` (headers and query).

**Ask your assistant**

No code: copy this into Claude or ChatGPT with [WBX Sandbox connected](https://sandbox.wbx.cz/docs/connect.md) and change it to fit.

```
Create a WBX webhook trigger named "On new order". It should start a job that prints the received data (the file input/webhook.body), with a time limit of 10 minutes and a price limit of US$0.10 (2.50 Kč). Give me the webhook URL.
```

Then paste the URL into the service that should call it. If the service can sign requests (GitHub can), ask for a signed webhook – see [Signed webhooks](https://sandbox.wbx.cz/docs/jobs/schedules.md#signature).

**Python**

`pip install wbxsandbox`, your key in `WBXSANDBOX_API_KEY`.

```
from wbxsandbox import Trigger

# the job reads what was sent: input/webhook.body (the body) and input/webhook.json (headers)
t = Trigger.create("On new order", "python -c \"import json; print(json.load(open('input/webhook.body')))\"",
                   webhook=True, timeout_seconds=600, max_cost="0.10")   # for CZK use "2.50"
print(t.webhook_url)                 # shown only now – store it like a password

# anyone with the URL starts a run:
import urllib.request
urllib.request.urlopen(urllib.request.Request(t.webhook_url, data=b'{"order": 1042}', method="POST"))
```

**TypeScript**

`npm install wbxsandbox` (Node.js 20+); save as `.mts` for top-level `await`.

```
import { WBX } from "wbxsandbox";

const wbx = new WBX();
const t = await wbx.triggers.create({
  name: "On new order", webhook: true, maxCost: "0.10",   // for CZK use "2.50"
  job: { command: "cat input/webhook.body", timeoutSeconds: 600 },
});
console.log(t.webhookUrl);           // shown only now – store it like a password

// anyone with the URL starts a run:
await fetch(t.webhookUrl!, { method: "POST", body: JSON.stringify({ order: 1042 }) });
```

**curl**

Just `curl` and `jq`; your key in `WBXSANDBOX_API_KEY`.

```
WEBHOOK_URL=$(curl -s -X POST https://sandbox.wbx.cz/v1/triggers -H "Authorization: Bearer $WBXSANDBOX_API_KEY" -d '{
  "name": "On new order", "webhook": {"enabled": true},
  "job": {"command": "cat input/webhook.body", "timeout_s": 600}, "max_cost": "0.10"
}' | jq -r .webhook_url)   # for CZK use "2.50"
echo "$WEBHOOK_URL"          # shown only now – store it like a password

curl -s -X POST "$WEBHOOK_URL" -d '{"order": 1042}'   # → 202 {"run_id": …, "job_id": …}
```

## How to tell it worked

- A test call returns `202` with a `run_id` and a `job_id`.
- The job's log shows the body you sent, for example `{"order": 1042}`.
- In the portal, *Schedules* shows the run with its job.

## If it doesn't work

| What you see | What to do |
| --- | --- |
| `401` | The trigger expects a signature and the call has none, or a wrong one. |
| `404` | The URL is wrong, or the trigger was deleted. |
| `409` | The trigger is paused, or its previous run still runs. |
| `413` or `429` | The body is over 1 MB, or more than 60 calls came in a minute (1000 a day). |

## What it costs

Every run is billed like a background job and limited by `max_cost`. Calls that are refused cost nothing. **Safety:** anyone with the URL can send anything. Do not let an AI agent follow instructions it finds in webhook data – treat it as data to check.

## Next steps

- [Schedules & webhooks](https://sandbox.wbx.cz/docs/jobs/schedules.md): Signatures, all answers, limits and the API.
- [Run on a schedule](https://sandbox.wbx.cz/docs/howto/schedule.md): The same trigger can also run on a timetable.
- [Webhooks when a job ends](https://sandbox.wbx.cz/docs/jobs/webhooks.md): Get told when a job or batch has finished.

Source: https://sandbox.wbx.cz/docs/howto/webhook
