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

# Create AI Detection order

> 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


## How to upload the image

After receiving the `uploadUrl` from the response, upload your image directly to S3 using a `PUT` request:

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

<Note>
  The presigned upload URL expires after **10 minutes**. Upload your image before it expires, then call the [Confirm order](/api-reference/ai-detection/confirm-order) endpoint.
</Note>

## Getting the detection result

Once you confirm the upload, the order status changes to `inProgress`. When detection completes, the result is available via:

1. **Webhook** — Subscribe to `order.aiDetection.completed` or `order.aiDetection.failed` events
2. **Polling** — Call the [Get order](/api-reference/orders/get-order) endpoint until status is `complete` or `failed`

The detection result is included in the order detail response under `aiDetection`:

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

### Status Codes

| `statusCode` | Meaning                     |
| ------------ | --------------------------- |
| `1`          | Highly likely AI-generated  |
| `2`          | Likely AI-generated         |
| `3`          | Likely human-created        |
| `4`          | Highly likely human-created |


## OpenAPI

````yaml /api-reference/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

````