Skip to content

Get Tracking No

API Overview

Exchanges the tracking number you assigned to a parcel for the WMG tracking number of that parcel. Use it when your system holds only your own reference and you need the WMG number for labelling or tracking.

The parcel must already exist — create it first with Create Single Parcel.

Request Information

  • Method: POST
  • Path: /api/create-barcode
  • Authentication: Bearer Token

Request Headers

FieldDescription
Content-Typeapplication/json
AuthorizationBearer <token>

Request Parameters

The request body is in JSON format and includes the following fields:

ParameterTypeRequiredDescription
BarcodestringYesThe tracking number you assigned to the parcel (your own reference), maximum 50 characters.
LabelTypestringYesLabel type. Currently only CN23 is available. Maximum 10 characters.
OriginstringYesOriginating country as a 2-letter code, e.g. SG for Singapore, TW for Taiwan.
DestinationstringYesDestination country as a 2-letter code, e.g. TW for Taiwan, JP for Japan.

Request Body Example

json
{
    "Barcode": "CUST0001234567",
    "LabelType": "CN23",
    "Origin": "SG",
    "Destination": "JP"
}

Authentication

This endpoint uses Bearer token authentication.

Obtain a token from Get Token and send it as Authorization: Bearer <Token>.

Response Information

The response is in JSON format.

Response Format

FieldTypeDescription
Codeinteger0 = success; non-zero = failure
MessagestringHuman-readable result
DataobjectPayload; empty array [] on failure

Success Response

  • Status Code: 200
json
{
    "Code": 0,
    "Message": "Success",
    "Data": {
        "Barcode": "CY180000662SG"
    }
}
FieldTypeDescription
Data.BarcodestringThe WMG tracking number of the matched parcel.

Error Response

  • Status Code: 200 (business logic error) or 4xx/5xx (system error)
json
{
    "Code": 1,
    "Message": "Parcel not found",
    "Data": []
}

Code Reference

CodeDescription
0Success
1Failure

Example

Bash

bash
BASE_URL="https://api.postal.test.wmgdelivery.com"
TOKEN="your_access_token"

curl -X POST "$BASE_URL/api/create-barcode" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{"Barcode":"CUST0001234567","LabelType":"CN23","Origin":"SG","Destination":"JP"}'

Windows PowerShell

powershell
$BASE_URL = "https://api.postal.test.wmgdelivery.com"
$TOKEN    = "your_access_token"

$body = @{
    Barcode     = "CUST0001234567"
    LabelType   = "CN23"
    Origin      = "SG"
    Destination = "JP"
} | ConvertTo-Json

$response = Invoke-RestMethod -Uri "$BASE_URL/api/create-barcode" -Method Post `
    -ContentType "application/json" -Body $body -Headers @{Authorization = "Bearer $TOKEN"}
$response | ConvertTo-Json -Depth 10

Python

python
import requests

BASE_URL = "https://api.postal.test.wmgdelivery.com"
TOKEN    = "your_access_token"

resp = requests.post(f"{BASE_URL}/api/create-barcode", json={
    "Barcode": "CUST0001234567",
    "LabelType": "CN23",
    "Origin": "SG",
    "Destination": "JP",
}, headers={"Authorization": f"Bearer {TOKEN}"}, timeout=10)
print(resp.json())

Node.js / TypeScript

typescript
const BASE_URL = "https://api.postal.test.wmgdelivery.com";
const TOKEN = "your_access_token";

const res = await fetch(`${BASE_URL}/api/create-barcode`, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": `Bearer ${TOKEN}`,
  },
  body: JSON.stringify({
    Barcode: "CUST0001234567",
    LabelType: "CN23",
    Origin: "SG",
    Destination: "JP",
  }),
});
console.log(await res.json());

PHP

php
<?php
$BASE_URL = 'https://api.postal.test.wmgdelivery.com';
$TOKEN    = 'your_access_token';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $BASE_URL . '/api/create-barcode');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'Authorization: Bearer ' . $TOKEN,
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'Barcode'     => 'CUST0001234567',
    'LabelType'   => 'CN23',
    'Origin'      => 'SG',
    'Destination' => 'JP',
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$response = curl_exec($ch);
curl_close($ch);

echo json_encode(json_decode($response, true), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "\n";
?>

Notes

  • The parcel is matched on your tracking number together with Origin and Destination, and only within your own account. A mismatch on any of them returns Parcel not found.
  • Barcode, Origin and Destination are normalised to upper case before matching, so their case does not matter for this endpoint.
  • LabelType is validated for length but does not affect which parcel is matched. Send CN23.
  • All other parameters are case-sensitive.

Error Codes

codemessageDescription
1Parcel not foundNo parcel in your account matches the supplied Barcode, Origin and Destination.
1Barcode requireBarcode is missing or empty.
1max size of Barcode must be 50Barcode is longer than 50 characters.
1LabelType requireLabelType is missing or empty.
1max size of LabelType must be 10LabelType is longer than 10 characters.
1Origin requireOrigin is missing or empty.
1max size of Origin must be 2Origin is longer than 2 characters.
1Destination requireDestination is missing or empty.
1max size of Destination must be 2Destination is longer than 2 characters.
1Error encountered, please contact tech@wmg-group.com with screenshot of error page for resolution.Unexpected server error.
1003Token errorThe token is missing, expired, or superseded by a newer login. Call Get Token again.