<!DOCTYPE html><html lang="ko"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>미담허브 API 문서</title><style>body{font-family:monospace;white-space:pre-wrap;padding:2rem;max-width:900px;margin:0 auto}</style></head><body># aimidam 물류 허브 API — AI 연동 문서

&gt; 버전 1.2.0 · 명세 기준 2026-11-22 · 생성 2026-11-22 15:20 KST
&gt; 원본 명세: https://hub.aimidam.com/docs/openapi-3.1.yaml

이 문서는 AI 에이전트가 외부 검색 없이 API를 연동하도록 작성됐다.
규칙: `llms.txt` → 이 문서 → 필요 시 OpenAPI 원본 순으로 읽는다.

<a id="change-log"></a>
## API 버전·호환성 정책

현재 공개 문서 계약 버전은 **1.2.0**입니다. `GET /api/external/partner/health` 응답의 `api_version: v2`는 런타임 파트너 API 계열을 뜻하며 문서 계약 버전과 구분합니다. 최신 문서와 OpenAPI 원본은 [API 안내](/api-guide), [OpenAPI 3.1](/docs/openapi-3.1.yaml)에서 확인합니다.

호환 가능한 변경:
- 기존 응답에 새 JSON 키를 추가하되 기존 키와 의미를 유지
- 선택 필드·선택 query를 추가
- 설명·예제·FAQ 같은 문서를 추가
- 기존 주소와 기존 필수 필드를 유지한 범위의 확장

비호환 변경:
- API 주소 삭제·이름 변경 또는 HTTP method 변경
- 기존 응답 JSON 키 삭제·이름 변경·의미 변경
- 기존 필드를 필수로 바꾸거나 인증·source 격리 동작을 변경
- 비호환 변경은 새 문서/API 버전과 마이그레이션 안내를 먼저 제공합니다. 기존 버전을 자동 폐기하거나 강제 마이그레이션하지 않습니다.

기존 파트너 연동을 보호하기 위해 API 주소, 응답 JSON 키, 기존 필수 필드는 유지합니다. 현재 무료 베타·test 키 정책은 기존 안내 범위에서만 적용됩니다.

### 주요 변경기록 (PR #19~#37)

- PR #19~#24: API 요청 로그·test 키 한도, 공개 페이지 메타/사이트맵, FAQ·API 안내 기능을 정리했습니다.
- PR #25~#27: 공개 화면 흐름·홈 링크와 관리자 통계 오류를 보완했습니다.
- PR #28~#31: 업체 개발자용 API 색인, 공개 유입 분석과 전환 확인 기반을 만들었습니다.
- PR #32~#34: 문의 채널·공개 가이드·비교 페이지·이벤트 추적을 확장했습니다.
- PR #35~#37: 파트너 셀프서비스와 업체 포털의 웹훅·사용량·결제 카드, 공개 연동 진입 흐름을 보강했습니다.
- 이 기록의 링크 기준점: [API 안내 빠른 시작](/api-guide#quickstart), [공개 AI/API 진입점](https://hub.aimidam.com/llms.txt).

## 엔드포인트 트리

```text
System        3개  헬스체크·공개 정보
Partner       4개  파트너 운영 API (DB 기록, 멱등)
Order         1개  전체 필드 발주
Warehouse     5개  입고·출고·재고·오류 접수
Tracking      1개  배송 상태·운송장 조회
Pricing       1개  운임 계산
Reference     1개  HS코드 등 참조 데이터
Webhooks      1개  상태 변경 통지 (허브 → 고객)
Compat       19개  호환용 mock (신규 연동 금지)

합계 36개
```

## 인증

- 운영 API: `X-Company-Id` + `X-Api-Key` 두 헤더가 모두 필요하다.
- 키는 업체 포털 `#portal/keys`에서 발급한다. 서버에만 보관한다.
- 인증 실패: `401 {&quot;success&quot;:false,&quot;error&quot;:&quot;unauthorized&quot;}`
- 공개 API와 mock에는 인증 헤더가 필요 없다.

## 연동 절차

### 신규 파트너 최초 연동

처음 연결할 때는 실제 주문을 만들지 않는 읽기·조회 흐름부터 확인합니다.

1. [업체 가입](/portal-signup) 후 [파트너 포털](/portal-partner-portal)에서 관리자 승인과 test 키 발급을 완료합니다.
2. `GET /api/external/partner/health`를 호출해 키와 연결을 확인합니다. 성공 응답은 `200`과 `success: true`입니다.
3. `POST /api/external/partner/quote`로 배송비 견적을 확인합니다. 요청 body는 아래 배송비 계약을 그대로 사용합니다.
4. `GET /api/external/partner/tracking?tracking_number=...`으로 송장 조회를 확인합니다. test 환경에서는 조회 가능한 송장번호를 사용하세요.
5. 위 순서는 [개발자 가이드의 실행 예제](/api-guide#quickstart)와 [Postman 실행 순서](/api-guide#quickstart)로도 확인할 수 있습니다.
6. health·배송비·송장 조회가 확인된 뒤 live 키와 주문 연동을 검토합니다. 주문·결제 요청은 이 최초 연결 확인 단계에 포함하지 않습니다.

7. Python 표준 라이브러리와 Postman 예제는 [API 안내 빠른 시작](/api-guide#quickstart)에 있습니다. Postman 변수는 `hub_base_url`, `hub_company_id`, `hub_api_key`, `hub_tracking_number`를 사용하고 요청 순서는 health → quote → tracking입니다.

#### Python (표준 라이브러리)

```python
import json
import os
import urllib.error
import urllib.request

base_url = os.environ[&quot;HUB_BASE_URL&quot;]
headers = {
    &quot;X-Company-Id&quot;: os.environ[&quot;HUB_COMPANY_ID&quot;],
    &quot;X-Api-Key&quot;: os.environ[&quot;HUB_API_KEY&quot;],
}

def call(method, path, body=None):
    data = json.dumps(body).encode() if body is not None else None
    request_headers = {**headers, &quot;Content-Type&quot;: &quot;application/json&quot;} if body is not None else headers
    request = urllib.request.Request(base_url + path, data=data, headers=request_headers, method=method)
    try:
        with urllib.request.urlopen(request, timeout=10) as response:
            print(response.status, response.read().decode())
    except urllib.error.HTTPError as error:
        print(error.code, error.read().decode())

call(&quot;GET&quot;, &quot;/api/external/partner/health&quot;)
call(&quot;POST&quot;, &quot;/api/external/partner/quote&quot;, {
    &quot;shipping_method&quot;: &quot;sea&quot;,
    &quot;weight_kg&quot;: 1.5,
    &quot;length_cm&quot;: 30,
    &quot;width_cm&quot;: 20,
    &quot;height_cm&quot;: 10,
})
call(&quot;GET&quot;, &quot;/api/external/partner/tracking?tracking_number=&quot; + os.environ[&quot;HUB_TRACKING_NUMBER&quot;])
```

### 웹훅 수신 처리

- 1. 업체 포털 키 관리 화면에서 `callback_url`을 등록한다. 등록하지 않으면 발송되지 않는다.
- 2. 수신 직후 raw body 바이트를 그대로 보관한다. JSON 파싱 후 재직렬화하면 서명 검증이 실패한다.
- 3. `hash_hmac(&quot;sha256&quot;, rawBody, webhook_secret)`의 16진수 결과와 `X-Webhook-Signature`를 `hash_equals`로 비교한다.
- 4. `source`가 자사 업체 값인지 확인하고 `external_order_no`로 자기 주문과 매칭한다.
- 5. 2xx로 즉시 응답한다. 허브는 재시도와 전송 기록이 없으므로 실패 응답은 유실된다.

### 오류 처리 규칙

- 401: 키·회사 ID가 틀렸거나 누락. 헤더 두 개를 다시 확인하고 키를 재발급한다.
- 400: 필수 필드 누락. 응답 `error` 값이 빠진 필드명이다.
- 404: `external_order_no` 또는 운송장 번호가 허브에 없다. 발주가 성공했는지 먼저 확인한다.
- 409: 같은 주문번호로 다른 본문이 들어왔거나 처리 중이다. 본문을 바꾸지 말고 기존 주문을 조회한다.
- 422: 필드 형식·범위 오류. `items` 또는 `errors`에 구체적 사유가 있다.
- 503: 멱등 처리 불가. 잠시 후 같은 본문으로 재시도해도 중복 생성되지 않는다.
- mock 응답(`&quot;mock&quot;:true`)이 오면 DB에 아무것도 기록되지 않은 것이다. 운영 경로로 다시 호출한다.

## 엔드포인트 상세

### [System] 헬스체크·공개 정보

<a id="get-ping"></a>
#### GET /api/ping — 헬스 체크

- 인증: 불필요

호출 예시:

```bash
curl -X GET &quot;https://hub.aimidam.com/api/ping&quot; \
  -H &quot;Content-Type: application/json&quot;
```

성공 `200`:

```json
{
  &quot;ok&quot;: true
}
```

---

#### GET /api/exchange-rate — 적용 환율 조회

- 인증: 불필요

호출 예시:

```bash
curl -X GET &quot;https://hub.aimidam.com/api/exchange-rate&quot; \
  -H &quot;Content-Type: application/json&quot;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;rate&quot;: 215.0
}
```

---

#### GET /api/postcode-proxy — 다음 우편번호 스크립트 프록시

- 인증: 불필요

호출 예시:

```bash
curl -X GET &quot;https://hub.aimidam.com/api/postcode-proxy&quot; \
  -H &quot;Content-Type: application/json&quot;
```

성공 `200`:

```json
null
```

---

### [Partner] 파트너 운영 API (DB 기록, 멱등)

<a id="post-external-partner-orders"></a>
#### POST /api/external/partner/orders — 파트너 발주 접수 (실제 주문 생성)

external_order_no 기준 멱등. 같은 번호 재전송 시 중복 생성되지 않는다.

- 인증: 필요 (X-Company-Id + X-Api-Key)

| 필드 | 위치 | 필수 | 타입 | 예시 | 설명 |
|---|---|---|---|---|---|
| `external_order_no` | body | **필수** | string | `SITE-2026-0001` | 멱등 키로 쓰는 외부 주문번호 |
| `receiver_name` | body | **필수** | string | `홍길동` |  |
| `receiver_phone` | body | **필수** | string | `1012345678` |  |
| `receiver_address` | body | — | string | `` |  |
| `receiver_zipcode` | body | — | string | `` |  |
| `weight_kg` | body | — | number | `` | actual_weight에 저장되며 운임 계산에는 사용되지 않음 |
| `product_title` | body | — | string | `` |  |
| `customer_note` | body | — | string | `` |  |
| `tracking_numbers` | body | — | array | `` | 현재 products_json에 그대로 저장됨 |

호출 예시:

```bash
curl -X POST &quot;https://hub.aimidam.com/api/external/partner/orders&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -H &quot;X-Company-Id: pk_test_...&quot; \
  -H &quot;X-Api-Key: YOUR_API_KEY&quot; \
  -d &#039;{
  &quot;external_order_no&quot;: &quot;SITE-2026-0001&quot;,
  &quot;receiver_name&quot;: &quot;홍길동&quot;,
  &quot;receiver_phone&quot;: 1012345678
}&#039;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;duplicate&quot;: true,
  &quot;source&quot;: &quot;문자열&quot;,
  &quot;external_order_no&quot;: &quot;문자열&quot;,
  &quot;quote_id&quot;: 0,
  &quot;order_no&quot;: &quot;문자열&quot;,
  &quot;status&quot;: &quot;received&quot;
}
```

오류:

| 코드 | 의미 | 응답 예시 |
|---|---|---|
| `400` | 필수값 누락 또는 잘못된 요청 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;external_order_no_required&quot;}` |
| `401` | 인증 실패 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;unauthorized&quot;}` |
| `409` | 주문 충돌 또는 처리 중 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;문자열&quot;}` |
| `503` | 멱등 처리 불가 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;문자열&quot;}` |

---

<a id="get-external-partner-order-status"></a>
#### GET /api/external/partner/order-status — 파트너 주문 상태 조회

- 인증: 필요 (X-Company-Id + X-Api-Key)

| 필드 | 위치 | 필수 | 타입 | 예시 | 설명 |
|---|---|---|---|---|---|
| `external_order_no` | query | **필수** | string | `SITE-2026-0001` |  |

호출 예시:

```bash
curl -X GET &quot;https://hub.aimidam.com/api/external/partner/order-status?external_order_no=SITE-2026-0001&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -H &quot;X-Company-Id: pk_test_...&quot; \
  -H &quot;X-Api-Key: YOUR_API_KEY&quot;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;source&quot;: &quot;문자열&quot;,
  &quot;external_order_no&quot;: &quot;문자열&quot;,
  &quot;order_no&quot;: &quot;문자열&quot;,
  &quot;status&quot;: &quot;received&quot;
}
```

오류:

| 코드 | 의미 | 응답 예시 |
|---|---|---|
| `400` | 필수값 누락 또는 잘못된 요청 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;external_order_no_required&quot;}` |
| `401` | 인증 실패 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;unauthorized&quot;}` |
| `404` | 대상 없음 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;not_found&quot;}` |

---

<a id="post-external-partner-status-change"></a>
#### POST /api/external/partner/status-change — 허브 상태 변경 및 웹훅 발송

등록된 callback_url이 있으면 서명된 웹훅을 1회 발송한다(재시도 없음).

- 인증: 필요 (X-Company-Id + X-Api-Key)

| 필드 | 위치 | 필수 | 타입 | 예시 | 설명 |
|---|---|---|---|---|---|
| `external_order_no` | body | **필수** | string | `` |  |
| `status` | body | **필수** | string | `` |  |

호출 예시:

```bash
curl -X POST &quot;https://hub.aimidam.com/api/external/partner/status-change&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -H &quot;X-Company-Id: pk_test_...&quot; \
  -H &quot;X-Api-Key: YOUR_API_KEY&quot; \
  -d &#039;{
  &quot;external_order_no&quot;: &quot;문자열&quot;,
  &quot;status&quot;: &quot;문자열&quot;
}&#039;
```

성공 `200`:

```json
{
  &quot;callback&quot;: {
    &quot;skipped&quot;: true,
    &quot;status&quot;: 0,
    &quot;error&quot;: &quot;문자열&quot;
  }
}
```

오류:

| 코드 | 의미 | 응답 예시 |
|---|---|---|
| `400` | 필수값 누락 또는 잘못된 요청 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;external_order_no_required&quot;}` |
| `401` | 인증 실패 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;unauthorized&quot;}` |
| `404` | 대상 없음 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;not_found&quot;}` |

---

<a id="get-external-partner-billing"></a>
#### GET /api/external/partner/billing — 파트너 월별 청구 조회 (최근 12개월)

- 인증: 필요 (X-Company-Id + X-Api-Key)

호출 예시:

```bash
curl -X GET &quot;https://hub.aimidam.com/api/external/partner/billing&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -H &quot;X-Company-Id: pk_test_...&quot; \
  -H &quot;X-Api-Key: YOUR_API_KEY&quot;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;source&quot;: &quot;문자열&quot;,
  &quot;items&quot;: [
    {
      &quot;source&quot;: &quot;문자열&quot;,
      &quot;billing_month&quot;: &quot;2026-11&quot;,
      &quot;order_count&quot;: 0,
      &quot;total_weight_kg&quot;: 0,
      &quot;amount_krw&quot;: 0,
      &quot;status&quot;: &quot;open&quot;
    }
  ]
}
```

오류:

| 코드 | 의미 | 응답 예시 |
|---|---|---|
| `401` | 인증 실패 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;unauthorized&quot;}` |

---

### [Order] 전체 필드 발주

#### POST /api/orders — 전체 필드 발주 접수

통관정보·HS코드·SKU·부가서비스까지 받는 실제 발주 경로.
`receiver_name`, `receiver_phone`(또는 `phone`), `receiver_address` 필수.
`customs_type`이 `business`가 아니면 `customs_id` 필수.
상품 HS코드가 없으면 거절된다(`1688club` source 제외).

- 인증: 필요 (X-Company-Id + X-Api-Key)

| 필드 | 위치 | 필수 | 타입 | 예시 | 설명 |
|---|---|---|---|---|---|
| `external_order_no` | body | **필수** | string | `` | 멱등 키 |
| `receiver_name` | body | **필수** | string | `` |  |
| `receiver_phone` | body | **필수** | string | `` |  |
| `phone` | body | — | string | `` | receiver_phone 대체 |
| `receiver_zipcode` | body | — | string | `` |  |
| `postal_code` | body | — | string | `` |  |
| `zipcode` | body | — | string | `` |  |
| `receiver_address` | body | **필수** | string | `` |  |
| `receiver_address_detail` | body | — | string | `` |  |
| `address_detail` | body | — | string | `` |  |
| `customs_type` | body | — | string | `` |  |
| `customs_id` | body | — | string | `` | personal일 때 필수 |
| `business_number` | body | — | string | `` |  |
| `foreigner_number` | body | — | string | `` |  |
| `receiver_name_en` | body | — | string | `` |  |
| `recipient_name_en` | body | — | string | `` |  |
| `shipping_center` | body | — | string | `` |  |
| `shipping_method` | body | — | string | `` |  |
| `delivery_request` | body | — | string | `` |  |
| `delivery_memo` | body | — | string | `` |  |
| `declared_amount` | body | — | string | `` |  |
| `declared_currency` | body | — | string | `` |  |
| `customer_note` | body | — | string | `` |  |
| `memo` | body | — | string | `` |  |
| `logistics_request` | body | — | string | `` |  |
| `tracking_numbers` | body | — | array | `` |  |
| `sku_info` | body | — | array | `` |  |
| `selected_options` | body | — | array | `` |  |
| `services` | body | — | array | `` |  |
| `extra_services` | body | — | array | `` |  |

호출 예시:

```bash
curl -X POST &quot;https://hub.aimidam.com/api/orders&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -H &quot;X-Company-Id: pk_test_...&quot; \
  -H &quot;X-Api-Key: YOUR_API_KEY&quot; \
  -d &#039;{
  &quot;external_order_no&quot;: &quot;문자열&quot;,
  &quot;receiver_name&quot;: &quot;문자열&quot;,
  &quot;receiver_phone&quot;: &quot;문자열&quot;,
  &quot;receiver_address&quot;: &quot;문자열&quot;
}&#039;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;order_no&quot;: &quot;문자열&quot;,
  &quot;orderSource&quot;: &quot;문자열&quot;,
  &quot;status&quot;: &quot;received&quot;,
  &quot;company&quot;: &quot;문자열&quot;,
  &quot;env&quot;: &quot;문자열&quot;,
  &quot;user_id&quot;: 0
}
```

오류:

| 코드 | 의미 | 응답 예시 |
|---|---|---|
| `401` | 인증 실패 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;unauthorized&quot;}` |
| `409` | 주문 충돌 또는 처리 중 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;문자열&quot;}` |
| `422` | 유효성 검증 실패 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;문자열&quot;}` |
| `500` | 생성 실패 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;문자열&quot;}` |

---

### [Warehouse] 입고·출고·재고·오류 접수

#### POST /api/inbound/scan — 입고 바코드 스캔

API 키의 source로 테넌트 범위를 제한한다.

- 인증: 필요 (X-Company-Id + X-Api-Key)

| 필드 | 위치 | 필수 | 타입 | 예시 | 설명 |
|---|---|---|---|---|---|
| `barcode` | body | **필수** | string | `` |  |

호출 예시:

```bash
curl -X POST &quot;https://hub.aimidam.com/api/inbound/scan&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -H &quot;X-Company-Id: pk_test_...&quot; \
  -H &quot;X-Api-Key: YOUR_API_KEY&quot; \
  -d &#039;{
  &quot;barcode&quot;: &quot;문자열&quot;
}&#039;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;scanId&quot;: 0,
  &quot;alreadyCompleted&quot;: true,
  &quot;photos&quot;: [
    {
      &quot;id&quot;: 0,
      &quot;path&quot;: &quot;문자열&quot;,
      &quot;url&quot;: &quot;문자열&quot;,
      &quot;sortOrder&quot;: 0
    }
  ]
}
```

오류:

| 코드 | 의미 | 응답 예시 |
|---|---|---|
| `401` | 인증 실패 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;unauthorized&quot;}` |
| `404` | 대상 없음 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;not_found&quot;}` |
| `422` | 유효성 검증 실패 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;문자열&quot;}` |

---

#### POST /api/outbound/scan — 출고 바코드 스캔

`route`(air|sea)와 주문 경로가 다르면 `mismatch`.
결제완료 주문은 `shipping_ready`로 변경한 후 `ready`를 반환한다.
몰 연동 콜백은 `MALL_API_TOKEN`/`MALL_API_URL`이 정의된 경우에만 발송되며 현재는 미정의다.

- 인증: 필요 (X-Company-Id + X-Api-Key)

| 필드 | 위치 | 필수 | 타입 | 예시 | 설명 |
|---|---|---|---|---|---|
| `route` | body | — | string | `` |  |

호출 예시:

```bash
curl -X POST &quot;https://hub.aimidam.com/api/outbound/scan&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -H &quot;X-Company-Id: pk_test_...&quot; \
  -H &quot;X-Api-Key: YOUR_API_KEY&quot; \
  -d &#039;{}&#039;
```

성공 `200`:

```json
{
  &quot;outcome&quot;: &quot;ready&quot;,
  &quot;message&quot;: &quot;문자열&quot;,
  &quot;orderIds&quot;: [
    0
  ],
  &quot;not_found&quot;: true
}
```

오류:

| 코드 | 의미 | 응답 예시 |
|---|---|---|
| `401` | 인증 실패 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;unauthorized&quot;}` |
| `404` | 대상 없음 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;not_found&quot;}` |
| `422` | 유효성 검증 실패 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;문자열&quot;}` |

---

#### POST /api/inventory/request — 재고(입고 예정) 신청

상품정보 1건 이상 필요. 현재 생성 건의 `order_source`는 `midam`으로 기록되므로
호출사 source 기준 조회에서는 보이지 않는다(기존 동작).

- 인증: 필요 (X-Company-Id + X-Api-Key)

| 필드 | 위치 | 필수 | 타입 | 예시 | 설명 |
|---|---|---|---|---|---|
| `tracking_numbers` | body | — | array | `` |  |
| `trackings` | body | — | array | `` |  |
| `product_url` | body | — | string | `` |  |
| `product_title` | body | — | string | `` |  |
| `product_name` | body | — | string | `` |  |
| `product_image` | body | — | string | `` |  |
| `quantity` | body | — | integer | `` |  |
| `manual_quantity` | body | — | integer | `` |  |
| `manual_unit_price` | body | — | number | `` |  |
| `shipping_center` | body | — | string | `` |  |
| `customer_note` | body | — | string | `` |  |
| `memo` | body | — | string | `` |  |

호출 예시:

```bash
curl -X POST &quot;https://hub.aimidam.com/api/inventory/request&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -H &quot;X-Company-Id: pk_test_...&quot; \
  -H &quot;X-Api-Key: YOUR_API_KEY&quot; \
  -d &#039;{}&#039;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;message&quot;: &quot;문자열&quot;,
  &quot;order_number&quot;: &quot;문자열&quot;,
  &quot;quote_id&quot;: 0,
  &quot;inventory_number&quot;: &quot;문자열&quot;,
  &quot;status&quot;: &quot;문자열&quot;,
  &quot;nodata_attached&quot;: 0
}
```

오류:

| 코드 | 의미 | 응답 예시 |
|---|---|---|
| `401` | 인증 실패 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;unauthorized&quot;}` |
| `422` | 유효성 검증 실패 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;문자열&quot;}` |

---

#### POST /api/inventory/search — 가용재고 검색

검수완료(`inspected`) 상태 재고만 반환한다. `limit`은 1~50.

- 인증: 필요 (X-Company-Id + X-Api-Key)

| 필드 | 위치 | 필수 | 타입 | 예시 | 설명 |
|---|---|---|---|---|---|
| `query` | body | — | string | `` |  |
| `limit` | body | — | integer | `` |  |

호출 예시:

```bash
curl -X POST &quot;https://hub.aimidam.com/api/inventory/search&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -H &quot;X-Company-Id: pk_test_...&quot; \
  -H &quot;X-Api-Key: YOUR_API_KEY&quot; \
  -d &#039;{}&#039;
```

성공 `200`:

```json
[
  {
    &quot;quote_id&quot;: 0,
    &quot;inventory_number&quot;: &quot;문자열&quot;,
    &quot;order_number&quot;: &quot;문자열&quot;,
    &quot;shipping_center&quot;: &quot;문자열&quot;,
    &quot;product_index&quot;: 0,
    &quot;name&quot;: &quot;문자열&quot;,
    &quot;name_en&quot;: &quot;문자열&quot;,
    &quot;color&quot;: &quot;문자열&quot;,
    &quot;size&quot;: &quot;문자열&quot;,
    &quot;price&quot;: 0,
    &quot;image&quot;: &quot;문자열&quot;,
    &quot;url&quot;: &quot;문자열&quot;,
    &quot;remaining_qty&quot;: 0,
    &quot;quantity&quot;: 0
  }
]
```

오류:

| 코드 | 의미 | 응답 예시 |
|---|---|---|
| `401` | 인증 실패 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;unauthorized&quot;}` |
| `422` | 유효성 검증 실패 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;문자열&quot;}` |

---

#### POST /api/inbound/error — 노데이타(오류 입고) 접수

`mailbox`가 API 키 사용자에게 속해야 한다(불일치 시 403).
알림톡 발송은 `ALIMTALK_NODATA_NOTIFY_ENABLED`가 정의된 경우에만 이뤄지며 현재는 미정의다.

- 인증: 필요 (X-Company-Id + X-Api-Key)

| 필드 | 위치 | 필수 | 타입 | 예시 | 설명 |
|---|---|---|---|---|---|
| `tracking_number` | body | **필수** | string | `` |  |
| `mailbox` | body | **필수** | string | `` |  |
| `product_name` | body | **필수** | string | `` |  |
| `quantity` | body | — | integer | `` |  |
| `cod_fee` | body | — | number | `` |  |
| `photos` | body | — | array | `` |  |

호출 예시:

```bash
curl -X POST &quot;https://hub.aimidam.com/api/inbound/error&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -H &quot;X-Company-Id: pk_test_...&quot; \
  -H &quot;X-Api-Key: YOUR_API_KEY&quot; \
  -d &#039;{
  &quot;tracking_number&quot;: &quot;문자열&quot;,
  &quot;mailbox&quot;: &quot;문자열&quot;,
  &quot;product_name&quot;: &quot;문자열&quot;
}&#039;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;message&quot;: &quot;문자열&quot;,
  &quot;receipt&quot;: {
    &quot;id&quot;: 0,
    &quot;tracking_number&quot;: &quot;문자열&quot;,
    &quot;mailbox_number&quot;: &quot;문자열&quot;,
    &quot;matched_username&quot;: &quot;문자열&quot;,
    &quot;product_name&quot;: &quot;문자열&quot;,
    &quot;quantity&quot;: 0,
    &quot;cod_fee&quot;: 0
  }
}
```

오류:

| 코드 | 의미 | 응답 예시 |
|---|---|---|
| `401` | 인증 실패 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;unauthorized&quot;}` |
| `403` | 사서함 불일치 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;문자열&quot;}` |
| `422` | 유효성 검증 실패 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;문자열&quot;}` |

---

### [Tracking] 배송 상태·운송장 조회

#### POST /api/tracking — 운송장 번호로 배송 상태 조회

이름은 마스킹되어 반환된다. API 키 source 범위의 주문만 조회된다.

- 인증: 필요 (X-Company-Id + X-Api-Key)

| 필드 | 위치 | 필수 | 타입 | 예시 | 설명 |
|---|---|---|---|---|---|
| `tracking_number` | body | **필수** | string | `` |  |

호출 예시:

```bash
curl -X POST &quot;https://hub.aimidam.com/api/tracking&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -H &quot;X-Company-Id: pk_test_...&quot; \
  -H &quot;X-Api-Key: YOUR_API_KEY&quot; \
  -d &#039;{
  &quot;tracking_number&quot;: &quot;문자열&quot;
}&#039;
```

성공 `200`:

```json
{
  &quot;shipment&quot;: {
    &quot;order_number&quot;: &quot;문자열&quot;,
    &quot;tracking_number&quot;: &quot;문자열&quot;,
    &quot;domestic_tracking&quot;: &quot;문자열&quot;,
    &quot;type&quot;: &quot;구매대행&quot;,
    &quot;status&quot;: &quot;문자열&quot;,
    &quot;status_label&quot;: &quot;문자열&quot;,
    &quot;product_title&quot;: &quot;문자열&quot;,
    &quot;recipient_name&quot;: &quot;문자열&quot;,
    &quot;created_at&quot;: &quot;문자열&quot;,
    &quot;updated_at&quot;: &quot;문자열&quot;
  },
  &quot;tracking&quot;: {}
}
```

오류:

| 코드 | 의미 | 응답 예시 |
|---|---|---|
| `401` | 인증 실패 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;unauthorized&quot;}` |
| `404` | 대상 없음 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;not_found&quot;}` |

---

### [Pricing] 운임 계산

#### POST /api/calculator — 운임 계산

`?action=shipping` 쿼리가 필수. 인증은 없지만 쓰기 동작은 없다.
항공은 실중량/부피무게 중 큰 값, 해운은 실중량, LCL은 CBM 기준.

- 인증: 필요 (X-Company-Id + X-Api-Key)

| 필드 | 위치 | 필수 | 타입 | 예시 | 설명 |
|---|---|---|---|---|---|
| `action` | query | **필수** | string | `` |  |
| `center_id` | body | — | integer | `` |  |
| `shipping_method` | body | — | string | `` |  |
| `weight_kg` | body | — | number | `` |  |
| `length_cm` | body | — | number | `` |  |
| `width_cm` | body | — | number | `` |  |
| `height_cm` | body | — | number | `` |  |
| `sea_port` | body | — | string | `` |  |
| `grade_level` | body | — | integer | `` |  |
| `extra_fees` | body | — | array | `` |  |

호출 예시:

```bash
curl -X POST &quot;https://hub.aimidam.com/api/calculator?action=문자열&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -H &quot;X-Company-Id: pk_test_...&quot; \
  -H &quot;X-Api-Key: YOUR_API_KEY&quot; \
  -d &#039;{}&#039;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;data&quot;: {
    &quot;total&quot;: 0,
    &quot;shipping_fee&quot;: 0,
    &quot;courier_extra_fee&quot;: 0,
    &quot;rate_route&quot;: &quot;문자열&quot;,
    &quot;chargeable_weight&quot;: 0
  }
}
```

오류:

| 코드 | 의미 | 응답 예시 |
|---|---|---|
| `400` | 필수값 누락 또는 잘못된 요청 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;external_order_no_required&quot;}` |
| `500` | 계산 오류 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;문자열&quot;}` |

---

### [Reference] HS코드 등 참조 데이터

<a id="get-hscode"></a>
#### GET /api/hscode — HS코드 검색

`keyword` 또는 `category` 중 하나는 필수.

- 인증: 불필요

| 필드 | 위치 | 필수 | 타입 | 예시 | 설명 |
|---|---|---|---|---|---|
| `keyword` | query | — | string | `` |  |
| `category` | query | — | string | `` |  |

호출 예시:

```bash
curl -X GET &quot;https://hub.aimidam.com/api/hscode&quot; \
  -H &quot;Content-Type: application/json&quot;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;data&quot;: [
    {
      &quot;id&quot;: &quot;문자열&quot;,
      &quot;code_6digit&quot;: &quot;문자열&quot;,
      &quot;code_10digit&quot;: &quot;문자열&quot;,
      &quot;name_kr&quot;: &quot;문자열&quot;,
      &quot;category&quot;: &quot;문자열&quot;,
      &quot;category_name&quot;: &quot;문자열&quot;,
      &quot;tariff_rate&quot;: 0
    }
  ]
}
```

오류:

| 코드 | 의미 | 응답 예시 |
|---|---|---|
| `400` | 필수값 누락 또는 잘못된 요청 | `{&quot;success&quot;: false, &quot;error&quot;: &quot;external_order_no_required&quot;}` |

---

### 테스트 Webhook (파트너 포털)

로그인한 승인 업체는 `/portal-partner-portal`의 **테스트 Webhook 발송**에서 실제 주문·재고·결제 변경 없이 저장된 자기 업체 callback URL로 테스트 이벤트를 보낼 수 있습니다.

제공 이벤트는 아래 3개입니다.

- `inbound_completed`
- `customs_hold`
- `domestic_tracking_issued`

테스트 요청은 기존 Webhook과 같은 JSON 필드(`event_id`, `event_version`, `event_type`, `source`, `external_order_no`)와 HMAC-SHA256 서명을 사용합니다. 수신 서버는 raw body와 기존 webhook secret으로 다음 값을 계산해 `X-Webhook-Signature`와 비교하세요.

```text
hash_hmac(&#039;sha256&#039;, rawBody, webhook_secret)
```

`X-Webhook-Event-Id`도 함께 전달됩니다. 포털은 발송 성공 여부, 수신 HTTP 상태, 실패 이유만 화면에 표시하며 테스트 발송은 10분에 3회로 제한됩니다. 기존 outbox와 재시도 처리를 재사용합니다.

### [Webhooks] 상태 변경 통지 (허브 → 고객)

#### POST (webhook) orderStatusChanged — 주문 상태 변경 통지 (허브 → 고객)

`/api/external/partner/status-change`가 성공하면 등록된 `callback_url`로 1회 POST한다.
서명은 요청 본문 raw bytes에 업체 `webhook_secret`을 키로 HMAC-SHA256을 계산한 16진수 문자열.
수신側는 `hash_equals(hash_hmac(&#039;sha256&#039;, rawBody, secret), header)`로 검증한다.
재시도·전송로그·서명 버전 협상은 없다.

- 인증: 불필요

| 필드 | 위치 | 필수 | 타입 | 예시 | 설명 |
|---|---|---|---|---|---|
| `X-Webhook-Signature` | header | **필수** | string | `` | HMAC-SHA256(raw body, webhook_secret) |
| `source` | body | **필수** | string | `` |  |
| `external_order_no` | body | **필수** | string | `` |  |
| `order_no` | body | **필수** | string | `` |  |
| `status` | body | **필수** | string | `` |  |

호출 예시:

```bash
curl -X POST &quot;https://hub.aimidam.com(webhook) orderStatusChanged&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#039;{
  &quot;source&quot;: &quot;문자열&quot;,
  &quot;external_order_no&quot;: &quot;문자열&quot;,
  &quot;order_no&quot;: &quot;문자열&quot;,
  &quot;status&quot;: &quot;문자열&quot;
}&#039;
```

성공 `200`:

```json
null
```

---

### [Compat] 호환용 mock (신규 연동 금지)

#### GET /api/external/_bootstrap — 호환용 부트스트랩 (mock)

- 인증: 불필요

호출 예시:

```bash
curl -X GET &quot;https://hub.aimidam.com/api/external/_bootstrap&quot; \
  -H &quot;Content-Type: application/json&quot;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;mock&quot;: true,
  &quot;endpoint&quot;: &quot;문자열&quot;,
  &quot;request_id&quot;: &quot;mock-request&quot;,
  &quot;items&quot;: [
    {}
  ],
  &quot;count&quot;: 0
}
```

---

#### GET /api/external/auth — 호환용 인증 확인 (mock)

- 인증: 불필요

호출 예시:

```bash
curl -X GET &quot;https://hub.aimidam.com/api/external/auth&quot; \
  -H &quot;Content-Type: application/json&quot;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;mock&quot;: true,
  &quot;endpoint&quot;: &quot;문자열&quot;,
  &quot;request_id&quot;: &quot;mock-request&quot;,
  &quot;items&quot;: [
    {}
  ],
  &quot;count&quot;: 0
}
```

---

#### POST /api/external/auth — 호환용 인증 확인 (mock)

- 인증: 불필요

호출 예시:

```bash
curl -X POST &quot;https://hub.aimidam.com/api/external/auth&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#039;{}&#039;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;mock&quot;: true,
  &quot;endpoint&quot;: &quot;문자열&quot;,
  &quot;request_id&quot;: &quot;mock-request&quot;,
  &quot;items&quot;: [
    {}
  ],
  &quot;count&quot;: 0
}
```

---

#### GET /api/external/order-status — 호환용 주문 상태 (mock) — 실제는 /partner/order-status

- 인증: 불필요

호출 예시:

```bash
curl -X GET &quot;https://hub.aimidam.com/api/external/order-status&quot; \
  -H &quot;Content-Type: application/json&quot;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;mock&quot;: true,
  &quot;endpoint&quot;: &quot;문자열&quot;,
  &quot;request_id&quot;: &quot;mock-request&quot;,
  &quot;items&quot;: [
    {}
  ],
  &quot;count&quot;: 0
}
```

---

#### POST /api/external/quote — 호환용 운임 견적 (mock)

- 인증: 불필요

호출 예시:

```bash
curl -X POST &quot;https://hub.aimidam.com/api/external/quote&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#039;{}&#039;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;mock&quot;: true,
  &quot;endpoint&quot;: &quot;문자열&quot;,
  &quot;request_id&quot;: &quot;mock-request&quot;,
  &quot;items&quot;: [
    {}
  ],
  &quot;count&quot;: 0
}
```

---

#### POST /api/external/shipping-request — 호환용 배송 신청 (mock) — 실제는 /partner/orders 또는 /orders

- 인증: 불필요

호출 예시:

```bash
curl -X POST &quot;https://hub.aimidam.com/api/external/shipping-request&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#039;{}&#039;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;mock&quot;: true,
  &quot;endpoint&quot;: &quot;문자열&quot;,
  &quot;request_id&quot;: &quot;mock-request&quot;,
  &quot;items&quot;: [
    {}
  ],
  &quot;count&quot;: 0
}
```

---

#### POST /api/about-contact — 문의 접수 (mock)

- 인증: 불필요

호출 예시:

```bash
curl -X POST &quot;https://hub.aimidam.com/api/about-contact&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#039;{}&#039;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;mock&quot;: true,
  &quot;endpoint&quot;: &quot;문자열&quot;,
  &quot;request_id&quot;: &quot;mock-request&quot;,
  &quot;items&quot;: [
    {}
  ],
  &quot;count&quot;: 0
}
```

---

#### POST /api/auth — 레거시 인증 (mock)

- 인증: 불필요

호출 예시:

```bash
curl -X POST &quot;https://hub.aimidam.com/api/auth&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#039;{}&#039;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;mock&quot;: true,
  &quot;endpoint&quot;: &quot;문자열&quot;,
  &quot;request_id&quot;: &quot;mock-request&quot;,
  &quot;items&quot;: [
    {}
  ],
  &quot;count&quot;: 0
}
```

---

#### GET /api/customs-clearance-items — 통관항목 조회 (mock)

- 인증: 불필요

호출 예시:

```bash
curl -X GET &quot;https://hub.aimidam.com/api/customs-clearance-items&quot; \
  -H &quot;Content-Type: application/json&quot;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;mock&quot;: true,
  &quot;endpoint&quot;: &quot;문자열&quot;,
  &quot;request_id&quot;: &quot;mock-request&quot;,
  &quot;items&quot;: [
    {}
  ],
  &quot;count&quot;: 0
}
```

---

#### POST /api/deploy-webhook — 웹훅 배포 트리거 (mock)

- 인증: 불필요

호출 예시:

```bash
curl -X POST &quot;https://hub.aimidam.com/api/deploy-webhook&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#039;{}&#039;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;mock&quot;: true,
  &quot;endpoint&quot;: &quot;문자열&quot;,
  &quot;request_id&quot;: &quot;mock-request&quot;,
  &quot;items&quot;: [
    {}
  ],
  &quot;count&quot;: 0
}
```

---

#### GET /api/error-receipt — 오류 접수 조회 (mock) — 실제 등록은 /inbound/error

- 인증: 불필요

호출 예시:

```bash
curl -X GET &quot;https://hub.aimidam.com/api/error-receipt&quot; \
  -H &quot;Content-Type: application/json&quot;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;mock&quot;: true,
  &quot;endpoint&quot;: &quot;문자열&quot;,
  &quot;request_id&quot;: &quot;mock-request&quot;,
  &quot;items&quot;: [
    {}
  ],
  &quot;count&quot;: 0
}
```

---

#### GET /api/legacy-mailbox — 레거시 사서함 조회 (mock)

- 인증: 불필요

호출 예시:

```bash
curl -X GET &quot;https://hub.aimidam.com/api/legacy-mailbox&quot; \
  -H &quot;Content-Type: application/json&quot;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;mock&quot;: true,
  &quot;endpoint&quot;: &quot;문자열&quot;,
  &quot;request_id&quot;: &quot;mock-request&quot;,
  &quot;items&quot;: [
    {}
  ],
  &quot;count&quot;: 0
}
```

---

#### GET /api/portal/calculator — 포털 계산기 (mock)

- 인증: 불필요

호출 예시:

```bash
curl -X GET &quot;https://hub.aimidam.com/api/portal/calculator&quot; \
  -H &quot;Content-Type: application/json&quot;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;mock&quot;: true,
  &quot;endpoint&quot;: &quot;문자열&quot;,
  &quot;request_id&quot;: &quot;mock-request&quot;,
  &quot;items&quot;: [
    {}
  ],
  &quot;count&quot;: 0
}
```

---

#### GET /api/settings — 설정 조회 (mock)

- 인증: 불필요

호출 예시:

```bash
curl -X GET &quot;https://hub.aimidam.com/api/settings&quot; \
  -H &quot;Content-Type: application/json&quot;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;mock&quot;: true,
  &quot;endpoint&quot;: &quot;문자열&quot;,
  &quot;request_id&quot;: &quot;mock-request&quot;,
  &quot;items&quot;: [
    {}
  ],
  &quot;count&quot;: 0
}
```

---

#### POST /api/shipping-request-bulk — 대량 배송 신청 (mock)

- 인증: 불필요

호출 예시:

```bash
curl -X POST &quot;https://hub.aimidam.com/api/shipping-request-bulk&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#039;{}&#039;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;mock&quot;: true,
  &quot;endpoint&quot;: &quot;문자열&quot;,
  &quot;request_id&quot;: &quot;mock-request&quot;,
  &quot;items&quot;: [
    {}
  ],
  &quot;count&quot;: 0
}
```

---

#### GET /api/v1/auth — v1 인증 (mock)

- 인증: 불필요

호출 예시:

```bash
curl -X GET &quot;https://hub.aimidam.com/api/v1/auth&quot; \
  -H &quot;Content-Type: application/json&quot;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;mock&quot;: true,
  &quot;endpoint&quot;: &quot;문자열&quot;,
  &quot;request_id&quot;: &quot;mock-request&quot;,
  &quot;items&quot;: [
    {}
  ],
  &quot;count&quot;: 0
}
```

---

#### GET /api/v1/hscodes — v1 HS코드 조회 (mock) — 실제는 /hscode

- 인증: 불필요

호출 예시:

```bash
curl -X GET &quot;https://hub.aimidam.com/api/v1/hscodes&quot; \
  -H &quot;Content-Type: application/json&quot;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;mock&quot;: true,
  &quot;endpoint&quot;: &quot;문자열&quot;,
  &quot;request_id&quot;: &quot;mock-request&quot;,
  &quot;items&quot;: [
    {}
  ],
  &quot;count&quot;: 0
}
```

---

#### POST /api/v1/quotes/china-tracking-update — 중국 운송장 갱신 (mock)

- 인증: 불필요

호출 예시:

```bash
curl -X POST &quot;https://hub.aimidam.com/api/v1/quotes/china-tracking-update&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#039;{}&#039;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;mock&quot;: true,
  &quot;endpoint&quot;: &quot;문자열&quot;,
  &quot;request_id&quot;: &quot;mock-request&quot;,
  &quot;items&quot;: [
    {}
  ],
  &quot;count&quot;: 0
}
```

---

#### POST /api/v1/quotes/status-update — 견적 상태 갱신 (mock)

- 인증: 불필요

호출 예시:

```bash
curl -X POST &quot;https://hub.aimidam.com/api/v1/quotes/status-update&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#039;{}&#039;
```

성공 `200`:

```json
{
  &quot;success&quot;: true,
  &quot;mock&quot;: true,
  &quot;endpoint&quot;: &quot;문자열&quot;,
  &quot;request_id&quot;: &quot;mock-request&quot;,
  &quot;items&quot;: [
    {}
  ],
  &quot;count&quot;: 0
}
```

---

## 공개하지 않는 엔드포인트

- /api/admin/*, /api/admin_*, /admin/* — 관리자 세션 전용
- /api/payment/*, /payment/* — 결제·mock 콜백, PAYMENT_LIVE 게이트
- /api/tt/* — T/T 정산·외환 (자격 확인 필요)
- /api/v1/members/*, /tt/* — 회원 세션·정산
- /api/v1/extension/*, /inbound/*-legacy — 확장/레거시 세션 API
- /api/address*, /api/quote(web.php), /api/shipping-request, /api/portal/shipping-request, /api/order-inquiry, /api/quotes, /api/cargo-tracking, /api/island-surcharge, /api/find-account, /api/account/* — 브라우저 세션 전용. 주의: POST /api/quote는 web.php:744가 먼저 등록되어 API 키 버전(api.php:449)을 가림
- /api/proxy-image — 임의 URL 프록시(SSRF 위험)
- /api/upload-image, /api/upload-photo, /api/upload-receipt-photos — 세션·파일 저장
- /api/image-search-results — 세션 의존
- /api/sync/glt — 구현 없음(스텁)
- /api/page-feedback — 공개 쓰기·스팸 위험

## 계약상 제약 (그대로 반영됨)

- `/partner/orders`는 `tracking_numbers`를 `products_json`에 저장한다. 통관부호·HS코드는 이 경로에서 받지 않는다.
- `/partner/orders`의 `weight_kg`는 `actual_weight`에 저장될 뿐 운임 계산에는 쓰이지 않는다.
- `/orders`는 통관정보와 HS코드를 받지만, 상품에 HS코드가 없으면 거절된다(`1688club` 제외).
- `/inventory/request`는 생성 시 `order_source=&#039;midam&#039;`으로 기록된다(호출사 source 아님).
- Webhook은 허브→고객 1방향이다. 상태 변경은 `partner_webhook_outbox`에 적재되고 dispatch가 서명 발송하며 재시도 상태를 기록한다. 운영 상태 이벤트는 5종이다.
- 일부 초기화 함수가 런타임 `CREATE TABLE IF NOT EXISTS`를 호출한다(기존 동작).

---

## 파트너 API 추가 엔드포인트

아래 엔드포인트는 카드 색인에서 참조하는 추가 API입니다.
모든 파트너 API에는 `X-Company-Id` + `X-Api-Key` 인증 헤더가 필요합니다.

<a id="get-external-partner-health"></a>
#### GET /api/external/partner/health — 연결 확인

- 인증: 필요 (test·live 모두 가능)
- 주문 생성 없음. 키 ID·API 키 유효성 확인용.

```bash
curl https://hub.aimidam.com/api/external/partner/health \
  -H &quot;X-Company-Id: pk_test_xxxxxxxx&quot; \
  -H &quot;X-Api-Key: sk_test_xxxxxxxx&quot;
# → {&quot;success&quot;:true,&quot;api_version&quot;:&quot;v2&quot;,&quot;source&quot;:&quot;업체코드&quot;,&quot;time&quot;:&quot;...&quot;}

- 실패: `401 unauthorized`. test·live 키 모두 health에 사용할 수 있습니다.
```

<a id="get-external-partner-orders-detail"></a>
#### GET /api/external/partner/orders/detail — 주문 상세

- 인증: 필요
- Query: `external_order_no` (업체 주문번호)

```bash
curl &quot;https://hub.aimidam.com/api/external/partner/orders/detail?external_order_no=M001&quot; \
  -H &quot;X-Company-Id: pk_live_xxxxxxxx&quot; \
  -H &quot;X-Api-Key: sk_live_xxxxxxxx&quot;
```

<a id="post-external-partner-orders-tracking"></a>
#### POST /api/external/partner/orders/tracking — 중국 송장 추가

- 인증: 필요
- Body: `external_order_no`, `tracking_number` (중국 운송장번호)

```bash
curl -X POST https://hub.aimidam.com/api/external/partner/orders/tracking \
  -H &quot;X-Company-Id: pk_live_xxxxxxxx&quot; \
  -H &quot;X-Api-Key: sk_live_xxxxxxxx&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#039;{&quot;external_order_no&quot;:&quot;M001&quot;,&quot;tracking_number&quot;:&quot;JT1234567890&quot;}&#039;
```

<a id="post-external-partner-orders-update"></a>
#### POST /api/external/partner/orders/update — 받는 사람 정보 수정

- 인증: 필요
- 포장 전까지만 수정 가능.
- Body: `external_order_no`, 수정할 필드 (name, phone, address 등)

```bash
curl -X POST https://hub.aimidam.com/api/external/partner/orders/update \
  -H &quot;X-Company-Id: pk_live_xxxxxxxx&quot; \
  -H &quot;X-Api-Key: sk_live_xxxxxxxx&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#039;{&quot;external_order_no&quot;:&quot;M001&quot;,&quot;receiver_phone&quot;:&quot;01012345678&quot;}&#039;
```

<a id="post-external-partner-orders-cancel"></a>
#### POST /api/external/partner/orders/cancel — 주문 취소

- 인증: 필요
- 포장 전까지만 취소 가능.
- Body: `external_order_no`

```bash
curl -X POST https://hub.aimidam.com/api/external/partner/orders/cancel \
  -H &quot;X-Company-Id: pk_live_xxxxxxxx&quot; \
  -H &quot;X-Api-Key: sk_live_xxxxxxxx&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#039;{&quot;external_order_no&quot;:&quot;M001&quot;}&#039;
```

<a id="post-external-partner-waybill-reserve"></a>
#### POST /api/external/partner/waybill/reserve — 송장 예약

- 인증: 필요
- Body: `count`, `center_code`(선택), `shipping_route`(선택), `courier`(선택)

```bash
curl -X POST https://hub.aimidam.com/api/external/partner/waybill/reserve \
  -H &quot;X-Company-Id: pk_live_xxxxxxxx&quot; \
  -H &quot;X-Api-Key: sk_live_xxxxxxxx&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#039;{&quot;count&quot;:5}&#039;
# → {&quot;success&quot;:true,&quot;reservation_id&quot;:&quot;...&quot;,&quot;waybills&quot;:[&quot;...&quot;,&quot;...&quot;]}
```

<a id="get-external-partner-waybill-options"></a>
#### GET /api/external/partner/waybill/options — 송장 옵션 조회

- 인증: 필요
- 선택 가능한 센터·노선·택배사 조합과 잔여 대역 수량 반환.

```bash
curl https://hub.aimidam.com/api/external/partner/waybill/options \
  -H &quot;X-Company-Id: pk_live_xxxxxxxx&quot; \
  -H &quot;X-Api-Key: sk_live_xxxxxxxx&quot;
```

<a id="get-external-partner-orders-delivery"></a>
#### GET /api/external/partner/orders/delivery — 국내 택배 조회

- 인증: 필요
- Query: `external_order_no`

```bash
curl &quot;https://hub.aimidam.com/api/external/partner/orders/delivery?external_order_no=M001&quot; \
  -H &quot;X-Company-Id: pk_live_xxxxxxxx&quot; \
  -H &quot;X-Api-Key: sk_live_xxxxxxxx&quot;
```

<a id="get-external-partner-orders-customs"></a>
#### GET /api/external/partner/orders/customs — 관세청 통관 이력

- 인증: 필요
- Query: `external_order_no`

```bash
curl &quot;https://hub.aimidam.com/api/external/partner/orders/customs?external_order_no=M001&quot; \
  -H &quot;X-Company-Id: pk_live_xxxxxxxx&quot; \
  -H &quot;X-Api-Key: sk_live_xxxxxxxx&quot;
```

<a id="get-external-partner-tracking"></a>
#### GET /api/external/partner/tracking — 송장번호로 조회

- 인증: 필요
- Query: `tracking_number` (내 업체 주문의 국내 송장번호)

```bash
curl &quot;https://hub.aimidam.com/api/external/partner/tracking?tracking_number=123456789012&quot; \
  -H &quot;X-Company-Id: pk_live_xxxxxxxx&quot; \
  -H &quot;X-Api-Key: sk_live_xxxxxxxx&quot;
```

- 성공: `200 {&quot;success&quot;:true,&quot;mode&quot;:&quot;full|delivery&quot;,&quot;result&quot;:{...}}`
- 실패: `400 tracking_number_required`, `401 unauthorized`, `404 tracking_not_found`. 외부 조회 실패는 `200`과 `success:false`로 반환될 수 있습니다.

<a id="get-external-partner-orders-photos"></a>
#### GET /api/external/partner/orders/photos — 입고 사진

- 인증: 필요
- Query: `external_order_no`

```bash
curl &quot;https://hub.aimidam.com/api/external/partner/orders/photos?external_order_no=M001&quot; \
  -H &quot;X-Company-Id: pk_live_xxxxxxxx&quot; \
  -H &quot;X-Api-Key: sk_live_xxxxxxxx&quot;
# → {&quot;success&quot;:true,&quot;photos&quot;:[{&quot;url&quot;:&quot;...&quot;,&quot;type&quot;:&quot;inbound&quot;,&quot;taken_at&quot;:&quot;...&quot;}]}
```

<a id="post-external-partner-customs-verify"></a>
#### POST /api/external/partner/customs/verify — 통관부호 확인

- 인증: 필요
- 하루 사용 한도 있음 (429 daily_limit_exceeded)
- 하루 사용 한도 있음 (429 daily_limit_exceeded)
- Body (개인): `customs_type`(=&quot;personal&quot;), `customs_code`, `name`, `phone`, `zipcode`(5자리 필수)
- Body (사업자): `customs_type`(=&quot;business&quot;), `customs_code`, `company_name`, `brno`(선택)

```bash
# 개인
curl -X POST https://hub.aimidam.com/api/external/partner/customs/verify \
  -H &quot;X-Company-Id: pk_live_xxxxxxxx&quot; \
  -H &quot;X-Api-Key: sk_live_xxxxxxxx&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#039;{&quot;customs_type&quot;:&quot;personal&quot;,&quot;customs_code&quot;:&quot;P123456789012&quot;,&quot;name&quot;:&quot;홍길동&quot;,&quot;phone&quot;:&quot;01012345678&quot;,&quot;zipcode&quot;:&quot;06236&quot;}&#039;

# 사업자
curl -X POST https://hub.aimidam.com/api/external/partner/customs/verify \
  -H &quot;X-Company-Id: pk_live_xxxxxxxx&quot; \
  -H &quot;X-Api-Key: sk_live_xxxxxxxx&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#039;{&quot;customs_type&quot;:&quot;business&quot;,&quot;customs_code&quot;:&quot;B123456789012&quot;,&quot;company_name&quot;:&quot;미담물류&quot;,&quot;brno&quot;:&quot;1234567890&quot;}&#039;
```

<a id="get-external-partner-customs-items"></a>
#### GET /api/external/partner/customs/items — 통관 품목(HS) 검색

- 인증: 필요
- Query: `keyword` (품목명)

```bash
curl &quot;https://hub.aimidam.com/api/external/partner/customs/items?keyword=의류&quot; \
  -H &quot;X-Company-Id: pk_live_xxxxxxxx&quot; \
  -H &quot;X-Api-Key: sk_live_xxxxxxxx&quot;
```

<a id="post-external-partner-quote"></a>
#### POST /api/external/partner/quote — 배송비 견적

- 인증: 필요
- Body: `shipping_method`(sea/air/등), `weight_kg`, `length_cm`, `width_cm`, `height_cm`

```bash
curl -X POST https://hub.aimidam.com/api/external/partner/quote \
  -H &quot;X-Company-Id: pk_live_xxxxxxxx&quot; \
  -H &quot;X-Api-Key: sk_live_xxxxxxxx&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#039;{&quot;shipping_method&quot;:&quot;sea&quot;,&quot;weight_kg&quot;:1.5,&quot;length_cm&quot;:30,&quot;width_cm&quot;:20,&quot;height_cm&quot;:10}&#039;
```

- 성공: `200 {&quot;success&quot;:true,&quot;estimate&quot;:{...}}`
- 실패: `401 unauthorized`, `422 invalid_input`, `500 quote_failed`.

<a id="get-external-partner-exchange-rate"></a>
#### GET /api/external/partner/exchange-rate — 환율

- 인증: 필요
- 위안(CNY) → 원(KRW) 현재 적용 환율.

```bash
curl https://hub.aimidam.com/api/external/partner/exchange-rate \
  -H &quot;X-Company-Id: pk_live_xxxxxxxx&quot; \
  -H &quot;X-Api-Key: sk_live_xxxxxxxx&quot;
# → {&quot;success&quot;:true,&quot;currency&quot;:&quot;CNY&quot;,&quot;to&quot;:&quot;KRW&quot;,&quot;rate&quot;:190.5}
```

<a id="get-external-partner-island-surcharge"></a>
#### GET /api/external/partner/island-surcharge — 도서산간 추가요금

- 인증: 필요
- Query: `zipcode` (5자리) 또는 `address` (둘 중 하나 필수)
- 응답: `zipcode`, `is_island`, `detail`

```bash
curl &quot;https://hub.aimidam.com/api/external/partner/island-surcharge?zipcode=63000&quot; \
  -H &quot;X-Company-Id: pk_live_xxxxxxxx&quot; \
  -H &quot;X-Api-Key: sk_live_xxxxxxxx&quot;
# → {&quot;success&quot;:true,&quot;zipcode&quot;:&quot;63000&quot;,&quot;is_island&quot;:true,&quot;detail&quot;:{...}}
```

<a id="post-external-partner-inventory-request"></a>
#### POST /api/external/partner/inventory/request — 재고 입고 신청

- 인증: 필요
- Body: 상품명, 수량, 선택 추가 정보

```bash
curl -X POST https://hub.aimidam.com/api/external/partner/inventory/request \
  -H &quot;X-Company-Id: pk_live_xxxxxxxx&quot; \
  -H &quot;X-Api-Key: sk_live_xxxxxxxx&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#039;{&quot;product_name&quot;:&quot;티셔츠&quot;,&quot;quantity&quot;:10}&#039;
```

<a id="get-external-partner-inventory"></a>
#### GET /api/external/partner/inventory — 내 재고 목록

- 인증: 필요
- 입고 대기 / 보관 중 / 소진 상태를 반환합니다.

```bash
curl https://hub.aimidam.com/api/external/partner/inventory \
  -H &quot;X-Company-Id: pk_live_xxxxxxxx&quot; \
  -H &quot;X-Api-Key: sk_live_xxxxxxxx&quot;
```

<a id="get-external-partner-error-receipts"></a>
#### GET /api/external/partner/error-receipts — 오류 입고 목록

- 인증: 필요
- 주인을 못 찾은 입고 물건 목록을 반환합니다.

```bash
curl https://hub.aimidam.com/api/external/partner/error-receipts \
  -H &quot;X-Company-Id: pk_live_xxxxxxxx&quot; \
  -H &quot;X-Api-Key: sk_live_xxxxxxxx&quot;
```

<a id="post-external-partner-error-receipts"></a>
#### POST /api/external/partner/error-receipts — 오류 입고 등록

- 인증: 필요
- Body: `tracking_number`, `mailbox`(내 사서함 번호), `product_name` — 3개 필수

```bash
curl -X POST https://hub.aimidam.com/api/external/partner/error-receipts \
  -H &quot;X-Company-Id: pk_live_xxxxxxxx&quot; \
  -H &quot;X-Api-Key: sk_live_xxxxxxxx&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#039;{&quot;tracking_number&quot;:&quot;JT9876543210&quot;,&quot;mailbox&quot;:&quot;A001&quot;,&quot;product_name&quot;:&quot;티셔츠&quot;}&#039;
```

<a id="post-external-partner-payments"></a>
#### POST /api/external/partner/payments — 결제 만들기

- 인증: 필요
- Body: `pay_type`, `method`, `amount`, `goods_name`, `external_order_no`, `return_url`, `cancel_url`
- Idempotency-Key 헤더 권장.

```bash
curl -X POST https://hub.aimidam.com/api/external/partner/payments \
  -H &quot;X-Company-Id: pk_live_xxxxxxxx&quot; \
  -H &quot;X-Api-Key: sk_live_xxxxxxxx&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -H &quot;Idempotency-Key: M001-pay-1&quot; \
  -d &#039;{&quot;pay_type&quot;:&quot;logistics&quot;,&quot;method&quot;:&quot;card&quot;,&quot;amount&quot;:35000,&quot;goods_name&quot;:&quot;배송비 M001&quot;,&quot;external_order_no&quot;:&quot;M001&quot;,&quot;return_url&quot;:&quot;https://myshop/done&quot;,&quot;cancel_url&quot;:&quot;https://myshop/cancel&quot;}&#039;
# → {&quot;success&quot;:true,&quot;payment&quot;:{&quot;payment_id&quot;:&quot;pay_...&quot;,&quot;status&quot;:&quot;ready&quot;,&quot;checkout_url&quot;:&quot;...&quot;}}
```

<a id="get-external-partner-payments-id"></a>
#### GET /api/external/partner/payments/{payment_id} — 결제 상태

- 인증: 필요
- Path: `payment_id` (pay_... 형태)

```bash
curl https://hub.aimidam.com/api/external/partner/payments/pay_xxxx \
  -H &quot;X-Company-Id: pk_live_xxxxxxxx&quot; \
  -H &quot;X-Api-Key: sk_live_xxxxxxxx&quot;
```

<a id="get-external-partner-payments"></a>
#### GET /api/external/partner/payments — 결제 목록

- 인증: 필요
- Query: `from`(날짜), `to`(날짜), `pay_type`, `status`, `page`

```bash
curl &quot;https://hub.aimidam.com/api/external/partner/payments?from=2026-11-01&amp;to=2026-11-30&quot; \
  -H &quot;X-Company-Id: pk_live_xxxxxxxx&quot; \
  -H &quot;X-Api-Key: sk_live_xxxxxxxx&quot;
```

<a id="post-external-partner-payments-id-cancel"></a>
#### POST /api/external/partner/payments/{payment_id}/cancel — 취소·환불

- 인증: 필요
- Body: `amount`(부분 환불 금액, 비우면 전액)

```bash
curl -X POST https://hub.aimidam.com/api/external/partner/payments/pay_xxxx/cancel \
  -H &quot;X-Company-Id: pk_live_xxxxxxxx&quot; \
  -H &quot;X-Api-Key: sk_live_xxxxxxxx&quot; \
  -H &quot;Content-Type: application/json&quot; \
  -d &#039;{}&#039;
```
</body></html>