{
  "openapi": "3.1.0",
  "info": {
    "title": "한택조 배송조회 API",
    "version": "1.1.0",
    "description": "키 없이 이용하는 공개 읽기 전용 API. 한택조에 동의하고 저장된 배송 기록을 조회합니다."
  },
  "servers": [
    {
      "url": "https://hantackjo.com"
    }
  ],
  "paths": {
    "/tracking-api.php": {
      "post": {
        "operationId": "lookupHantrackShipment",
        "summary": "국제우편 최신 배송 상태와 동회차 집계 조회",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "tracking_number",
                  "lookup_authorized"
                ],
                "properties": {
                  "tracking_number": {
                    "type": "string",
                    "pattern": "^[A-Z]{2}[0-9]{9}KR$"
                  },
                  "lookup_authorized": {
                    "type": "boolean",
                    "const": true,
                    "description": "사용자가 해당 번호를 조회할 권한이 있고 한택조로 번호를 전송하는 데 동의했음을 확인한 경우에만 true."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "저장 기록 및 동회차 요약",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "enum": [
                        "ok",
                        "no_actual_event"
                      ]
                    },
                    "latest_event": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "properties": {
                        "status": {
                          "type": "string"
                        },
                        "recorded_at": {
                          "type": "string",
                          "description": "원본 배송기록 일시. 제공처에 따라 시간대가 다를 수 있음."
                        }
                      }
                    },
                    "checked_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "stale": {
                      "type": "boolean"
                    },
                    "batch": {
                      "type": "object",
                      "properties": {
                        "status": {
                          "enum": [
                            "available",
                            "batch_unknown",
                            "insufficient_sample"
                          ]
                        },
                        "match": {
                          "const": "dispatch_round"
                        },
                        "method": {
                          "enum": [
                            "air",
                            "sea"
                          ]
                        },
                        "origin_exchange_office": {
                          "type": "string"
                        },
                        "destination_exchange_office": {
                          "type": "string"
                        },
                        "dispatch_year": {
                          "type": "integer"
                        },
                        "round_number": {
                          "type": "string"
                        },
                        "sample_size": {
                          "type": "integer"
                        },
                        "arrived": {
                          "type": "integer"
                        },
                        "customs_cleared": {
                          "type": "integer"
                        },
                        "delivered": {
                          "type": "integer"
                        }
                      }
                    },
                    "source_url": {
                      "type": "string",
                      "format": "uri"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "잘못된 등기번호 또는 권한 확인 누락"
          },
          "404": {
            "description": "사용 가능한 저장 기록 없음. 배송 여부를 판단할 수 없음."
          },
          "413": {
            "description": "본문 크기 초과"
          },
          "415": {
            "description": "JSON 필수"
          },
          "429": {
            "description": "호출량 초과. Retry-After에 안내된 초만큼 기다린 뒤 다시 요청하세요.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "503": {
            "description": "조회 서비스 일시 이용 불가"
          }
        }
      }
    }
  }
}
