> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anygen.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Trigger Webhook

External systems can trigger a claw session by calling a webhook endpoint. No login session is required — the `webhook_id` path parameter itself acts as the bearer secret.

Both `POST` and `GET` are supported. They have the same behavior; the only difference is how the prompt is passed.

***

## 1. Trigger via POST

```http theme={null}
POST https://www.anygen.io/v1/openapi/anyclaw/webhook/{webhook_id}
Content-Type: application/json
```

`Content-Type` can be `application/json`, `text/plain`, or any other type.

The entire HTTP request body is delivered directly to the claw as the prompt. The body is **not parsed**, and it does **not** need to be valid JSON.

This makes integration with external systems almost zero-cost. Default webhook payloads from services such as GitHub, Linear, Zapier, and others can be forwarded directly.

### Request Body

The body can be any text content. All examples below are valid:

```text theme={null}
PR #128 has been merged.
{
  "event": "pull_request.merged",
  "pr": 128,
  "title": "fix login bug"
}
hello
```

### Success Response

HTTP `200`

```json theme={null}
{
  "success": true,
  "webhook_id": "wh_xxxxxxxxxxxxxxxxxxxxxx",
  "claw_token": "claw_xxxxxxxxxxxxxxxxxxxxxx",
  "chat_token": "chat_xxxxxxxxxxxxxxxxxxxxxx"
}
```

### Response Fields

| Field        | Description                                                                                      |
| ------------ | ------------------------------------------------------------------------------------------------ |
| `success`    | Whether the webhook trigger request was accepted successfully.                                   |
| `webhook_id` | The webhook ID used for this trigger request.                                                    |
| `claw_token` | The token of the claw that will handle the prompt.                                               |
| `chat_token` | The token of the session created for this webhook trigger. Use it to query message status later. |

> Execution is asynchronous. When `chat_token` is returned, the claw may not have started processing yet. The caller should poll the message API to retrieve the reply/status.

***

## 2. Trigger via GET

GET triggering is provided for convenient browser or `curl` usage.

```http theme={null}
GET https://www.anygen.io/v1/openapi/anyclaw/webhook/{webhook_id}?text=xxx
```

### Query Parameters

| Parameter | Location | Required | Description                        |
| --------- | -------- | -------- | ---------------------------------- |
| `text`    | Query    | Yes      | The prompt to deliver to the claw. |

### Success Response

The response structure is the same as the POST trigger response.

```json theme={null}
{
  "success": true,
  "webhook_id": "wh_xxxxxxxxxxxxxxxxxxxxxx",
  "claw_token": "claw_xxxxxxxxxxxxxxxxxxxxxx",
  "chat_token": "chat_xxxxxxxxxxxxxxxxxxxxxx"
}
```

***

## 3. Error Responses

| HTTP Status | Business Code | Scenario                                                               |
| ----------- | ------------- | ---------------------------------------------------------------------- |
| `404`       | `100004002`   | The `webhook_id` does not exist or has been deleted.                   |
| `403`       | `100004003`   | The webhook is disabled.                                               |
| `500`       | `100009000`   | Failed to start the claw session. Check the `error` field for details. |

### Disabled Webhook

```json theme={null}
{
  "success": false,
  "error": "[code=100004003] webhook is disabled"
}
```

### Deleted or Non-existent Webhook

```json theme={null}
{
  "success": false,
  "error": "[code=100004002] webhook not found"
}
```

***

## 4. cURL Examples

### POST Example

The entire request body is used as the prompt.

```bash theme={null}
curl -X POST 'https://www.anygen.io/v1/openapi/anyclaw/webhook/wh_xxxxxxxxxxxxxxxxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{"event":"pull_request.merged","pr":128}'
```

### GET Example

The `text` query parameter is used as the prompt.

```bash theme={null}
curl 'https://www.anygen.io/v1/openapi/anyclaw/webhook/wh_xxxxxxxxxxxxxxxxxxxxxx?text=hello'
```
