# Webhook Triggers for Managed Agent Automations

> Start a Type.com managed agent automation from any service that can send HTTP events, with a Type.com webhook URL or a webhook adapter in code.

Canonical page: https://docs.type.com/automations/webhooks/

A webhook trigger lets an external service start work in a Space. The service sends an HTTP request, and Type starts a run. There are two ways to receive webhooks:

- **A custom webhook URL.** Type.com gives you a URL and an optional secret. Any service that can send HTTP events can use it, for example Sentry or a custom system. A new automation starts with an agent stage that follows your instructions. You can replace it with code stages.
- **A provider webhook adapter.** You write a TypeScript adapter for a connected service. The adapter registers the webhook with the service, verifies each request, and changes it into events for your automation's stages.

| | Webhook URL | Webhook adapter |
| --- | --- | --- |
| Stages | An agent stage with your instructions, which you can replace with your own stages | Your own stages |
| Registers the webhook in the service | You | The adapter's `setup` |
| Verifies requests | Type.com, with the optional secret | The adapter's `receive` |
| Needs a connection in Type | No | Yes |

Slack and GitHub events need no webhook setup. See [Slack](https://docs.type.com/automations/slack/index.md) and [GitHub](https://docs.type.com/automations/github/index.md).

## A custom webhook URL

### Create a webhook automation

New event sources use the same automation editor and run history as scheduled automations. This includes custom webhooks, Slack, GitHub, Linear, RSS feeds, and email inboxes. Existing sources keep their previous behavior.

1. Open the Space's **Automations** page.
2. Select **New automation**, choose **Webhook** in **Trigger**, and enter a **Webhook name**. If the sender signs requests, enter its secret in **Webhook secret (optional)**.
3. Choose the **Channel** where the automation runs.
4. Write **Instructions** that describe what the automation should do. Instructions are required.
5. Select **Create automation**. Type opens the new automation. Under **Event trigger**, select **Copy webhook URL**.
6. Configure the sending service to use that URL.

A test event is optional. Creation does not wait for sample data or generate a message component. The new automation has two stages. The `handle` agent stage gets the event and follows your saved instructions. Its result, an `outcome` (`completed` or `no_results`) and a short `summary`, goes to the `finish` code stage, which completes the run with it. You can replace or extend these stages with code-only or mixed behavior. The automation controls what gets posted to the channel.

You can also ask Type in chat to create the source and build its automation, including code-only behavior. For a custom webhook, the creation card opens **Set up webhook**, where you can copy the URL, enter a signing secret securely, and inspect optional tests. Reopen the modal from the same card at any time. Keep signing secrets in this form, not in chat or automation code.

### Verify receipt or run a test

- **Listen for test** watches for the next accepted event and shows its actual payload. **Check receipt** refreshes the latest accepted event. These checks do not run the automation or verify the sender's configuration.
- For custom webhook URLs, **Copy receipt-only test URL** provides a separate endpoint ending in `/test`. Send a signed request using the same secret and signature rules as the normal endpoint. This records receipt without executing the automation.
- **Run with this event** sends a received event through the saved subscription. You can also enter a custom test payload. It uses the same shape as a received event, with the sender's JSON in `data`. See [The event](#the-event). This is a live run and can send messages or perform other actions. Enable the automation before running it. The panel shows the test status (queued, dispatched, running, completed, or failed) and any error. A run that waits for an agent stage shows as running until the whole graph completes. A run that needs attention shows as failed.

RSS, inbox, and connected-provider receipts come from their normal delivery paths. Those deliveries can run an enabled automation; refreshing the receipt does not suppress them.

Existing legacy sources remain editable under **Synced events**.

Type.com detects the signature header and the supported algorithm from a valid signed request. To add or replace the secret later, or to set the header yourself, open the automation and use **Webhook security**. Saving these settings makes Type detect the algorithm again from the next valid request.

> **Caution:** If you leave the secret empty, Type does not verify the signature of requests. Treat the generated URL as a credential, and keep it private. If someone else gets the URL, pause its automation to stop actions and remove the URL from the sending service. Pausing an automation does not revoke its endpoint. Type still accepts requests and records the latest receipt, but it does not run a paused automation. It does not replay those events when you enable the automation again.

### Send a JSON event

Send an HTTP `POST` to the copied URL with `Content-Type: application/json`. The top-level payload must be a JSON object, not an array, string, or `null`.

For an unsigned webhook, set `TYPE_WEBHOOK_URL` in your local environment to the URL that you copied from Type. Then run this command:

```sh
curl --fail-with-body "$TYPE_WEBHOOK_URL" \
  -H 'Content-Type: application/json' \
  --data-binary '{"event":"deployment.completed","environment":"staging","status":"success"}'
```

A successful request returns HTTP 200 with `{"success":true}`. This response does not mean that the managed agent completed its work. For a new code-first automation, check its receipt and run history. A channel message appears only when the automation chooses to post one.

### Send an event with GET

The same custom webhook URL accepts `GET`. Query parameters become the event payload, available as `input.data` in a code stage:

```sh
curl --fail-with-body --get "$TYPE_WEBHOOK_URL" \
  --data-urlencode 'event=deployment.completed' \
  --data-urlencode 'environment=staging' \
  --data-urlencode 'status=success'
```

Values stay strings: `amount=49` becomes `"49"`, not the number `49`. Repeated keys become lists in their original order: `tag=release&tag=backend` becomes `{"tag":["release","backend"]}`. Empty values stay empty strings, and a request with no query parameters delivers `{}`. GET does not read a JSON body.

GET requests trigger the same automation flow as POST. Use the URL ending in `/test` to record receipt without running the automation. Responses are not cacheable. `HEAD` requests return `405` and do not record or trigger an event. GET is not automatically treated as a provider verification challenge; provider-specific challenge responses belong in a webhook adapter.

Opening a GET webhook URL can trigger work, including when a link preview fetches it. Keep it private and use the receipt-only URL when checking setup.

### Send a signed event

For a custom sender, Type supports HMAC-SHA256 and HMAC-SHA1, with hexadecimal or Base64 digests. Use HMAC-SHA256 for new integrations. Type also accepts a `sha256=` or `sha1=` prefix on the signature value.

Some providers sign a different message, for example a timestamp and the body. A custom URL cannot verify these signatures. Use a [webhook adapter](#with-code-a-webhook-adapter), which verifies the signature in its own code.

This example needs Node.js 20 or later. In your local environment or secret manager, set these variables:

- `TYPE_WEBHOOK_URL`: the URL that you copied from Type.
- `TYPE_WEBHOOK_SECRET`: the **same secret you saved in Type**.

Do not put the secret in the payload or in source code.

```sh
node --input-type=module <<'JS'

const body = JSON.stringify({
  event: 'deployment.completed',
  environment: 'staging',
  status: 'success',
});
const signature = createHmac('sha256', process.env.TYPE_WEBHOOK_SECRET)
  .update(body, 'utf8')
  .digest('hex');

const response = await fetch(process.env.TYPE_WEBHOOK_URL, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-Type-Signature': `sha256=${signature}`,
  },
  body,
});
console.log(response.status, await response.text());
if (!response.ok) process.exitCode = 1;
JS
```

The example signs and sends the same UTF-8 body. If you change whitespace, line endings, or JSON format after you sign the body, the signature becomes incorrect.

After the first valid signed request, continue to use the header and the algorithm that Type detected. If the webhook has a secret, Type rejects an unsigned test request.

For GET, sign the **exact encoded query string without the leading `?`**, and send the signature in the same header. Do not sign an empty body or decoded JSON, and do not put the secret or signature in the query string. For example:

```js
const query = new URLSearchParams({
  event: "deployment.completed",
  environment: "staging",
}).toString();
const signature = createHmac("sha256", process.env.TYPE_WEBHOOK_SECRET)
  .update(query, "utf8")
  .digest("hex");
const url = new URL(process.env.TYPE_WEBHOOK_URL);
url.search = query;
const response = await fetch(url, {
  method: "GET",
  headers: { "X-Type-Signature": `sha256=${signature}` },
});
```

This uses the same `createHmac` import and environment variables as the POST example. Changing query order or encoding after signing invalidates the signature, even if the decoded values are the same. These rules also apply to the receipt-only `/test` URL.

### The event

Type gives each accepted request to the automation as an event with this shape:

```json
{
  "type": "webhook.received",
  "id": "<delivery ID>",
  "resourceType": "webhook",
  "resourceId": "<webhook ID>",
  "data": { "event": "deployment.completed", "environment": "staging", "status": "success" }
}
```

- `data` is the JSON body of a `POST`, or the query parameters of a `GET`.
- `id` is the value of the request's `webhook-id`, `X-GitHub-Delivery`, or `X-Shopify-Webhook-Id` header, if it has one. Otherwise Type makes a new ID for each request.
- Type queues an event ID only once for each subscription. If the sender retries with the same delivery header, the automation does not run again. Without one of these headers, each request is a new event.

### Limits and errors

Type limits the serialized, parsed JSON payload to **1,048,576 characters**. Type counts characters after it parses the JSON. The event that Type queues for an automation, including the fields around `data`, must also fit in **1 MiB** of UTF-8 JSON. The server also rejects request bodies larger than **10 MiB**.

For predictable delivery, keep the full JSON request well below 1 MiB. Send links to large files. Do not put large files in the payload.

| Response | What to check |
| --- | --- |
| 200, `{"success":true}` | Type accepted the request. Check the automation's receipt and run history for the result. |
| 400, invalid JSON or payload type | Send valid JSON with an object at the top level. |
| 400, payload exceeds maximum, or event exceeds 1 MiB | Make the serialized JSON payload smaller. |
| 400, invalid webhook signature | Use the saved secret, and the signature header and algorithm that Type detected. Sign the exact POST body or encoded GET query that you send. |
| 400, webhook not found or disabled | Copy the current URL from Type. Make sure that the source is enabled. |
| 413, request entity too large | Make the raw HTTP request body smaller than the server limit. |
| 500, internal server error | Retry later. Send a delivery header with a stable ID (see [The event](#the-event)) so that a retry cannot start a second run. |

### Write useful instructions

Good webhook instructions tell the managed agent:

- Which service sends the event.
- Which event types are important.
- Which fields to summarize for people.
- When to act, when to ask, and when to only notify.

### Changes to event data

If the sender changes its payload, update the instructions or code as needed and test a representative event. New code-first sources do not generate a component from the first payload.

### Use code with a custom webhook URL

A custom URL can run code only. It does not need a provider adapter or an agent stage. Replace the stages of the automation that Type created for the webhook, for example by asking Type in the automation's conversation. Keep its `event_source` subscription. Then test the new code with **Run with this event**.

This example accepts an HTTP body such as `{"orderId":"demo-123","amount":49}`. These are invented example values. The entry stage gets the full [event](#the-event); the sender's JSON is in `input.data`.

```ts title="src/main.ts"

const orderEvent = z.object({
  type: z.literal("webhook.received"),
  id: z.string(),
  resourceId: z.string().nullable(),
  resourceType: z.string().nullable(),
  data: z.object({
    orderId: z.string(),
    amount: z.number(),
  }),
});

export default automation({
  output: z.object({ orderId: z.string(), amount: z.number() }),
  deployment: {
    mode: "code",
    subscriptions: {
      onEvent: {
        title: "Summarize orders",
        description: "Save an order summary in the run result.",
        source: {
          kind: "event_source",
          sourceId: "ches_example", // Replace with your webhook's source ID.
          events: ["webhook.received"],
        },
        schema: orderEvent,
        entry: "summarize",
      },
    },
  },
  stages: {
    summarize: code({
      input: orderEvent,
      transitions: [],
      run: ({ input }) =>
        complete({ orderId: input.data.orderId, amount: input.data.amount }),
    }),
  },
});
```

Replace `ches_example` with your webhook's source ID. The code that Type generated for the automation has it in `source.sourceId`, and `create_task` returns it as `sourceId`. The source must belong to the automation's Space.

- `entry` names the stage that gets each event. That stage's `input` schema checks the event.
- `complete(...)` ends the run and saves its output in run history. It does not post a channel message.
- `mode: "code"` means that no agent stage runs.
- Type verifies the signature before the entry stage runs, with the secret saved in **Webhook security**.
- For `GET`, every value in `data` is a string or a list of strings. Use `z.string()` in the schema, then convert the value in the stage.

## With code: a webhook adapter

For a service that can send webhooks, write a **webhook adapter**. Slack and GitHub events need no adapter. The adapter:

1. registers the webhook with the service (`setup`),
2. verifies each incoming request and changes it into events (`receive`),
3. removes the webhook when it is no longer needed (`remove`).

Type.com hosts the callback URL and sends the events to your automation.

> **Note:** The service must have a connection in Type that can make API requests, for example a [Custom API connection](https://docs.type.com/connectors-and-skills/custom-apis/index.md). Only an integration manager can install an adapter. After that, other automations that use the same credential account can subscribe to it.

### Project layout

- meeting-log/
  - type.json
  - fixtures.json automation fixtures
  - src/
    - main.ts the automation
    - events.ts the event schema
    - webhook.ts the adapter
    - fixtures.json adapter fixtures (uploaded as a module)

### 1. Define the event

Put the event schema in its own module. The adapter and the automation both import it.

```ts title="src/events.ts"

export const meetingCompleted = webhookEvent(
  "meeting.completed",
  z.object({ id: z.string().min(1), title: z.string(), summary: z.string().nullable() }),
);
```

### 2. Write `setup`

The adapter module exports its events, its fixtures, and a default object with the lifecycle methods. `setup` must be idempotent. If Type calls it two times, it must find the same registration. It must not make a second one.

```ts title="src/webhook.ts"

export { default as fixtures } from "./fixtures.json";
export const events = [meetingCompleted];

const registration = z.looseObject({ id: z.string().min(1), url: z.string() });

export default {
  async setup(ctx) {
    // Find a registration that an earlier attempt made.
    const list = await ctx.request({ method: "GET", path: "/webhooks", query: { url: ctx.url } });
    if (list.isErr()) return err(list.error);
    if (list.value.status !== 200) return err(new Error("Could not list webhooks"));
    const found = z.array(registration).safeParse(list.value.data);
    if (!found.success) return err(new Error("Invalid webhook list"));
    const existing = found.data.find((item) => item.url === ctx.url);
    if (existing) return ok({ id: existing.id, state: {} });

    // Create one, with the stable operation ID as the idempotency key.
    const created = await ctx.request({
      method: "POST",
      path: "/webhooks",
      headers: { "Idempotency-Key": ctx.operationId },
      body: { url: ctx.url, events: [...ctx.events], secret: ctx.secret },
    });
    if (created.isErr()) return err(created.error);
    if (created.value.status !== 201) return err(new Error("Could not register webhook"));
    const parsed = registration.safeParse(created.value.data);
    if (!parsed.success || parsed.data.url !== ctx.url) return err(new Error("Invalid registration response"));
    return ok({ id: parsed.data.id, state: {} });
  },
  // receive and remove follow
} satisfies IntegrationWebhook;
```

This example uses a sample API. Change the paths, the body, and the status codes to match the service's documentation.

### 3. Write `receive`

Verify the signature against the raw body, before you parse it.

```ts title="src/webhook.ts"
  receive(ctx, request) {
    const timestamp = request.headers["x-meeting-timestamp"];
    const seconds = Number(timestamp);
    if (!timestamp || !Number.isSafeInteger(seconds) || Math.abs(Date.parse(ctx.now) / 1000 - seconds) > 300)
      return ok({ kind: "reject", status: 401 });

    const expected = ctx.crypto.hmac({
      algorithm: "sha256",
      key: ctx.secret,
      data: `${timestamp}.${request.rawBody}`,
      encoding: "hex",
    });
    if (!ctx.crypto.equal(expected, request.headers["x-meeting-signature"] ?? ""))
      return ok({ kind: "reject", status: 401 });

    const json = Result.fromThrowable((text: string): unknown => JSON.parse(text))(request.rawBody);
    if (json.isErr()) return ok({ kind: "reject", status: 400 });
    const body = z.looseObject({
      id: z.string().min(1),
      type: z.literal("meeting.completed"),
      meeting: z.looseObject({ id: z.string().min(1), title: z.string(), summary: z.string().nullish() }),
    }).safeParse(json.value);
    if (!body.success) return ok({ kind: "reject", status: 400 });

    return ok({
      kind: "events",
      events: [{
        id: body.data.id, // the provider's event ID, stable across retries
        type: "meeting.completed",
        resourceType: "meeting",
        resourceId: body.data.meeting.id,
        data: { id: body.data.meeting.id, title: body.data.meeting.title, summary: body.data.meeting.summary ?? null },
      }],
    });
  },
```

- Use `ctx.crypto.equal` to compare signatures.
- If the service sends a timestamp, check it.
- Use the provider's event ID as `id`. A random ID stops retry deduplication.
- `receive` has no network access. It cannot call the service.

### 4. Write `remove`

```ts title="src/webhook.ts"
  async remove(ctx) {
    if (!ctx.registration) return ok(undefined);
    const response = await ctx.request({
      method: "DELETE",
      path: `/webhooks/${encodeURIComponent(ctx.registration.id)}`,
    });
    if (response.isErr()) return err(response.error);
    return response.value.status === 204 || response.value.status === 404
      ? ok(undefined)
      : err(new Error("Could not remove webhook"));
  },
```

If the webhook is already gone, return `ok(undefined)`.

### 5. Add adapter fixtures

Each adapter needs 2 to 20 fixtures in its `fixtures` export. At least one fixture must accept an event, and at least one must reject a request. Type runs them at each deploy, with no network access.

This file tests the `receive` code above. The signatures are HMAC-SHA256 values of `<timestamp>.<raw body>`, made with the fake secret in each fixture.

```json title="src/fixtures.json"
[
  {
    "name": "signed delivery",
    "secret": "fixture-only-signing-key",
    "now": "2026-06-01T00:00:00.000Z",
    "registration": null,
    "request": {
      "method": "POST",
      "query": {},
      "headers": {
        "x-meeting-timestamp": "1780272000",
        "x-meeting-signature": "acdbfd350e77b32e9e9a6a2997e80c7d6e0c24cfafa0e55769dbdc0094e91fbb"
      },
      "rawBody": "{\"id\":\"evt_1\",\"type\":\"meeting.completed\",\"meeting\":{\"id\":\"meeting_1\",\"title\":\"Weekly planning\",\"extra\":true},\"extra\":true}"
    },
    "expected": {
      "kind": "events",
      "events": [
        {
          "id": "evt_1",
          "type": "meeting.completed",
          "resourceType": "meeting",
          "resourceId": "meeting_1",
          "data": {
            "id": "meeting_1",
            "title": "Weekly planning",
            "summary": null
          }
        }
      ]
    }
  },
  {
    "name": "forged signature",
    "secret": "fixture-only-signing-key",
    "now": "2026-06-01T00:00:00.000Z",
    "registration": null,
    "request": {
      "method": "POST",
      "query": {},
      "headers": {
        "x-meeting-timestamp": "1780272000",
        "x-meeting-signature": "0000000000000000000000000000000000000000000000000000000000000000"
      },
      "rawBody": "{\"id\":\"evt_1\",\"type\":\"meeting.completed\",\"meeting\":{\"id\":\"meeting_1\",\"title\":\"Weekly planning\",\"extra\":true},\"extra\":true}"
    },
    "expected": {
      "kind": "reject",
      "status": 401
    }
  },
  {
    "name": "changed body",
    "secret": "fixture-only-signing-key",
    "now": "2026-06-01T00:00:00.000Z",
    "registration": null,
    "request": {
      "method": "POST",
      "query": {},
      "headers": {
        "x-meeting-timestamp": "1780272000",
        "x-meeting-signature": "acdbfd350e77b32e9e9a6a2997e80c7d6e0c24cfafa0e55769dbdc0094e91fbb"
      },
      "rawBody": "{\"id\":\"evt_1\",\"type\":\"meeting.completed\",\"meeting\":{\"id\":\"meeting_1\",\"title\":\"Weekly planning (edited)\",\"extra\":true},\"extra\":true}"
    },
    "expected": {
      "kind": "reject",
      "status": 401
    }
  },
  {
    "name": "old timestamp",
    "secret": "fixture-only-signing-key",
    "now": "2026-06-01T00:00:00.000Z",
    "registration": null,
    "request": {
      "method": "POST",
      "query": {},
      "headers": {
        "x-meeting-timestamp": "1780271000",
        "x-meeting-signature": "ef230da479eb3112d2164b8cb4f31fcdce69013a7a85170d835764ca141f8330"
      },
      "rawBody": "{\"id\":\"evt_1\",\"type\":\"meeting.completed\",\"meeting\":{\"id\":\"meeting_1\",\"title\":\"Weekly planning\",\"extra\":true},\"extra\":true}"
    },
    "expected": {
      "kind": "reject",
      "status": 401
    }
  },
  {
    "name": "missing required fields",
    "secret": "fixture-only-signing-key",
    "now": "2026-06-01T00:00:00.000Z",
    "registration": null,
    "request": {
      "method": "POST",
      "query": {},
      "headers": {
        "x-meeting-timestamp": "1780272000",
        "x-meeting-signature": "aabf9100d1bb107b0f68f30c7ff706d4a6c09750ead7752cf2712a1263fad2a6"
      },
      "rawBody": "{\"id\":\"evt_2\",\"type\":\"meeting.completed\",\"meeting\":{\"id\":\"meeting_2\"}}"
    },
    "expected": {
      "kind": "reject",
      "status": 400
    }
  }
]
```

| Fixture | Checks that `receive` |
| --- | --- |
| `signed delivery` | accepts a valid signed event, keeps only the fields in `data`, and sets `summary` to `null` when it is missing. |
| `forged signature` | rejects a wrong signature with `401`. |
| `changed body` | rejects a body that changed after it was signed. |
| `old timestamp` | rejects a signed request that is more than 5 minutes old. |
| `missing required fields` | rejects a signed body without a meeting title with `400`. |

Use only fake secrets in fixtures. If the service sends a challenge request, add a fixture for it too.

### 6. Subscribe the automation

```ts title="src/main.ts"

export default automation({
  output: z.object({ meetingId: z.string(), title: z.string() }),
  deployment: {
    webhooks: {
      meetings: { connectionId: "orgint_example", entrypoint: "src/webhook.ts" },
    },
    subscriptions: {
      meetingReady: {
        title: "Log a completed meeting",
        description: "Record a verified meeting in automation history",
        source: {
          kind: "integration",
          connectionId: "orgint_example",
          webhook: "meetings",
          events: ["meeting.completed"],
        },
        schema: meetingCompleted,
        entry: "record",
      },
    },
  },
  stages: {
    record: code({
      input: meetingCompleted,
      transitions: [],
      run: ({ input }) => complete({ meetingId: input.data.id, title: input.data.title }),
    }),
  },
});
```

- `webhooks.meetings` installs the adapter in `src/webhook.ts` on the connection, with the key `meetings`.
- `source.webhook: "meetings"` subscribes to that adapter. `events` must be events that the adapter declares.
- The `record` stage gets the event that `receive` returned. The provider's fields are in `input.data`.

### 7. Deploy

1. Run `type-cli automations deploy ./meeting-log --space <space>`.
2. Type runs the adapter fixtures and the automation fixtures.
3. At activation, Type calls `setup`. Type keeps the callback URL and the secret before it calls `setup`, so the service can send a challenge.
4. When the registration is `ready` and the subscription is active, Type accepts events.

A second automation can use the same webhook. Set `source.webhook: "meetings"` and omit the `webhooks` field. It must use the same credential account on the connection.

Type saves the adapter, and the modules that it imports, on the connection. Changes to `src/main.ts` do not change the adapter. If you change `src/webhook.ts`, `src/events.ts`, or `src/fixtures.json` and deploy again with the same key, the deploy fails with a conflict. Publish the change with the `replace` [management operation](https://docs.type.com/automations/reference/webhook-adapters/index.md#management-operations), or use a new key.

See the [Webhook Adapter API](https://docs.type.com/automations/reference/webhook-adapters/index.md) for all fields and limits.

## Limitations

**Webhook URL**

- A `POST` body must be a JSON object, and size limits apply. See [Limits and errors](#limits-and-errors).

**Webhook adapter**

- Before the registration is ready, Type.com answers `503`. The service must retry. Type does not keep these events.
- If someone reconnects or changes the credential, Type answers `404` until an integration manager runs `setup` again.
- Type allows 120 incoming requests each minute for each workspace. More requests get `429`.
- Removal during a disconnect is best effort. It is possible that you must remove the webhook in the service manually.
- Fixtures test your parser. They do not prove that the service uses the signature format that you wrote. Check the service's documentation.
