{
  "openapi": "3.1.0",
  "info": {
    "title": "Ship-Anything Freight Engineering API (W4-C08)",
    "version": "1.0.0",
    "summary": "Deterministic Parcel DIM/3D Packing, Ocean LCL/FCL/Air, Customs Document Compiler, GSR Claims & Amazon FBA Cliff Engine",
    "description": "Pure Python deterministic freight optimization, Commercial Invoice & Packing List reconciliation, 15-day GSR carrier refund scanning, and Amazon US FBA size-tier cliff analysis. Flat fixed-price prepaid credits with zero recovery split and 0% commission; strictly $0 billed (charged_micros=0, status_code=422) on invalid dimensions, negative weights, or imbalanced customs documents. Zero customer data resale.",
    "contact": {
      "name": "ship-anything",
      "email": "ops@ship.fastmesh.dev",
      "url": "https://ship.fastmesh.dev"
    }
  },
  "servers": [
    {
      "url": "https://ship.fastmesh.dev",
      "description": "Production HTTPS Gateway"
    },
    {
      "url": "http://127.0.0.1:9008",
      "description": "Local Upstream Instance"
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "operationId": "getHealth",
        "summary": "Service liveness, ArchiveCache stats, and Creem ledger telemetry",
        "responses": {
          "200": {
            "description": "Healthy JSON status envelope"
          }
        }
      }
    },
    "/openapi.json": {
      "get": {
        "operationId": "getOpenApiSpec",
        "summary": "Return this OpenAPI 3.1.0 schema",
        "responses": {
          "200": {
            "description": "OpenAPI JSON document"
          }
        }
      }
    },
    "/v1/dim-pack": {
      "post": {
        "operationId": "dimPackOptimize",
        "summary": "Parcel DIM weight (139/166/5000/6000), AHS/LPS/Over-Max detection, 6-orientation 3D bin packing & cliff trim optimizer ($0.15)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "carrier": {
                    "type": "string",
                    "default": "ups_domestic"
                  },
                  "dim_divisor": {
                    "type": "number"
                  },
                  "length": {
                    "type": "number"
                  },
                  "width": {
                    "type": "number"
                  },
                  "height": {
                    "type": "number"
                  },
                  "weight": {
                    "type": "number"
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "carton": {
                    "type": "object"
                  },
                  "annual_volume": {
                    "type": "integer",
                    "default": 1200
                  },
                  "tenant_id": {
                    "type": "string",
                    "default": "public"
                  },
                  "bypass_cache": {
                    "type": "boolean",
                    "default": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "DIM weight, 3D packing placements, and cliff optimization savings"
          },
          "422": {
            "description": "Invalid dimensions, weight, or carrier ($0 billed)"
          }
        }
      }
    },
    "/v1/ocean-fcl": {
      "post": {
        "operationId": "oceanFclPlanner",
        "summary": "Ocean LCL vs 20GP/40GP/40HQ FCL & Air Freight (167 kg/CBM) / Express mode & break-even planner ($0.25)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "total_cbm": {
                    "type": "number"
                  },
                  "total_weight_kg": {
                    "type": "number"
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "lcl_rate_per_wm_usd": {
                    "type": "number"
                  },
                  "lcl_fixed_fees_usd": {
                    "type": "number"
                  },
                  "fcl_20gp_usd": {
                    "type": "number"
                  },
                  "fcl_40gp_usd": {
                    "type": "number"
                  },
                  "fcl_40hq_usd": {
                    "type": "number"
                  },
                  "air_rate_per_kg_usd": {
                    "type": "number"
                  },
                  "tenant_id": {
                    "type": "string",
                    "default": "public"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Mode comparison, utilization %, and exact break-even CBM thresholds"
          },
          "422": {
            "description": "Invalid CBM, weight, or rates ($0 billed)"
          }
        }
      }
    },
    "/v1/customs-docs": {
      "post": {
        "operationId": "compileCustomsDocs",
        "summary": "Compile and strictly reconcile Commercial Invoice + Packing List (HTML/JSON/CSV/SHA-256; $0.50)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "shipper",
                  "consignee",
                  "incoterm"
                ],
                "properties": {
                  "invoice_number": {
                    "type": "string"
                  },
                  "incoterm": {
                    "type": "string",
                    "enum": [
                      "EXW",
                      "FCA",
                      "FOB",
                      "CFR",
                      "CIF",
                      "CIP",
                      "DAP",
                      "DDP"
                    ]
                  },
                  "currency": {
                    "type": "string",
                    "default": "USD"
                  },
                  "shipper": {
                    "type": "object"
                  },
                  "consignee": {
                    "type": "object"
                  },
                  "line_items": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "cartons": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "declared_subtotal": {
                    "type": "number"
                  },
                  "freight_cost": {
                    "type": "number"
                  },
                  "insurance_cost": {
                    "type": "number"
                  },
                  "tenant_id": {
                    "type": "string",
                    "default": "public"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Reconciled Commercial Invoice + Packing List HTML, JSON, CSV, and SHA-256"
          },
          "422": {
            "description": "Arithmetic/weight/Incoterm mismatch or undervaluation attempt ($0 billed)"
          }
        }
      }
    },
    "/v1/gsr-claims": {
      "post": {
        "operationId": "scanGsrClaims",
        "summary": "15-day GSR late-delivery refund & invoice overcharge scanner with excusable exception filtering ($0.50)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "csv_text": {
                    "type": "string"
                  },
                  "shipments": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "audit_date_utc": {
                    "type": "string"
                  },
                  "claim_deadline_days": {
                    "type": "integer",
                    "default": 15
                  },
                  "tenant_id": {
                    "type": "string",
                    "default": "public"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Recoverable USD totals and carrier Dispute/Claim Pack (JSON + CSV)"
          },
          "422": {
            "description": "Empty or malformed shipment data ($0 billed)"
          }
        }
      }
    },
    "/v1/fba-audit": {
      "post": {
        "operationId": "auditFbaCatalog",
        "summary": "Amazon US FBA size-tier cliff & packaging trim optimizer (DIM 139; $0.25)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "skus"
                ],
                "properties": {
                  "skus": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "max_trim_in": {
                    "type": "number",
                    "default": 1.5
                  },
                  "tenant_id": {
                    "type": "string",
                    "default": "public"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "FBA tier classification and ranked annual savings opportunities"
          },
          "422": {
            "description": "Empty or invalid SKU dimensions/weights ($0 billed)"
          }
        }
      }
    },
    "/v1/batch-audit": {
      "post": {
        "operationId": "runBatchAudit",
        "summary": "Concurrent multi-row freight audit (GSR, DIM, or FBA) with barbarian_core TableWaterfallEngine & ApprovalBudgetGuard",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "rows"
                ],
                "properties": {
                  "mode": {
                    "type": "string",
                    "default": "gsr-claims"
                  },
                  "rows": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "audit_date_utc": {
                    "type": "string"
                  },
                  "budget_cap_micros": {
                    "type": "integer"
                  },
                  "tenant_id": {
                    "type": "string",
                    "default": "public"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Ordered concurrent batch results with per-row $0 error shield"
          },
          "422": {
            "description": "Invalid batch payload or budget guard rejection ($0 billed)"
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "operationId": "mcpJsonRpc",
        "summary": "Native MCP JSON-RPC 2.0 endpoint exposing 6 flat freight tools + 4 DualMcpFacade constant-context meta-tools",
        "responses": {
          "200": {
            "description": "JSON-RPC 2.0 response"
          }
        }
      }
    },
    "/webhooks/creem": {
      "post": {
        "operationId": "creemWebhook",
        "summary": "HMAC-SHA256 verified idempotent Creem.io prepaid credit fulfillment webhook",
        "responses": {
          "200": {
            "description": "Webhook processed idempotently"
          },
          "401": {
            "description": "Invalid creem-signature digest"
          }
        }
      }
    }
  }
}