API Reference
Method reference for the TypeScript SDK: the constructor, endpoints, direct delivery, usage and introspection, with links to the reference for requests, emails, forwarding, teams and sharing, helpers and types.
Updated Nov 2026
The reference is split by topic so each page loads quickly:
- Requests: list, search, wait for, replay and export captured requests; provider detection, body parsing, payload schemas and request diffing
- Emails: wait for mail, codes and links, parsed fields, attachments and test emails
- Forwarding: destinations, filters, formats, secrets, deliveries, alerts and templates
- Teams and sharing: teams,
client.shares, the flow builder, sandbox and agent registration - Types, helpers and errors: matchers, signature verification, duration strings, exported types and error classes
Constructor
import { WebhooksCC } from "@webhooks-cc/sdk";
const client = new WebhooksCC({
apiKey: string, // Your API key. Required unless getAccessToken is given.
getAccessToken?: (o?: { forceRefresh?: boolean }) => Promise<string>,
// Optional. Supplies an expiring token instead (agents).
baseUrl?: string, // Optional. Override API base URL.
webhookUrl?: string, // Optional. Override webhook receiver URL.
timeout?: number, // Optional. Request timeout in ms (default: 30000).
retry?: RetryOptions, // Optional. Automatic retry configuration.
hooks?: ClientHooks, // Optional. Lifecycle hooks for observability.
emailDomain?: string, // Optional. Domain for emails.address() (default: mailhooks.cc).
fetch?: typeof fetch, // Optional. The fetch every call goes through (proxies, tests).
userAgent?: string, // Optional. Your product token, like "my-tool/1.2", sent before
// the SDK's (webhooks-cc-sdk/<version>) in the User-Agent.
});Retries are off by default (maxAttempts: 1). With retry, GET, PUT and DELETE calls are repeated after a network error, a timeout or a status in retryOn (429, 500, 502, 503 and 504 by default), and any call after a 429, which the API sends before doing anything. A POST or PATCH that failed any other way is not repeated: it may have gone through, and a second endpoints.create() would leave an extra endpoint. Nor is requests.clear() without before, whose repeat would also delete what arrived in between.
Endpoints
/endpointsclient.endpoints.create
Create a new webhook endpoint. The slug is auto-generated.
create(options?: CreateEndpointOptions): Promise<Endpoint>| Param | Type | Required | Description |
|---|---|---|---|
name | string | no | Display name |
ephemeral | boolean | no | Auto-delete after TTL |
expiresIn | string | number | no | Custom expiry duration, like "12h" or "7d"; implies ephemeral |
mockResponse | MockResponse | no | Mock response config |
responseRules | ResponseRule[] | no | Response rules, first match wins |
notificationUrl | string | no | Adds a Notifications destination: a chat message, at most one a second |
site | EndpointSite | no | Which site's dashboard lists it: "webhooks", "mailhooks" or "both" (the default). Listing only; both addresses work either way |
MockResponse fields:
| Field | Type | Required | Description |
|---|---|---|---|
status | number | yes | HTTP status code (100-599) |
body | string | no | Response body |
headers | Record<string, string> | no | Response headers |
delay | number | no | Response delay in ms (0-30000) |
/endpointsclient.endpoints.list
List the endpoints you own (each with sharedWith) and those shared with you through a subscribed team (each with fromTeam, the oldest share, and fromTeams, every one of your teams it is shared with), as one array. Each carries favorite, whether you marked it as a favourite.
list(options?: ListEndpointsOptions): Promise<Endpoint[]>| Param | Type | Required | Description |
|---|---|---|---|
team | string | no | Keep only endpoints tied to this team, matched via fromTeams, fromTeam, or sharedWith. A team id or a unique name (case-insensitive), resolved through teams.list(); an ambiguous name throws |
/endpoints/:slugclient.endpoints.get
Get a single endpoint by slug.
get(slug: string): Promise<Endpoint>/endpoints/:slugclient.endpoints.update
Update an endpoint's settings. Only the options you pass change.
update(slug: string, options: UpdateEndpointOptions): Promise<Endpoint>| Param | Type | Required | Description |
|---|---|---|---|
slug | string | yes | Endpoint slug |
name | string | no | New display name |
mockResponse | MockResponse | null | no | Default response (see fields above), or null to clear |
responseRules | ResponseRule[] | null | no | Response rules, or null to clear |
notificationUrl | string | null | no | Sets the Notifications destination, or null removes it |
showEmailExtracts | boolean | no | Pick codes and links out of emails (owner only) |
site | EndpointSite | no | Which site's dashboard lists it (owner only) |
emailFields | EmailField[] | null | no | Named fields to pick out of every email, at most 20; replaces the list (owner only) |
layouts | Layout[] | null | no | Layouts that read the endpoint's emails before delivery, at most 50; replaces the list (owner only) |
retentionDays | number | null | no | Keep requests this many days (1 up to the plan's), or null for the plan's (owner only) |
deleteAfterDelivery | boolean | no | Delete each request once every delivery is settled (owner only) |
agentRepo | string | null | no | GitHub owner/name a coding agent fixes failed deliveries in (fix prompts), or null to clear (owner only) |
signingProvider | string | null | no | Provider for server-side signature verification, or null to turn it off |
signingSecret | string | null | no | The provider's signing secret (stored encrypted, never returned) |
signingHeader | string | null | no | The header name for the generic-hmac provider |
Mock response bodies and header values can hold placeholders such as {{ json.id }}, filled in from each request.
/endpoints/:slug/responses/previewclient.endpoints.previewResponse
A dry run: which response rule answers a captured request, and the response with its placeholders filled in, exactly as the receiver would send it. Nothing is sent.
previewResponse(slug: string, options?: PreviewResponseOptions): Promise<ResponsePreview>| Param | Type | Required | Description |
|---|---|---|---|
slug | string | yes | Endpoint slug |
requestId | string | no | A captured request on the endpoint (default: the newest HTTP request) |
mockResponse | MockResponse | null | no | Try an unsaved default response; left out, the saved one applies |
responseRules | ResponseRule[] | null | no | Try unsaved rules; left out, the saved ones apply |
Returns rule ({ index, name } of the rule that answers, or null for the default response), response ({ status, headers, body, delay }, or null for the plain 200 OK), unknownPlaceholders (sent as written), email (true when the request is an email, which never gets a mock response) and request (the request it ran against; sample when none was captured yet).
const preview = await client.endpoints.previewResponse("payments", {
responseRules: [
{
conditions: [{ field: "body_path", op: "gt", path: "data.amount", value: "10000" }],
response: { status: 422, body: '{"amount": {{ json.data.amount }}}', headers: {} },
},
],
});The SDK also exports the rule language itself: evaluateConditions(group, subject) checks conditions against a request and renderTemplate(template, context) fills in placeholders, with the same results as the receiver.
/endpoints/:slug/layouts/previewclient.endpoints.previewLayouts
A dry run of the endpoint's layouts on a captured email: which layout matches and what it finds. Uses the endpoint's newest email unless requestId is given, and the saved layouts unless layouts are. Nothing is saved or sent and no parsed pages are used: attachments show an earlier parse, never a new one. Owner only.
previewLayouts(slug: string, options?: { layouts?: Layout[]; requestId?: string }): Promise<LayoutsPreview>
// Returns: { problems, layoutsCap, request, parsed }/endpoints/:slug/replayclient.endpoints.redeliver
Send the endpoint's requests received in a time range through its destinations again, at most 500, oldest first: after a pattern was fixed or a destination came back. Owner only. limit is the most one call takes; appliedUntil is the end the range had (until, or without one the server's time when it ran); nextSince is there only when requests in the range are left, and goes on with them as the next call's since, with appliedUntil as its until. When more than 500 requests share one millisecond, the extra ones in it are skipped by that continuation.
redeliver(
slug: string,
range?: { since?: number; until?: number; kind?: "http" | "email" }
): Promise<{
requests: number;
queued: number;
limit: number;
appliedUntil: number;
nextSince?: number;
}>/endpoints/:slugclient.endpoints.delete
Delete an endpoint and all its captured requests.
delete(slug: string): Promise<void>/endpoints/:slug/favoriteclient.endpoints.favorite
Mark an endpoint as one of your favourites, and unfavorite to unmark it. A favourite is your own choice, never the endpoint's, so you can mark endpoints shared with you through a team too. Both are idempotent and return the new state; list() and get() report it as favorite. They need an account: sandbox tokens are refused.
favorite(slug: string): Promise<{ favorite: boolean }> // PUT /endpoints/:slug/favorite
unfavorite(slug: string): Promise<{ favorite: boolean }> // DELETE /endpoints/:slug/favoriteawait client.endpoints.favorite("payments");
const favourites = (await client.endpoints.list()).filter((e) => e.favorite);/w/:slugclient.endpoints.send
Send a test webhook to an endpoint. Sends directly to the receiver, does not go through the API.
send(slug: string, options?: SendOptions): Promise<Response>| Param | Type | Required | Description |
|---|---|---|---|
slug | string | yes | Endpoint slug |
method | string | no | HTTP method (default: "POST") |
headers | Record<string, string> | no | HTTP headers to include |
body | unknown | no | Request body (JSON-serialized) |
/w/:slugclient.endpoints.sendTemplate
Send a provider template webhook with generated signature headers.
sendTemplate(slug: string, options: SendTemplateOptions): Promise<Response>| Param | Type | Required | Description |
|---|---|---|---|
slug | string | yes | Endpoint slug |
provider | TemplateProvider | yes | Provider template to generate |
template | string | no | Provider-specific template preset |
secret | string | yes | Shared secret for signature generation; not needed for unsigned templates (secretRequired: false: sendgrid, discord, paypal, plaid) |
event | string | no | Provider event/topic override |
method | string | no | HTTP method override (defaults to POST) |
timestamp | number | no | Unix timestamp override for signature generation |
messageId | string | no | Message id for standard-webhooks, clerk and resend signatures (random by default); not in SDK 1.15.0 or earlier |
headers | Record<string, string> | no | Additional headers |
body | unknown | no | Template body override |
Direct Delivery
(any URL)client.sendTo
Send a webhook directly to any URL with optional provider signing. Use it for local integration testing: send properly signed webhooks to localhost handlers without routing through webhooks.cc.
sendTo(url: string, options?: SendToOptions): Promise<Response>| Param | Type | Required | Description |
|---|---|---|---|
url | string | yes | Target URL (http or https) |
provider | TemplateProvider | no | Provider template for signing |
template | string | no | Provider-specific template preset, like "checkout.session.completed"; its sample body is sent when body is left out |
secret | string | no | Secret for signature generation (required when provider is set) |
body | unknown | no | Request body (JSON-serialized if not a string) |
headers | Record<string, string> | no | Additional headers |
method | string | no | HTTP method (default: "POST") |
event | string | no | Event name |
timestamp | number | no | Unix timestamp override for deterministic signatures in tests |
messageId | string | no | Message id for standard-webhooks, clerk and resend signatures (random by default); with timestamp, makes them deterministic. Not in SDK 1.15.0 or earlier |
(build only)client.buildRequest
Build a signed webhook request without sending it. Returns the computed URL, method, headers, and body.
buildRequest(url: string, options?: SendToOptions): Promise<{url, method, headers, body?}>Usage
/usageclient.usage
Get current request quota and usage.
usage(): Promise<UsageInfo>
// Returns: { used, limit, remaining, plan, periodEnd, parsedPages, previewData, aiAssists }
// parsedPages: { used, limit, creditPages, overage, resetsAt }
// previewData: { bytes, limitBytes, over, resetsAt } (null where sharing is not offered)
// aiAssists: { used, allowed, nextAt } (rolling 30 days; null where not offered)Introspection
(local)client.describe
Returns a static description of all SDK operations and their parameters. No API call is made. Useful for AI agents and tool discovery.
describe(): SDKDescription