{"openapi":"3.1.0","info":{"title":"Lane Cost Unified Freight API","version":"0.4.0","description":"Single API and webhook stream across REST and X12 EDI freight carriers (Warp, Uber Freight, TQL, J.B. Hunt, Curri, and Manual Brokers). Includes pre-flight booking checks, global edge quote caching, two-way per-load carrier email threading, VICS BOL & Rate Confirmation PDF generation, and missing-POD monitoring."},"servers":[{"url":"https://app.lanecost.com","description":"Production API"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"frt_live_...","description":"Tenant API key passed in Authorization: Bearer frt_live_..."}},"schemas":{"BookingCheckIssue":{"type":"object","required":["code","severity","field","message"],"properties":{"code":{"type":"string"},"severity":{"type":"string","enum":["error","warning"]},"field":{"type":"string"},"stopSequence":{"type":"integer"},"message":{"type":"string"}}},"BookingCheckResult":{"type":"object","required":["ok","errors","warnings","summary"],"properties":{"ok":{"type":"boolean"},"errors":{"type":"array","items":{"$ref":"#/components/schemas/BookingCheckIssue"}},"warnings":{"type":"array","items":{"$ref":"#/components/schemas/BookingCheckIssue"}},"summary":{"type":"object","properties":{"totalWeightLbs":{"type":"number"},"palletSlots":{"type":"integer"},"equipmentLabel":{"type":"string"},"maxWeightLbs":{"type":"number"},"maxPallets":{"type":["integer","null"]}}}}},"ErrorResponse":{"type":"object","required":["error"],"properties":{"error":{"type":"string"},"message":{"type":"string"},"bookingCheck":{"$ref":"#/components/schemas/BookingCheckResult"}}}}},"paths":{"/health":{"get":{"summary":"Service health check","security":[],"responses":{"200":{"description":"Healthy service status"}}}},"/v1/providers":{"get":{"summary":"List all supported carrier & broker connectors","security":[],"responses":{"200":{"description":"List of provider manifests and capabilities"}}}},"/v1/providers/connections":{"get":{"summary":"List active carrier connections for the authenticated tenant","responses":{"200":{"description":"Tenant carrier connections (secrets redacted)"}}}},"/v1/providers/{providerId}/connect":{"post":{"summary":"Validate, encrypt, and save carrier credentials","parameters":[{"name":"providerId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"Connection saved"},"422":{"description":"Invalid credentials shape"}}}},"/v1/providers/{providerId}/test":{"post":{"summary":"Run a live authentication/connectivity health check against a connected carrier","parameters":[{"name":"providerId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Health check result ({ ok, latencyMs, message })"}}}},"/v1/shipments/validate":{"post":{"summary":"Run carrier-agnostic pre-flight booking checks","description":"Checks pickup dates in the past, weight & pallet slots against equipment limits, liftgate on 53' vans, unanswered dock questions, and missing site contacts.","parameters":[{"name":"stage","in":"query","schema":{"type":"string","enum":["quote","tender"]}},{"name":"strict","in":"query","schema":{"type":"boolean"}}],"responses":{"200":{"description":"Validation result with plain errors and warnings","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BookingCheckResult"}}}}}}},"/v1/quotes":{"post":{"summary":"Fan out multi-carrier quotes with global edge QuoteCacheDO caching","parameters":[{"name":"refresh","in":"query","schema":{"type":"boolean"}}],"responses":{"200":{"description":"Quotes sorted cheapest-first plus unavailable providers and cache hits"},"422":{"description":"Booking checks failed before reaching carriers"}}}},"/v1/shipments":{"get":{"summary":"List shipments for the authenticated tenant","parameters":[{"name":"status","in":"query","schema":{"type":"string"}},{"name":"needsResponse","in":"query","schema":{"type":"boolean"}},{"name":"limit","in":"query","schema":{"type":"integer"}}],"responses":{"200":{"description":"List of shipments"}}},"post":{"summary":"Validate and book/tender a load directly with a carrier (idempotent on externalId)","description":"Automatically enforces booking checks before reaching any carrier, prevents double-booking if externalId already exists, assigns a two-way load email (loads+<externalId>@lanecost.com), and fires shipment.created webhook.","parameters":[{"name":"strict","in":"query","schema":{"type":"boolean"}}],"responses":{"200":{"description":"Idempotent replay of existing shipment with same externalId"},"201":{"description":"Shipment booked/tendered"},"422":{"description":"Booking check failed or carrier rejected tender"}}}},"/v1/shipments/{shipmentId}":{"get":{"summary":"Get shipment details, canonical event timeline, charges, and archived documents","parameters":[{"name":"shipmentId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Full shipment state"},"404":{"description":"Not found"}}}},"/v1/shipments/{shipmentId}/cancel":{"post":{"summary":"Cancel a shipment and notify contacts & webhooks","parameters":[{"name":"shipmentId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Shipment cancelled"},"409":{"description":"Invalid transition"}}}},"/v1/shipments/{shipmentId}/carrier-swap":{"post":{"summary":"Swap carrier on a live load without cancelling it","parameters":[{"name":"shipmentId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Carrier swapped and recorded as carrier_swap event"}}}},"/v1/shipments/{shipmentId}/charges":{"post":{"summary":"Attach an accessorial or extra fee (e.g. detention, redelivery, lumper) to a shipment","parameters":[{"name":"shipmentId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"Charge appended"}}}},"/v1/shipments/{shipmentId}/sync-tracking":{"post":{"summary":"Poll live tracking milestones from REST carriers (e.g. Warp, Sandbox)","parameters":[{"name":"shipmentId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Synced events count and latest status"}}}},"/v1/shipments/{shipmentId}/resolve-response":{"post":{"summary":"Clear the needsResponse flag after ops answers a carrier email","parameters":[{"name":"shipmentId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Flag cleared"}}}},"/v1/shipments/{shipmentId}/events":{"post":{"summary":"Append a validated milestone event (enforces deterministic state machine)","parameters":[{"name":"shipmentId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"Event appended"},"409":{"description":"Illegal status transition"}}}},"/v1/shipments/{shipmentId}/documents":{"post":{"summary":"Immutably archive a document (POD, signed BOL, lumper receipt) to locked R2","parameters":[{"name":"shipmentId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"201":{"description":"Document archived and notifications sent"}}}},"/v1/alerts":{"get":{"summary":"List missing-POD alerts (>N hours after delivery) and carrier emails awaiting a response","parameters":[{"name":"podMissingAfterHours","in":"query","schema":{"type":"number","default":4}}],"responses":{"200":{"description":"Current tenant operational alerts"}}}},"/v1/webhooks":{"get":{"summary":"List configured webhook endpoints for the authenticated tenant","responses":{"200":{"description":"Webhook endpoints"}}},"post":{"summary":"Register a webhook endpoint (returns one-time whsec_ signing secret)","responses":{"201":{"description":"Webhook created with signing secret"}}}},"/v1/webhooks/{webhookId}":{"delete":{"summary":"Delete a webhook endpoint","parameters":[{"name":"webhookId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Deleted"}}}},"/v1/webhooks/{webhookId}/test":{"post":{"summary":"Send a signed webhook.test event to verify your webhook receiver","parameters":[{"name":"webhookId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Delivery result ({ delivered, httpStatus, latencyMs })"}}}},"/v1/webhooks/{webhookId}/deliveries":{"get":{"summary":"Inspect recent webhook delivery attempts, HTTP statuses, and errors","parameters":[{"name":"webhookId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Recent delivery logs"}}}},"/v1/documents/bol":{"post":{"summary":"Generate a print-ready VICS Straight Bill of Lading PDF with Code-128B barcode","parameters":[{"name":"shipmentId","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"application/pdf binary"}}}},"/v1/documents/rate-con":{"post":{"summary":"Generate a carrier-ready Rate Confirmation PDF","parameters":[{"name":"shipmentId","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"application/pdf binary"}}}},"/v1/documents/{documentId}":{"get":{"summary":"Download an immutably archived document from R2","parameters":[{"name":"documentId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Document binary with X-Document-Sha256 header"}}}},"/v1/edi/parse":{"post":{"summary":"Parse raw X12 EDI (204, 210, 214, 990, 997) into canonical JSON events","responses":{"200":{"description":"Parsed X12 envelope and canonical events"}}}}}}