{
  "openapi": "3.1.0",
  "info": {
    "title": "Xpedora partner API",
    "version": "1.0.0",
    "description": "Shipment tracking and approved partner operations. This is the Xpedora contract. See the 17TRACK onboarding guide for carrier integration."
  },
  "servers": [
    {
      "url": "https://xpedora.com"
    }
  ],
  "security": [
    {
      "PartnerBearer": []
    }
  ],
  "paths": {
    "/api/partners/v1/tracking/lookup": {
      "post": {
        "operationId": "lookupTracking",
        "summary": "Look up shipment tracking",
        "x-required-scope": "tracking:read",
        "responses": {
          "200": {
            "description": "Current shipment status and newest scans first.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "shipment": {
                      "$ref": "#/components/schemas/TrackingShipment"
                    }
                  },
                  "required": [
                    "shipment"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "413": {
            "$ref": "#/components/responses/RequestTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "description": "1 KiB maximum.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "number": {
                    "$ref": "#/components/schemas/TrackingNumber"
                  }
                },
                "required": [
                  "number"
                ]
              }
            }
          }
        }
      }
    },
    "/api/partners/v1/tracking/batch": {
      "post": {
        "operationId": "batchTracking",
        "summary": "Look up multiple tracking numbers",
        "x-required-scope": "tracking:read",
        "responses": {
          "200": {
            "description": "Results follow the input order, including duplicates. Number strings are trimmed and uppercased.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TrackingBatchItem"
                      }
                    }
                  },
                  "required": [
                    "results"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "413": {
            "$ref": "#/components/responses/RequestTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "description": "4 KiB maximum. Invalid tracking numbers produce individual errors.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "numbers": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "minItems": 1,
                    "maxItems": 50
                  }
                },
                "required": [
                  "numbers"
                ]
              }
            }
          }
        }
      }
    },
    "/api/partners/v1/rates": {
      "post": {
        "operationId": "estimateRates",
        "summary": "Estimate rates from configured Xpedora tariffs",
        "description": "Read-only. An approved quote is required before creating a shipment.",
        "x-required-scope": "rates:read",
        "requestBody": {
          "required": true,
          "description": "4 KiB maximum.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A rate estimate for eligible services, or a quote required result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RatesResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "413": {
            "$ref": "#/components/responses/RequestTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/partners/v1/quotes": {
      "post": {
        "operationId": "createQuote",
        "summary": "Request a quote",
        "x-required-scope": "quotes:write",
        "responses": {
          "200": {
            "description": "Existing request returned for idempotent replay.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "quote": {
                      "$ref": "#/components/schemas/Quote"
                    }
                  },
                  "required": [
                    "quote"
                  ]
                }
              }
            }
          },
          "201": {
            "description": "Quote requested.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "quote": {
                      "$ref": "#/components/schemas/Quote"
                    }
                  },
                  "required": [
                    "quote"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "The request conflicts with the current record or an earlier request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "enum": [
                        "idempotency_conflict"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/RequestTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteRequest"
              }
            }
          },
          "description": "4 KiB maximum."
        }
      }
    },
    "/api/partners/v1/quotes/{reference}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/QuoteReference"
        }
      ],
      "get": {
        "operationId": "getQuote",
        "summary": "Get an owned quote",
        "x-required-scope": "quotes:write",
        "responses": {
          "200": {
            "description": "Current record returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "quote": {
                      "$ref": "#/components/schemas/Quote"
                    }
                  },
                  "required": [
                    "quote"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/partners/v1/quotes/{reference}/accept": {
      "parameters": [
        {
          "$ref": "#/components/parameters/QuoteReference"
        }
      ],
      "post": {
        "operationId": "acceptQuote",
        "summary": "Accept an owned quote offer",
        "x-required-scope": "quotes:write",
        "responses": {
          "200": {
            "description": "Current record returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "quote": {
                      "$ref": "#/components/schemas/Quote"
                    }
                  },
                  "required": [
                    "quote"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "The request conflicts with the current record or an earlier request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "enum": [
                        "quote_changed",
                        "quote_not_offered",
                        "offer_expired"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/RequestTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "description": "1 KiB maximum. Send the current offered amount, VAT and expiry.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteOffer"
              }
            }
          }
        }
      }
    },
    "/api/partners/v1/shipments": {
      "post": {
        "operationId": "createShipment",
        "summary": "Create a shipment from an accepted quote",
        "x-required-scope": "shipments:write",
        "responses": {
          "200": {
            "description": "Equivalent retry returned the existing shipment.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "shipment": {
                      "$ref": "#/components/schemas/Shipment"
                    }
                  },
                  "required": [
                    "shipment"
                  ]
                }
              }
            }
          },
          "201": {
            "description": "Shipment created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "shipment": {
                      "$ref": "#/components/schemas/Shipment"
                    }
                  },
                  "required": [
                    "shipment"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "The request conflicts with the current record or an earlier request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "enum": [
                        "quote_not_accepted",
                        "shipment_conflict"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/RequestTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ShipmentRequest"
              }
            }
          },
          "description": "4 KiB maximum."
        }
      }
    },
    "/api/partners/v1/shipments/{number}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ShipmentNumber"
        }
      ],
      "get": {
        "operationId": "getShipment",
        "summary": "Get an owned shipment",
        "x-required-scope": "shipments:write",
        "responses": {
          "200": {
            "description": "Current record returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "shipment": {
                      "$ref": "#/components/schemas/Shipment"
                    }
                  },
                  "required": [
                    "shipment"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/partners/v1/shipments/{number}/label": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ShipmentNumber"
        }
      ],
      "get": {
        "operationId": "getShipmentLabel",
        "summary": "Get the A6 SVG shipment label",
        "x-required-scope": "shipments:write",
        "responses": {
          "200": {
            "description": "SVG attachment with shipment address details and a Code 128 barcode.",
            "content": {
              "image/svg+xml": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            },
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "Shipment sender details are missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "const": "label_unavailable"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/partners/v1/pickups": {
      "post": {
        "operationId": "createPickup",
        "summary": "Request a pickup",
        "x-required-scope": "pickups:write",
        "responses": {
          "200": {
            "description": "Existing request returned for idempotent replay.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "pickup": {
                      "$ref": "#/components/schemas/Pickup"
                    }
                  },
                  "required": [
                    "pickup"
                  ]
                }
              }
            }
          },
          "201": {
            "description": "Pickup requested.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "pickup": {
                      "$ref": "#/components/schemas/Pickup"
                    }
                  },
                  "required": [
                    "pickup"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "The request conflicts with the current record or an earlier request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "enum": [
                        "idempotency_conflict",
                        "pickup_conflict"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/RequestTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PickupRequest"
              }
            }
          },
          "description": "4 KiB maximum."
        }
      }
    },
    "/api/partners/v1/pickups/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/PickupId"
        }
      ],
      "get": {
        "operationId": "getPickup",
        "summary": "Get an owned pickup",
        "x-required-scope": "pickups:write",
        "responses": {
          "200": {
            "description": "Current record returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "pickup": {
                      "$ref": "#/components/schemas/Pickup"
                    }
                  },
                  "required": [
                    "pickup"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "patch": {
        "operationId": "cancelPickup",
        "summary": "Cancel a requested pickup",
        "x-required-scope": "pickups:write",
        "responses": {
          "200": {
            "description": "Current record returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "pickup": {
                      "$ref": "#/components/schemas/Pickup"
                    }
                  },
                  "required": [
                    "pickup"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "The request conflicts with the current record or an earlier request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "enum": [
                        "invalid_transition"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/RequestTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string",
                    "const": "cancelled"
                  }
                },
                "required": [
                  "status"
                ],
                "additionalProperties": false
              }
            }
          },
          "description": "4 KiB maximum."
        }
      }
    }
  },
  "webhooks": {
    "shipmentTrackingUpdated": {
      "post": {
        "operationId": "shipmentTrackingUpdated",
        "summary": "Receive a tracking event from Xpedora",
        "security": [],
        "parameters": [
          {
            "name": "X-Xpedora-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Stable ID to deduplicate retries."
          },
          {
            "name": "X-Xpedora-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]+$"
            },
            "description": "Signature timestamp in Unix seconds."
          },
          {
            "name": "X-Xpedora-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^v1=[a-f0-9]{64}$"
            },
            "description": "HMAC-SHA256 of <timestamp>.<raw UTF-8 body> with the shared signing key."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Event accepted."
          },
          "default": {
            "description": "Delivery failed and may be retried."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "PartnerBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Xpedora-issued partner bearer token. Required scopes appear on each operation."
      }
    },
    "parameters": {
      "QuoteReference": {
        "name": "reference",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "pattern": "^[Xx][Qq]-[0-9A-Fa-f]{16}$"
        }
      },
      "ShipmentNumber": {
        "name": "number",
        "in": "path",
        "required": true,
        "schema": {
          "$ref": "#/components/schemas/TrackingNumber"
        }
      },
      "PickupId": {
        "name": "id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid",
          "pattern": "^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$"
        }
      },
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": true,
        "schema": {
          "type": "string",
          "minLength": 8,
          "maxLength": 128,
          "pattern": "^[A-Za-z0-9._~-]{8,128}$"
        },
        "description": "Reuse the key only to retry the same create request in this operation."
      }
    },
    "responses": {
      "InvalidRequest": {
        "description": "Invalid request.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string",
                  "const": "invalid_request"
                }
              },
              "required": [
                "error"
              ]
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Bearer token is missing or invalid.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string",
                  "const": "unauthorized"
                }
              },
              "required": [
                "error"
              ]
            }
          }
        }
      },
      "Forbidden": {
        "description": "Token lacks the required scope.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string",
                  "const": "forbidden"
                }
              },
              "required": [
                "error"
              ]
            }
          }
        }
      },
      "NotFound": {
        "description": "Resource is missing or inaccessible to this partner.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string",
                  "const": "not_found"
                }
              },
              "required": [
                "error"
              ]
            }
          }
        }
      },
      "RequestTooLarge": {
        "description": "JSON body exceeds the endpoint limit.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string",
                  "const": "request_too_large"
                }
              },
              "required": [
                "error"
              ]
            }
          }
        }
      },
      "UnsupportedMediaType": {
        "description": "Set Content-Type to application/json.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string",
                  "const": "unsupported_media_type"
                }
              },
              "required": [
                "error"
              ]
            }
          }
        }
      },
      "RateLimited": {
        "description": "Partner request rate limit exceeded.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string",
                  "const": "rate_limited"
                }
              },
              "required": [
                "error"
              ]
            }
          }
        }
      },
      "Unavailable": {
        "description": "The capability is unavailable or disabled.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string",
                  "const": "unavailable"
                }
              },
              "required": [
                "error"
              ]
            }
          }
        }
      }
    },
    "schemas": {
      "TrackingNumber": {
        "type": "string",
        "pattern": "^[Xx][Pp][Dd]-[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{16}$",
        "description": "Case-insensitive Xpedora shipment number. The service trims surrounding whitespace before validation."
      },
      "ShipmentStatus": {
        "type": "string",
        "enum": [
          "created",
          "picked_up",
          "in_transit",
          "out_for_delivery",
          "attempted",
          "delivered",
          "returned"
        ]
      },
      "LocationCoordinates": {
        "type": "object",
        "properties": {
          "latitude": {
            "type": "number",
            "minimum": -90,
            "maximum": 90
          },
          "longitude": {
            "type": "number",
            "minimum": -180,
            "maximum": 180
          }
        },
        "required": [
          "latitude",
          "longitude"
        ]
      },
      "TrackingEvent": {
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/ShipmentStatus"
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time",
            "description": "UTC timestamp."
          },
          "location": {
            "type": [
              "string",
              "null"
            ],
            "description": "Approved public scan area label, if available."
          },
          "locationCoordinates": {
            "$ref": "#/components/schemas/LocationCoordinates"
          }
        },
        "required": [
          "status",
          "occurredAt",
          "location"
        ]
      },
      "LastKnownLocation": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string"
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time",
            "description": "UTC timestamp."
          },
          "latitude": {
            "type": "number",
            "minimum": -90,
            "maximum": 90
          },
          "longitude": {
            "type": "number",
            "minimum": -180,
            "maximum": 180
          }
        },
        "required": [
          "label",
          "occurredAt"
        ]
      },
      "TrackingShipment": {
        "type": "object",
        "properties": {
          "number": {
            "$ref": "#/components/schemas/TrackingNumber"
          },
          "status": {
            "$ref": "#/components/schemas/ShipmentStatus"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "UTC timestamp."
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TrackingEvent"
            }
          },
          "lastKnownLocation": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/LastKnownLocation"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "number",
          "status",
          "updatedAt",
          "events",
          "lastKnownLocation"
        ]
      },
      "TrackingBatchItem": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "number": {
                "type": "string"
              },
              "shipment": {
                "$ref": "#/components/schemas/TrackingShipment"
              }
            },
            "required": [
              "number",
              "shipment"
            ]
          },
          {
            "type": "object",
            "properties": {
              "number": {
                "type": "string"
              },
              "error": {
                "type": "string",
                "enum": [
                  "invalid_request",
                  "not_found"
                ]
              }
            },
            "required": [
              "number",
              "error"
            ]
          }
        ]
      },
      "QuoteRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 2,
            "maxLength": 100
          },
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 254
          },
          "phone": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 30,
                "pattern": "^[+0-9() .-]*$"
              },
              {
                "type": "null"
              }
            ]
          },
          "originPostalCode": {
            "type": "string",
            "minLength": 2,
            "maxLength": 12,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9 -]{0,10}[A-Za-z0-9]$"
          },
          "destinationPostalCode": {
            "type": "string",
            "minLength": 2,
            "maxLength": 12,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9 -]{0,10}[A-Za-z0-9]$"
          },
          "pieces": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "description": "Number of parcels."
          },
          "weightKg": {
            "type": "number",
            "minimum": 0.01,
            "maximum": 1000
          },
          "lengthCm": {
            "type": "number",
            "minimum": 1,
            "maximum": 250
          },
          "widthCm": {
            "type": "number",
            "minimum": 1,
            "maximum": 250
          },
          "heightCm": {
            "type": "number",
            "minimum": 1,
            "maximum": 250
          },
          "locale": {
            "type": "string",
            "enum": [
              "el",
              "en"
            ]
          }
        },
        "required": [
          "name",
          "email",
          "originPostalCode",
          "destinationPostalCode",
          "pieces",
          "weightKg",
          "lengthCm",
          "widthCm",
          "heightCm",
          "locale"
        ]
      },
      "QuoteOffer": {
        "type": "object",
        "properties": {
          "priceCents": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10000000,
            "description": "Price in euro cents excluding VAT."
          },
          "vatBps": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10000,
            "description": "VAT in basis points."
          },
          "validUntil": {
            "type": "string",
            "format": "date"
          }
        },
        "required": [
          "priceCents",
          "vatBps",
          "validUntil"
        ]
      },
      "Quote": {
        "type": "object",
        "properties": {
          "reference": {
            "type": "string",
            "pattern": "^[Xx][Qq]-[0-9A-Fa-f]{16}$"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "offered",
              "accepted",
              "declined",
              "converted"
            ]
          },
          "originPostalCode": {
            "type": "string",
            "minLength": 2,
            "maxLength": 12,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9 -]{0,10}[A-Za-z0-9]$"
          },
          "destinationPostalCode": {
            "type": "string",
            "minLength": 2,
            "maxLength": 12,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9 -]{0,10}[A-Za-z0-9]$"
          },
          "pieces": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100
          },
          "weightKg": {
            "type": "number",
            "minimum": 0.01,
            "maximum": 1000
          },
          "lengthCm": {
            "type": "number",
            "minimum": 1,
            "maximum": 250
          },
          "widthCm": {
            "type": "number",
            "minimum": 1,
            "maximum": 250
          },
          "heightCm": {
            "type": "number",
            "minimum": 1,
            "maximum": 250
          },
          "priceCents": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 1,
                "maximum": 10000000
              },
              {
                "type": "null"
              }
            ],
            "description": "Price in euro cents excluding VAT."
          },
          "vatBps": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0,
                "maximum": 10000
              },
              {
                "type": "null"
              }
            ],
            "description": "VAT in basis points."
          },
          "currency": {
            "type": "string",
            "const": "EUR"
          },
          "validUntil": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "UTC timestamp."
          },
          "shipmentNumber": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/TrackingNumber"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "reference",
          "status",
          "originPostalCode",
          "destinationPostalCode",
          "pieces",
          "weightKg",
          "lengthCm",
          "widthCm",
          "heightCm",
          "priceCents",
          "vatBps",
          "currency",
          "validUntil",
          "createdAt",
          "shipmentNumber"
        ]
      },
      "ShipmentRequest": {
        "type": "object",
        "properties": {
          "quoteReference": {
            "type": "string",
            "pattern": "^[Xx][Qq]-[0-9A-Fa-f]{16}$"
          },
          "senderName": {
            "type": "string",
            "minLength": 2,
            "maxLength": 160
          },
          "senderAddress": {
            "type": "string",
            "minLength": 4,
            "maxLength": 300
          },
          "senderPhone": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 40,
                "pattern": "^(?:[+0-9() .-]*[0-9][+0-9() .-]*| *)$",
                "description": "A blank field is treated as absent."
              },
              {
                "type": "null"
              }
            ]
          },
          "recipientName": {
            "type": "string",
            "minLength": 2,
            "maxLength": 160
          },
          "recipientAddress": {
            "type": "string",
            "minLength": 4,
            "maxLength": 300
          },
          "recipientPhone": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 40,
                "pattern": "^(?:[+0-9() .-]*[0-9][+0-9() .-]*| *)$",
                "description": "A blank field is treated as absent."
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "quoteReference",
          "senderName",
          "senderAddress",
          "recipientName",
          "recipientAddress"
        ]
      },
      "Shipment": {
        "type": "object",
        "properties": {
          "number": {
            "$ref": "#/components/schemas/TrackingNumber"
          },
          "quoteReference": {
            "type": "string",
            "pattern": "^[Xx][Qq]-[0-9A-Fa-f]{16}$"
          },
          "status": {
            "$ref": "#/components/schemas/ShipmentStatus"
          },
          "originPostalCode": {
            "type": "string",
            "minLength": 2,
            "maxLength": 12,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9 -]{0,10}[A-Za-z0-9]$"
          },
          "destinationPostalCode": {
            "type": "string",
            "minLength": 2,
            "maxLength": 12,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9 -]{0,10}[A-Za-z0-9]$"
          },
          "pieces": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 1,
                "maximum": 100
              },
              {
                "type": "null"
              }
            ]
          },
          "weightKg": {
            "anyOf": [
              {
                "type": "number",
                "minimum": 0.01,
                "maximum": 1000
              },
              {
                "type": "null"
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "UTC timestamp."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "UTC timestamp."
          }
        },
        "required": [
          "number",
          "quoteReference",
          "status",
          "originPostalCode",
          "destinationPostalCode",
          "pieces",
          "weightKg",
          "createdAt",
          "updatedAt"
        ]
      },
      "PickupRequest": {
        "type": "object",
        "properties": {
          "trackingNumber": {
            "type": "string",
            "pattern": "^[Xx][Pp][Dd]-[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{16}$",
            "description": "Case-insensitive Xpedora shipment number. The service trims surrounding whitespace before validation."
          },
          "requestedDate": {
            "type": "string",
            "format": "date",
            "description": "For new requests, today through 90 days ahead in Europe/Athens, inclusive."
          },
          "notes": {
            "type": "string",
            "maxLength": 500,
            "description": "Optional internal handling note. Control characters are disallowed."
          }
        },
        "required": [
          "trackingNumber",
          "requestedDate"
        ],
        "additionalProperties": false
      },
      "Pickup": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$"
          },
          "trackingNumber": {
            "$ref": "#/components/schemas/TrackingNumber"
          },
          "requestedDate": {
            "type": "string",
            "format": "date"
          },
          "status": {
            "type": "string",
            "enum": [
              "requested",
              "confirmed",
              "completed",
              "cancelled"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "UTC timestamp."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "UTC timestamp."
          }
        },
        "required": [
          "id",
          "trackingNumber",
          "requestedDate",
          "status",
          "createdAt",
          "updatedAt"
        ]
      },
      "WebhookEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "const": "shipment.tracking.updated"
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time",
            "description": "UTC timestamp."
          },
          "shipment": {
            "type": "object",
            "properties": {
              "number": {
                "$ref": "#/components/schemas/TrackingNumber"
              },
              "status": {
                "$ref": "#/components/schemas/ShipmentStatus"
              },
              "location": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "locationCoordinates": {
                "$ref": "#/components/schemas/LocationCoordinates"
              }
            },
            "required": [
              "number",
              "status",
              "location"
            ]
          }
        },
        "required": [
          "id",
          "type",
          "occurredAt",
          "shipment"
        ]
      },
      "RateRequest": {
        "type": "object",
        "properties": {
          "originPostalCode": {
            "type": "string",
            "minLength": 2,
            "maxLength": 12,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9 -]{0,10}[A-Za-z0-9]$"
          },
          "destinationPostalCode": {
            "type": "string",
            "minLength": 2,
            "maxLength": 12,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9 -]{0,10}[A-Za-z0-9]$"
          },
          "pieces": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "description": "Number of parcels."
          },
          "weightKg": {
            "type": "number",
            "minimum": 0.01,
            "maximum": 1000,
            "description": "Value for each identical parcel (kg)."
          },
          "lengthCm": {
            "type": "number",
            "minimum": 1,
            "maximum": 250,
            "description": "Value for each identical parcel (cm)."
          },
          "widthCm": {
            "type": "number",
            "minimum": 1,
            "maximum": 250,
            "description": "Value for each identical parcel (cm)."
          },
          "heightCm": {
            "type": "number",
            "minimum": 1,
            "maximum": 250,
            "description": "Value for each identical parcel (cm)."
          }
        },
        "required": [
          "originPostalCode",
          "destinationPostalCode",
          "pieces",
          "weightKg",
          "lengthCm",
          "widthCm",
          "heightCm"
        ]
      },
      "Rate": {
        "type": "object",
        "properties": {
          "serviceCode": {
            "type": "string",
            "pattern": "^[A-Z0-9_-]{1,32}$"
          },
          "serviceName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "currency": {
            "type": "string",
            "const": "EUR"
          },
          "chargeableWeightKg": {
            "type": "number",
            "description": "Chargeable weight per parcel in kilograms, rounded up to the gram.",
            "minimum": 0.01,
            "maximum": 10000
          },
          "netCents": {
            "type": "integer",
            "minimum": 1,
            "description": "Net shipment estimate in euro cents."
          },
          "vatBps": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10000,
            "description": "VAT in basis points."
          },
          "vatCents": {
            "type": "integer",
            "minimum": 0,
            "description": "VAT on the shipment estimate in euro cents."
          },
          "totalCents": {
            "type": "integer",
            "minimum": 1,
            "description": "Total shipment estimate including VAT, in euro cents."
          }
        },
        "required": [
          "serviceCode",
          "serviceName",
          "currency",
          "chargeableWeightKg",
          "netCents",
          "vatBps",
          "vatCents",
          "totalCents"
        ]
      },
      "RatesResponse": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "availability": {
                "const": "estimated"
              },
              "rates": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Rate"
                },
                "minItems": 1
              }
            },
            "required": [
              "availability",
              "rates"
            ]
          },
          {
            "type": "object",
            "properties": {
              "availability": {
                "const": "quote_required"
              },
              "rates": {
                "type": "array",
                "maxItems": 0
              }
            },
            "required": [
              "availability",
              "rates"
            ]
          }
        ]
      }
    }
  }
}
