واجهة برمجة التطبيقات (REST API) للشركاء

واجهة برمجة تطبيقات (API) لاستلام الشركاء

قم بدمج طلبات الاستلام وعناوين الاستلام المحفوظة لحسابات الشركاء (client_type: partner). تستخدم كل من طلبات الاستلام والشحنات الدولية نفس نقطة النهاية shipmentCrud. يتم توجيه طلبات الاستلام تلقائيًا عند استخدام الحقول الخاصة بالاستلام أو تعيين api_scope.

نقطة النهاية

رابط الإنتاج (POST فقط):

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

Request envelope

الميدانالوصف
api_tokenRequired. Partner token from Profile > API tab (tnx_...). Bearer header also works.
actionRequired. e.g. verify_account, create, list, get
api_scopeRequired for pickup list/get ("pickup") and address CRUD ("address")
dataRequired for create/update. Pickup fields go inside data, not at top level

Identifiers

الميدانالوصف
pickup_numberPU-XXXXXX format. From create response or list. Use for get, cancel, get_tracking.
id (pickup)24-char hex. Alternative to pickup_number for get.
destination_selectiontnx:{branchId} or partner:{warehouseId}. Copy exactly from list_destinations.
id (address)24-char hex from address list or create. Use for address get, update, delete.
waybill_numberYour reference string. You provide it on create.

مسار العمل الموصى به

  1. verify_account - confirm token works and account is partner
  2. allowed_cities - (optional) confirm pickup city is served
  3. list_destinations - get a real destination_selection value
  4. quote_fee - (optional) estimate fee before create
  5. create - submit pickup using values from list_destinations
  6. list / get - read back pickup_number for tracking or cancel
  7. get_tracking - only after staff approval assigns tracking code
  • Set api_scope: pickup for list and get pickup requests.
  • Set api_scope: address for all saved address CRUD calls.
  • Pickup routing also triggers when action is verify_account, allowed_cities, list_destinations, quote_fee, get_tracking, or cancel.
  • If you see shipper_address required on create, pickup was not routed. Include data.pickup_location, data.destination_selection, and data.waybill_number.

المصادقة

  1. 01

    Partner account required

    Pickup API is available only to partner accounts (client_type: partner). Standard client tokens return HTTP 403.

  2. 02

    Generate an API token

    In the client app, open Profile > API tab and copy your tnx_... token. Keep it secret. Do not embed tokens in public frontend code.

  3. 03

    Authenticate requests

    Include api_token in every JSON body, or send Authorization: Bearer tnx_... . All calls use POST with Content-Type: application/json.

منصة تجريبية لواجهة برمجة التطبيقات (API)

قم بإجراء مكالمات مباشرة مع Crud الخاص بشحنات الإنتاج عبر وكيل هذا الموقع. الصق رمز tnx_ الخاص بشريكك أدناه. تظل الرموز سارية فقط خلال جلسة المتصفح الحالية.

إجراءات طلب الاستلام

verify_account

POST /shipmentCrud

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

Confirms token and partner account type.

Auth: api_token in body or Bearer header

مثال على الطلب

{
  "api_token": "tnx_...",
  "action": "verify_account"
}

مثال على الرد

{
  "success": true,
  "account": {
    "user_email": "partner@example.com",
    "partner_id": "abc123",
    "partner_name": "Example Partner",
    "client_type": "partner"
  }
}

list_destinations

POST /shipmentCrud

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

Returns read-only destination options. Copy destination_selection exactly from tnx_branches[] or partner_branches[].

Auth: api_token

مثال على الطلب

{
  "api_token": "tnx_...",
  "action": "list_destinations"
}

quote_fee

POST /shipmentCrud

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

Estimate pickup fee before creating a request.

Auth: api_token

حقول الطلب

الميدانالوصف
cityPickup city (must be in allowed cities)
items[]Parcel lines with description, quantity, weight_kg, length_cm, width_cm, height_cm

مثال على الطلب

{
  "api_token": "tnx_...",
  "action": "quote_fee",
  "city": "Bangkok",
  "items": [{
    "description": "Box",
    "quantity": 1,
    "weight_kg": 2.5,
    "length_cm": 30,
    "width_cm": 20,
    "height_cm": 15
  }]
}

create

POST /shipmentCrud

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

Creates a pickup request. Run list_destinations first and copy a real destination_selection.

Auth: api_token

حقول الطلب

الميدانالوصف
data.pickup_location or data.pickup_address_idInline contact + address, or saved address id
data.destination_selectionFrom list_destinations (tnx:... or partner:...)
data.waybill_numberYour reference / waybill number
data.items[] or data.parcels[]At least one parcel with weight and all dimensions

مثال على الطلب

{
  "api_token": "tnx_...",
  "action": "create",
  "data": {
    "pickup_location": {
      "contact_name": "John Doe",
      "contact_phone": "+66812345678",
      "address_line1": "123 Sukhumvit Road",
      "city": "Bangkok",
      "postal_code": "10110"
    },
    "destination_selection": "tnx:69a5bdade602b67c968f2ef6",
    "waybill_number": "WB123456789",
    "items": [{
      "description": "Electronics box",
      "quantity": 1,
      "weight_kg": 2.5,
      "length_cm": 30,
      "width_cm": 20,
      "height_cm": 15
    }]
  }
}

list

POST /shipmentCrud

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

Paginated list of your partner account pickup requests. Always set api_scope: pickup.

Auth: api_token + api_scope: pickup

مثال على الطلب

{
  "api_token": "tnx_...",
  "api_scope": "pickup",
  "action": "list",
  "page": 1,
  "limit": 20
}

get

POST /shipmentCrud

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

Fetch one pickup by pickup_number (preferred) or internal id.

Auth: api_token + api_scope: pickup

مثال على الطلب

{
  "api_token": "tnx_...",
  "api_scope": "pickup",
  "action": "get",
  "pickup_number": "PU-NWU19Y"
}

cancel

POST /shipmentCrud

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

Cancel an open pickup (pending, requested, or confirmed). reason is required.

Auth: api_token

مثال على الطلب

{
  "api_token": "tnx_...",
  "action": "cancel",
  "pickup_number": "PU-ABC123",
  "reason": "Customer rescheduled"
}

get_tracking

POST /shipmentCrud

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

Live tracking after staff approval assigns a tracking code.

Auth: api_token

مثال على الطلب

{
  "api_token": "tnx_...",
  "action": "get_tracking",
  "pickup_number": "PU-ABC123"
}

عناوين الاستلام المحفوظة

استخدم عنوان api_scope في جميع استدعاءات CRUD المتعلقة بالعناوين. قم بالإشارة إلى pickup_address_id عند الإنشاء لإعادة استخدام موقع محفوظ.

list

POST /shipmentCrud

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

List saved pickup addresses for your partner account.

مثال على الطلب

{
  "api_token": "tnx_...",
  "api_scope": "address",
  "action": "list",
  "page": 1,
  "limit": 20
}

create

POST /shipmentCrud

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

Create a saved pickup address. City must be in the allowed service area.

مثال على الطلب

{
  "api_token": "tnx_...",
  "api_scope": "address",
  "action": "create",
  "data": {
    "address_name": "Bangkok Warehouse",
    "contact_name": "John Doe",
    "contact_phone": "+66812345678",
    "address_line1": "456 Warehouse Lane",
    "city": "Bangkok",
    "postal_code": "10110"
  }
}

منطقة الخدمة

يقتصر الاستلام على تايلاند فقط. ويجب أن تقع مدينة الاستلام ضمن منطقة الخدمة المسموح بها.

  • Bangkok
  • Hua Hin
  • Pran Buri
  • Cha-am
  • Tha Yang
  • Ban Lat
  • Phetchaburi
  • Khao Yoi
  • Pak Tho
  • Samut Songkhram
  • Samut Sakhon

الأخطاء

HTTP status codes

الميدانالوصف
400Validation error (missing field, invalid city, bad destination_selection)
401Missing or invalid api_token
403Token valid but account is not a partner
404Pickup request or address not found
502Tracking app temporarily unavailable (get_tracking)

الأسئلة الشائعة حول خدمة استلام الشريك

من يمكنه استخدام واجهة برمجة تطبيقات «Partner Pickup»؟
حسابات الشركاء فقط (client_type: partner). أما رموز العملاء القياسية فتتلقى استجابة HTTP 403. وتتوفر واجهة برمجة تطبيقات Pickup فقط لحسابات الشركاء.
ما هي نقطة نهاية واجهة برمجة التطبيقات (API) الخاصة بخدمة «Partner Pickup»؟
تستخدم جميع المكالمات المتعلقة بالاستلام والعناوين المحفوظة طريقة POST https://app.thainexus.co.th/functions/shipmentCrud مع نوع المحتوى Content-Type application/json. وتقوم نفس نقطة النهاية بمعالجة عمليات CRUD الخاصة بالشحن الدولي عندما لا يتم تشغيل مسار الاستلام.
كيف يمكنني الحصول على «destination_selection» عند إنشاء السجل؟
استدعِ الدالة `list_destinations` وانسخ `destination_selection` بالضبط من `tnx_branches` أو `partner_branches`. لا تبتكر قيمًا مثل `tnx:test-branch`.
متى يكون استخدام api_scope ضروريًا؟
اضبط «api_scope» على «pickup» لقائمة الاستلام وعمليات الاستلام. اضبط «api_scope» على «address» لعمليات إنشاء وقراءة وحذف وتعديل العناوين المحفوظة. يتم توجيه إجراءات الاستلام الأخرى تلقائيًا.