openapi: 3.0.3 info: title: Last-Mile Delivery API version: 0.1.0 contact: name: last-mile-delivery maintainers url: https://github.com/IQVO/last-mile-delivery description: >- REST contract of the last-mile-delivery bounded context of the retail network (logistics tier), derived from retail-network-docs model/model.yaml (contexts[last-mile-delivery].rest, .aggregates, .publishes, conventions.errors) and adjusted by the orchestrator's contracts-delta and Gap Register resolutions (G5, G11, G16, G17, G34). The context runs the network's delivery stations: it schedules delivery waves (induct cutoff, delivery window, stop capacity), inducts arrived packages into them, plans routes for delivery service partners (DSPs) and records delivery attempts. No endpoint carries an address or any other PII: packages are identified by tracking number and grouped into stops by the opaque `stopKey` that shipping-and-tracking derives at label time. No authentication, consistent with the rest of the network. Every state changing POST takes a required `Idempotency-Key` header (table idempotency_keys, 24 h): a missing key is 400 `idempotency-key-required`, a key that is not 1 to 128 printable ASCII characters is 400 `idempotency-key-invalid`, a key reused with another method, path or body is 409 `idempotency-key-reused`, and a repeated request replays the stored answer with the header `Idempotency-Replayed: true`. A 2xx is stored and a 5xx never; a refusal is stored (and replayed) only when it is final for the request, and a refusal that depends on state that can change is not stored, so its key is released and the retry executes again (the lists are on the `Idempotency-Key` parameter; ADR 0019). Every collection is paged with `limit` and `cursor` and answers `{items, nextCursor}`; an undeclared query parameter is 400 `unknown-query-parameter`. Errors are RFC 9457 `application/problem+json`; the `type` is a slug. The shared slugs are `not-found` (404), `illegal-transition` (409), `concurrent-update` (409) and `validation-failed` (422), plus one slug per model Err name (kebab-case without the `Err` prefix). Request bodies are decoded strictly (unknown fields, an empty body, trailing data and a body over 64 KiB are 422 `validation-failed`); a NUL character (U+0000) in the query string or a body is 422 `validation-failed`, in the path it is 404 `resource-not-found`. A path no route serves is 404 `resource-not-found`, a method a path does not serve is 405 `method-not-allowed` (problem+json), and an unmapped failure is an opaque 500 `internal-error` (never stored for replay). Every problem body carries `type`, `title`, `status`, `detail` and `instance`. The first eight operations of this file are the model's REST list; `getWaveStops`, `cancelWave`, `getRoute`, `deactivatePartner` and `declareWaveCost` are the additions of Gap Register G11, G17, G34 and roadmap F7 (ADR 0002, ADR 0011). The read-only analytics reports (tag reports, ADR 0012) are served by cmd/lm-reports on its own port (per-path server) from the separate analytical database. servers: - url: http://localhost:8080 tags: - name: Waves description: Delivery waves of a station (aggregate DeliveryWave). - name: Routes description: DSP van routes and delivery attempts (aggregate Route). - name: Partners description: Delivery service partners (aggregate DeliveryServicePartner). - name: reports description: >- Read-only analytics reports (ADR 0012), served by cmd/lm-reports from the separate analytical database the projector feeds from this context's own events and analytics topics. Days are UTC calendar days; from and to are inclusive dates; a rate or mean whose denominator is zero is null. paths: /waves: post: tags: [Waves] operationId: scheduleWave summary: Schedule a delivery wave (ScheduleWave) description: >- Creates an OPEN wave and publishes DeliveryWaveScheduled. Enforces inductCutoffAt < windowStart < windowEnd (ErrInvalidWaveTimes, 422 invalid-wave-times) and that stationNodeId is a DELIVERY_STATION known from node-topology (ErrUnknownStation, 422 unknown-station). Packages that arrived while no wave was eligible are inducted into the new wave in arrival order (policy InductDeferredOnSchedule). parameters: - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ScheduleWaveRequest' responses: '201': description: Wave scheduled. headers: Idempotency-Replayed: $ref: '#/components/headers/IdempotencyReplayed' content: application/json: schema: $ref: '#/components/schemas/DeliveryWave' '400': $ref: '#/components/responses/BadRequest' '409': $ref: '#/components/responses/Conflict' '422': $ref: '#/components/responses/Unprocessable' '500': $ref: '#/components/responses/InternalError' get: tags: [Waves] operationId: listWaves summary: List the waves of a station for a service date description: >- Returns the waves of the station on the service date ordered by inductCutoffAt then waveId, one keyset page at a time. A station or date with no wave is an empty list. parameters: - $ref: '#/components/parameters/Limit' - $ref: '#/components/parameters/Cursor' - name: stationNodeId in: query required: true description: The delivery station (node-topology nodeId). schema: type: string - name: serviceDate in: query required: true description: The station's local service date. schema: type: string format: date responses: '200': description: The waves, ordered by inductCutoffAt. content: application/json: schema: $ref: '#/components/schemas/DeliveryWavePage' '400': $ref: '#/components/responses/BadRequest' '422': $ref: '#/components/responses/Unprocessable' '500': $ref: '#/components/responses/InternalError' /waves/{waveId}/stops: get: tags: [Waves] operationId: getWaveStops summary: List the stops of a wave (packages grouped by stopKey) description: >- Returns the packages inducted into the wave grouped into stops by the opaque stopKey (Gap Register G11), ordered by the first induction of each stop. A package with no label data is its own stop. The planner builds PlanRoute from this list. No address is ever returned. parameters: - $ref: '#/components/parameters/WaveId' - $ref: '#/components/parameters/Limit' - $ref: '#/components/parameters/Cursor' responses: '200': description: One page of the stops of the wave. content: application/json: schema: $ref: '#/components/schemas/WaveStopPage' '400': $ref: '#/components/responses/BadRequest' '404': $ref: '#/components/responses/NotFound' '422': $ref: '#/components/responses/Unprocessable' '500': $ref: '#/components/responses/InternalError' /waves/{waveId}/induction-closures: post: tags: [Waves] operationId: closeInduction summary: Close induction of a wave (CloseInduction) description: OPEN to INDUCTION_CLOSED. No event is published. parameters: - $ref: '#/components/parameters/WaveId' - $ref: '#/components/parameters/IdempotencyKey' responses: '200': description: Induction closed. headers: Idempotency-Replayed: $ref: '#/components/headers/IdempotencyReplayed' content: application/json: schema: $ref: '#/components/schemas/DeliveryWave' '400': $ref: '#/components/responses/BadRequest' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/Conflict' '422': $ref: '#/components/responses/Unprocessable' '500': $ref: '#/components/responses/InternalError' /waves/{waveId}/dispatches: post: tags: [Waves] operationId: dispatchWave summary: Dispatch a wave (DispatchWave) description: >- INDUCTION_CLOSED to DISPATCHED. No event is published for the wave itself. Packages inducted in the wave that no route holds are re-inducted onto the next wave (Gap Register G17 mechanism). A wave with no route left to run completes at once (policy CompleteWaveOnLastRoute), so the response may show COMPLETED. parameters: - $ref: '#/components/parameters/WaveId' - $ref: '#/components/parameters/IdempotencyKey' responses: '200': description: Wave dispatched. headers: Idempotency-Replayed: $ref: '#/components/headers/IdempotencyReplayed' content: application/json: schema: $ref: '#/components/schemas/DeliveryWave' '400': $ref: '#/components/responses/BadRequest' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/Conflict' '422': $ref: '#/components/responses/Unprocessable' '500': $ref: '#/components/responses/InternalError' /waves/{waveId}/cancellations: post: tags: [Waves] operationId: cancelWave summary: Cancel a wave (CancelWave) description: >- OPEN to CANCELLED, publishes DeliveryWaveCancelled (an integration event, Gap Register G5). Every package inducted in the wave is re-inducted onto the next eligible wave in the same transaction (Gap Register G17); a package with no eligible wave is deferred (PackageInductionDeferred). parameters: - $ref: '#/components/parameters/WaveId' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/CancelWaveRequest' responses: '200': description: Wave cancelled. headers: Idempotency-Replayed: $ref: '#/components/headers/IdempotencyReplayed' content: application/json: schema: $ref: '#/components/schemas/DeliveryWave' '400': $ref: '#/components/responses/BadRequest' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/Conflict' '422': $ref: '#/components/responses/Unprocessable' '500': $ref: '#/components/responses/InternalError' /waves/{waveId}/cost-declarations: post: tags: [Waves] operationId: declareWaveCost summary: Declare the stop cost of a wave (DeclareCost) description: >- Records the planner's declared marginal cost of ONE delivery stop on the wave (driver time plus mileage share), integer cents, single-currency study (roadmap feature F7, provider B; ADR 0011), and publishes WaveCostDeclared for order-sourcing's money-denominated AssignmentCost. The cost is per stop (the G11 stopKey grouping), never per package. 0 is a legal declared zero marginal cost; a wave with no declaration reports 0 and leaves a consumer's estimate incomplete. Allowed while the wave still runs (OPEN, INDUCTION_CLOSED or DISPATCHED, illegal-transition once CANCELLED or COMPLETED); a later declaration overwrites the earlier one and publishes again. parameters: - $ref: '#/components/parameters/WaveId' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/DeclareWaveCostRequest' responses: '201': description: Stop cost declared. headers: Idempotency-Replayed: $ref: '#/components/headers/IdempotencyReplayed' content: application/json: schema: $ref: '#/components/schemas/DeliveryWave' '400': $ref: '#/components/responses/BadRequest' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/Conflict' '422': $ref: '#/components/responses/Unprocessable' '500': $ref: '#/components/responses/InternalError' /waves/{waveId}/emission-declarations: post: tags: [Waves] operationId: declareWaveEmission summary: Declare the stop emission of a wave (DeclareEmission) description: >- Records the planner's declared marginal greenhouse emission of ONE delivery stop on the wave (the stop's share of the route's driving), in grams of CO2 equivalent (roadmap feature C9; ADR 0016), and publishes WaveEmissionDeclared for order-sourcing's estimatedCo2eGrams. The emission is per stop (the G11 stopKey grouping), never per package. 0 is a legal declared zero marginal emission; a wave with no declaration reports 0 and leaves a consumer's estimate incomplete. Allowed while the wave still runs (OPEN, INDUCTION_CLOSED or DISPATCHED, illegal-transition once CANCELLED or COMPLETED); a later declaration overwrites the earlier one and publishes again. Ranking is untouched by this fact: carbon is recorded, not optimised, in this slice. parameters: - $ref: '#/components/parameters/WaveId' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/DeclareWaveEmissionRequest' responses: '201': description: Stop emission declared. headers: Idempotency-Replayed: $ref: '#/components/headers/IdempotencyReplayed' content: application/json: schema: $ref: '#/components/schemas/DeliveryWave' '400': $ref: '#/components/responses/BadRequest' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/Conflict' '422': $ref: '#/components/responses/Unprocessable' '500': $ref: '#/components/responses/InternalError' /routes: post: tags: [Routes] operationId: planRoute summary: Plan a DSP van route in a wave (PlanRoute) description: >- Creates a PLANNED route and publishes RoutePlanned (analytics stream only). The wave must be INDUCTION_CLOSED (illegal-transition), the partner ACTIVE, of the wave's station and the stops at most the partner's van capacity (ErrRouteOverCapacity, 409 route-over-capacity). Every package must be inducted in the wave and not on another route, and the packages of one stop must share one stopKey (G34). parameters: - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/PlanRouteRequest' responses: '201': description: Route planned. headers: Idempotency-Replayed: $ref: '#/components/headers/IdempotencyReplayed' content: application/json: schema: $ref: '#/components/schemas/Route' '400': $ref: '#/components/responses/BadRequest' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/Conflict' '422': $ref: '#/components/responses/Unprocessable' '500': $ref: '#/components/responses/InternalError' /routes/{routeId}: get: tags: [Routes] operationId: getRoute summary: Get a route with its stops and attempts description: Returns the route, its stops (with derived outcomes) and every recorded attempt. parameters: - $ref: '#/components/parameters/RouteId' responses: '200': description: The route. content: application/json: schema: $ref: '#/components/schemas/Route' '404': $ref: '#/components/responses/NotFound' '422': $ref: '#/components/responses/Unprocessable' '500': $ref: '#/components/responses/InternalError' /routes/{routeId}/starts: post: tags: [Routes] operationId: startRoute summary: Start a route (StartRoute) description: >- PLANNED to OUT_FOR_DELIVERY; the route's wave must be DISPATCHED (illegal-transition otherwise). Publishes one PackageOutForDelivery per tracking number on the route. parameters: - $ref: '#/components/parameters/RouteId' - $ref: '#/components/parameters/IdempotencyKey' responses: '200': description: Route out for delivery. headers: Idempotency-Replayed: $ref: '#/components/headers/IdempotencyReplayed' content: application/json: schema: $ref: '#/components/schemas/Route' '400': $ref: '#/components/responses/BadRequest' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/Conflict' '422': $ref: '#/components/responses/Unprocessable' '500': $ref: '#/components/responses/InternalError' /routes/{routeId}/attempts: post: tags: [Routes] operationId: recordAttempt summary: Record a delivery attempt (RecordAttempt) description: >- Records DELIVERED, FAILED or COLLECTED for one package on an OUT_FOR_DELIVERY route and publishes DeliveryAttempted. COLLECTED is valid only for a package inducted into the wave as a PICKUP (ADR 0017, activation-gated; every induction is DELIVERY until then). Errors: ErrRouteNotStarted (409 route-not-started), ErrAlreadyDelivered (409 already-delivered). A FAILED attempt counts in the package's attempt history and re-inducts the package onto the next wave (policy RetryNextWave); the third failure publishes PackageReturnInitiated instead. The attempt that records the last outstanding package completes the route, and the last completed route completes the wave. parameters: - $ref: '#/components/parameters/RouteId' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/RecordAttemptRequest' responses: '201': description: Attempt recorded. headers: Idempotency-Replayed: $ref: '#/components/headers/IdempotencyReplayed' content: application/json: schema: $ref: '#/components/schemas/Attempt' '400': $ref: '#/components/responses/BadRequest' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/Conflict' '422': $ref: '#/components/responses/Unprocessable' '500': $ref: '#/components/responses/InternalError' /partners: post: tags: [Partners] operationId: contractPartner summary: Contract a delivery service partner (ContractPartner) description: >- Creates an ACTIVE partner. Van capacity must be greater than zero (ErrInvalidVanCapacity, 422 invalid-van-capacity) and stationNodeId a known DELIVERY_STATION (ErrUnknownStation, 422 unknown-station). parameters: - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ContractPartnerRequest' responses: '201': description: Partner contracted. headers: Idempotency-Replayed: $ref: '#/components/headers/IdempotencyReplayed' content: application/json: schema: $ref: '#/components/schemas/DeliveryServicePartner' '400': $ref: '#/components/responses/BadRequest' '409': $ref: '#/components/responses/Conflict' '422': $ref: '#/components/responses/Unprocessable' '500': $ref: '#/components/responses/InternalError' /partners/{dspId}/deactivations: post: tags: [Partners] operationId: deactivatePartner summary: Deactivate a delivery service partner (DeactivatePartner) description: >- ACTIVE to INACTIVE (Gap Register G34). An inactive partner can be given no new route; routes already planned are unaffected. parameters: - $ref: '#/components/parameters/DspId' - $ref: '#/components/parameters/IdempotencyKey' responses: '200': description: Partner deactivated. headers: Idempotency-Replayed: $ref: '#/components/headers/IdempotencyReplayed' content: application/json: schema: $ref: '#/components/schemas/DeliveryServicePartner' '400': $ref: '#/components/responses/BadRequest' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/Conflict' /reports/route-efficiency: servers: - url: http://localhost:8092 get: tags: [reports] operationId: getRouteEfficiencyReport x-pagination-exempt: report summary: Route efficiency per day and delivery station description: >- Per UTC day of completion and per delivery station (stationNodeId), over the completed routes: a route counts as completed when every package it took out for delivery has an attempt (the precondition of CompleteRoute, which raises no event) and its RoutePlanned is projected; its day is the day of its last attempt. routesCompleted is their count; stopsPerRoute = stops / routesCompleted (stops = the routes' RoutePlanned stopCount); packagesPerStop = packages attempted / distinct stops attempted (every stop of a completed route was attempted, so the denominator is the stops); declaredCostPerStopCents = the stop-weighted mean of the waves' declared costPerStopCents over the routes whose wave declared a cost, null when none did; costPerPackageCents = declaredCostPerStopCents x the stops of those routes / their packages, null when undefined. Days without a completed route are omitted. parameters: - $ref: '#/components/parameters/ReportFrom' - $ref: '#/components/parameters/ReportTo' responses: '200': description: The report for the range. content: application/json: schema: $ref: '#/components/schemas/RouteEfficiencyReport' '400': $ref: '#/components/responses/InvalidReportRange' '500': $ref: '#/components/responses/InternalError' /reports/attempt-outcomes: servers: - url: http://localhost:8092 get: tags: [reports] operationId: getAttemptOutcomesReport x-pagination-exempt: report summary: Delivery attempt outcomes and first-attempt success per day and station description: >- Per UTC day and per delivery station (the station of the attempt's route, UNKNOWN while its PackageOutForDelivery is not projected): attempts, deliveredAttempts and failedAttempts are the DeliveryAttempted of the day by outcome; a success is DELIVERED or COLLECTED (both count in deliveredAttempts, ADR 0017), a failure FAILED; packagesAttempted are the packages whose FIRST attempt fell on the day, packagesWithFirstAttemptSuccess those of them delivered at it; firstAttemptSuccessRate = packagesWithFirstAttemptSuccess / packagesAttempted; meanAttemptsPerPackage = all the attempts of those packages (any day) / packagesAttempted; both null without a first attempt. returnsInitiated counts the PackageReturnInitiated of the day (its CloudEvents time) at the station of the package's latest attempt. Days without any of these are omitted. parameters: - $ref: '#/components/parameters/ReportFrom' - $ref: '#/components/parameters/ReportTo' responses: '200': description: The report for the range. content: application/json: schema: $ref: '#/components/schemas/AttemptOutcomesReport' '400': $ref: '#/components/responses/InvalidReportRange' '500': $ref: '#/components/responses/InternalError' /reports/eta-window: servers: - url: http://localhost:8092 get: tags: [reports] operationId: getEtaWindowReport x-pagination-exempt: report summary: Share of deliveries inside their day-of ETA window per day and station description: >- Per UTC day of the DELIVERED attempt and per delivery station (the station of the attempt's route, UNKNOWN while its PackageOutForDelivery is not projected). deliveriesWithEta counts the delivered packages that had a StopEtaWindowAssigned window for the same route (ADR 0013); deliveriesInsideEta those delivered with etaStart <= attempt instant <= etaEnd (both bounds are inside), deliveriesBeforeEta before etaStart and deliveriesAfterEta after etaEnd; etaHitRate = deliveriesInsideEta / deliveriesWithEta, null when no delivery of the day and station had an ETA. Only the attempt that DELIVERED counts; a delivered package whose ETA was never projected (no ETA was raised, or the projection has not caught up) is not in the denominator. Days without a delivery are omitted. The windows are a deterministic spread of the route's stops over the wave window, so the first weeks of etaHitRate are a baseline, not a verdict. parameters: - $ref: '#/components/parameters/ReportFrom' - $ref: '#/components/parameters/ReportTo' responses: '200': description: The report for the range. content: application/json: schema: $ref: '#/components/schemas/EtaWindowReport' '400': $ref: '#/components/responses/InvalidReportRange' '500': $ref: '#/components/responses/InternalError' /reports/wave-utilisation: servers: - url: http://localhost:8092 get: tags: [reports] operationId: getWaveUtilisationReport x-pagination-exempt: report summary: Wave stop-capacity utilisation per service date and station description: >- Per serviceDate and delivery station of the scheduled waves: wavesScheduled, wavesCancelled (those with a DeliveryWaveCancelled), stopCapacity (the sum of the scheduled stopCapacity) and stopsInducted (the sum of each wave's highest assignedStops of DeliveryWaveCapacityChanged, 0 without one); utilisation = stopsInducted / stopCapacity, null when the capacity is 0. Cancelled waves stay in every sum. Dates without a wave are omitted. parameters: - $ref: '#/components/parameters/ReportFrom' - $ref: '#/components/parameters/ReportTo' responses: '200': description: The report for the range. content: application/json: schema: $ref: '#/components/schemas/WaveUtilisationReport' '400': $ref: '#/components/responses/InvalidReportRange' '500': $ref: '#/components/responses/InternalError' /reports/freshness: servers: - url: http://localhost:8092 get: tags: [reports] operationId: getReportFreshness summary: How far the analytics projection is behind description: >- asOf is the CloudEvents time of the newest event the projector applied; lagSeconds is now minus asOf, never negative. Both are null until the first event. One endpoint for every report: they all read the same projection. responses: '200': description: The projection's freshness. content: application/json: schema: $ref: '#/components/schemas/ReportFreshness' '500': $ref: '#/components/responses/InternalError' components: parameters: IdempotencyKey: name: Idempotency-Key in: header required: true description: | Client-generated key (a UUID) per logical submit, 1 to 128 printable ASCII characters. A retry with the same method, path and body replays the stored answer with `Idempotency-Replayed: true` and changes nothing; the same key with another method, path or body is 409 `idempotency-key-reused`. Keys are global. What is stored. A 2xx is stored. A 5xx is never stored. A refusal is stored (and replayed) only when it is final for the request: `validation-failed`, `invalid-wave-times`, `invalid-van-capacity`, `already-delivered`, `attempt-already-recorded`, `package-already-routed`, `induction-closed` and `already-inducted`. A refusal that depends on state that can change is NOT stored: its key is released, a retry with the same key and request executes again (it can succeed once the state allows), and a different request under the released key is a new request, not `idempotency-key-reused`. These are `concurrent-update` (re-read, then retry), `not-found`, `unknown-station`, `package-not-on-route`, `package-not-inducted`, `stop-key-mismatch`, `route-over-capacity`, `partner-inactive`, `partner-station-mismatch`, `route-not-started`, `route-incomplete`, `wave-full` and `illegal-transition`; the 409 `idempotency-key-reused` is itself never stored. Rows are kept 24 hours. schema: type: string minLength: 1 maxLength: 128 pattern: '^[\x20-\x7e]+$' Limit: name: limit in: query required: false description: Page size, 1 to 500 (default 100). schema: type: integer minimum: 1 maximum: 500 default: 100 Cursor: name: cursor in: query required: false description: Opaque cursor from the `nextCursor` of the previous page; repeat the filters on every page. schema: type: string WaveId: name: waveId in: path required: true schema: type: string RouteId: name: routeId in: path required: true schema: type: string DspId: name: dspId in: path required: true schema: type: string ReportFrom: name: from in: query required: false description: First UTC day of the range, inclusive. Omitted = 29 days before `to` (a 30-day range). schema: type: string format: date ReportTo: name: to in: query required: false description: Last UTC day of the range, inclusive. Omitted = today. At most 366 days from `from`. schema: type: string format: date headers: IdempotencyReplayed: description: Present, with the value `true`, only when the answer is a replay of the stored first answer. schema: type: string enum: ['true'] responses: BadRequest: description: >- The request is malformed at the HTTP level. Problem types `idempotency-key-required` (no Idempotency-Key header), `idempotency-key-invalid` (not 1 to 128 printable ASCII characters), `invalid-limit`, `invalid-cursor`, `unknown-query-parameter`. `invalid-limit` is a limit outside 1 to 500, empty or repeated; `invalid-cursor` a cursor that is not a page token or is repeated. content: application/problem+json: schema: $ref: '#/components/schemas/Problem' NotFound: description: >- The wave, route, partner or (for an attempt) the package on the route does not exist, or the path matches no route or holds a NUL character. Problem types `not-found`, `package-not-on-route`, `resource-not-found`. headers: Idempotency-Replayed: $ref: '#/components/headers/IdempotencyReplayed' content: application/problem+json: schema: $ref: '#/components/schemas/Problem' Conflict: description: >- Conflict with the aggregate's state or capacity. Problem types: `illegal-transition`, `concurrent-update`, `route-over-capacity`, `route-not-started`, `already-delivered`, `attempt-already-recorded`, `package-not-inducted`, `package-already-routed`, `stop-key-mismatch`, `partner-inactive`, `partner-station-mismatch`, `route-incomplete`. `idempotency-key-reused` (the Idempotency-Key was already used with a different method, path or body). ErrWaveFull (`wave-full`), ErrInductionClosed (`induction-closed`) and ErrAlreadyInducted (`already-inducted`) are raised only by policy-driven induction, which has no route. headers: Idempotency-Replayed: $ref: '#/components/headers/IdempotencyReplayed' content: application/problem+json: schema: $ref: '#/components/schemas/Problem' InternalError: description: >- Unexpected failure: problem type `internal-error`, detail "an unexpected error occurred". Never stored for idempotent replay. content: application/problem+json: schema: $ref: '#/components/schemas/Problem' Unprocessable: description: >- Validation failed. Problem types: `validation-failed` (body that is not valid JSON for the operation, with an unknown field, empty, with trailing data or over 64 KiB; a NUL character in the query or body; a missing or malformed query filter; a value-object rule), `invalid-wave-times` (ErrInvalidWaveTimes), `invalid-van-capacity` (ErrInvalidVanCapacity), `unknown-station` (ErrUnknownStation). headers: Idempotency-Replayed: $ref: '#/components/headers/IdempotencyReplayed' content: application/problem+json: schema: $ref: '#/components/schemas/Problem' InvalidReportRange: description: >- invalid-report-range. from or to is not a date (YYYY-MM-DD), from is after to, or the range exceeds 366 days. content: application/problem+json: schema: $ref: '#/components/schemas/Problem' schemas: RouteEfficiencyReport: type: object required: [from, to, days] properties: from: type: string format: date to: type: string format: date days: type: array items: $ref: '#/components/schemas/RouteEfficiencyDay' RouteEfficiencyDay: type: object required: [day, stationNodeId, routesCompleted, stopsPerRoute, packagesPerStop, declaredCostPerStopCents, costPerPackageCents] properties: day: type: string format: date stationNodeId: type: string description: The delivery station node id of the routes. routesCompleted: type: integer minimum: 1 stopsPerRoute: type: number minimum: 0 nullable: true packagesPerStop: type: number minimum: 0 nullable: true declaredCostPerStopCents: type: number minimum: 0 nullable: true description: Stop-weighted mean of the declared costPerStopCents; null when no wave of the day's routes declared a cost. costPerPackageCents: type: number minimum: 0 nullable: true AttemptOutcomesReport: type: object required: [from, to, days] properties: from: type: string format: date to: type: string format: date days: type: array items: $ref: '#/components/schemas/AttemptOutcomesDay' AttemptOutcomesDay: type: object required: [day, stationNodeId, attempts, deliveredAttempts, failedAttempts, packagesAttempted, packagesWithFirstAttemptSuccess, firstAttemptSuccessRate, meanAttemptsPerPackage, returnsInitiated] properties: day: type: string format: date stationNodeId: type: string description: The delivery station node id, or UNKNOWN while the route's out-for-delivery fact is not projected. attempts: type: integer minimum: 0 deliveredAttempts: type: integer minimum: 0 failedAttempts: type: integer minimum: 0 packagesAttempted: type: integer minimum: 0 packagesWithFirstAttemptSuccess: type: integer minimum: 0 firstAttemptSuccessRate: type: number minimum: 0 maximum: 1 nullable: true meanAttemptsPerPackage: type: number minimum: 1 nullable: true returnsInitiated: type: integer minimum: 0 EtaWindowReport: type: object required: [from, to, days] properties: from: type: string format: date to: type: string format: date days: type: array items: $ref: '#/components/schemas/EtaWindowDay' EtaWindowDay: type: object required: [day, stationNodeId, deliveriesWithEta, deliveriesInsideEta, deliveriesBeforeEta, deliveriesAfterEta, etaHitRate] properties: day: type: string format: date description: The UTC day of the DELIVERED attempt. stationNodeId: type: string description: The delivery station node id, or UNKNOWN while the route's out-for-delivery fact is not projected. deliveriesWithEta: type: integer minimum: 0 deliveriesInsideEta: type: integer minimum: 0 deliveriesBeforeEta: type: integer minimum: 0 deliveriesAfterEta: type: integer minimum: 0 etaHitRate: type: number minimum: 0 maximum: 1 nullable: true WaveUtilisationReport: type: object required: [from, to, days] properties: from: type: string format: date to: type: string format: date days: type: array items: $ref: '#/components/schemas/WaveUtilisationDay' WaveUtilisationDay: type: object required: [day, stationNodeId, wavesScheduled, wavesCancelled, stopCapacity, stopsInducted, utilisation] properties: day: type: string format: date description: The waves' serviceDate. stationNodeId: type: string wavesScheduled: type: integer minimum: 1 wavesCancelled: type: integer minimum: 0 stopCapacity: type: integer minimum: 0 stopsInducted: type: integer minimum: 0 utilisation: type: number minimum: 0 nullable: true ReportFreshness: type: object required: [asOf, lagSeconds] properties: asOf: type: string format: date-time nullable: true lagSeconds: type: number minimum: 0 nullable: true DeliveryWavePage: type: object required: [items] properties: items: type: array items: $ref: '#/components/schemas/DeliveryWave' nextCursor: type: string description: Absent on the last page. WaveStopPage: type: object required: [items] properties: items: type: array items: $ref: '#/components/schemas/WaveStop' nextCursor: type: string description: Absent on the last page. Problem: type: object description: RFC 9457 problem details. required: [type, title, status, detail, instance] properties: type: type: string description: Problem type slug, for example `wave-full`. example: wave-full title: type: string example: The wave has no stop capacity left status: type: integer example: 409 detail: type: string instance: type: string description: The escaped request path. WaveState: type: string enum: [OPEN, INDUCTION_CLOSED, DISPATCHED, COMPLETED, CANCELLED] ScheduleWaveRequest: type: object additionalProperties: false required: [stationNodeId, serviceDate, inductCutoffAt, windowStart, windowEnd, stopCapacity] properties: stationNodeId: type: string description: The delivery station (node-topology nodeId). serviceDate: type: string format: date inductCutoffAt: type: string format: date-time description: Must be before windowStart. windowStart: type: string format: date-time description: Must be before windowEnd. windowEnd: type: string format: date-time stopCapacity: type: integer minimum: 0 maximum: 2147483647 CancelWaveRequest: type: object additionalProperties: false required: [reason] properties: reason: type: string minLength: 1 maxLength: 200 description: Trimmed text without control characters. DeclareWaveCostRequest: type: object additionalProperties: false required: [costPerStopCents] properties: costPerStopCents: type: integer format: int64 minimum: 0 maximum: 10000000 description: >- The declared marginal cost of ONE delivery stop on the wave, integer cents (single-currency study; no currency field). 0 is a legal declared zero marginal cost. DeclareWaveEmissionRequest: type: object additionalProperties: false required: [gCo2ePerStop] properties: gCo2ePerStop: type: integer format: int64 minimum: 0 maximum: 10000000 description: >- The declared marginal greenhouse emission of ONE delivery stop on the wave, in grams of CO2 equivalent (gCo2e). 0 is a legal declared zero marginal emission. DeliveryWave: type: object required: [waveId, stationNodeId, serviceDate, inductCutoffAt, windowStart, windowEnd, stopCapacity, assignedStops, remainingStops, state, costPerStopCents, gCo2ePerStop] properties: waveId: type: string stationNodeId: type: string serviceDate: type: string format: date inductCutoffAt: type: string format: date-time windowStart: type: string format: date-time windowEnd: type: string format: date-time stopCapacity: type: integer minimum: 0 assignedStops: type: integer minimum: 0 remainingStops: type: integer minimum: 0 state: $ref: '#/components/schemas/WaveState' cancelReason: type: string description: Present only on a CANCELLED wave. costPerStopCents: type: integer format: int64 minimum: 0 maximum: 10000000 description: The declared marginal cost of ONE delivery stop on this wave, integer cents (ADR 0011). 0 until declared and for a declared zero alike. gCo2ePerStop: type: integer format: int64 minimum: 0 maximum: 10000000 description: The declared marginal greenhouse emission of ONE delivery stop on this wave, in grams of CO2 equivalent (ADR 0016). 0 until declared and for a declared zero alike. WaveStop: type: object required: [stopKey, trackingNumbers] properties: stopKey: type: string description: Opaque keyed hash of the normalized address, from shipping-and-tracking; `pkg:` when no label data was received. destinationPostalPrefix: type: string description: Present when the label data carried it. trackingNumbers: type: array items: type: string RouteState: type: string enum: [PLANNED, OUT_FOR_DELIVERY, COMPLETED] Outcome: type: string enum: [DELIVERED, FAILED, COLLECTED] StopInput: type: object additionalProperties: false required: [stopNo, trackingNumbers] properties: stopNo: type: integer minimum: 1 description: 1-based position; the stops of a route are numbered 1..n without gaps. trackingNumbers: type: array minItems: 1 items: type: string Stop: type: object required: [stopNo, trackingNumbers] properties: stopNo: type: integer minimum: 1 trackingNumbers: type: array items: type: string outcome: type: string enum: [DELIVERED, FAILED] description: >- Derived from the per-package attempts (Gap Register G17): omitted until every package of the stop has an attempt, then DELIVERED when none failed (delivered or collected, ADR 0017), else FAILED. PlanRouteRequest: type: object additionalProperties: false required: [waveId, dspId, stops] properties: waveId: type: string dspId: type: string stops: type: array minItems: 1 description: Ordered stops; at most the partner's van capacity. items: $ref: '#/components/schemas/StopInput' Route: type: object required: [routeId, waveId, dspId, stationNodeId, state, stopCount, stops, attempts] properties: routeId: type: string waveId: type: string dspId: type: string stationNodeId: type: string state: $ref: '#/components/schemas/RouteState' stopCount: type: integer minimum: 1 stops: type: array items: $ref: '#/components/schemas/Stop' attempts: type: array items: $ref: '#/components/schemas/Attempt' RecordAttemptRequest: type: object additionalProperties: false required: [trackingNumber, outcome, at] properties: trackingNumber: type: string outcome: $ref: '#/components/schemas/Outcome' failureReason: type: string minLength: 1 maxLength: 200 description: Required when outcome is FAILED and forbidden when DELIVERED or COLLECTED; free text (trimmed, no control characters), the model defines no vocabulary. outcomeDetail: $ref: '#/components/schemas/OutcomeDetail' at: type: string format: date-time OutcomeDetail: type: string enum: [NOT_HOME, ACCESS_PROBLEM, OTHER, SAFE_PLACE_USED] description: >- Optional category of the attempt, reported by the driver client. FAILED accepts NOT_HOME, ACCESS_PROBLEM and OTHER; DELIVERED accepts SAFE_PLACE_USED; any other pairing is 422 validation-failed. Omitted means not reported (a legacy client), which is not the same as OTHER. It never replaces failureReason. Attempt: type: object required: [routeId, trackingNumber, outcome, at] properties: routeId: type: string trackingNumber: type: string outcome: $ref: '#/components/schemas/Outcome' outcomeDetail: $ref: '#/components/schemas/OutcomeDetail' failureReason: type: string at: type: string format: date-time PartnerState: type: string enum: [ACTIVE, INACTIVE] ContractPartnerRequest: type: object additionalProperties: false required: [stationNodeId, vanCapacity] properties: stationNodeId: type: string description: The delivery station the partner is contracted to. vanCapacity: type: integer minimum: 1 maximum: 2147483647 description: Maximum stops per route; must be greater than zero. DeliveryServicePartner: type: object required: [dspId, stationNodeId, vanCapacity, state] properties: dspId: type: string stationNodeId: type: string vanCapacity: type: integer minimum: 1 state: $ref: '#/components/schemas/PartnerState'