API เดียว
ส่งได้ทุกขนส่ง
เรทของคุณเอง
ระบบของคุณส่งคำสั่งเดียว พัสดุถูกจองกับขนส่งที่คุณเลือก ด้วยเรท เครดิต และเงื่อนไขที่คุณตกลงกับขนส่งไว้เอง
อยากเปลี่ยนขนส่ง แก้บรรทัดเดียว
บรรทัดที่เปลี่ยน: 1
ใช้ได้กับขนส่งที่เชื่อมบัญชีไว้แล้ว ยกเว้น SPX ที่ต้องส่งเพิ่ม 3 ฟิลด์
Quickstart: พัสดุชิ้นแรกใน 4 คำสั่ง
ระวัง
ไม่มี sandbox ทุกคำสั่งสร้างออเดอร์คือพัสดุจริงกับขนส่งจริง อย่าสร้างออเดอร์เพื่อทดสอบ
บัญชีใหม่ใช้ thaipost0 ได้ทันทีสำหรับพัสดุที่ไม่เก็บเงินปลายทาง คือไปรษณีย์ไทยแบบไม่ต้องมีบัญชี API นำพัสดุไปส่งที่เคาน์เตอร์หรือเรียกไปรษณีย์มารับ แล้วจ่ายค่าส่งเป็นเงินสด ขนส่งเจ้าอื่นต้องเชื่อมบัญชีของคุณในแอป ProShip ก่อน
sh
export PROSHIP_API_KEY # ตั้งค่าไว้แล้วจากขั้นสมัครด้านล่าง
H="Authorization: Bearer $PROSHIP_API_KEY"
API=https://api.proship.me
# 0. username จาก key (ใช้ในฟิลด์ user)
python3 -c 'import os,json,base64; p=os.environ["PROSHIP_API_KEY"].split(".")[1]; c=json.loads(base64.urlsafe_b64decode(p+"="*(-len(p)%4))); print(c.get("username") or c.get("user"))'
# 1. ร้านผู้ส่ง: ใช้ id เป็น shopId
curl -s "$API/core/v1/shops" -H "$H"
# 2. สร้างออเดอร์ (พัสดุจริง)
curl -s -X POST "$API/orders/v1/orders" -H "$H" -H 'Content-Type: application/json' -d '{
"user": "<username จาก key>",
"shopId": "shop-xxxx",
"shippingMethod": "thaipost0",
"weight": 500,
"customer": {
"name": "<ชื่อผู้รับ>",
"phoneNo": "<เบอร์ผู้รับ>",
"address": { "address": "<บ้านเลขที่ ถนน>", "subDistrict": "<ตำบล>", "district": "<อำเภอ>", "province": "<จังหวัด>", "zipcode": <รหัสไปรษณีย์ 5 หลัก> }
},
"codAmount": 0,
"remarks": "INV-1001"
}'
# -> {"message":"Success","id":"order-xxxx|1727591940677"}
# 3. สถานะและเลขพัสดุ (id แบบสั้น)
curl -s "$API/orders/v1/orders/order-xxxx" -H "$H"
# 4. ใบปะหน้า PDF (id แบบเต็ม)
curl -s -X POST "$API/print/v1/print-label" -H "$H" -H 'Content-Type: application/json' \
-d '{"orders":["order-xxxx|1727591940677"],"size":"normal","printer":"proship","base64":true}' \
| jq -r '.base64 // .data' | base64 -d > label.pdfjs
// quickstart.mjs — Node 18+
import { writeFileSync } from "node:fs";
const API = "https://api.proship.me";
const KEY = process.env.PROSHIP_API_KEY;
const H = { Authorization: `Bearer ${KEY}`, "Content-Type": "application/json" };
const claims = JSON.parse(Buffer.from(KEY.split(".")[1], "base64url").toString("utf8"));
const user = claims.username ?? claims.user;
// ผู้รับ: ใส่ข้อมูลจริงก่อนรัน คำสั่งนี้สร้างพัสดุจริง
const recipient = {
name: "<ชื่อผู้รับ>", phoneNo: "<เบอร์ผู้รับ>",
address: { address: "<บ้านเลขที่ ถนน>", subDistrict: "<ตำบล>", district: "<อำเภอ>", province: "<จังหวัด>", zipcode: 0 },
};
if (recipient.phoneNo.startsWith("<")) throw new Error("ใส่ข้อมูลผู้รับจริงก่อนรัน");
// 1. ร้านผู้ส่ง
const shops = await (await fetch(`${API}/core/v1/shops`, { headers: H })).json();
if (!shops.length) throw new Error("ยังไม่มีร้านผู้ส่ง สร้างด้วย POST /core/v1/shops ก่อน");
const shopId = shops[0].id; // มีหลายร้าน ให้เลือกร้านที่ส่งจริง
// 2. สร้างออเดอร์ (พัสดุจริง)
const order = await (await fetch(`${API}/orders/v1/orders`, {
method: "POST", headers: H,
body: JSON.stringify({
user, shopId, shippingMethod: "thaipost0", weight: 500,
customer: recipient, codAmount: 0, remarks: "INV-1001",
}),
})).json(); // { message, id: "order-xxxx|1727591940677" }
// 3. สถานะและเลขพัสดุ (id แบบสั้น)
const shortId = order.id.split("|")[0];
const detail = await (await fetch(`${API}/orders/v1/orders/${shortId}`, { headers: H })).json();
console.log(detail.status, detail.trackingNo);
// 4. ใบปะหน้า PDF (id แบบเต็ม)
const label = await (await fetch(`${API}/print/v1/print-label`, {
method: "POST", headers: H,
body: JSON.stringify({ orders: [order.id], size: "normal", printer: "proship", base64: true }),
})).json();
writeFileSync("label.pdf", Buffer.from(label.base64 ?? label.data, "base64"));python
# quickstart.py — pip install requests
import os, json, base64, requests
API = "https://api.proship.me"
KEY = os.environ["PROSHIP_API_KEY"]
H = {"Authorization": f"Bearer {KEY}", "Content-Type": "application/json"}
p = KEY.split(".")[1]
claims = json.loads(base64.urlsafe_b64decode(p + "=" * (-len(p) % 4)))
user = claims.get("username") or claims.get("user")
# ผู้รับ: ใส่ข้อมูลจริงก่อนรัน คำสั่งนี้สร้างพัสดุจริง
recipient = {
"name": "<ชื่อผู้รับ>", "phoneNo": "<เบอร์ผู้รับ>",
"address": {"address": "<บ้านเลขที่ ถนน>", "subDistrict": "<ตำบล>", "district": "<อำเภอ>", "province": "<จังหวัด>", "zipcode": 0},
}
if recipient["phoneNo"].startswith("<"):
raise SystemExit("ใส่ข้อมูลผู้รับจริงก่อนรัน")
# 1. ร้านผู้ส่ง
shops = requests.get(f"{API}/core/v1/shops", headers=H, timeout=30).json()
if not shops:
raise SystemExit("ยังไม่มีร้านผู้ส่ง สร้างด้วย POST /core/v1/shops ก่อน")
shop_id = shops[0]["id"] # มีหลายร้าน ให้เลือกร้านที่ส่งจริง
# 2. สร้างออเดอร์ (พัสดุจริง)
order = requests.post(f"{API}/orders/v1/orders", headers=H, timeout=30, json={
"user": user, "shopId": shop_id, "shippingMethod": "thaipost0", "weight": 500,
"customer": recipient, "codAmount": 0, "remarks": "INV-1001",
}).json() # {"message": "Success", "id": "order-xxxx|1727591940677"}
# 3. สถานะและเลขพัสดุ (id แบบสั้น)
short_id = order["id"].split("|")[0]
detail = requests.get(f"{API}/orders/v1/orders/{short_id}", headers=H, timeout=30).json()
print(detail["status"], detail.get("trackingNo"))
# 4. ใบปะหน้า PDF (id แบบเต็ม)
label = requests.post(f"{API}/print/v1/print-label", headers=H, timeout=60,
json={"orders": [order["id"]], "size": "normal", "printer": "proship", "base64": True}).json()
open("label.pdf", "wb").write(base64.b64decode(label.get("base64") or label.get("data")))สมัครและรับ API key
สมัครด้วยอีเมล ยืนยันรหัส 6 หลัก แล้วได้ key เลือกทำผ่าน API ในหน้านี้ หรือให้ AI ของคุณทำ
สมัครด้วย API call เดียว ได้ key กลับมาทันที หรือให้ AI ของคุณทำ
โหมดตัวอย่าง: ยังไม่สร้างบัญชีจริง ใช้รหัส 123456
- อีเมล
- รหัสยืนยัน
- บัญชี
- ร้านผู้ส่ง
API key ของคุณ
ตัวอย่าง ไม่ใช่ key จริง
แสดงครั้งเดียว เก็บไว้ในที่ปลอดภัย
บัญชีใหม่ส่งไปรษณีย์ไทยแบบไม่เก็บเงินปลายทางได้ทันที
API=https://new.proship.co.th/v1/onboarding
# 1. เริ่มสมัคร แล้วส่งอีเมลเพื่อรับรหัส 6 หลัก
SID=$(curl -s -X POST $API/proship/start -H 'Content-Type: application/json' -d '{}' | jq -r .session_id)
curl -s -X POST $API/sessions/$SID/submit -H 'Content-Type: application/json' -d '{"email":"<อีเมลที่ใช้งานจริง>"}'
# 2. ยืนยันรหัสจากอีเมล
curl -s -X POST $API/sessions/$SID/submit -H 'Content-Type: application/json' -d '{"code":"<รหัส 6 หลักจากอีเมล>"}'
# 3. สร้างบัญชี
curl -s -X POST $API/sessions/$SID/submit -H 'Content-Type: application/json' -d '{"name":"<ชื่อผู้ติดต่อ>","phone":"<เบอร์มือถือ>"}'
# 4. สร้างร้านผู้ส่ง
curl -s -X POST $API/sessions/$SID/submit -H 'Content-Type: application/json' -d '{"shop_name":"<ชื่อร้านผู้ส่ง>","shop_phone":"<เบอร์โทรบนใบปะหน้า>","address":{"address":"<บ้านเลขที่ ถนน>","sub_district":"<ตำบล>","district":"<อำเภอ>","province":"<จังหวัด>","zipcode":"<รหัสไปรษณีย์ 5 หลัก>"}}'
# 5. เลือกขนส่ง (เว้นว่าง = ไปรษณีย์ไทย) แล้วรับ API key
curl -s -X POST $API/sessions/$SID/submit -H 'Content-Type: application/json' -d '{"couriers":""}'
# เก็บ key เข้า environment variable โดยไม่พิมพ์ออกจอ
export PROSHIP_API_KEY=$(curl -s -X POST $API/sessions/$SID/submit -H 'Content-Type: application/json' -d '{}' | jq -r .result.api_token)
ทุกคำสั่งตอบกลับเป็น JSON บอกขั้นถัดไปในฟิลด์ step
# กรอกทีละบรรทัด รหัสผ่านจะไม่แสดงบนจอและไม่ค้างใน history
printf 'ชื่อร้านหรือธุรกิจ: '; read -r PS_NAME
printf 'เบอร์มือถือ: '; read -r PS_PHONE
printf 'อีเมล: '; read -r PS_EMAIL
printf 'รหัสผ่าน: '; stty -echo; read -r PS_PASSWORD; stty echo; echo
PS_NAME="$PS_NAME" PS_PHONE="$PS_PHONE" PS_EMAIL="$PS_EMAIL" PS_PASSWORD="$PS_PASSWORD" \
python3 -c 'import os,json; pw=os.environ["PS_PASSWORD"]; print(json.dumps({"username":os.environ["PS_NAME"],"phoneNo":os.environ["PS_PHONE"],"email":os.environ["PS_EMAIL"].lower(),"password":pw,"passwordConfirmation":pw}))' \
| curl -sS --max-time 30 -o register-response.json -w '%{http_code}\n' \
-X POST https://api.proship.me/auth/v1/auth/register -H 'Content-Type: application/json' --data-binary @-
# ได้ 200 = สำเร็จ เก็บ key เข้า environment variable โดยไม่พิมพ์ออกจอ
export PROSHIP_API_KEY=$(python3 -c 'import json; print(json.load(open("register-response.json"))["token"])') && rm -f register-response.jsonค่า token ในคำตอบคือ API key ใช้กับทุกคำสั่ง คำสั่งชุดนี้เก็บไว้ใน PROSHIP_API_KEY ให้แล้ว
ใช้อีเมลและรหัสผ่านเดียวกันนี้เข้าแอป ProShip ที่ app.proship.co.th
ถ้า timeout อย่าส่งซ้ำ ให้ลองเข้าสู่ระบบก่อน บัญชีอาจถูกสร้างไปแล้ว
บัญชีใหม่อาจยังไม่มีร้านผู้ส่ง ถ้า GET /core/v1/shops ได้ array ว่าง ให้สร้างร้านด้วย POST /core/v1/shops ก่อน
ข้อควรรู้
มีบัญชี ProShip อยู่แล้ว คัดลอก key ได้ในแอปที่เมนู การตั้งค่า > การเชื่อมต่อ API
key เป็น token อายุยาว เข้าถึงบัญชีได้ทั้งหมด เก็บใน environment variable อย่าใส่ใน URL หรือ log
Endpoints
ทุก path ต่อจาก https://api.proship.me
| Action | Method and path | Order id | Kind |
|---|---|---|---|
| Register an account | POST /auth/v1/auth/register | none | write, never auto-retry, no key needed |
| Shops | GET /core/v1/shops | none | read |
| Create shop | POST /core/v1/shops | none | write, never auto-retry |
| Allowed carriers | GET /core/v1/settings/shippingMethods | none | read |
| Parse a Thai address | GET /utils/v1/parse-address?text= | none | read |
| Check duplicate | POST /orders/v1/orders/check-duplicate | none | lookup |
| Create order | POST /orders/v1/orders | returns full | write, never auto-retry |
| Create batch | POST /batch/v1/orders-batch | returns batch id | write, never auto-retry |
| Get order (track) | GET /orders/v1/orders/{id} | short | read |
| List orders | GET /orders/v1/orders-v2 | none | read |
| Update order | PUT /orders/v1/orders/{id} | short | write |
| Update status | PUT /orders/v1/orders/{id}/status | short | write |
| Cancel order | DELETE /orders/v1/orders/{id} | short | write |
| Shop for label | POST /utils/v1/orders/{id}/update-shop-for-label | short | write |
| Print labels | POST /print/v1/print-label | full, in body | returns a PDF |
| Print batch | POST /batch/v1/print-batch | batch id, in body | returns a PDF |
| Get webhook | GET /core/v1/settings/webhook | none | read |
| Set webhook | PUT /core/v1/settings/webhook | none | write |
| J&T wallet top-up QR | POST /wallet/v1/gen-qr | none | write |
Carriers (shippingMethod)
| Code | Carrier | Note |
|---|---|---|
thaipost | Thailand Post, your own API account | for sellers who already have an API account with Thailand Post: postage on credit terms, billed by Thailand Post; connect the account in the ProShip app first; weight up to 20,000 g |
thaipost0 | Thailand Post, no API account | works on a new account: drop the parcel at a post office counter or request a pickup, and pay the postage in cash |
kerry | Kerry Express (KEX) | connect your account in the ProShip app first |
flash | Flash Express | connect your account in the ProShip app first |
shopee | SPX Express | connect your account in the ProShip app first; also send custRef, express_insured_value, parcel_item_name; weight up to 20,000 g |
jt | J&T Express | connect your account in the ProShip app first; prepaid from the J&T wallet, so a create can fail when the wallet is empty |
dhl | DHL | connect your account in the ProShip app first |
COD กับไปรษณีย์ไทย ทั้ง thaipost และ thaipost0 ต้องมี COD wallet ที่ร้าน
เปลี่ยนขนส่ง = เปลี่ยนค่า shippingMethod ค่าเดียว ยกเว้น SPX ที่ต้องส่งเพิ่ม 3 ฟิลด์
Order status codes
| Code | Meaning | Thai label in the app |
|---|---|---|
-2 | Blacklisted recipient | ระงับการใช้งาน |
-1 | Draft | ฉบับร่าง |
1 | Pending, waiting for carrier pickup | รอรับพัสดุ |
2 | To ship | จัดส่งแล้ว |
3 | Picked up by carrier | ขนส่งรับพัสดุแล้ว |
4 | Delivered | จัดส่งสำเร็จ |
5 | Cancelled by seller | ยกเลิกโดยผู้ขาย |
6 | Out for delivery | กำลังนำส่ง |
8 | Returned to sender | ตีกลับผู้ส่ง |
34 | Recipient not answering the phone | ลูกค้าไม่รับโทรศัพท์ |
41 | Delivery problem | มีปัญหาการจัดส่ง |
สถานะจบ: 4, 5, 8 ควรแจ้งผู้ขายเมื่อเจอ 8, 34, 41
Webhooks
ProShip ส่ง POST เป็น JSON {"type", "data"} ไปที่ URL ของคุณ ตอบ 200 ให้เร็ว
| type | When | data |
|---|---|---|
ORDER_STATUS_CHANGE_MANUAL | status changed in ProShip | the full order, same shape as Get order |
ORDER_STATUS_CHANGE_SHIPPER_WEBHOOK | status changed by the carrier | the full order, same shape as Get order |
WEIGHT_UPDATE | the carrier weighed the parcel | {"orderId", "createdAt", "data": {…}}, raw carrier fields weight, length, width, height, price, pno |
PRICE_UPDATE | the carrier's final price | same wrapper, raw fields include freightPrice, codFee, codAmount, remoteAreaFee, pno |
ระวัง
webhook ไม่มีลายเซ็น ให้ตั้ง secret header เองตอน Set webhook แล้วปฏิเสธคำขอที่ไม่มี header นั้น
API=https://api.proship.me
H="Authorization: Bearer $PROSHIP_API_KEY"
curl -s -X PUT "$API/core/v1/settings/webhook" -H "$H" -H 'Content-Type: application/json' \
-d '{"url":"https://example.com/proship-webhook","headers":"{\"X-Webhook-Secret\":\"<your secret>\"}"}'
# -> {"message":"Success"}// Express
const SECRET = process.env.PROSHIP_WEBHOOK_SECRET;
app.post("/proship-webhook", express.json(), (req, res) => {
if (!SECRET || req.get("X-Webhook-Secret") !== SECRET) return res.sendStatus(401);
res.sendStatus(200); // ตอบก่อน แล้วค่อยทำงาน
const { type, data } = req.body || {};
if (String(type || "").startsWith("ORDER_STATUS_CHANGE")) {
const fullId = `${data.id}|${data.createdAt}`; // ใช้พิมพ์ใบปะหน้า
// data.status, data.trackingNo
}
});รับได้ทั้ง WEIGHT_UPDATE และ WEIGHT UPDATE, PRICE_UPDATE และ PRICE UPDATE
ฟิลด์ดิบจากขนส่งเป็น string ในหน่วยของขนส่งเอง ตรวจเทียบกับออเดอร์ก่อนใช้เป็นบาท
Errors
ทุกสถานะที่ไม่ใช่ 2xx คือ error และ body มาได้ 3 แบบ
- object ที่มี
messageเช่น{"message": "Unauthorized"} - array ของ string หรือ string ธรรมดา มักมากับ 400 หรือ 422
- 401 กับ key ที่เคยใช้ได้ แปลว่า key ใช้ไม่ได้แล้ว
const errorText = (body) => Array.isArray(body) ? body.join("; ")
: typeof body === "string" ? body
: (body && body.message) || JSON.stringify(body);ข้อควรรู้ก่อนขึ้น production
- id มีสองแบบ — id เต็มคือ
order-xxxx|1727591940677ส่วน id สั้นคือส่วนหน้า|ใช้ id สั้นใน URL (Get, Update, Cancel) และ id เต็มใน body ของ Print labelsjsconst shortId = (id) => String(id).split("|")[0]; const fullId = (o) => String(o.id).includes("|") ? o.id : `${o.id}|${o.createdAt}`; - อย่า retry การสร้างออเดอร์อัตโนมัติ — ไม่มี idempotency key ถ้า timeout หรือ 5xx ให้ไล่ List orders แล้วเทียบ
remarksด้วย Get order ก่อน แล้วค่อยตัดสินใจ - ไม่มี sandbox — ทุก write คือของจริงบนบัญชีผู้ขาย
- List orders ไม่มีตัวกรองวันที่ — ใช้ cursor
ExclusiveStartKeyจากLastEvaluatedKeyและ dedupe ด้วยid - พิมพ์ใบปะหน้าครั้งละไม่ถึง 50 ออเดอร์ — ส่ง
base64: trueเสมอ แล้วตรวจว่าไฟล์ขึ้นต้นด้วย%PDF - หน่วย — น้ำหนักเป็นกรัม เงินเป็นบาท เวลาเป็น epoch milliseconds และ response อาจบอก
Content-Typeเป็นtext/plainให้ parse เป็น JSON เสมอ
สิ่งที่ API ยังทำไม่ได้
การขอราคาค่าส่ง การเชื่อมบัญชีขนส่ง สินค้าและสต็อก รายงาน ยอดเงินใน COD wallet และฟีเจอร์แชท ทำในแอป ProShip
ทำไมต้อง ProShip API
คำถามที่พบบ่อย
รองรับขนส่งเจ้าไหนบ้าง
ไปรษณีย์ไทย, Flash, Kerry, SPX, J&T และ DHL ระบุด้วยฟิลด์ shippingMethod
ต้องมีบัญชีกับขนส่งก่อนไหม
บัญชีใหม่ส่งไปรษณีย์ไทยแบบไม่เก็บเงินปลายทางได้ทันทีด้วย thaipost0 นำไปส่งที่เคาน์เตอร์หรือเรียกรับ แล้วจ่ายค่าส่งเป็นเงินสด ถ้ามีบัญชี API กับไปรษณีย์ไทยแบบเครดิตอยู่แล้ว ใช้ thaipost ส่วนขนส่งเจ้าอื่นต้องเชื่อมบัญชีของคุณในแอป ProShip ก่อน ถ้ายังไม่มี ทีมงานช่วยตั้งค่าให้
ทุกขนส่งใช้ข้อมูลชุดเดียวกันจริงไหม
โครงสร้างเดียวกัน ยกเว้น SPX ที่ต้องส่งเพิ่ม 3 ฟิลด์ เอกสารระบุไว้ครบ
มีอะไรที่ API ยังทำไม่ได้
การขอราคาค่าส่ง การเชื่อมบัญชีขนส่ง สินค้าและสต็อก รายงาน และฟีเจอร์แชท ทำในแอป ProShip
มีค่าใช้จ่ายยังไง
เงื่อนไขขึ้นอยู่กับลักษณะธุรกิจและวอลุ่มของคุณ ทักมาคุยกับทีมงานได้เลย
เอกสาร API อยู่ที่ไหน
อ่านได้ที่ proship.co.th/developers ฉบับที่ AI อ่านเองได้อยู่ที่ /developers/llms.txt
สมัครผ่าน API ต้องยืนยันตัวตนอย่างไร
ยืนยันด้วยรหัส 6 หลักที่ส่งไปยังอีเมลของคุณ รหัสมีอายุ 10 นาที