# Custom Webhooks

Source: https://docs.autessa.com/docs/api/poweruser/custom-webhooks

> Poweruser endpoints for creating, configuring, sharing, and auditing custom webhook handlers.

# Custom Webhooks

Custom webhooks give you a public HTTPS endpoint that external systems (payment processors, CRMs, CI pipelines, form builders) can call to trigger a tool, agent, manager, or AutessaDB operation inside Autessa. This page covers **managing webhook definitions** — creating them, updating their configuration, rotating keys, sharing, and auditing deliveries — via the poweruser API.

> This page manages webhook **definitions**. External systems **call** the webhook through the client-side execution endpoint (`/clients/custom-webhooks?resourceId={webhookId}`), which accepts any HTTP method and authenticates with the webhook's own `wh:` key, the sender's signature, or a validation script. See the [Custom Webhooks execution API](/docs/api/custom-webhooks.md) for the trigger URL, payload format, and execution pipeline.

---

## Base URL

```
https://api.autessa.com/autessa_poweruser/custom-webhooks
```

All management endpoints are `POST` with a JSON body. Authenticate with your poweruser key in the `Authorization` header (no `Bearer` prefix):

```
Authorization: pwrusr:{id}:{secret}
```

---

## The webhook object

Every webhook returned by these endpoints has the same shape.

- `id` (string) — Unique ID of the webhook. This is the `resourceId` external systems use in the trigger URL: `https://api.autessa.com/clients/custom-webhooks?resourceId={id}`.
- `companyId` (string) — The company that owns the webhook.
- `ownerId` (string) — The user who created the webhook. Only the owner can delete it.
- `webhookConfig` (object) — The full webhook configuration. See [The webhookConfig object](#the-webhookconfig-object) below.
- `apiKeyId` (string) — ID of the dedicated webhook API key. This matches the `{keyId}` segment of the webhook's `wh:{keyId}:{keySecret}` key. The secret itself is never returned here — only from [`/create`](#create-webhook-) and [`/refresh-api-key`](#refresh-api-key-).
- `isEnabled` (boolean) — Whether the webhook accepts deliveries. Disabled webhooks reject trigger requests.
- `sharingLevel` (string) — Visibility of the webhook: `PRIVATE`, `SPECIFIC_MEMBER`, or `COMPANY`.
- `companyPermissionLevel` (string) — Access level granted to everyone in the company when `sharingLevel` is `COMPANY`: `READ`, `WRITE`, `PUBLISH`, or `ADMIN`.
- `createdAt` (string) — When the webhook was created, as an ISO-8601 UTC timestamp (e.g. `2026-06-30T18:22:41`).
- `updatedAt` (string) — When the webhook was last updated, as an ISO-8601 UTC timestamp.
- `userAccessLevel` (string) — The calling user's effective access to this webhook: `READ`, `WRITE`, `PUBLISH`, or `ADMIN`.

### The webhookConfig object

- `name` (string, required) — Display name of the webhook. Required on create.
- `description` (string) — What the webhook is for.
- `validationConfig` (object) — Custom request validation; required when `authMode` is `SCRIPT`. See [validationConfig](#validationconfig).
- `payloadTransformConfig` (object) — How the incoming payload is turned into variables. See [payloadTransformConfig](#payloadtransformconfig).
- `resourceExecutionConfig` (object) — Which resource runs when the webhook fires, and with what inputs. See [resourceExecutionConfig](#resourceexecutionconfig).
- `executionSettings` (object) — Timeout and retry behavior. See [executionSettings](#executionsettings).
- `authMode` (string) — How callers authenticate: `API_KEY` (default: the webhook's `wh:` key, plus the signature too if a `signatureConfig` is set), `SIGNATURE` (the sender's signature, verified with `signatureConfig`; the trigger URL carries no key), `API_KEY_OR_SIGNATURE` (a key that is sent must be valid; with no key, the signature must verify), or `SCRIPT` (no key and no built-in signature: the validation script decides, and is required; the trigger URL carries no key).
- `signatureConfig` (object) — The sender's signature scheme, verified on every call when set. See [signatureConfig](#signatureconfig).
- `handshakeConfig` (object) — Verification handshakes answered immediately, without running the handler. See [handshakeConfig](#handshakeconfig).
- `responseConfig` (object) — The HTTP reply the sender receives. Omit for the execution JSON with status `200` (when a `signatureConfig` or `handshakeConfig` is set) or `202`. See [responseConfig](#responseconfig).
- `dedupeConfig` (object) — Which field identifies a redelivery of the same event. Omit to use the signature scheme's delivery ID, where it has one. See [dedupeConfig](#dedupeconfig).

### validationConfig

- `enableValidation` (boolean) — Records whether validation is switched on in the builder. It does not control whether the script runs: a webhook with a `validationScript` runs it on every delivery. To stop validating, remove the script.
- `validationScript` (string) — AutessaScript that runs on every delivery after the key or signature check; with `authMode: SCRIPT` it is the only check, and it is required. It receives `method`, `url`, `body`, `headers`, `headersLower`, and `queryParams` as variables (keys redacted; signature headers are kept) and answers with `response.setResponse(String(true))` or `String(false)` — `false` rejects the delivery with `401`. For a signature scheme `signatureConfig` doesn't cover, check it with `secrets.verifyHmac`, `secrets.verifyHmacSha256`, or `cryptoUtils.verifySignature`. See [Webhook scripts](/docs/api/custom-webhooks.md#webhook-scripts).

### signatureConfig

See [Signature verification](/docs/api/custom-webhooks.md#signature-verification) for each provider's header and secret.

- `scheme` (string, required) — `META`, `GITHUB`, `STRIPE`, `SLACK`, `SHOPIFY`, `TWILIO`, `SVIX`, or `GENERIC_HMAC`.
- `secretName` (string, required) — Name of the [Autessa Secret](/docs/guide/agentic/secrets.md) holding the signing secret (App Secret, Signing Secret, Auth Token, `whsec_` secret, and so on). The value is never stored in the webhook config. Saving adds this webhook to the secret's [What can use it](/docs/guide/agentic/secrets.md#what-can-use-a-secret) list if you have `USE` on it.
- `header` (string) — `GENERIC_HMAC` only: the header carrying the signature.
- `algorithm` (string) — `GENERIC_HMAC` only: `SHA256` (default), `SHA1`, or `SHA512`.
- `encoding` (string) — `GENERIC_HMAC` only: `HEX` (default) or `BASE64`.
- `prefix` (string) — `GENERIC_HMAC` only: text removed from the header value before comparing, e.g. `sha256=`.
- `toleranceSeconds` (integer) — `STRIPE`, `SLACK`, and `SVIX`: maximum age of the signed timestamp, in seconds. Defaults to `300`.

### handshakeConfig

See [Verification handshakes](/docs/api/custom-webhooks.md#verification-handshakes) for what each preset answers.

- `preset` (string) — `META`, `SLACK`, `MS_GRAPH`, `DROPBOX`, `ZOOM`, `X`, or `CUSTOM`. `X` answers a `GET` with a `crc_token` query parameter with `{"response_token": "sha256=..."}`, the base64 HMAC-SHA256 of `crc_token` keyed by your X app's consumer secret. A token containing `{` or `[`, or longer than 512 characters, is refused.
- `verifyToken` (string) — `META` only: the verify token entered in the Meta app dashboard. The handshake is refused unless `hub.verify_token` matches it.
- `secretName` (string) — `ZOOM` and `X` only, and required for them: name of the Autessa Secret holding the Zoom Secret Token or the X consumer secret. Saving adds this webhook to the secret's [What can use it](/docs/guide/agentic/secrets.md#what-can-use-a-secret) list if you have `USE` on it.
- `script` (string) — AutessaScript checked after the preset and the rules, for handshakes no rule can express, such as a computed answer or a call back to the sender to confirm a subscription. It can be set with no preset. It sees the same variables as a validation script. Set no response for a normal delivery, `response.setResponse(JSON.stringify({status, contentType, body}))` to answer the call, or `response.setResponse('text')` for a `200` `text/plain` reply; throwing refuses the call with `401`. It runs before authentication, so it must check the sender's signature itself. Because anyone with the URL can run it, it can use only the `api`, `secrets`, `cryptoUtils`, and `mathUtils` helpers, its `api` calls return only their status, and once it has called out its reply is a plain `200` acknowledgment. See [Handshake script](/docs/api/custom-webhooks.md#handshake-script).
- `rules` (array<object>) — Custom rules, checked after the preset (or on their own with `CUSTOM`). Each rule has `method` (optional; any method when omitted), `whenSource` (`QUERY`, `HEADER`, or `BODY`), `whenPath` (field name or dotted body path), `whenEquals` (optional; presence is enough when omitted), `replyStatus` (default `200`), `replyContentType` (default `text/plain`), and `replyFrom` (`query.<name>`, `header.<name>`, `body.<path>`, or literal text).

### responseConfig

See [Customizing the reply](/docs/api/custom-webhooks.md#customizing-the-reply).

- `mode` (string) — `ACK` (default): reply immediately and run the handler afterwards. `HANDLER_OUTPUT` (`TOOL` handlers only): run the tool during the request and reply with its result; if the tool fails, the sender gets `500` with `{"error": "..."}`.
- `statusCode` (integer) — Status of the acknowledgement. Defaults to `200` when the webhook has a `signatureConfig` or `handshakeConfig`, otherwise `202`.
- `contentType` (string) — Content type of the acknowledgement. Defaults to `application/json`.
- `bodyTemplate` (string) — Body of the acknowledgement. Supports `@@{executionId}`, `@@{webhookId}`, `@@{query.<name>}`, `@@{header.<name>}`, and `@@{body.<path>}`. Omit to keep the default execution JSON.
- `syncTimeoutSeconds` (integer) — `HANDLER_OUTPUT` only: seconds to wait for the tool before sending the acknowledgement and finishing in the background. Defaults to `10`, maximum `25`.

### dedupeConfig

Without a `dedupeConfig`, webhooks whose signature scheme carries a delivery ID dedupe on it: `GITHUB` (`X-GitHub-Delivery` header), `STRIPE` (body `id`), `SLACK` (body `event_id`), `SHOPIFY` (`X-Shopify-Webhook-Id` header), and `SVIX` (`svix-id` header). `META`, `TWILIO`, `GENERIC_HMAC`, and `SCRIPT`-mode webhooks don't dedupe by default. See [Duplicate deliveries](/docs/api/custom-webhooks.md#duplicate-deliveries).

- `source` (string) — `HEADER` or `BODY`.
- `path` (string) — Header name, or dotted path into the body (e.g. `id`, `event_id`). An empty `path` turns deduplication off.
- `windowHours` (integer) — How long a delivery ID is remembered. Defaults to `72`.

### payloadTransformConfig

- `transformType` (string) — `JSONPATH` (default) or `AUTESSA_SCRIPT`.
- `jsonPathMappings` (object) — Map of variable name to JSONPath expression evaluated against the delivery body, e.g. `{"orderId": "$.order.id"}`. Used when `transformType` is `JSONPATH`.
- `transformScript` (string) — AutessaScript for complex transformations. It receives `payload` (raw body string), `headers`, and `queryParams` as variables (keys redacted) and must return a JSON object of variable mappings. Used when `transformType` is `AUTESSA_SCRIPT`.

The extracted variables are substituted into the handler's configured inputs wherever a `@@{variableName}` reference appears.

### resourceExecutionConfig

- `resourceType` (string) — Type of resource to execute: `TOOL`, `AGENT`, `MANAGER`, or `AUTESSADB`.
- `resourceId` (string) — ID of the target tool, agent, or manager. Not used when `resourceType` is `AUTESSADB` — the target table is set in `autessaDbConfig.targetTableId` instead.
- `variables` (object) — Tool input variables (`TOOL` only). Values support `@@{variableName}` references.
- `environmentVariables` (object) — Environment variables for the execution (`TOOL`, `AGENT`, `MANAGER`). Values support `@@{variableName}` references.
- `promptTemplateVariables` (object) — Prompt template variables (`AGENT`, `MANAGER`). Values support `@@{variableName}` references.
- `privateVariables` (object) — Secret variables (`TOOL`). Not written to execution logs. Values support `@@{variableName}` references.
- `userMessage` (string) — The user message sent to the agent or manager (`AGENT`, `MANAGER`). Supports `@@{variableName}` references.
- `autessaDbConfig` (object) — Direct database operation configuration (`AUTESSADB` only). See [autessaDbConfig](#autessadbconfig).

### autessaDbConfig

- `operation` (string) — The database operation: `INSERT`, `UPDATE`, `UPSERT`, or `DELETE`.
- `targetTableId` (string) — ID of the target AutessaDB table.
- `values` (object) — Column values to insert or update. Map of column name to a typed column-value object (`columnType` plus the matching value field, e.g. `textValue`, `integerValue`, `floatValue`, `booleanValue`, `multiSelectValue`, `filePath`, or `variableValue`). Values support `@@{variableName}` references.
- `recordId` (string) — For single-row updates: the specific record ID to update. Mutually exclusive with `whereGroups`. Supports `@@{variableName}` references.
- `whereGroups` (array<object>) — For batch updates: WHERE condition groups matching the records to modify. Mutually exclusive with `recordId`.
- `groupsLogicalOperator` (string) — Logical operator between WHERE groups: `AND` or `OR`. Only used with `whereGroups`.
- `description` (string) — Optional description of what the operation does.

### executionSettings

- `timeoutSeconds` (integer) — Execution timeout in seconds. Defaults to `300`.
- `maxRetries` (integer) — How many more times the handler runs after it fails in the background. Defaults to `3`. Not used for `HANDLER_OUTPUT` replies.
- `retryDelaySeconds` (integer) — Delay before the first retry, in seconds. Defaults to `5`, doubling on each attempt up to 15 minutes.

```json title="The webhook object"
{
  "id": "V1StGXR8Z5",
  "companyId": "kTn4vB2p9Q",
  "ownerId": "aB3xK9mQ2w",
  "webhookConfig": {
    "name": "Order events",
    "description": "Handles order.created events from the storefront",
    "validationConfig": {
      "enableValidation": false
    },
    "payloadTransformConfig": {
      "transformType": "JSONPATH",
      "jsonPathMappings": {
        "orderId": "$.order.id",
        "eventType": "$.event.type"
      }
    },
    "resourceExecutionConfig": {
      "resourceType": "AGENT",
      "resourceId": "pQ7wXr2LmN",
      "userMessage": "Process order @@{orderId} for event @@{eventType}",
      "environmentVariables": {
        "SOURCE": "storefront"
      },
      "promptTemplateVariables": {}
    },
    "executionSettings": {
      "timeoutSeconds": 300,
      "maxRetries": 3,
      "retryDelaySeconds": 5
    }
  },
  "apiKeyId": "c1f2a3b4-5d6e-4789-9abc-0def12345678",
  "isEnabled": true,
  "sharingLevel": "PRIVATE",
  "companyPermissionLevel": null,
  "createdAt": "2026-06-30T18:22:41",
  "updatedAt": "2026-06-30T18:22:41",
  "userAccessLevel": "ADMIN"
}
```

---

## Create Webhook **POST** `/create`

Creates a new webhook handler. The webhook is created **enabled**, and a dedicated webhook API key (named after the webhook) is generated for it. The response returns the full key value — `wh:{keyId}:{keySecret}` — **once**; only the key ID is stored retrievably, so save the key now. If you lose it, rotate it with [`/refresh-api-key`](#refresh-api-key-).

The webhook's public trigger URL is derived from the returned `id`:

```
https://api.autessa.com/clients/custom-webhooks?resourceId={id}
```

The `webhookConfig.name` field is required; everything else in the configuration is optional and can be filled in later with [`/update`](#update-webhook-).

### Request Body

- `webhookConfig` (object, required) — The webhook configuration. Must include `name`. See [The webhookConfig object](#the-webhookconfig-object).

### Response

- `webhook` (object) — The created webhook. See [The webhook object](#the-webhook-object).
- `apiKey` (string) — The full webhook API key (`wh:{keyId}:{keySecret}`). **Returned only in this response** — store it securely.
- `errors` (array<string>) — Array of error messages. Absent on success.

**cURL:**

```bash
curl https://api.autessa.com/autessa_poweruser/custom-webhooks/create \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "webhookConfig": {
      "name": "Order events",
      "description": "Handles order.created events from the storefront",
      "payloadTransformConfig": {
        "transformType": "JSONPATH",
        "jsonPathMappings": {
          "orderId": "$.order.id",
          "eventType": "$.event.type"
        }
      },
      "resourceExecutionConfig": {
        "resourceType": "AGENT",
        "resourceId": "pQ7wXr2LmN",
        "userMessage": "Process order @@{orderId} for event @@{eventType}"
      }
    }
  }'
```

**JavaScript:**

```javascript
const response = await fetch(
  'https://api.autessa.com/autessa_poweruser/custom-webhooks/create',
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': process.env.POWERUSER_KEY
    },
    body: JSON.stringify({
      webhookConfig: {
        name: 'Order events',
        description: 'Handles order.created events from the storefront',
        payloadTransformConfig: {
          transformType: 'JSONPATH',
          jsonPathMappings: {
            orderId: '$.order.id',
            eventType: '$.event.type'
          }
        },
        resourceExecutionConfig: {
          resourceType: 'AGENT',
          resourceId: 'pQ7wXr2LmN',
          userMessage: 'Process order @@{orderId} for event @@{eventType}'
        }
      }
    })
  }
);

const data = await response.json();
console.log(data.webhook.id, data.apiKey); // save the key!
```

**Python:**

```python
import os
import requests

response = requests.post(
    'https://api.autessa.com/autessa_poweruser/custom-webhooks/create',
    headers={'Authorization': os.environ['POWERUSER_KEY']},
    json={
        'webhookConfig': {
            'name': 'Order events',
            'description': 'Handles order.created events from the storefront',
            'payloadTransformConfig': {
                'transformType': 'JSONPATH',
                'jsonPathMappings': {
                    'orderId': '$.order.id',
                    'eventType': '$.event.type'
                }
            },
            'resourceExecutionConfig': {
                'resourceType': 'AGENT',
                'resourceId': 'pQ7wXr2LmN',
                'userMessage': 'Process order @@{orderId} for event @@{eventType}'
            }
        }
    }
)

data = response.json()
print(data['webhook']['id'], data['apiKey'])  # save the key!
```

```json title="JSON"
{
  "webhook": {
    "id": "V1StGXR8Z5",
    "companyId": "kTn4vB2p9Q",
    "ownerId": "aB3xK9mQ2w",
    "webhookConfig": {
      "name": "Order events",
      "description": "Handles order.created events from the storefront",
      "payloadTransformConfig": {
        "transformType": "JSONPATH",
        "jsonPathMappings": {
          "orderId": "$.order.id",
          "eventType": "$.event.type"
        }
      },
      "resourceExecutionConfig": {
        "resourceType": "AGENT",
        "resourceId": "pQ7wXr2LmN",
        "userMessage": "Process order @@{orderId} for event @@{eventType}"
      }
    },
    "apiKeyId": "c1f2a3b4-5d6e-4789-9abc-0def12345678",
    "isEnabled": true,
    "sharingLevel": "PRIVATE",
    "createdAt": "2026-06-30T18:22:41",
    "updatedAt": "2026-06-30T18:22:41",
    "userAccessLevel": "ADMIN"
  },
  "apiKey": "wh:c1f2a3b4-5d6e-4789-9abc-0def12345678:sk_9f8e7d6c5b4a"
}
```

---

## Get Webhook **POST** `/get`

Fetches a single webhook by ID. Requires at least `READ` access to the webhook.

### Request Body

- `webhookId` (string, required) — ID of the webhook to fetch.

### Response

- `webhook` (object) — The webhook. See [The webhook object](#the-webhook-object).
- `errors` (array<string>) — Array of error messages. Absent on success.

```bash title="cURL"
curl https://api.autessa.com/autessa_poweruser/custom-webhooks/get \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{"webhookId": "V1StGXR8Z5"}'
```

```json title="JSON"
{
  "webhook": {
    "id": "V1StGXR8Z5",
    "companyId": "kTn4vB2p9Q",
    "ownerId": "aB3xK9mQ2w",
    "webhookConfig": {
      "name": "Order events",
      "resourceExecutionConfig": {
        "resourceType": "AGENT",
        "resourceId": "pQ7wXr2LmN"
      }
    },
    "apiKeyId": "c1f2a3b4-5d6e-4789-9abc-0def12345678",
    "isEnabled": true,
    "sharingLevel": "PRIVATE",
    "createdAt": "2026-06-30T18:22:41",
    "updatedAt": "2026-06-30T18:22:41",
    "userAccessLevel": "ADMIN"
  }
}
```

---

## List Webhooks **POST** `/get-all`

Lists every webhook the calling user can access in the current company — webhooks they own, webhooks shared with them directly, and company-shared webhooks.

### Request Body

No fields — send an empty JSON object (`{}`).

### Response

- `webhooks` (array<object>) — All accessible webhooks. See [The webhook object](#the-webhook-object).
- `errors` (array<string>) — Array of error messages. Absent on success.

```bash title="cURL"
curl https://api.autessa.com/autessa_poweruser/custom-webhooks/get-all \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

```json title="JSON"
{
  "webhooks": [
    {
      "id": "V1StGXR8Z5",
      "companyId": "kTn4vB2p9Q",
      "ownerId": "aB3xK9mQ2w",
      "webhookConfig": {
        "name": "Order events"
      },
      "apiKeyId": "c1f2a3b4-5d6e-4789-9abc-0def12345678",
      "isEnabled": true,
      "sharingLevel": "COMPANY",
      "companyPermissionLevel": "READ",
      "createdAt": "2026-06-30T18:22:41",
      "updatedAt": "2026-06-30T18:22:41",
      "userAccessLevel": "ADMIN"
    }
  ]
}
```

---

## Update Webhook **POST** `/update`

Updates a webhook's configuration and/or toggles it on or off. Requires `WRITE` access or higher — `READ`-only users are rejected.

The `webhookConfig` you send **replaces** the stored configuration, so send the complete config (fetch it with [`/get`](#get-webhook-), modify, and send it back). If `isEnabled` is omitted, the current enabled state is kept.

### Request Body

- `webhookId` (string, required) — ID of the webhook to update.
- `webhookConfig` (object) — The full replacement configuration. See [The webhookConfig object](#the-webhookconfig-object).
- `isEnabled` (boolean) — Set `false` to pause deliveries, `true` to resume. Unchanged if omitted.

### Response

- `webhook` (object) — The updated webhook. See [The webhook object](#the-webhook-object).
- `errors` (array<string>) — Array of error messages. Absent on success.

```bash title="cURL"
curl https://api.autessa.com/autessa_poweruser/custom-webhooks/update \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "webhookId": "V1StGXR8Z5",
    "webhookConfig": {
      "name": "Order events",
      "description": "Now also handles refund events",
      "payloadTransformConfig": {
        "transformType": "JSONPATH",
        "jsonPathMappings": {
          "orderId": "$.order.id",
          "eventType": "$.event.type"
        }
      },
      "resourceExecutionConfig": {
        "resourceType": "AGENT",
        "resourceId": "pQ7wXr2LmN",
        "userMessage": "Process order @@{orderId} for event @@{eventType}"
      }
    },
    "isEnabled": true
  }'
```

```json title="JSON"
{
  "webhook": {
    "id": "V1StGXR8Z5",
    "companyId": "kTn4vB2p9Q",
    "ownerId": "aB3xK9mQ2w",
    "webhookConfig": {
      "name": "Order events",
      "description": "Now also handles refund events"
    },
    "apiKeyId": "c1f2a3b4-5d6e-4789-9abc-0def12345678",
    "isEnabled": true,
    "sharingLevel": "PRIVATE",
    "createdAt": "2026-06-30T18:22:41",
    "updatedAt": "2026-07-01T09:15:03",
    "userAccessLevel": "ADMIN"
  }
}
```

---

## Delete Webhook **POST** `/delete`

Permanently deletes a webhook. Only the webhook's **owner** can delete it — even `ADMIN`-level collaborators are rejected. External calls to the webhook's trigger URL stop working immediately.

### Request Body

- `webhookId` (string, required) — ID of the webhook to delete.

### Response

- `deleted` (boolean) — `true` if the webhook was deleted.
- `errors` (array<string>) — Array of error messages. Absent on success.

```bash title="cURL"
curl https://api.autessa.com/autessa_poweruser/custom-webhooks/delete \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{"webhookId": "V1StGXR8Z5"}'
```

```json title="JSON"
{
  "deleted": true
}
```

---

## Refresh API Key **POST** `/refresh-api-key`

Rotates the webhook's API key. The **old key is invalidated immediately** — any external system still sending it will start receiving `401` on the trigger URL — and a new full key value is generated and **returned once** in this response. Update the calling systems with the new key right away.

Requires `ADMIN` access to the webhook.

### Request Body

- `webhookId` (string, required) — ID of the webhook whose key to rotate.

### Response

- `apiKey` (string) — The new webhook API key (`wh:{keyId}:{keySecret}`). **Returned only in this response** — store it securely.
- `errors` (array<string>) — Array of error messages. Absent on success.

```bash title="cURL"
curl https://api.autessa.com/autessa_poweruser/custom-webhooks/refresh-api-key \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{"webhookId": "V1StGXR8Z5"}'
```

```json title="JSON"
{
  "apiKey": "wh:c1f2a3b4-5d6e-4789-9abc-0def12345678:sk_2b3c4d5e6f7a"
}
```

---

## Get Execution History **POST** `/get-execution-history`

Returns the paginated delivery log for a webhook — every trigger request, including handshakes, duplicates, and rejected calls, with its status, timing, and full execution details (request payload, transformed variables, and the handler's request/response). Requires at least `READ` access to the webhook.

Each entry's `executionId` matches the `executionId` returned to the caller by the [execution endpoint](/docs/api/custom-webhooks.md), so you can correlate a specific delivery end to end. To run a stored delivery again, use **Replay** in the builder or `autessa custom-webhooks replay --executionId <executionId>`; to try a sample call without a sender, use `autessa custom-webhooks test` (see [Test and replay from the CLI](/docs/guide/api-management/webhook-handlers.md#test-and-replay-from-the-cli)).

### Request Body

- `webhookId` (string, required) — ID of the webhook whose history to fetch.
- `status` (string) — Optional status filter: `QUEUED`, `PROCESSING`, `SUCCESS`, `FAILED`, `TRANSFORM_FAILED`, `RETRYING`, `HANDSHAKE`, `DUPLICATE`, or `REJECTED`. Omit to return all statuses.
- `page` (integer) — Zero-based page number. Defaults to `0`.
- `size` (integer) — Page size. Defaults to `20`.

### Response

- `history` (array<object>) — Execution history entries, one per delivery attempt. See fields below.
- `totalPages` (integer) — Total number of pages available.
- `totalElements` (integer) — Total number of history entries matching the query.
- `currentPage` (integer) — The zero-based page number returned.
- `errors` (array<string>) — Array of error messages. Absent on success.

### History entry fields

- `id` (string) — Unique ID of the history record (a UUID string).
- `executionId` (string) — Delivery correlation ID — the same value the execution endpoint returned to the external caller.
- `webhookId` (string) — ID of the webhook that received the delivery.
- `resourceType` (string) — Type of handler resource that ran: `TOOL`, `AGENT`, `MANAGER`, or `AUTESSADB`.
- `resourceId` (string) — ID of the handler resource that ran.
- `queuedAt` (string) — When the delivery was accepted and queued (ISO-8601 UTC timestamp).
- `startedAt` (string) — When background execution started. Null while still queued.
- `endedAt` (string) — When execution finished. Null until the run completes.
- `durationMs` (integer) — Execution duration in milliseconds.
- `status` (string) — Current status of the delivery: `QUEUED`, `PROCESSING`, `SUCCESS`, `FAILED`, `TRANSFORM_FAILED` (the payload transform failed and the handler did not run), `RETRYING` (failed, and will run again), `HANDSHAKE` (a verification handshake answered without running the handler), `DUPLICATE` (a redelivery that was not run again), or `REJECTED` (failed the key, signature, or validation check and got a `401`; `errorMessage` says why).
- `attemptNumber` (integer) — Which retry attempt this entry represents (`1` for the first attempt).
- `executionDetails` (object) — Full delivery detail. See fields below.

### executionDetails fields

- `webhookName` (string) — Name of the webhook at the time of delivery.
- `httpMethod` (string) — HTTP method the external system used (`GET`, `POST`, `PUT`, `DELETE`, `PATCH`).
- `sourceIp` (string) — IP address the delivery came from.
- `requestHeaders` (string) — The delivery's HTTP headers, JSON-encoded. The webhook key and other credential headers are redacted.
- `requestPayload` (string) — The raw request body as received.
- `transformType` (string) — Transform that was applied: `JSONPATH` or `AUTESSA_SCRIPT`.
- `transformedVariables` (string) — The variables extracted from the payload, JSON-encoded.
- `transformError` (string) — Error message if the payload transform failed. Null otherwise.
- `resourceRequestJson` (string) — The request sent to the handler resource, JSON-encoded.
- `resourceResponseJson` (string) — The handler resource's response, JSON-encoded.
- `errorMessage` (string) — Error message if execution failed. Null otherwise.

**cURL:**

```bash
curl https://api.autessa.com/autessa_poweruser/custom-webhooks/get-execution-history \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "webhookId": "V1StGXR8Z5",
    "status": "FAILED",
    "page": 0,
    "size": 20
  }'
```

**JavaScript:**

```javascript
const response = await fetch(
  'https://api.autessa.com/autessa_poweruser/custom-webhooks/get-execution-history',
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': process.env.POWERUSER_KEY
    },
    body: JSON.stringify({
      webhookId: 'V1StGXR8Z5',
      status: 'FAILED',
      page: 0,
      size: 20
    })
  }
);

const data = await response.json();
for (const entry of data.history) {
  console.log(entry.executionId, entry.status, entry.durationMs);
}
```

**Python:**

```python
import os
import requests

response = requests.post(
    'https://api.autessa.com/autessa_poweruser/custom-webhooks/get-execution-history',
    headers={'Authorization': os.environ['POWERUSER_KEY']},
    json={
        'webhookId': 'V1StGXR8Z5',
        'status': 'FAILED',
        'page': 0,
        'size': 20
    }
)

data = response.json()
for entry in data['history']:
    print(entry['executionId'], entry['status'], entry['durationMs'])
```

```json title="JSON"
{
  "history": [
    {
      "id": "7d0a4c2e-91f3-4b6a-8c5d-1e2f3a4b5c6d",
      "executionId": "exec_f47ac10b58cc",
      "webhookId": "V1StGXR8Z5",
      "resourceType": "AGENT",
      "resourceId": "pQ7wXr2LmN",
      "queuedAt": "2026-07-01T08:30:12",
      "startedAt": "2026-07-01T08:30:13",
      "endedAt": "2026-07-01T08:30:19",
      "durationMs": 6114,
      "status": "FAILED",
      "attemptNumber": 1,
      "executionDetails": {
        "webhookName": "Order events",
        "httpMethod": "POST",
        "sourceIp": "203.0.113.42",
        "requestHeaders": "{\"content-type\": \"application/json\"}",
        "requestPayload": "{\"order\": {\"id\": \"ord_991\"}, \"event\": {\"type\": \"order.created\"}}",
        "transformType": "JSONPATH",
        "transformedVariables": "{\"orderId\": \"ord_991\", \"eventType\": \"order.created\"}",
        "transformError": null,
        "resourceRequestJson": "{\"agentId\": \"pQ7wXr2LmN\", \"input\": [...]}",
        "resourceResponseJson": null,
        "errorMessage": "Agent execution timed out after 300 seconds"
      }
    }
  ],
  "totalPages": 3,
  "totalElements": 47,
  "currentPage": 0
}
```

---

## Share Webhook **POST** `/share`

Changes who can see and manage a webhook. Requires `ADMIN` access, and the webhook must belong to your current company.

Sharing has three levels:

- `PRIVATE` — only the owner (and existing direct shares) can access it.
- `COMPANY` — everyone in the company gets the access level in `accessLevel`.
- `SPECIFIC_MEMBER` — the users in `usersToAdd` get their individual access levels.

> This endpoint changes the same sharing as the [Share dialog](/docs/guide/platform/sharing.md). Sharing with `COMPANY` adds a company-wide grant and keeps everyone already shared individually at their own level. People get the highest level from any grant that covers them.

### Request Body

- `webhookId` (string, required) — ID of the webhook to share.
- `level` (string, required) — Sharing level: `PRIVATE`, `COMPANY`, or `SPECIFIC_MEMBER`.
- `accessLevel` (string) — Access level granted company-wide: `READ`, `WRITE`, `PUBLISH`, or `ADMIN`. Required when `level` is `COMPANY`.
- `usersToAdd` (array<object>) — Users to grant access to. Required when `level` is `SPECIFIC_MEMBER`. Each entry has `userEmail` (string), `userId` (string), and `accessLevel` (string).
- `usersToRemove` (array<object>) — Users to drop from access when editing an existing share. Same entry shape as `usersToAdd`.

### Response

- `updated` (boolean) — `true` if the sharing settings were saved.
- `errors` (array<string>) — Array of error messages. Absent on success.

```bash title="cURL"
curl https://api.autessa.com/autessa_poweruser/custom-webhooks/share \
  -H "Authorization: $POWERUSER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "webhookId": "V1StGXR8Z5",
    "level": "SPECIFIC_MEMBER",
    "usersToAdd": [
      {
        "userEmail": "teammate@example.com",
        "userId": "mK4rT8vZ1x",
        "accessLevel": "WRITE"
      }
    ]
  }'
```

```json title="JSON"
{
  "updated": true
}
```

---

## Errors

All endpoints return errors in a consistent shape. Exceptions are caught server-side and folded into the `errors` array of the response — when `errors` is present, the HTTP status is non-2xx.

- `errors` (array<string>) — Human-readable error messages, e.g. `"Webhook not found"`, `"Webhook must have a name in the configuration"`, `"Only the owner can delete this webhook"`, `"Only admins can refresh the API key"`.

Common failure cases:

- **401** — missing or invalid poweruser key, or the key lacks access to the target webhook (not-found and permission failures are both reported this way).
- **Validation failures** — missing `webhookConfig`, or a config without a `name` on create.
- **Permission failures** — `READ`-only users calling `/update`; non-owners calling `/delete`; non-`ADMIN` users calling `/refresh-api-key` or `/share`.

---

## Related

- [Poweruser API overview](/docs/api/poweruser.md)
- [Custom Webhooks execution API](/docs/api/custom-webhooks.md) — the public trigger endpoint external systems call
- [Poweruser Agents API](/docs/api/poweruser/agents.md)
- [Poweruser Tools API](/docs/api/poweruser/tools.md)
- [Poweruser AutessaDB Tables API](/docs/api/poweruser/autessadb-tables.md)

