{
  "openapi": "3.0.3",
  "info": {
    "title": "4PX International Tracking API",
    "version": "1.0.0",
    "description": "Read-only shipment tracking. Customer names, email addresses and street addresses are excluded.",
    "contact": {
      "email": "customer@4px.it.com",
      "url": "https://4px.it.com/support"
    }
  },
  "servers": [
    {
      "url": "https://4px.it.com"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/api/v1/tracking/{number}": {
      "get": {
        "operationId": "getShipmentTracking",
        "summary": "Get a shipment\u2019s current tracking information",
        "description": "Events are newest first and only include visible, due updates. Paused generated events, hidden events, and generated stages beyond the administrator\u2019s selected stop stage are excluded. Poll at most once per minute per shipment. No artificial UI delay applies to API calls.",
        "parameters": [
          {
            "name": "number",
            "in": "path",
            "required": true,
            "description": "Case-insensitive tracking number. The example is illustrative, not a guaranteed stored shipment.",
            "schema": {
              "type": "string",
              "pattern": "^([Dd][Ee][Mm][Oo])?4[Pp][Xx][A-Za-z0-9]{8,32}$"
            },
            "example": "4PX0123456789ABCDEF"
          }
        ],
        "responses": {
          "200": {
            "description": "Current shipment status and visible events, newest first.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Shipment"
                },
                "example": {
                  "number": "4PX0123456789ABCDEF",
                  "mode": "customer_test",
                  "simulated": true,
                  "notice": "Shipment information is provided by the operator.",
                  "origin": "Shenzhen, China",
                  "destination": "London, United Kingdom",
                  "carrier": "4PX",
                  "estimatedDelivery": "2026-10-12T16:00:00.000Z",
                  "status": "In transit",
                  "stage": 1,
                  "progressStage": 1,
                  "events": [
                    {
                      "at": "2026-10-02T09:00:00.000Z",
                      "location": "Shenzhen",
                      "description": "Shipment picked up",
                      "stage": 1,
                      "simulated": true
                    }
                  ],
                  "trackingUrl": "https://4px.it.com/track?number=4PX0123456789ABCDEF",
                  "lastEventAt": "2026-10-02T09:00:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "Invalid tracking number.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "invalid_tracking_number"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "unauthorized"
                }
              }
            }
          },
          "404": {
            "description": "Unknown, trashed, or permanently deleted shipment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "not_found"
                }
              }
            }
          },
          "429": {
            "description": "120 requests per minute per IP exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "rate_limited"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds until the next request window.",
                "schema": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 60
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable; error can also be api_not_configured.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": "temporarily_unavailable"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Server-side shared API key supplied by the site administrator. Never expose it in browser JavaScript."
      }
    },
    "schemas": {
      "Shipment": {
        "type": "object",
        "required": [
          "number",
          "notice",
          "origin",
          "destination",
          "carrier",
          "status",
          "mode",
          "simulated",
          "estimatedDelivery",
          "stage",
          "progressStage",
          "events",
          "trackingUrl",
          "lastEventAt"
        ],
        "properties": {
          "number": {
            "type": "string"
          },
          "notice": {
            "type": "string"
          },
          "origin": {
            "type": "string"
          },
          "destination": {
            "type": "string"
          },
          "carrier": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "mode": {
            "type": "string",
            "enum": [
              "demo",
              "customer_test"
            ]
          },
          "simulated": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "estimatedDelivery": {
            "type": "string",
            "format": "date-time"
          },
          "stage": {
            "type": "integer",
            "minimum": -1,
            "maximum": 7
          },
          "progressStage": {
            "type": "integer",
            "minimum": -1,
            "maximum": 5
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TrackingEvent"
            }
          },
          "trackingUrl": {
            "type": "string",
            "format": "uri"
          },
          "lastEventAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "TrackingEvent": {
        "type": "object",
        "required": [
          "at",
          "location",
          "description",
          "stage",
          "simulated"
        ],
        "properties": {
          "at": {
            "type": "string",
            "format": "date-time"
          },
          "location": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "stage": {
            "type": "integer",
            "minimum": 0,
            "maximum": 7
          },
          "simulated": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "enum": [
              "invalid_tracking_number",
              "unauthorized",
              "not_found",
              "rate_limited",
              "api_not_configured",
              "temporarily_unavailable"
            ]
          }
        }
      }
    }
  }
}
