> ## 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.

# AI Detection 주문 생성

> AI Detection 주문을 생성하고 이미지 업로드를 위한 S3 프리사인드 URL을 발급합니다.

## 처리 흐름

1. 이 엔드포인트를 호출하여 프리사인드 업로드 URL을 발급받습니다
2. 발급된 프리사인드 URL로 이미지를 S3에 직접 업로드합니다
3. `POST /api/v2/orders/ai-detection/{orderId}/confirm` 을 호출하여 비동기 감지를 시작합니다
4. 웹훅 또는 주문 상세 조회 엔드포인트를 통해 결과를 확인합니다

## 주문 상태

| 상태 | 설명 |
|------|------|
| `pending` | 파일 업로드 대기 중 |
| `inProgress` | 감지 처리 중 |
| `complete` | 감지 완료, 결과 확인 가능 |
| `failed` | 감지 실패 |

## 지원 파일 형식

jpg, jpeg, png, webp, bmp, tiff


## 이미지 업로드 방법

응답에서 받은 `uploadUrl`을 사용하여 `PUT` 요청으로 S3에 직접 이미지를 업로드합니다:

```bash theme={null}
curl -X PUT "UPLOAD_URL" \
  -H "Content-Type: image/jpeg" \
  --data-binary @photo.jpg
```

<Note>
  프리사인드 업로드 URL은 **10분** 후 만료됩니다. 만료 전에 이미지를 업로드하고 [주문 확인](/ko/api-reference/ai-detection/confirm-order) 엔드포인트를 호출하세요.
</Note>

## 감지 결과 확인

업로드를 확인하면 주문 상태가 `inProgress`로 변경됩니다. 감지가 완료되면 다음 방법으로 결과를 확인할 수 있습니다:

1. **웹훅** — `order.aiDetection.completed` 또는 `order.aiDetection.failed` 이벤트 구독
2. **폴링** — [주문 상세 조회](/ko/api-reference/orders/get-order) 엔드포인트를 상태가 `complete` 또는 `failed`가 될 때까지 호출

감지 결과는 주문 상세 응답의 `aiDetection` 필드에 포함됩니다:

```json theme={null}
{
  "data": {
    "orderId": "...",
    "status": "complete",
    "aiDetection": {
      "probability": 0.97,
      "statusCode": 1
    }
  }
}
```

### 상태 코드

| `statusCode` | 의미                 |
| ------------ | ------------------ |
| `1`          | AI 생성 가능성 매우 높음    |
| `2`          | AI 생성 가능성 높음       |
| `3`          | 사람이 창작했을 가능성 높음    |
| `4`          | 사람이 창작했을 가능성 매우 높음 |


## OpenAPI

````yaml POST /api/v2/orders/ai-detection
openapi: 3.0.0
info:
  title: BIZ MORI API
  version: 2.0.0
  description: |
    BIZ MORI API provides four core services for digital content protection:
    - **Anti-AI**: Protect images from AI training
    - **Watermark Embed**: Embed invisible digital watermarks into images
    - **Watermark Extract**: Extract and verify watermarks from images
    - **AI Detection**: Detect whether an image is AI-generated
  contact:
    name: BIZ MORI Support
    email: support@bizmori.com
servers:
  - url: https://api.bizmori.com
    description: Production
security: []
tags:
  - name: Anti-AI
    description: Anti-AI image protection orders
  - name: Watermark Embed
    description: Watermark embedding orders
  - name: Watermark Extract
    description: Watermark extraction orders
  - name: AI Detection
    description: AI-generated image detection orders
  - name: Orders
    description: Order query and management
  - name: Webhooks
    description: Webhook configuration and events
paths:
  /api/v2/orders/ai-detection:
    post:
      tags:
        - AI Detection
      summary: Create AI Detection order
      description: >
        Creates an AI Detection order and issues a presigned S3 upload URL for
        the image.


        ## Flow


        1. Call this endpoint to receive a presigned upload URL

        2. Upload the image directly to S3 using the presigned URL

        3. Call `POST /api/v2/orders/ai-detection/confirm` to start async
        detection

        4. Use webhooks or poll the order detail endpoint for the result


        ## Order Status


        | Status | Description |

        |--------|-------------|

        | `pending` | Waiting for file upload |

        | `inProgress` | Detection is in progress |

        | `complete` | Detection complete, result available |

        | `failed` | Detection failed |


        ## Supported Formats


        jpg, jpeg, png, webp, bmp, tiff
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - idempotencyKey
                - fileName
              properties:
                idempotencyKey:
                  type: string
                  description: Idempotency key to prevent duplicate requests
                  example: key-ai-detection-001
                orderName:
                  type: string
                  maxLength: 64
                  description: Order name (optional, auto-generated if not provided)
                  example: my-detection-order
                fileName:
                  type: string
                  description: >-
                    Image file name with extension. Supported: jpg, jpeg, png,
                    webp, bmp, tiff
                  example: photo.jpg
                options:
                  type: object
                  description: >-
                    Output options (optional). Generated files are included in
                    the order detail response.
                  properties:
                    generateHeatmap:
                      type: boolean
                      default: false
                      description: Generate AI detection heatmap image
                    generateOverlay:
                      type: boolean
                      default: false
                      description: Generate heatmap overlay on original image
                    generateThumbnail:
                      type: boolean
                      default: false
                      description: Generate thumbnail image
      responses:
        '200':
          description: Order created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      orderId:
                        type: string
                        description: Order ID
                      orderName:
                        type: string
                        description: Order name
                      status:
                        type: string
                        enum:
                          - pending
                        description: Order status
                      file:
                        type: object
                        properties:
                          fileId:
                            type: integer
                            description: File record ID
                          fileName:
                            type: string
                            description: File name
                          uploadUrl:
                            type: string
                            format: uri
                            description: Presigned S3 URL for direct file upload
                          fileKey:
                            type: string
                            description: S3 file key
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/UsageLimitExceeded'
      security:
        - BearerAuth: []
      x-codeSamples:
        - lang: curl
          label: cURL
          source: |-
            curl -X POST https://api.bizmori.com/api/v2/orders/ai-detection \
              -H "Authorization: Bearer YOUR_API_TOKEN" \
              -H "Content-Type: application/json" \
              -d '{"idempotencyKey": "key-ai-001", "fileName": "photo.jpg"}'
        - lang: javascript
          label: JavaScript
          source: >-
            const response = await
            fetch('https://api.bizmori.com/api/v2/orders/ai-detection', {
              method: 'POST',
              headers: {
                'Authorization': 'Bearer YOUR_API_TOKEN',
                'Content-Type': 'application/json'
              },
              body: JSON.stringify({
                idempotencyKey: 'key-ai-001',
                fileName: 'photo.jpg'
              })
            });

            const data = await response.json();
        - lang: python
          label: Python
          source: |-
            import requests

            response = requests.post(
                'https://api.bizmori.com/api/v2/orders/ai-detection',
                headers={'Authorization': 'Bearer YOUR_API_TOKEN'},
                json={'idempotencyKey': 'key-ai-001', 'fileName': 'photo.jpg'}
            )
            data = response.json()
components:
  responses:
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            code: VALIDATION_FAILED
    Unauthorized:
      description: Authentication failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            code: AUTH_NOT_AUTHENTICATED
    UsageLimitExceeded:
      description: Usage limit exceeded
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            code: USAGE_LIMIT_EXCEEDED
  schemas:
    ErrorResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: API Key for external client access

````