# Tạo / sửa điểm nhận webhook

> webhook_save — Create (no endpoint_id) or change an endpoint.

Source: https://x.builera.app/docs/vi/reference/webhook_save

`webhook_save` · Đổi thiết lập trong X-Buddy

> [!NOTE]
> Mô tả kỹ thuật bằng tiếng Anh — đúng chữ AI agent đọc qua MCP.

Create (no endpoint_id) or change an endpoint. Creating returns the signing secret ONCE (Standard Webhooks: webhook-id, webhook-timestamp, webhook-signature = v1,base64 HMAC-SHA256 of id.timestamp.body). Changing needs expected_revision. Retries: 30 s, 2 min, 10 min, 1 h, 6 h… for 72 h; 20 failures in a row in 24 h pause it.

| | |
|---|---|
| REST | `POST /api/public/v1/webhooks` |
| Công cụ MCP | `webhook_save` |
| Quyền cần có | `integrations.manage` — Chủ, Quản lý |
| Nhóm quyền | `webhooks:manage` |
| Nhóm | Sự kiện và webhook |
| Hiện sẵn trong hồ sơ | Hạ tầng |

## Đầu vào {#input}

| Trường | Kiểu | Bắt buộc | Mô tả |
|---|---|---|---|
| `endpoint_id` | string (uuid) | Không |  |
| `name` | string (1–60 chars) | Có | A name people recognise, e.g. "n8n inbox flow". |
| `url` | string (uri, 0–500 chars) | Có | HTTPS address that receives the events (no internal / private addresses). |
| `event_types` | array of `job.succeeded` · `job.failed` · `job.unknown` · `job.held` · `job.cancelled` · `batch.completed` · `dm.received` · `dm.request_received` · `reply.received` · `mention.received` · `follower.gained` · `follower.lost` · `post.published` · `post.failed` · `post.partial` · `campaign.person_entered` · `campaign.person_replied` · `campaign.person_completed` · `campaign.paused_auto` · `account.session_lost` · `account.session_restored` · `account.safety_changed` · `account.x_rate_limited` · `account.chat_locked` · `vps.offline` · `vps.online` · `proxy.failed` · `alert.opened` · `integration.paused` · `scan.completed` · `limit.reached` (1–31 items) | Có | Which event types to send. |
| `account_ids` | array of string (uuid) (0–200 items) | Không | Only events of these accounts (account-less events always arrive). null = every account. |
| `group_ids` | array of string (uuid) (0–50 items) | Không | Only events of accounts in these groups. null = no group filter. |
| `message_content` | boolean | Không | Include message / reply text (needs the connection's read-message-text right). |
| `expected_revision` | integer (1–∞) | Không | The revision you read (optimistic locking); a newer revision fails with revision_conflict. |

## Kết quả {#output}

Trả về kết quả của thao tác trong phong bì `{ data, meta }`.

> [!IMPORTANT]
> Cần khoá idempotency (`Idempotency-Key`, 8–128 ký tự). Gửi lại cùng khoá không bao giờ làm lại việc.

## Ví dụ {#example}

### Gọi qua REST {#example-rest}

```bash
curl -X POST "https://reach-link-craft.lovable.app/api/public/v1/webhooks" \
  -H "Authorization: Bearer $XBUDDY_API_KEY" \
  -H "Idempotency-Key: 6f1c2a90-example-key" \
  -H "Content-Type: application/json" \
  -d '{"name":"Example","url":"https://example.com/","event_types":["job.succeeded"]}'
```

### Gọi qua MCP {#example-mcp}

```json
{
  "method": "tools/call",
  "params": {
    "name": "webhook_save",
    "arguments": {
      "name": "Example",
      "url": "https://example.com/",
      "event_types": [
        "job.succeeded"
      ],
      "idempotency_key": "6f1c2a90-example-key"
    }
  }
}
```

## Lỗi có thể gặp {#errors}

| Mã | HTTP | Thử lại được |
|---|---|---|
| [`unauthorized`](/docs/vi/errors/unauthorized) | 401 | Không |
| [`key_expired`](/docs/vi/errors/key_expired) | 401 | Không |
| [`integration_revoked`](/docs/vi/errors/integration_revoked) | 401 | Không |
| [`connection_not_linked`](/docs/vi/errors/connection_not_linked) | 403 | Không |
| [`integration_paused`](/docs/vi/errors/integration_paused) | 403 | Không |
| [`workspace_integrations_paused`](/docs/vi/errors/workspace_integrations_paused) | 403 | Không |
| [`integration_authorization_lost`](/docs/vi/errors/integration_authorization_lost) | 403 | Không |
| [`workspace_suspended`](/docs/vi/errors/workspace_suspended) | 403 | Không |
| [`forbidden`](/docs/vi/errors/forbidden) | 403 | Không |
| [`invalid_input`](/docs/vi/errors/invalid_input) | 422 | Không |
| [`rate_limited`](/docs/vi/errors/rate_limited) | 429 | Có |
| [`internal`](/docs/vi/errors/internal) | 500 | Có |
| [`read_only`](/docs/vi/errors/read_only) | 403 | Không |
| [`idempotency_key_required`](/docs/vi/errors/idempotency_key_required) | 428 | Không |
| [`idempotency_conflict`](/docs/vi/errors/idempotency_conflict) | 409 | Không |
| [`idempotency_processing`](/docs/vi/errors/idempotency_processing) | 409 | Có |
| [`conflict`](/docs/vi/errors/conflict) | 409 | Không |
| [`precondition_failed`](/docs/vi/errors/precondition_failed) | 422 | Không |
| [`revision_required`](/docs/vi/errors/revision_required) | 428 | Không |
| [`revision_conflict`](/docs/vi/errors/revision_conflict) | 412 | Không |
| [`not_found`](/docs/vi/errors/not_found) | 404 | Không |

[Về danh sách thao tác](/docs/vi/reference)
