AbstractAbstractcreateCreates a new webhook endpoint.
Generates a unique HTTP endpoint that will invoke the callback function when requests are received. The callback receives the WebhookRequest plus any extraArgs.
Provider-Specific Behavior:
authorization parameter.users.watch endpoint. Requires authorization parameter with Gmail scopes.pubsub: true): Returns a Google Pub/Sub topic name instead of a webhook URL.
Use this for services that deliver events via Pub/Sub (e.g., Google Workspace Events API).
A Pub/Sub topic and push subscription are created automatically; the returned topic name
can be passed to any Google API that accepts a Pub/Sub notification endpoint.Webhook creation options
Optionalprovider?: AuthProviderOptional provider for provider-specific webhook routing
Optionalauthorization?: AuthorizationOptional authorization for provider-specific webhooks (required for Slack and Gmail)
Optionalpubsub?: booleanWhen true, creates a Google Pub/Sub topic instead of a webhook URL.
Optionalasync?: booleanControls whether the returned webhook URL runs callbacks synchronously or asynchronously.
Async (default, async: true) — Plot enqueues each incoming
request and immediately returns 200 { queued: true }. A background
queue consumer runs the callback with bounded concurrency. The
sender never sees the callback's return value or any error thrown
by it, and delivery is at-least-once (the callback must be
idempotent). This is the right default for the vast majority of
webhooks — service event notifications, bulk-import fan-out, etc. —
because it removes ingress-path database pressure and prevents
sender-side retry storms when callbacks are slow.
Sync (async: false) — Plot runs the callback inline and
responds with the callback's return value. Required when:
validationToken and
expects the token echoed as text/plain).When async: false, a callback returning a string is sent back
with Content-Type: text/plain; any other value is serialized as
JSON. undefined / void yields a plain 200 OK body.
Defaults to true.
Function receiving (request, ...extraArgs)
Additional arguments to pass to the callback (type-checked, no functions allowed)
Promise resolving to the webhook URL, or for Gmail/Pub/Sub, a Pub/Sub topic name
// Pub/Sub webhook for Workspace Events API
const topicName = await this.tools.network.createWebhook(
{ pubsub: true },
this.onEventReceived,
channelId
);
// topicName: "projects/plot-prod/topics/ps-abc123"
// Pass topic name to Workspace Events API
await api.createSubscription(targetResource, topicName, eventTypes);
AbstractdeleteDeletes an existing webhook endpoint.
Removes the webhook endpoint and stops processing requests. Works with all webhook types (standard, Slack, and Gmail).
For Gmail webhooks: Also deletes the associated Google Pub/Sub topic and subscription.
For Slack webhooks: Removes the callback registration for the specific team.
For standard webhooks: Removes the webhook endpoint. Any subsequent requests to the deleted webhook will return 404.
The webhook identifier returned from createWebhook().
This can be a URL (standard webhooks), a Pub/Sub topic name (Gmail),
or an opaque identifier (Slack). Always pass the exact value returned
from createWebhook().
Promise that resolves when the webhook is deleted
Built-in tool for requesting HTTP access permissions and managing webhooks.
The Network tool serves two purposes:
IMPORTANT: Must be requested in the Twist or Tool Init method to declare HTTP access permissions. Without requesting this tool with the appropriate URLs, all outbound HTTP requests (fetch, etc.) will be blocked.
Permission Patterns:
*- Allow access to all URLshttps://*.example.com- Allow access to all subdomainshttps://api.example.com/*- Allow access to all paths on the domainhttps://api.example.com/v1/*- Allow access to specific path prefixWebhook Characteristics:
Example
Example