Shipment Tracking API

The WooCommerce REST API enable external apps use a set of API endpoints to read and write various parts of WooCommerce data. The AST plugin extends the WooCommerce Rest API and adds Shipment Tracking endpoints that allows to create, view, and delete shipment tracking information in orders.

To use the Shipment Tracking endpoint, you’ll need to generate a Rest API Key for your WooCommerce store. These API keys are the permission for external systems to connect with your store’s API.

🔐 How to Get WooCommerce API Keys

To authenticate with the Shipment Tracking API, you’ll need your WooCommerce Consumer Key and Consumer Secret.

🛠️ Steps to Generate API Keys:

  1. Go to your WordPress dashboard.
  2. Navigate to WooCommerce > Settings > Advanced > REST API.
  3. Click Add Key.
  4. Enter a name (e.g., “AST API Access”).
  5. Choose a user (with Admin rights recommended).
  6. Set Permissions to Read/Write.
  7. Click Generate API Key.

✅ You will now see your Consumer Key and Consumer Secret—copy and store them securely.

blank

🧾 Shipment Tracking API Properties

PropertyTypeRequiredDescription
order_idinteger✅ YesWooCommerce Order ID.
tracking_providerstring✅ YesShipping carrier (must match an enabled name or alias).
tracking_numberstring✅ YesShipment tracking number.
date_shippedstring✅ YesDate in format: DD-MM-YYYY or MM-DD-YYYY (must match API settings).
status_shippedinteger✅ Yes0 – No change
1 – Mark order as Shipped
2 – Mark as Partially Shipped
(Default: 0)
replace_trackingbooleanNo0 – Add to existing tracking
1 – Replace all tracking
(Default: 0)
skustringNoComma-separated SKUs (for per-item tracking).
qtystringNoQuantities matching SKUs (for per-item tracking).

🔄 Add Shipment Tracking to an Order

Endpoint:

https://yourdomaon.com/wp-json/wc-shipment-tracking/v3/orders/<order_id>/shipment-trackings

Please note: the shipment tracking endpoint works with WooCommerce API v1, v2, and v3. In the documentation, only v1 is shown. We are also compatible with old version od the AST PRO REST API endpoint – wc-ast/v3.

Example:

POST /wp-json/wc-shipment-tracking/v3/orders/<order_id>/shipment-trackings/

curl -X POST https://your-domain.com/wp-json/wc-shipment-tracking/v3/orders/<order_id>/shipment-tracking
	-u consumer_key:consumer_secret 
	-H "Content-Type: application/json" 
	-d '{
		"tracking_provider": "Fedex",
		"tracking_number": "12345678",
		"date_shipped": "2019-03-08",
		"status_shipped": 1,
		"replace_tracking": 1
	}'

Response:

"Tracking ID: fb7170d97d0e628bc3b565999d07c6a9"

🔍 Get Shipment Tracking Info

Endpoint:

GET /wp-json/wc-shipment-tracking/v3/orders/<order_id>/shipment-trackings/

Example:

curl -X GET https://your-domain.com/wp-json/wc-shipment-tracking/v3/orders/<order_id>/shipment-trackings 
  -u consumer_key:consumer_secret 

Response:


  {
  "tracking_id": "feb9bde4475fda92cc9408607b7ecb66",
  "tracking_provider": "Fedex",
  "tracking_link": "http://www.fedex.com/Tracking?action=track&tracknumbers=12345678",
  "tracking_number": "12345678",
  "date_shipped": "2019-03-08",
  "_links": {
    "self": [
      {
        "href": "https://your-domain.com/wp-json/wc/v1/orders/340/shipment-trackings"
      }
    ],
    "collection": [
      {
        "href": "https://your-domain.com/wp-json/wc/v1/orders/340/shipment-trackings"
      }
    ],
    "up": [
      {
        "href": "https://your-domain.com/wp-json/wc/v1/orders/340"
      }
    ]
  }
}

❌ Delete Shipment Tracking

Endpoint:

DELETE /wp-json/wc-shipment-tracking/v3/orders/<order_id>/shipment-trackings/<tracking_id>

Example:

curl -X DELETE https://your-domain.com/wp-json/wc-shipment-tracking/v3/orders/340/shipment-trackings/fa61d174a05d2f34323b51d92823947d \
-u consumer_key:consumer_secret

Response:

"Tracking ID: fa61d174a05d2f34323b51d92823947d"

🧭 Get Shipping Carriers

Endpoint:

GET /wp-json/wc-shipment-tracking/v3/orders/<order_id>/shipment-trackings/providers

Example:

curl -X GET https://your-domain.com/wp-json/wc-shipment-tracking/v3/orders/340/shipment-trackings/providers \
-u consumer_key:consumer_secret

Response Sample:

{
  "United States (US)": {
    "USPS": "https://tools.usps.com/go/TrackConfirmAction_input?qtc_tLabels1=%number%",
    "UPS": "http://wwwapps.ups.com/WebTracking/track?track=yes&trackNums=%number%"
  },
  "India": {
    "Delhivery": "https://www.delhivery.com/track/package/%number%"
  }
}

❗ API Request Errors

Status CodeErrorDescription
200 OKSuccessRequest completed successfully.
201 CreatedTracking AddedTracking successfully created.
400 Bad RequestInvalid Request FormatRequest is malformed or missing required data.
401 UnauthorizedAuthentication FailedAPI keys are missing, incorrect, or lack permissions.
403 ForbiddenAccess DeniedUser lacks the correct privileges.
404 Not FoundResource Not FoundOrder ID or endpoint does not exist.
409 ConflictDuplicate EntryTracking already exists without replace flag.
500 Internal ErrorServer ErrorServer-side issue. Check logs or contact support.

📬 Postman Example

To test using Postman:

  1. Method: POST
  2. URL:
https://your-domain.com/wp-json/wc-shipment-tracking/v3/orders/340/shipment-trackings
  1. Authorization:
    • Type: Basic Auth
    • Username: Consumer Key
    • Password: Consumer Secret
  2. Headers:
Content-Type: application/json
  1. Body → Raw → JSON:
{
"tracking_provider": "UPS",
"tracking_number": "1Z9999",
"date_shipped": "10-07-2024",
"status_shipped": 1
}

✅ Click Send and confirm the response includes a Tracking ID.

blank

Then go to the Authorization section and select Type Basic Auth. Use REST API Consumer key and consumer secret in the username and password field and click on Send.

blank

Free

Download