# Webhooks (/developers/webhooks)

> Start Luso8 workflows from your systems with a secret webhook URL, and call your own endpoints from workflows and campaigns.

> **Preview:** this feature is in preview. The contract is stable enough to build against, but details may change before general availability.

Luso8 connects to your systems over HTTP in two directions today:

- **Inbound**: your system calls a secret URL to start a Luso8 [workflow](/luso8/workflows).
- **Outbound**: a **Webhook** step in a workflow or a campaign sequence calls your URL with JSON.

<Callout type="info" title="Event subscriptions are planned">
Luso8 does not yet offer event subscriptions (registering one URL to receive events such as `contact.created` for the whole workspace). Until then, build the same thing with a workflow: trigger it on the event you care about and add a Webhook step that calls your endpoint.
</Callout>

## Inbound: trigger a workflow [#inbound-trigger-a-workflow]

Any workflow whose trigger is **Webhook** gets its own secret URL. A `POST` to that URL starts a run, and the JSON body becomes the run's input.

<Steps>
<Step>
### Create the workflow [#create-the-workflow]

In Luso8, open **AI tools → Workflows**, create a workflow and set its trigger to **Webhook**.
</Step>

<Step>
### Copy the webhook URL [#copy-the-webhook-url]

Open the trigger settings to generate the URL. It has this shape:

```text
https://api.luso8.rexplore.ai/api/v1/ai-workflows/hooks/<workflow_id>/<secret>
```
</Step>

<Step>
### Activate the workflow [#activate-the-workflow]

Compile and activate the workflow. Only active workflows accept webhook calls.
</Step>
</Steps>

### Send an event [#send-an-event]

```bash tab="cURL"
curl -X POST "$LUSO8_WORKFLOW_WEBHOOK_URL" \
  -H "Content-Type: application/json" \
  -H "X-Event: order.paid" \
  -d '{
    "order_id": "ord_1042",
    "amount": 129.0,
    "currency": "USD",
    "customer": { "email": "ada@example.com", "name": "Ada Lovelace" }
  }'
```

```js tab="JavaScript"
await fetch(process.env.LUSO8_WORKFLOW_WEBHOOK_URL, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json', 'X-Event': 'order.paid' },
  body: JSON.stringify({
    order_id: 'ord_1042',
    amount: 129.0,
    currency: 'USD',
    customer: { email: 'ada@example.com', name: 'Ada Lovelace' },
  }),
});
```

```python tab="Python"
import os
import requests

requests.post(
    os.environ["LUSO8_WORKFLOW_WEBHOOK_URL"],
    headers={"X-Event": "order.paid"},
    json={
        "order_id": "ord_1042",
        "amount": 129.0,
        "currency": "USD",
        "customer": {"email": "ada@example.com", "name": "Ada Lovelace"},
    },
    timeout=30,
).raise_for_status()
```

A successful call returns the new run:

```json
{
  "success": true,
  "run_id": "4a1f0c2e-6a51-4f7e-9d2b-1c8e5b9f3a77",
  "status": "pending",
  "dispatched": true,
  "message": "Workflow triggered"
}
```

### Using the payload in steps [#using-the-payload-in-steps]

The body is available to every step as `trigger` (and as `input` for the first step). Step fields accept template expressions, so a notification message could read:

```text
New order {{ trigger.order_id }} from {{ trigger.customer.name }} ({{ trigger.amount }} {{ trigger.currency }})
```

Missing fields resolve to empty values instead of failing, so `{{ trigger.customer.phone or "no phone" }}` is safe. A body that is not a JSON object (for example an array) is wrapped as `{"data": ...}`. The `User-Agent`, `Content-Type` and `X-Event` request headers are added under `_headers`.

### Responses [#responses]

| Status | Meaning |
| --- | --- |
| `200` | The run was created. `dispatched: false` means it is queued and will start shortly. |
| `404` `Webhook not found` | Wrong workflow ID or secret, or the workflow's trigger is not Webhook |
| `409` `Workflow is not active` | Activate the workflow first |

<Callout type="warn" title="Treat the URL as a secret">
The secret in the path is the only credential. Store the URL like an API key, never in client-side code. If it leaks, deactivate the workflow right away (inactive workflows reject webhook calls with `409`), and contact [hello@rexplore.ai](mailto:hello@rexplore.ai) to rotate the secret.
</Callout>

## Outbound: call your endpoint [#outbound-call-your-endpoint]

Add a **Webhook** step to a [workflow](/luso8/workflows) or a [campaign](/luso8/campaigns) sequence to call your own API.

| Setting | Description |
| --- | --- |
| URL | Must start with `https://` (or `http://`). Templates are allowed, for example `https://example.com/hooks/{{ trigger.order_id }}`. |
| Method | `GET`, `POST`, `PUT`, `PATCH` or `DELETE`. Defaults to `POST`. |
| Headers | Key-value pairs, templates allowed. Use them to authenticate to your endpoint. |
| Body | A JSON body, templates allowed. If you leave it empty, the step sends its input (the previous step's output or the trigger payload). |
| Ignore errors | By default a response with status `400` or higher fails the step. Turn this on to continue anyway. |

Requests time out after the step's timeout (at most two minutes). The step's output contains your endpoint's status code and response, so later steps can branch on it with a **Condition** step.

### Securing your endpoint [#securing-your-endpoint]

Luso8 does not sign outbound requests yet. Protect your endpoint by checking a secret you choose:

- add a header such as `Authorization: Bearer <random-secret>` in the step's **Headers**, and reject requests without it, or
- include a long random token in the URL path and verify it on your side.

Always use HTTPS, and make your handler idempotent: a run can be retried, so the same event may arrive more than once.

## Related [#related]

<LinkGrid>
<LinkItem href="/luso8/workflows" title="Workflows">
Triggers, steps and runs in the app.
</LinkItem>

<LinkItem href="/luso8/campaigns" title="Campaigns">
Webhook steps inside outreach sequences.
</LinkItem>

<LinkItem href="/developers/api-reference" title="API reference">
Trigger workflows with an API key instead.
</LinkItem>

<LinkItem href="/developers/mcp" title="Remote MCP server">
Let AI tools run workflows for you.
</LinkItem>
</LinkGrid>