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

# 🔄 웹훅

> 플러그 API는 특정 이벤트가 발생할 때 자동으로 HTTP POST 요청을 보내는 웹훅을 지원합니다.

## 웹훅 설정

웹훅을 사용하려면 다음 단계를 따르세요

1. 웹훅 URL을 플러그 대시보드(비즈니스 설정 -> 웹훅 & API)에서 설정합니다
2. 수신할 이벤트 유형을 선택합니다

## 지원 이벤트

플러그 API에서 지원하는 웹훅 이벤트

### 의뢰 이벤트

* 제목 변경
* 단계 변경
* 예상 견적 변경
* 문의 일시 변경
* 연결 고객 변경

### 견적서 이벤트

* 제목 변경
* 견적일자 변경
* 견적번호 변경
* 담당자 정보 변경
* 수신자 정보 변경
* 견적서 상태 변경
* 통화 변경
* VAT 옵션 변경

<Tip>
  각 이벤트는 사용자가 웹훅 설정에서 개별적으로 선택할 수 있습니다. 필요한 이벤트만 선택하여 불필요한 알림을 줄일 수 있습니다.
</Tip>

## 웹훅 페이로드 구조

모든 웹훅은 다음과 같은 기본 구조를 가집니다:

```json theme={null}
{
  "event_type": "inquiry",
  "timestamp": "2024-01-15T10:30:45.123456",
  "changed_fields": ["name", "status"],
  "data": {
     // 이벤트 관련 데이터
  }
}
```

### 필드 설명

| 필드               | 타입     | 설명                                   |
| ---------------- | ------ | ------------------------------------ |
| `event_type`     | string | 발생한 이벤트 유형 ("inquiry" 또는 "estimate") |
| `timestamp`      | string | 이벤트 발생 시간 (ISO 8601 형식)              |
| `changed_fields` | array  | 변경된 필드 목록                            |
| `data`           | object | 이벤트와 관련된 실제 데이터                      |

## 이벤트별 페이로드 예시

### 의뢰 변경 이벤트

```json theme={null}
  {
    "event_type": "inquiry",
    "timestamp": "2024-01-15T10:30:45.123456",
    "changed_fields": ["name", "status", "inquiry_date", "estimate", "client"],
    "data": {
      "id": 1234,
      "name": "모바일 앱 개발 프로젝트 의뢰",
      "status": {
        "id": 2,
        "title": "검토 중"
      },
      "estimate": "15000000",
      "inquiry_date": "2024-01-15T09:00:00",
      "client": {
        "id": 567,
        "company_name": "(주)테크스타트업",
        "ceo_name": "김대표",
        "email": "ceo@techstartup.co.kr",
        "contact": "010-1234-5678",
        "in_charge": "박매니저"
      }
    }
  }
```

### 견적서 변경 이벤트

```json theme={null}
  {
    "data": {
      "id": 886,
      "note": "프로젝트 관련 메모",
      "title": "모바일 앱 개발 견적서",
      "status": "확정",
      "has_vat": true,
      "vat_type": "부가세 별도",
      "total_vat": 0.0,
      "currency_code": "KRW",
      "discount_rate": 0,
      "estimate_date": "2024-01-16",
      "unique_number": "202401-001",
      "discount_amount": 0.0,
      "final_total_amount": 0.0,
      "total_supply_amount": 0.0,
      "total_category_amount": 0.0,
      "total_discount_amount": 0.0,
      "inquiry": {
        "id": 32030,
        "name": "모바일 앱 개발 프로젝트 의뢰"
      },
      "language": "KOR",
      "receiver": {
        "id": 853,
        "email": "customer@company.com",
        "contact": "010-1234-5678",
        "ceo_name": "김대표",
        "company_name": "(주)테크스타트업",
        "company_address": "서울특별시 강남구 테헤란로 123",
        "business_registration_number": "123-45-67890"
      },
      "supplier": {
        "id": 853,
        "email": "supplier@pluuug.com",
        "ceo_name": "박플러그",
        "company_name": "플러그개발",
        "company_address": "서울특별시 서초구 플러그로 456",
        "business_registration_number": "987-65-43210"
      },
      "in_charge": {
        "id": 164,
        "name": "이담당",
        "email": "manager@pluuug.com",
        "phone": "0507-1234-5678"
      },
      "category_set": [
        {
          "id": 2546,
          "type": "품목",
          "title": "개발비",
          "item_set": [
            {
              "id": 3706,
              "unit": "일",
              "title": "UI/UX 디자인",
              "quantity": 0.0,
              "unit_cost": 0.0,
              "total_cost": 0.0,
              "description": "모바일 앱 UI/UX 디자인",
              "number_of_people": 1
            }
          ],
          "information_type": null,
          "item_display_name": "항목",
          "total_item_amount": 0.0,
          "unit_display_name": "단위",
          "display_item_image": false,
          "information_content": null,
          "quantity_display_name": "수량",
          "unit_cost_display_name": "단가",
          "total_cost_display_name": "금액",
          "description_display_name": "설명",
          "number_of_people_display_name": "인원"
        }
      ]
    },
    "timestamp": "2024-01-15T14:22:15.789012",
    "event_type": "estimate",
    "changed_fields": ["title", "status", "unique_number", "estimate_date", "currency_code", "vat_type", "in_charge", "receiver"]
  }
```

## 인증

웹훅 요청의 보안을 위해 Authorization 헤더에 토큰을 포함하여 전송합니다.

### 인증 방법

웹훅 요청은 다음과 같은 Authorization 헤더를 포함합니다:

```
Authorization: Bearer your-webhook-token
```

웹훅 엔드포인트에서는 이 토큰을 검증하여 요청의 유효성을 확인해야 합니다.
