API REST

API documentation

View endpoint documentation for quotation, shipping services, and shipment CRUD. Production APIs use a personal token from Profile Settings. A separate UAT host is available for integration testing. Tracking API access requires a short registration form and has no UAT environment.

URL cơ sở API

Production base URL: https://app.thainexus.co.th/functions

Hãy thêm tên hàm vào URL này. Ví dụ:

  • POSThttps://app.thainexus.co.th/functions/apiQuote
  • POSThttps://app.thainexus.co.th/functions/shipmentCrud
  • POSThttps://app.thainexus.co.th/functions/apiShippingServices

Interactive live tests live in the client app. Get your production token from Profile Settings.

Môi trường UAT (thử nghiệm)

Use the UAT host to build and verify integrations before switching to production. Request and response shapes match production for quotation, shipping services, and shipment CRUD. Tracking events and the Tracking API are production-only; there is no UAT for tracking.

UAT base URL: https://uat-dev.thainexus.co.th/functions

Same function paths as production (apiQuote, apiShippingServices, shipmentCrud). Example:

  • POSThttps://uat-dev.thainexus.co.th/functions/apiQuote
  • POSThttps://uat-dev.thainexus.co.th/functions/shipmentCrud
  • POSThttps://uat-dev.thainexus.co.th/functions/apiShippingServices

Cách nhận khóa API UAT

  1. 01

    Request a UAT API key

    UAT keys are not self-serve. Email contact@thainexus.co.th (or contact your Thai Nexus account manager) and ask for a UAT API key. Keys use the format uat_tnx_... and only work on the UAT host.

  2. 02

    Call the UAT base URL

    Send the same paths as production, but against https://uat-dev.thainexus.co.th/functions. Do not use a production tnx_... token on UAT, and do not use a uat_tnx_... token on production.

  3. 03

    Authenticate UAT requests

    Send Authorization: Bearer uat_tnx_... or include api_token in the JSON body. shipmentCrud always expects api_token in the body.

Ví dụ về yêu cầu báo giá UAT

curl -X POST https://uat-dev.thainexus.co.th/functions/apiQuote \
  -H "Content-Type: application/json" \
  -d '{
    "api_token": "uat_tnx_XXXXXXXX_XXXXXXXX_XXXXXXXX",
    "country": "US",
    "actual_weight_kg": 2.5,
    "length_cm": 30,
    "width_cm": 20,
    "height_cm": 15,
    "is_document": false
  }'
  • Supported on UAT: apiQuote, apiShippingServices, and shipmentCrud.
  • shipmentCrud on UAT is a sandbox. Creates, updates, and deletes stay on UAT and do not write to production shipments.
  • There is no UAT for tracking events or the Tracking API. Use public tracking or request production Tracking API access below.
  • When your integration is ready, switch the base URL to production and use your Profile Settings tnx_... token.

Need a key? Email contact@thainexus.co.th with subject "UAT API key request".

Xác thực

Steps below are for production (tnx_...). For UAT keys, see UAT (test) environment.

  1. 01

    Create a free client account

    Register at https://app.thainexus.co.th/register, verify your email, and sign in.

  2. 02

    Generate an API token

    Open Profile Settings in the client app and generate a token (format tnx_...). Keep it secret. Store integrations (WooCommerce, Shopify, BigCommerce) use the same token.

  3. 03

    Authenticate requests

    Send Authorization: Bearer tnx_... or include api_token in the JSON body. All shipmentCrud endpoints pass api_token in the request body.

Điểm cuối

Quotation API

POST /apiQuote

Full endpoint: https://app.thainexus.co.th/functions/apiQuote

Returns shipping quotes from all active couriers for a given package. Rates come from our live pricing engine. Destination TH and THAILAND are accepted. Unlike the public shipping calculator, this API does not suppress domestic Thailand quotes.

Auth: Pass api_token in the request body (from Profile Settings)

Các trường yêu cầu

Cánh đồngMô tả
api_tokenstring - Your API token
countrystring - ISO code (US, GB, TH, JP) or full name (UNITED STATES, THAILAND). TH is not suppressed.
actual_weight_kgnumber - Actual weight in kg
length_cmnumber - Package length in cm
width_cmnumber - Package width in cm
height_cmnumber - Package height in cm
is_documentboolean - Optional (default false). If true, returns only document-type quotes. If false, excludes document quotes.

Ví dụ về yêu cầu

{
  "api_token": "tnx_XXXXXXXX_XXXXXXXX_XXXXXXXX_XXXXXXXX",
  "country": "US",
  "actual_weight_kg": 2.5,
  "length_cm": 30,
  "width_cm": 20,
  "height_cm": 15,
  "is_document": false
}

cURL example

curl -X POST https://app.thainexus.co.th/functions/apiQuote \
  -H "Content-Type: application/json" \
  -d '{
    "api_token": "tnx_XXXXXXXX_XXXXXXXX_XXXXXXXX_XXXXXXXX",
    "country": "US",
    "actual_weight_kg": 2.5,
    "length_cm": 30,
    "width_cm": 20,
    "height_cm": 15,
    "is_document": false
  }'

Ví dụ về câu trả lời

{
  "success": true,
  "country": "US",
  "package": {
    "actual_weight_kg": 2.5,
    "length_cm": 30,
    "width_cm": 20,
    "height_cm": 15
  },
  "quotes_count": 3,
  "quotes": [
    {
      "courier_name": "flex_dap",
      "display_name": "Flex DAP",
      "delivery_type": "pickup",
      "estimated_days": "5-10",
      "final_price_thb": 1250,
      "currency": "THB",
      "chargeable_weight_kg": 2.5,
      "weight_used": "actual",
      "volumetric_weight_kg": 1.8,
      "is_oversize": false
    }
  ]
}

Response fields

Cánh đồngMô tả
courier_nameInternal courier ID
display_nameHuman-readable name
final_price_thbTotal price in THB
estimated_daysDelivery estimate (e.g. "5-10")
chargeable_weight_kgWeight used for pricing
weight_used"actual" or "volumetric"
  • Unlike the public calculator, domestic Thailand quotes are not suppressed.
  • Live testing is available in the client app under Integrations / API documentation.
  • For pre-production testing, call the same path on https://uat-dev.thainexus.co.th/functions with a uat_tnx_... key (contact us for a UAT key).

Service List API

POST /apiShippingServices

Full endpoint: https://app.thainexus.co.th/functions/apiShippingServices

Returns all active shipping services with their name, logo, and ID. Uses the same personal API token from Profile Settings (the tnx_... token) as apiQuote and other client APIs.

Auth: Bearer token recommended, or api_token in the request body

Các trường yêu cầu

Cánh đồngMô tả
api_tokenOptional if Authorization: Bearer tnx_... is set. No other body fields required.

Ví dụ về yêu cầu

{
  "api_token": "tnx_xxxxxxxxxxxxxxxxxxxx"
}

cURL example

curl --location 'https://app.thainexus.co.th/functions/apiShippingServices' \
  --header 'Authorization: Bearer tnx_xxxxxxxxxxxxxxxxxxxx'

fetch example

const response = await fetch(
  "https://app.thainexus.co.th/functions/apiShippingServices",
  {
    method: "GET",
    headers: {
      "Authorization": "Bearer tnx_xxxxxxxxxxxxxxxxxxxx"
    }
  }
);
const data = await response.json();

Ví dụ về câu trả lời

{
  "success": true,
  "cached": false,
  "cache_expires_at": "2026-06-12T10:00:00.000Z",
  "total": 10,
  "data": [
    {
      "id": "swift_dap",
      "service_name": "Thai Nexus Express Swift DAP",
      "logo": "https://..."
    }
  ]
}

Response fields

Cánh đồngMô tả
idstring - Unique service identifier (e.g. swift_dap)
service_namestring - Full display name
logostring | null - URL to the service logo image
cachedboolean - Whether this response was reused
cache_expires_atISO datetime - When this response expires
  • Use service IDs when creating shipments from your store integration.
  • UAT: same path on https://uat-dev.thainexus.co.th/functions with a uat_tnx_... key.

Shipment CRUD API

POST /shipmentCrud

Full endpoint: https://app.thainexus.co.th/functions/shipmentCrud

All endpoints use the shipmentCrud backend function. Pass the action field to select the operation. Soft-delete is used - records remain in the database for audit but are excluded from standard queries.

Auth: Pass your api_token in the request body (get it from Profile Settings)

Các trường yêu cầu

Cánh đồngMô tả
api_tokenYour personal API token
actioncreate | update | get | list | delete | restore
request_numberRequired for get / update / delete / restore
dataObject with shipment fields (create / update)
page / limit / statusOptional list filters
reasonOptional delete reason

Ví dụ về yêu cầu

{
  "api_token": "tnx_YOUR_TOKEN",
  "action": "create",
  "data": {
    "shipper_address": {
      "name": "John Doe",
      "phone": "+66812345678",
      "address_line1": "123 Sukhumvit",
      "city": "Bangkok",
      "country": "TH"
    },
    "consignee_address": {
      "name": "Jane Smith",
      "phone": "+12025551234",
      "address_line1": "456 Main St",
      "city": "New York",
      "state": "NY",
      "postal_code": "10001",
      "country": "US"
    },
    "actual_weight_kg": 2.5,
    "length_cm": 30,
    "width_cm": 20,
    "height_cm": 15,
    "shipment_type": "parcel",
    "shipment_description": "Electronics"
  }
}

Actions

Create shipment
action: create

Create a new shipment request with origin/destination/dimensions. Volumetric weight is auto-calculated from dimensions. Status defaults to pending.

Dữ liệu yêu cầu
{
  "api_token": "tnx_YOUR_TOKEN",
  "action": "create",
  "data": {
    "shipper_address": {
      "name": "John Doe",
      "phone": "+66812345678",
      "address_line1": "123 Sukhumvit",
      "city": "Bangkok",
      "country": "TH"
    },
    "consignee_address": {
      "name": "Jane Smith",
      "phone": "+12025551234",
      "address_line1": "456 Main St",
      "city": "New York",
      "state": "NY",
      "postal_code": "10001",
      "country": "US"
    },
    "actual_weight_kg": 2.5,
    "length_cm": 30,
    "width_cm": 20,
    "height_cm": 15,
    "shipment_type": "parcel",
    "shipment_description": "Electronics"
  }
}
Response
{
  "success": true,
  "action": "create",
  "data": {
    "id": "abc123",
    "request_number": "SR-X9K2F7",
    "status": "pending",
    "volumetric_weight_kg": 1.8,
    "submitted_date": "2026-04-24T10:00:00Z"
  }
}
Update shipment
action: update

Update a shipment's details. Blocked for shipped/completed shipments. Updates are blocked when status is: in_transit, delivered, confiscated, returned, lost. Staff can bypass this restriction.

Dữ liệu yêu cầu
{
  "api_token": "tnx_YOUR_TOKEN",
  "action": "update",
  "request_number": "SR-X9K2F7",
  "data": {
    "actual_weight_kg": 3.0,
    "shipment_description": "Updated description"
  }
}
Response
{
  "success": true,
  "action": "update",
  "data": {
    "id": "abc123",
    "request_number": "SR-X9K2F7",
    "updated_fields": ["actual_weight_kg", "shipment_description", "volumetric_weight_kg"]
  }
}
Get shipment
action: get

Get a single shipment by ID or request number.

Dữ liệu yêu cầu
{
  "api_token": "tnx_YOUR_TOKEN",
  "action": "get",
  "request_number": "SR-X9K2F7"
}
Response
{
  "success": true,
  "action": "get",
  "data": { /* full ShipmentRequest entity */ }
}
List shipments
action: list

Paginated list of shipments for the authenticated user. Staff can list all shipments or filter by client_email. Soft-deleted records are excluded.

Dữ liệu yêu cầu
{
  "api_token": "tnx_YOUR_TOKEN",
  "action": "list",
  "page": 1,
  "limit": 20,
  "status": "pending"
}
Response
{
  "success": true,
  "action": "list",
  "data": [ /* summary shipment objects */ ],
  "pagination": { "page": 1, "limit": 20, "total": 45, "total_pages": 3 }
}
Delete shipment
action: delete

Soft-delete a shipment. Record remains for audit. Sets is_deleted=true with timestamp. Active/shipped shipments cannot be deleted by clients.

Dữ liệu yêu cầu
{
  "api_token": "tnx_YOUR_TOKEN",
  "action": "delete",
  "request_number": "SR-X9K2F7",
  "reason": "Created by mistake"
}
Response
{
  "success": true,
  "action": "delete",
  "data": {
    "id": "abc123",
    "request_number": "SR-X9K2F7",
    "deleted_at": "2026-04-24T10:30:00Z"
  }
}
Restore shipment
action: restore

Restore a soft-deleted shipment (staff only).

Dữ liệu yêu cầu
{
  "api_token": "tnx_YOUR_TOKEN",
  "action": "restore",
  "request_number": "SR-X9K2F7"
}
Response
{
  "success": true,
  "action": "restore",
  "data": { "id": "abc123", "request_number": "SR-X9K2F7" }
}
  • Volumetric weight is auto-calculated from dimensions. Status defaults to pending on create.
  • Updates are blocked when status is in_transit, delivered, confiscated, returned, or lost (staff can bypass).
  • Soft-delete sets is_deleted=true with timestamp. Active/shipped shipments cannot be deleted by clients.
  • Restore is staff only.
  • Staff can list all shipments or filter by client_email. Soft-deleted records are excluded from list.
  • UAT: same actions on https://uat-dev.thainexus.co.th/functions/shipmentCrud with a uat_tnx_... key. UAT shipment data is sandbox-only and does not affect production.

Tracking API

POST /Tracking API (registration required)

Programmatic access to Thai Nexus Express tracking events for TNX references and linked carrier updates. Access is provisioned after you submit the registration form on this page. There is no UAT environment for tracking events.

Auth: Issued after registration approval

Các trường yêu cầu

Cánh đồngMô tả
trackingNumberTNX reference or supported carrier/ref number
refreshOptional boolean to force a fresh pull

Ví dụ về yêu cầu

{
  "trackingNumber": "TNX1783820599067POM",
  "refresh": true
}
  • Public browser tracking stays on tracking.thainexus.co.th without an API key.
  • API access is for platforms, marketplaces, and internal tools that need structured event data.
  • Rate limits apply; 429 responses mean you should back off and retry.
  • No UAT for tracking events. Test against production tracking only after access is approved.

API đón đối tác

Tài khoản đối tác có thể gửi yêu cầu nhận hàng tại Thái Lan và quản lý các địa chỉ nhận hàng đã lưu thông quashipCrud. Điều này tách biệt với CRUD vận chuyển quốc tế và yêu cầu đối tác client_type.

  • Cùng một URL cơ sở: POST https://app.thainexus.co.th/functions/shipmentCrud
  • Các hành động bao gồm verify_account, list_destination, quote_fee, tạo, liệt kê, nhận, hủy và get_tracking.
  • Đặt địa chỉ hoặc địa chỉ nhận hàng api_scope cho danh sách và nhận đường gọi đến người xử lý nhận hàng.

Yêu cầu quyền truy cập API theo dõi

API theo dõi không tự phục vụ. Hãy gửi biểu mẫu này và chúng tôi sẽ trả lời trong vòng một ngày làm việc kèm theo thông tin xác thực hoặc các câu hỏi tiếp theo. Không có môi trường UAT để theo dõi sự kiện; quyền truy cập chỉ được sản xuất sau khi được phê duyệt.

Câu hỏi thường gặp dành cho nhà phát triển

API Thai Nexus có phải là gói trả phí không?
Báo giá, danh sách dịch vụ vận chuyển và giao hàng CRUD sử dụng mã thông báo tài khoản khách hàng miễn phí từ Cài đặt hồ sơ trong ứng dụng khách. Không có phí mỗi cuộc gọi đối với việc tích hợp cửa hàng tiêu chuẩn trong phạm vi sử dụng hợp lý. Quyền truy cập API theo dõi được cấp sau khi mẫu đăng ký được xem xét. Việc sử dụng API theo dõi khối lượng lớn phải được tiết lộ trên biểu mẫu.
Tôi lấy mã thông báo API Thai Nexus ở đâu?
Đăng nhập vào ứng dụng khách, mở Cài đặt hồ sơ và tạo hoặc sao chép mã thông báo sản xuất tnx_ của bạn. Tích hợp WooCommerce, Shopify và BigCommerce sử dụng cùng một mã thông báo. Khóa UAT sử dụng tiền tố uat_tnx_ và được cấp theo yêu cầu; chúng không có sẵn trong Cài đặt hồ sơ. Không bao giờ nhúng mã thông báo vào mã giao diện người dùng công khai.
Môi trường API Thai Nexus UAT là gì?
UAT chạy tại uat-dev.thainexus.co.th để báo giá, dịch vụ vận chuyển và vận chuyển CRUD trước khi bạn đi vào hoạt động. Yêu cầu khóa API UAT từ Thai Nexus; nó không tự phục vụ. Không có UAT để theo dõi sự kiện; tính năng theo dõi chỉ tiếp tục được sản xuất sau khi API theo dõi được phê duyệt.
Sự khác biệt giữa API theo dõi Thai Nexus và theo dõi công khai là gì?
Bất kỳ ai cũng có thể theo dõi số TNX trên track.thainexus.co.th mà không cần xác thực. API theo dõi trả về các sự kiện JSON có cấu trúc cho hệ thống và yêu cầu đăng ký. Không có UAT để theo dõi. Áp dụng giới hạn tỷ lệ; HTTP 429 có nghĩa là lùi lại và thử lại.
Giới hạn tốc độ API Thai Nexus là gì?
Điểm cuối API theo dõi và theo dõi công khai bị giới hạn tỷ lệ trên mỗi IP và mã thông báo. Phản hồi HTTP 429 có nghĩa là chờ và thử lại với thời gian chờ. Việc bỏ phiếu số lượng lớn nên được thay thế bằng các khoảng thời gian hoặc webhook hợp lý khi có sẵn. Tiết lộ khối lượng dự kiến ​​trên biểu mẫu đăng ký API theo dõi.
Thai Nexus cung cấp những API nào để vận chuyển?
Báo giá, danh sách dịch vụ vận chuyển, điểm cuối API CRUD và theo dõi lô hàng. Mã thông báo sản xuất đến từ Cài đặt hồ sơ trong ứng dụng khách (tiền tố tnx_). Khóa UAT được cấp theo yêu cầu để báo giá và kiểm tra lô hàng. Đường dẫn đầy đủ và ví dụ có trên trang dành cho nhà phát triển.
Thai Nexus có tích hợp với Shopify không?
Có thông qua tích hợp Shopify đã xuất bản bằng cách sử dụng mã thông báo API ứng dụng khách của bạn để có tỷ lệ thanh toán trực tiếp và tạo lô hàng. Cài đặt từ trang tích hợp. Mã thông báo tương tự như WooCommerce và BigCommerce. API theo dõi là đăng ký riêng biệt.
Thai Nexus có tích hợp với WooCommerce không?
Đúng. Plugin WooCommerce sử dụng cùng mã thông báo tnx_ từ Cài đặt hồ sơ. Định cấu hình địa chỉ xuất xứ là kho Hua Hin hoặc Bangkok của bạn. Báo giá gọi điểm cuối báo giá được ghi lại trên trang nhà phát triển.
Xác thực API Thai Nexus hoạt động như thế nào?
Mã thông báo mang có tiền tố tnx_ từ Cài đặt hồ sơ sau khi khách hàng đăng nhập. Không bao giờ nhúng mã thông báo vào JavaScript giao diện người dùng công khai. Xoay vòng các mã thông báo bị xâm phạm ngay lập tức. UAT sử dụng khóa uat_tnx_ được cấp thủ công chứ không phải từ Cài đặt hồ sơ.
URL cơ sở API Thai Nexus là gì?
URL cơ sở sản xuất được ghi lại trên trang dành cho nhà phát triển và khớp với máy chủ được các lệnh gọi API ứng dụng khách sử dụng. Nối các tên hàm như apiQuote hoặcshipCrud. Máy chủ UAT riêng biệt tại uat-dev.thainexus.co.th để thử nghiệm trước khi hoạt động.
Làm cách nào để hiển thị phí vận chuyển trực tiếp khi thanh toán từ Thái Lan?
Gọi điểm cuối báo giá từ chương trình phụ trợ cửa hàng của bạn với trọng lượng, kích thước và quốc gia đích. Tích hợp Thai Nexus Shopify, WooCommerce và BigCommerce thực hiện cùng một cuộc gọi. Giá chỉ mang tính biểu thị cho đến khi nội dung được xác nhận; báo giá ràng buộc có thể cần xem xét thủ công đối với hàng hóa bị hạn chế.
Ai cung cấp API vận chuyển từ Thái Lan?
Thai Nexus Point Co., Ltd. cung cấp các điểm cuối REST để báo giá, vận chuyển và theo dõi. Đăng ký / ID thuế 0775567004498. API gốc của nhà cung cấp dịch vụ (DHL, FedEx) là các hợp đồng riêng biệt; Thai Nexus tóm tắt việc đặt chỗ nhiều hãng vận chuyển đằng sau một mã thông báo.