{"openapi":"3.1.0","info":{"title":"KAIMAIL API","version":"1.0.0","description":"ซื้อบัญชีอีเมล รับข้อมูลบัญชี และอ่านอีเมล/OTP อัตโนมัติ\n\n- ส่ง key ใน `Authorization: Bearer km_live_...` (สร้างได้ที่ https://kaimail.shop/me/account/api)\n- เงินทุกช่องเป็นสตางค์ (จำนวนเต็ม) เวลาเป็น ISO-8601 UTC\n- สำเร็จ `{ data }` ผิดพลาด `{ error: { code, message, details } }` ตัดสินใจจาก `error.code`\n- เอกสารภาษาไทย: https://kaimail.shop/developers","contact":{"name":"KAIMAIL","url":"https://kaimail.shop/developers"}},"servers":[{"url":"https://api.kaimail.shop/v1"},{"url":"https://kaimail.shop/api/v1"}],"security":[{"bearer":[]}],"tags":[{"name":"account","description":"บัญชีและยอดเงิน"},{"name":"products","description":"สินค้าและราคา"},{"name":"orders","description":"สั่งซื้อและรับข้อมูลบัญชี"},{"name":"mailboxes","description":"อ่านอีเมลและ OTP ของบัญชีที่ซื้อ"}],"paths":{"/me":{"get":{"tags":["account"],"operationId":"getMe","summary":"ยอดเงิน ระดับตัวแทน และข้อมูลของ key ที่ใช้","responses":{"200":{"description":"ข้อมูลบัญชี","headers":{"X-Request-Id":{"$ref":"#/components/headers/RequestId"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimitRemaining"}},"content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/Me"}}}}}},"401":{"description":"ไม่ได้ส่ง key หรือ key ผิด/ถูกยกเลิก (unauthorized, invalid_api_key)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"ไม่มีสิทธิ์ (api_disabled, access_not_approved, access_blocked, account_banned, ip_not_allowed, scope_denied)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"เรียกถี่เกินไป (rate_limited) รอตาม Retry-After","headers":{"Retry-After":{"$ref":"#/components/headers/RetryAfter"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/wallet/transactions":{"get":{"tags":["account"],"operationId":"listWalletTransactions","summary":"รายการเงินเข้าออก ใหม่สุดก่อน","parameters":[{"name":"limit","in":"query","required":false,"description":"จำนวนต่อหน้า (สูงสุด 100)","schema":{"type":"integer","minimum":1,"maximum":100,"default":50}},{"name":"cursor","in":"query","required":false,"description":"next_cursor จากหน้าก่อน","schema":{"type":"string"}}],"responses":{"200":{"description":"รายการ","headers":{"X-Request-Id":{"$ref":"#/components/headers/RequestId"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimitRemaining"}},"content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/WalletTx"}},"next_cursor":{"type":["string","null"]}}}}}},"401":{"description":"ไม่ได้ส่ง key หรือ key ผิด/ถูกยกเลิก (unauthorized, invalid_api_key)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"ไม่มีสิทธิ์ (api_disabled, access_not_approved, access_blocked, account_banned, ip_not_allowed, scope_denied)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"เรียกถี่เกินไป (rate_limited) รอตาม Retry-After","headers":{"Retry-After":{"$ref":"#/components/headers/RetryAfter"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/products":{"get":{"tags":["products"],"operationId":"listProducts","summary":"สินค้าที่เปิดขาย พร้อมราคาต่อชิ้นสำหรับบัญชีนี้และจำนวนคงเหลือ","responses":{"200":{"description":"สินค้า","headers":{"X-Request-Id":{"$ref":"#/components/headers/RequestId"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimitRemaining"}},"content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Product"}}}}}}},"401":{"description":"ไม่ได้ส่ง key หรือ key ผิด/ถูกยกเลิก (unauthorized, invalid_api_key)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"ไม่มีสิทธิ์ (api_disabled, access_not_approved, access_blocked, account_banned, ip_not_allowed, scope_denied)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"เรียกถี่เกินไป (rate_limited) รอตาม Retry-After","headers":{"Retry-After":{"$ref":"#/components/headers/RetryAfter"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/products/{id}":{"get":{"tags":["products"],"operationId":"getProduct","summary":"สินค้าหนึ่งตัว พร้อมราคาของจำนวนที่ระบุ (ราคาแพ็ก + ส่วนลดตัวแทน)","parameters":[{"name":"id","in":"path","required":true,"description":"id สินค้า","schema":{"type":"integer"}},{"name":"qty","in":"query","required":false,"description":"จำนวนที่ใช้คิดราคา","schema":{"type":"integer","minimum":1,"default":1}}],"responses":{"200":{"description":"สินค้า","headers":{"X-Request-Id":{"$ref":"#/components/headers/RequestId"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimitRemaining"}},"content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/Product"}}}}}},"401":{"description":"ไม่ได้ส่ง key หรือ key ผิด/ถูกยกเลิก (unauthorized, invalid_api_key)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"ไม่มีสิทธิ์ (api_disabled, access_not_approved, access_blocked, account_banned, ip_not_allowed, scope_denied)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"ไม่พบสินค้า หรือปิดขาย (product_not_found)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"ข้อมูลไม่ถูกต้อง (validation_error)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"เรียกถี่เกินไป (rate_limited) รอตาม Retry-After","headers":{"Retry-After":{"$ref":"#/components/headers/RetryAfter"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/orders":{"get":{"tags":["orders"],"operationId":"listOrders","summary":"ออเดอร์ของบัญชีนี้ ใหม่สุดก่อน","parameters":[{"name":"status","in":"query","required":false,"description":"กรองตามสถานะ","schema":{"$ref":"#/components/schemas/OrderStatus"}},{"name":"limit","in":"query","required":false,"description":"จำนวนต่อหน้า (สูงสุด 100)","schema":{"type":"integer","minimum":1,"maximum":100,"default":50}},{"name":"cursor","in":"query","required":false,"description":"next_cursor จากหน้าก่อน","schema":{"type":"string","example":"KM-01234"}}],"responses":{"200":{"description":"ออเดอร์","headers":{"X-Request-Id":{"$ref":"#/components/headers/RequestId"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimitRemaining"}},"content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Order"}},"next_cursor":{"type":["string","null"]}}}}}},"401":{"description":"ไม่ได้ส่ง key หรือ key ผิด/ถูกยกเลิก (unauthorized, invalid_api_key)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"ไม่มีสิทธิ์ (api_disabled, access_not_approved, access_blocked, account_banned, ip_not_allowed, scope_denied)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"ข้อมูลไม่ถูกต้อง","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"เรียกถี่เกินไป (rate_limited) รอตาม Retry-After","headers":{"Retry-After":{"$ref":"#/components/headers/RetryAfter"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["orders"],"operationId":"createOrder","summary":"ซื้อสินค้าด้วยยอดเงินในบัญชี (ต้องมีสิทธิ์ buy)","description":"ส่ง `Idempotency-Key` ทุกครั้ง ส่งซ้ำด้วยค่าเดิมได้ออเดอร์เดิม (`idempotent_replay: true`) ไม่หักเงินซ้ำ\n\n201 = ได้สินค้าแล้ว, 202 = กำลังเตรียมสินค้า (ถาม GET /orders/{code} ทุก 3–5 วินาที), 200 = คำขอซ้ำ\n\n`?dry_run=true` = ตรวจราคา สต๊อก ยอดเงิน และเพดานต่อวันโดยไม่ซื้อ (ไม่ต้องมี Idempotency-Key)","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"ค่าไม่ซ้ำต่อคำสั่งซื้อ เช่นเลขออเดอร์ฝั่งคุณ (บังคับเมื่อไม่ใช่ dry_run)","schema":{"type":"string","pattern":"^[A-Za-z0-9._:-]{1,64}$"}},{"name":"dry_run","in":"query","required":false,"description":"ตรวจโดยไม่ซื้อจริง","schema":{"type":"boolean"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateOrder"}}}},"responses":{"200":{"description":"คำขอซ้ำ (คืนสถานะปัจจุบัน) หรือผล dry_run","content":{"application/json":{"schema":{"oneOf":[{"type":"object","properties":{"data":{"$ref":"#/components/schemas/OrderWithBalance"},"idempotent_replay":{"const":true}}},{"type":"object","properties":{"data":{"$ref":"#/components/schemas/DryRun"}}}]}}}},"201":{"description":"ซื้อสำเร็จ ได้สินค้าแล้ว","headers":{"X-Request-Id":{"$ref":"#/components/headers/RequestId"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimitRemaining"}},"content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/OrderWithBalance"},"idempotent_replay":{"const":false}}}}}},"202":{"description":"ชำระแล้ว กำลังเตรียมสินค้า","headers":{"X-Request-Id":{"$ref":"#/components/headers/RequestId"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimitRemaining"}},"content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/OrderWithBalance"},"idempotent_replay":{"const":false}}}}}},"400":{"description":"body ไม่ใช่ JSON (invalid_json)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"ไม่ได้ส่ง key หรือ key ผิด/ถูกยกเลิก (unauthorized, invalid_api_key)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"ยอดเงินไม่พอ (insufficient_balance) details.shortfall_satang = ขาดอีกเท่าไร","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"ไม่มีสิทธิ์ (api_disabled, access_not_approved, access_blocked, account_banned, ip_not_allowed, scope_denied)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"ไม่พบสินค้า (product_not_found)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"สต๊อกไม่พอ (out_of_stock, details.available), ราคาเกิน max_unit_price_satang (price_changed) หรือ Idempotency-Key เคยใช้กับสินค้า/จำนวนอื่น (idempotency_mismatch)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"body ใหญ่เกิน 8 KB (payload_too_large)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"ข้อมูลไม่ถูกต้อง (validation_error, idempotency_key_required, qty_over_limit, invalid_qty)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"เรียกถี่เกินไป (rate_limited) รอตาม Retry-After","headers":{"Retry-After":{"$ref":"#/components/headers/RetryAfter"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/orders/{code}":{"get":{"tags":["orders"],"operationId":"getOrder","summary":"สถานะออเดอร์","parameters":[{"name":"code","in":"path","required":true,"description":"รหัสออเดอร์","schema":{"type":"string","example":"KM-01234"}}],"responses":{"200":{"description":"ออเดอร์","headers":{"X-Request-Id":{"$ref":"#/components/headers/RequestId"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimitRemaining"}},"content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/Order"}}}}}},"401":{"description":"ไม่ได้ส่ง key หรือ key ผิด/ถูกยกเลิก (unauthorized, invalid_api_key)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"ไม่มีสิทธิ์ (api_disabled, access_not_approved, access_blocked, account_banned, ip_not_allowed, scope_denied)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"ไม่พบออเดอร์ หรือไม่ใช่ของบัญชีนี้ (order_not_found)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"เรียกถี่เกินไป (rate_limited) รอตาม Retry-After","headers":{"Retry-After":{"$ref":"#/components/headers/RetryAfter"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/orders/{code}/items":{"get":{"tags":["orders"],"operationId":"getOrderItems","summary":"ข้อมูลบัญชีที่ได้รับ (ใช้ได้เมื่อ status = delivered)","parameters":[{"name":"code","in":"path","required":true,"description":"รหัสออเดอร์","schema":{"type":"string","example":"KM-01234"}},{"name":"format","in":"query","required":false,"description":"txt = บรรทัดละบัญชี ทุกชิ้นในครั้งเดียว","schema":{"type":"string","enum":["json","txt"],"default":"json"}},{"name":"sep","in":"query","required":false,"description":"ตัวคั่นของ format=txt","schema":{"type":"string","enum":["pipe","colon","comma","tab"],"default":"pipe"}},{"name":"offset","in":"query","required":false,"description":"เริ่มที่ชิ้นที่ (format=json)","schema":{"type":"integer","minimum":0,"default":0}},{"name":"limit","in":"query","required":false,"description":"จำนวนต่อหน้า (สูงสุด 5000)","schema":{"type":"integer","minimum":1,"maximum":5000,"default":1000}}],"responses":{"200":{"description":"บัญชีที่ได้รับ","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/OrderItems"},"next_offset":{"type":["integer","null"]}}}},"text/plain":{"schema":{"type":"string","example":"user1@hotmail.com|Pass1\nuser2@hotmail.com|Pass2\n"}}}},"401":{"description":"ไม่ได้ส่ง key หรือ key ผิด/ถูกยกเลิก (unauthorized, invalid_api_key)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"ไม่มีสิทธิ์ (api_disabled, access_not_approved, access_blocked, account_banned, ip_not_allowed, scope_denied)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"ไม่พบออเดอร์ (order_not_found) หรือไม่มีข้อมูลบัญชี (items_not_found)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"ยังไม่ได้ส่งมอบ (not_delivered) details.status = สถานะตอนนี้","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"เรียกถี่เกินไป (rate_limited) รอตาม Retry-After","headers":{"Retry-After":{"$ref":"#/components/headers/RetryAfter"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/mailboxes/{email}/otp":{"get":{"tags":["mailboxes"],"operationId":"getMailboxOtp","summary":"OTP ล่าสุดในกล่องจดหมาย (รวมจดหมายขยะ) ใหม่สุดก่อน","parameters":[{"name":"email","in":"path","required":true,"description":"อีเมลของบัญชีที่ซื้อและได้รับแล้ว","schema":{"type":"string","format":"email"}},{"name":"since","in":"query","required":false,"description":"เอาเฉพาะที่ได้รับหลังเวลานี้ (กันได้รหัสเก่า)","schema":{"type":"string","format":"date-time"}}],"responses":{"200":{"description":"OTP","headers":{"X-Request-Id":{"$ref":"#/components/headers/RequestId"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimitRemaining"}},"content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/MailboxOtp"}}}}}},"401":{"description":"ไม่ได้ส่ง key หรือ key ผิด/ถูกยกเลิก (unauthorized, invalid_api_key)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"ไม่มีสิทธิ์ (api_disabled, access_not_approved, access_blocked, account_banned, ip_not_allowed, scope_denied)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"ไม่พบอีเมลนี้ในออเดอร์ที่ได้รับแล้วของบัญชีนี้ (mailbox_not_found)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"เข้ากล่องจดหมายไม่ได้ (mailbox_auth_failed) หรือข้อมูลไม่ถูกต้อง (validation_error)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"เรียกถี่เกินไป (rate_limited) รอตาม Retry-After","headers":{"Retry-After":{"$ref":"#/components/headers/RetryAfter"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"อ่านเมลไม่ได้ชั่วคราว (mail_unavailable)","headers":{"Retry-After":{"$ref":"#/components/headers/RetryAfter"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/mailboxes/{email}/messages":{"get":{"tags":["mailboxes"],"operationId":"listMailboxMessages","summary":"จดหมายล่าสุด 30 ฉบับ (กล่องจดหมาย + จดหมายขยะ)","parameters":[{"name":"email","in":"path","required":true,"description":"อีเมลของบัญชีที่ซื้อและได้รับแล้ว","schema":{"type":"string","format":"email"}}],"responses":{"200":{"description":"จดหมาย","headers":{"X-Request-Id":{"$ref":"#/components/headers/RequestId"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimitRemaining"}},"content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object","properties":{"email":{"type":"string"},"messages":{"type":"array","items":{"$ref":"#/components/schemas/MailSummary"}}}}}}}}},"401":{"description":"ไม่ได้ส่ง key หรือ key ผิด/ถูกยกเลิก (unauthorized, invalid_api_key)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"ไม่มีสิทธิ์ (api_disabled, access_not_approved, access_blocked, account_banned, ip_not_allowed, scope_denied)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"ไม่พบอีเมลนี้ในออเดอร์ที่ได้รับแล้วของบัญชีนี้ (mailbox_not_found)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"เข้ากล่องจดหมายไม่ได้ (mailbox_auth_failed) หรือข้อมูลไม่ถูกต้อง (validation_error)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"เรียกถี่เกินไป (rate_limited) รอตาม Retry-After","headers":{"Retry-After":{"$ref":"#/components/headers/RetryAfter"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"อ่านเมลไม่ได้ชั่วคราว (mail_unavailable)","headers":{"Retry-After":{"$ref":"#/components/headers/RetryAfter"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/mailboxes/{email}/messages/{id}":{"get":{"tags":["mailboxes"],"operationId":"getMailboxMessage","summary":"เนื้อหาเต็มของจดหมาย","parameters":[{"name":"email","in":"path","required":true,"description":"อีเมลของบัญชีที่ซื้อและได้รับแล้ว","schema":{"type":"string","format":"email"}},{"name":"id","in":"path","required":true,"description":"id จากรายการ messages (เข้ารหัสด้วย URL encoding)","schema":{"type":"string"}}],"responses":{"200":{"description":"จดหมาย","headers":{"X-Request-Id":{"$ref":"#/components/headers/RequestId"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimitRemaining"}},"content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object","properties":{"email":{"type":"string"},"message":{"$ref":"#/components/schemas/MailDetail"}}}}}}}},"400":{"description":"id ไม่ถูกต้อง (invalid_message_id)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"ไม่ได้ส่ง key หรือ key ผิด/ถูกยกเลิก (unauthorized, invalid_api_key)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"ไม่มีสิทธิ์ (api_disabled, access_not_approved, access_blocked, account_banned, ip_not_allowed, scope_denied)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"ไม่พบอีเมลนี้ในออเดอร์ที่ได้รับแล้วของบัญชีนี้ (mailbox_not_found)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"เข้ากล่องจดหมายไม่ได้ (mailbox_auth_failed) หรือข้อมูลไม่ถูกต้อง (validation_error)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"เรียกถี่เกินไป (rate_limited) รอตาม Retry-After","headers":{"Retry-After":{"$ref":"#/components/headers/RetryAfter"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"อ่านเมลไม่ได้ชั่วคราว (mail_unavailable)","headers":{"Retry-After":{"$ref":"#/components/headers/RetryAfter"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","bearerFormat":"km_live_<8 hex>_<32 chars>"}},"headers":{"RequestId":{"description":"รหัสคำขอ ส่งให้ทีมงานเมื่อต้องการให้ตรวจสอบ","schema":{"type":"string"}},"RateLimitRemaining":{"description":"จำนวนครั้งที่เหลือในนาทีนี้ (เพดาน 120 ครั้ง/นาที/key)","schema":{"type":"integer"}},"RetryAfter":{"description":"รอกี่วินาทีแล้วค่อยเรียกใหม่","schema":{"type":"integer"}}},"schemas":{"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","description":"รหัสภาษาอังกฤษ ไม่เปลี่ยน","example":"insufficient_balance"},"message":{"type":"string","description":"ข้อความภาษาไทยสำหรับคนอ่าน"},"details":{"type":"object","additionalProperties":true,"example":{"shortfall_satang":3500}}}}}},"Me":{"type":"object","properties":{"name":{"type":"string"},"balance_satang":{"type":"integer","description":"ยอดเงินคงเหลือ (สตางค์)"},"agent":{"type":"object","properties":{"rank":{"type":"integer","enum":[0,1,2]},"discount_pct":{"type":"integer"}}},"key":{"type":"object","properties":{"name":{"type":"string"},"key":{"type":"string","example":"km_live_1a2b3c4d_••••"},"scopes":{"type":"array","items":{"type":"string","enum":["read","buy"]}},"ip_allow":{"type":"array","items":{"type":"string"}},"daily_limit_satang":{"type":["integer","null"]},"spent_24h_satang":{"type":"integer"},"created_at":{"type":"string","format":"date-time"}}}}},"WalletTx":{"type":"object","properties":{"id":{"type":"integer"},"amount_satang":{"type":"integer","description":"บวก = เงินเข้า ลบ = เงินออก (สตางค์)"},"kind":{"type":"string","enum":["topup","order","refund","bonus","adjust","other"]},"ref":{"type":"string","description":"อ้างอิง เช่นรหัสออเดอร์"},"note":{"type":"string"},"created_at":{"type":"string","format":"date-time"}}},"Product":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"description":{"type":"string"},"unit_price_satang":{"type":"integer","description":"ราคาต่อชิ้นสำหรับบัญชีนี้ ที่จำนวน quote_qty (สตางค์)"},"list_price_satang":{"type":"integer","description":"ราคาปกติต่อชิ้น (สตางค์)"},"discount_pct":{"type":"integer"},"quote_qty":{"type":"integer"},"total_satang":{"type":"integer","description":"unit_price_satang × quote_qty (สตางค์)"},"tiers":{"type":"array","items":{"type":"object","properties":{"min_qty":{"type":"integer"},"unit_price_satang":{"type":"integer"}}}},"delivery":{"type":"string","enum":["instant","manual"],"description":"manual = ทีมงานส่งให้ภายหลัง"},"available":{"type":["integer","null"],"description":"จำนวนคงเหลือ (null = ไม่จำกัด สำหรับ manual)"},"in_stock":{"type":"boolean"},"max_per_order":{"type":"integer"},"fields":{"type":"array","items":{"type":"string"},"example":["email","password"],"description":"ช่องที่ได้รับใน items"},"readmail":{"type":"boolean","description":"อ่านอีเมล/OTP ผ่าน /mailboxes ได้"},"may_process_async":{"type":"boolean","description":"true = การซื้ออาจตอบ 202 processing ก่อนได้ของ"}}},"OrderStatus":{"type":"string","enum":["pending_payment","processing","delivered","cancelled"]},"Order":{"type":"object","properties":{"code":{"type":"string","example":"KM-01234"},"status":{"$ref":"#/components/schemas/OrderStatus"},"product_id":{"type":["integer","null"]},"product_name":{"type":"string"},"qty":{"type":"integer"},"unit_price_satang":{"type":"integer"},"total_satang":{"type":"integer"},"list_price_satang":{"type":["integer","null"]},"refunded":{"type":"boolean","description":"ยกเลิกและคืนเงินเข้าบัญชีแล้ว (ซื้อใหม่ใช้ Idempotency-Key ใหม่)"},"client_ref":{"type":["string","null"],"description":"Idempotency-Key ที่ใช้สั่ง"},"source":{"type":"string","enum":["api","web","line","admin"]},"items_url":{"type":["string","null"],"example":"/v1/orders/KM-01234/items"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"OrderWithBalance":{"allOf":[{"$ref":"#/components/schemas/Order"},{"type":"object","properties":{"balance_satang":{"type":"integer","description":"ยอดเงินคงเหลือหลังสั่ง (สตางค์)"}}}]},"CreateOrder":{"type":"object","required":["product_id"],"properties":{"product_id":{"type":"integer"},"qty":{"type":"integer","minimum":1,"default":1},"max_unit_price_satang":{"type":"integer","minimum":0,"description":"ราคาต่อชิ้นสูงสุดที่ยอมจ่าย ราคาจริงแพงกว่านี้ = ไม่ซื้อ (price_changed)"}},"example":{"product_id":1,"qty":100,"max_unit_price_satang":70}},"DryRun":{"type":"object","properties":{"dry_run":{"const":true},"product_id":{"type":"integer"},"qty":{"type":"integer"},"unit_price_satang":{"type":"integer"},"total_satang":{"type":"integer"},"balance_satang":{"type":"integer"},"balance_after_satang":{"type":"integer"}}},"OrderItems":{"type":"object","properties":{"order_code":{"type":"string"},"total":{"type":"integer"},"offset":{"type":"integer"},"read_url":{"type":["string","null"],"description":"ลิงก์อ่านเมลแบบหน้าเว็บ"},"items":{"type":"array","items":{"type":"object","additionalProperties":{"type":["string","null"]},"properties":{"email":{"type":"string"},"password":{"type":"string"},"recovery_email":{"type":"string"},"claim_code":{"type":["string","null"],"description":"ชิ้นที่ได้จากการเคลมด้วยโค้ดนี้"}}}}}},"Otp":{"type":"object","properties":{"code":{"type":"string","example":"482913"},"confidence":{"type":"string","enum":["high","medium"]},"service":{"type":"string","example":"Facebook"},"from_name":{"type":"string"},"from_address":{"type":"string"},"subject":{"type":"string"},"folder":{"type":"string","enum":["inbox","junk","recovery"],"description":"recovery = รหัสจากเมลสำรอง (อีเมลกู้คืนของบัญชี) สินค้าที่มีเมลสำรองเท่านั้น"},"received_at":{"type":"string","format":"date-time"},"message_id":{"type":"string","description":"เปิดอ่านต่อด้วย /mailboxes/{email}/messages/{id} ได้เฉพาะ folder inbox/junk"}}},"MailboxOtp":{"type":"object","properties":{"email":{"type":"string"},"latest":{"oneOf":[{"$ref":"#/components/schemas/Otp"},{"type":"null"}]},"otps":{"type":"array","items":{"$ref":"#/components/schemas/Otp"}}}},"MailSummary":{"type":"object","properties":{"id":{"type":"string"},"folder":{"type":"string","enum":["inbox","junk"]},"subject":{"type":"string"},"from_name":{"type":"string"},"from_address":{"type":"string"},"service":{"type":"string"},"received_at":{"type":"string","format":"date-time"},"preview":{"type":"string"},"is_read":{"type":"boolean"},"has_attachments":{"type":"boolean"},"otp":{"type":["string","null"]}}},"MailDetail":{"type":"object","properties":{"id":{"type":"string"},"subject":{"type":"string"},"from_name":{"type":"string"},"from_address":{"type":"string"},"service":{"type":"string"},"to":{"type":"array","items":{"type":"string"}},"received_at":{"type":"string","format":"date-time"},"has_attachments":{"type":"boolean"},"text":{"type":"string"},"html":{"type":["string","null"]},"links":{"type":"array","items":{"type":"object","properties":{"text":{"type":"string"},"url":{"type":"string"}}}},"otps":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string"},"confidence":{"type":"string","enum":["high","medium"]}}}}}}}}}