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

# 웹훅 생성

> 새 웹훅을 등록합니다.
- 여러 웹훅 등록 가능
- 등록 시 서명 시크릿이 반환됩니다

**중요**: 시크릿은 이 응답에서만 확인 가능합니다. 안전하게 보관하세요.

## 웹훅 이벤트 타입

| 이벤트 타입 | 설명 |
|------------|------|
| `order.antiAi.completed` | Anti-AI 처리 완료 |
| `order.antiAi.failed` | Anti-AI 처리 실패 |
| `order.watermarkEmbed.completed` | 워터마크 삽입 완료 |
| `order.watermarkEmbed.failed` | 워터마크 삽입 실패 |
| `order.watermarkExtract.completed` | 워터마크 추출 완료 |
| `order.watermarkExtract.failed` | 워터마크 추출 실패 |

## 서명 검증

웹훅 요청에는 `X-MoriBiz-Signature` 헤더가 포함됩니다.
서명은 등록 시 발급된 시크릿으로 HMAC-SHA256을 사용하여 생성됩니다.

```javascript
const crypto = require('crypto');
const signature = crypto.createHmac('sha256', secret)
  .update(JSON.stringify(payload))
  .digest('hex');
```

## 재시도 정책

- 최대 3회 재시도
- 지수 백오프 (1초, 2초, 4초)
- 성공 응답: 2xx 상태 코드




## OpenAPI

````yaml /ko/api-reference/openapi.yaml post /api/v2/orders/webhooks
openapi: 3.0.0
info:
  title: BIZ MORI API
  version: 2.0.0
  description: |
    BIZ MORI API는 디지털 콘텐츠 보호를 위한 네 가지 핵심 서비스를 제공합니다:
    - **Anti-AI**: 이미지를 AI 학습으로부터 보호
    - **Watermark Embed**: 이미지에 보이지 않는 디지털 워터마크 삽입
    - **Watermark Extract**: 이미지에서 워터마크 추출 및 검증
    - **AI Detection**: 이미지가 AI로 생성되었는지 감지
  contact:
    name: BIZ MORI 지원
    email: support@bizmori.com
servers:
  - url: https://api.bizmori.com
    description: 프로덕션
security: []
tags:
  - name: Anti-AI
    description: AI 학습 방지 이미지 보호 주문
  - name: Watermark Embed
    description: 워터마크 삽입 주문
  - name: Watermark Extract
    description: 워터마크 추출 주문
  - name: AI Detection
    description: AI 생성 이미지 감지 주문
  - name: Orders
    description: 주문 조회 및 관리
  - name: Webhooks
    description: 웹훅 설정 및 이벤트
paths:
  /api/v2/orders/webhooks:
    post:
      tags:
        - Webhooks
      summary: 웹훅 생성
      description: |
        새 웹훅을 등록합니다.
        - 여러 웹훅 등록 가능
        - 등록 시 서명 시크릿이 반환됩니다

        **중요**: 시크릿은 이 응답에서만 확인 가능합니다. 안전하게 보관하세요.

        ## 웹훅 이벤트 타입

        | 이벤트 타입 | 설명 |
        |------------|------|
        | `order.antiAi.completed` | Anti-AI 처리 완료 |
        | `order.antiAi.failed` | Anti-AI 처리 실패 |
        | `order.watermarkEmbed.completed` | 워터마크 삽입 완료 |
        | `order.watermarkEmbed.failed` | 워터마크 삽입 실패 |
        | `order.watermarkExtract.completed` | 워터마크 추출 완료 |
        | `order.watermarkExtract.failed` | 워터마크 추출 실패 |

        ## 서명 검증

        웹훅 요청에는 `X-MoriBiz-Signature` 헤더가 포함됩니다.
        서명은 등록 시 발급된 시크릿으로 HMAC-SHA256을 사용하여 생성됩니다.

        ```javascript
        const crypto = require('crypto');
        const signature = crypto.createHmac('sha256', secret)
          .update(JSON.stringify(payload))
          .digest('hex');
        ```

        ## 재시도 정책

        - 최대 3회 재시도
        - 지수 백오프 (1초, 2초, 4초)
        - 성공 응답: 2xx 상태 코드
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebhookCreateRequest'
      responses:
        '200':
          description: 웹훅 생성 성공
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
                        description: 웹훅 ID
                      name:
                        type: string
                        description: 웹훅 이름
                      secret:
                        type: string
                        description: |
                          웹훅 서명 시크릿.
                          **주의**: 이 값은 다시 조회할 수 없습니다. 안전하게 보관하세요.
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
      security:
        - BearerAuth: []
      x-codeSamples:
        - lang: curl
          label: cURL
          source: |-
            curl -X POST https://api.bizmori.com/api/v2/orders/webhooks \
              -H "Authorization: Bearer YOUR_API_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{
                "name": "My Webhook",
                "url": "https://example.com/webhook"
              }'
        - lang: javascript
          label: JavaScript
          source: >-
            const response = await
            fetch('https://api.bizmori.com/api/v2/orders/webhooks', {
              method: 'POST',
              headers: {
                'Authorization': 'Bearer YOUR_API_TOKEN',
                'Content-Type': 'application/json'
              },
              body: JSON.stringify({
                name: 'My Webhook',
                url: 'https://example.com/webhook'
              })
            });

            const data = await response.json();

            // Save data.data.secret securely — it won't be shown again
        - lang: python
          label: Python
          source: |-
            import requests

            response = requests.post(
                'https://api.bizmori.com/api/v2/orders/webhooks',
                headers={'Authorization': 'Bearer YOUR_API_TOKEN'},
                json={
                    'name': 'My Webhook',
                    'url': 'https://example.com/webhook'
                }
            )
            data = response.json()
            # Save data['data']['secret'] securely — it won't be shown again
components:
  schemas:
    WebhookCreateRequest:
      type: object
      required:
        - url
      properties:
        name:
          type: string
          maxLength: 100
          description: 웹훅 이름 (식별용)
        url:
          type: string
          format: uri
          description: 웹훅 엔드포인트 URL
          example: https://example.com/webhook
    ErrorResponse:
      type: object
      properties:
        code:
          type: string
          description: 에러 코드
  responses:
    BadRequest:
      description: 잘못된 요청
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            code: VALIDATION_FAILED
    Unauthorized:
      description: 인증 실패
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            code: AUTH_NOT_AUTHENTICATED
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: 외부 클라이언트 접근을 위한 API 키

````