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

# 인증

> BIZ MORI API 요청을 인증하는 방법

모든 API 엔드포인트는 **API 키**를 Bearer 토큰 형식으로 전달하여 인증해야 합니다.

## API 키 발급

1. [BIZ MORI 대시보드](https://app.bizmori.com)에 로그인합니다
2. [**API 키**](https://app.bizmori.com/keys)로 이동합니다
3. **신규 발급**을 클릭합니다
4. 키를 복사하여 안전하게 보관합니다 — **한 번만 표시됩니다**

<Warning>
  API 키는 계정의 API에 대한 전체 접근 권한을 부여합니다. 클라이언트 코드, 공개 저장소, 버전 관리 시스템에 절대 노출하지 마세요. 환경 변수로 저장하세요.
</Warning>

## API 키 사용 방법

모든 요청에서 `Authorization: Bearer` 헤더로 API 키를 전달합니다:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.bizmori.com/api/v2/orders/anti-ai \
    -H "Authorization: Bearer YOUR_API_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{"idempotencyKey": "unique-key", "files": [{"fileName": "image.jpg"}]}'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.bizmori.com/api/v2/orders/anti-ai', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_TOKEN',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      idempotencyKey: 'unique-key',
      files: [{ fileName: 'image.jpg' }],
    }),
  });

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://api.bizmori.com/api/v2/orders/anti-ai',
      headers={
          'Authorization': 'Bearer YOUR_API_TOKEN',
      },
      json={
          'idempotencyKey': 'unique-key',
          'files': [{'fileName': 'image.jpg'}],
      },
  )
  data = response.json()
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init('https://api.bizmori.com/api/v2/orders/anti-ai');
  curl_setopt_array($ch, [
      CURLOPT_POST           => true,
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_HTTPHEADER     => [
          'Authorization: Bearer YOUR_API_TOKEN',
          'Content-Type: application/json',
      ],
      CURLOPT_POSTFIELDS => json_encode([
          'idempotencyKey' => 'unique-key',
          'files'          => [['fileName' => 'image.jpg']],
      ]),
  ]);
  $data = json_decode(curl_exec($ch), true);
  curl_close($ch);
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'json'

  uri  = URI('https://api.bizmori.com/api/v2/orders/anti-ai')
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true

  req = Net::HTTP::Post.new(uri)
  req['Authorization'] = 'Bearer YOUR_API_TOKEN'
  req['Content-Type']  = 'application/json'
  req.body = JSON.generate(
    idempotencyKey: 'unique-key',
    files: [{ fileName: 'image.jpg' }]
  )

  data = JSON.parse(http.request(req).body)
  ```

  ```go Go theme={null}
  package main

  import (
  	"bytes"
  	"encoding/json"
  	"net/http"
  )

  func main() {
  	body, _ := json.Marshal(map[string]any{
  		"idempotencyKey": "unique-key",
  		"files":          []map[string]string{{"fileName": "image.jpg"}},
  	})

  	req, _ := http.NewRequest("POST",
  		"https://api.bizmori.com/api/v2/orders/anti-ai",
  		bytes.NewBuffer(body),
  	)
  	req.Header.Set("Authorization", "Bearer YOUR_API_TOKEN")
  	req.Header.Set("Content-Type", "application/json")

  	resp, _ := http.DefaultClient.Do(req)
  	defer resp.Body.Close()
  }
  ```

  ```java Java theme={null}
  import java.net.URI;
  import java.net.http.*;

  HttpClient client = HttpClient.newHttpClient();
  HttpRequest request = HttpRequest.newBuilder()
      .uri(URI.create("https://api.bizmori.com/api/v2/orders/anti-ai"))
      .header("Authorization", "Bearer YOUR_API_TOKEN")
      .header("Content-Type", "application/json")
      .POST(HttpRequest.BodyPublishers.ofString(
          "{\"idempotencyKey\":\"unique-key\",\"files\":[{\"fileName\":\"image.jpg\"}]}"
      ))
      .build();

  HttpResponse<String> response =
      client.send(request, HttpResponse.BodyHandlers.ofString());
  ```
</CodeGroup>

## 멱등성 (Idempotency)

모든 주문 생성 엔드포인트는 `idempotencyKey` 파라미터를 지원합니다. 동일한 키로 중복 요청을 보내면 새 주문을 생성하는 대신 **기존 주문을 반환**합니다. 네트워크 재시도 시 이중 처리를 방지할 수 있습니다.

```json theme={null}
{
  "idempotencyKey": "01960d3e-a4f2-7b3c-8a1d-4c7e2f9b0a3d",
  "files": [...]
}
```

**UUID v7**을 사용하는 것을 권장합니다. 비즈니스 로직에서 파생된 결정론적 키(예: `user-{id}-batch-{timestamp}`)도 사용할 수 있습니다.
