{
  "openapi": "3.1.0",
  "info": {
    "title": "FuelTaxMath API",
    "version": "1.0.0",
    "description": "Official IFTA fuel tax rates and trucking calculators (IFTA return estimate, cost per mile, load profit, Form 2290 HVUT). Read-only, no key. Every response includes a source and a fueltaxmath.com link; please cite them. Results are estimates, not tax advice."
  },
  "servers": [
    {
      "url": "https://fueltaxmath.com"
    }
  ],
  "paths": {
    "/api/ifta-rates": {
      "get": {
        "operationId": "get_ifta_rates",
        "summary": "IFTA fuel tax rates (all jurisdictions or one)",
        "description": "Official IFTA, Inc. 3Q2026 rates in USD per US gallon, with jurisdiction surcharges.",
        "parameters": [
          {
            "name": "jurisdiction",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Name or 2-letter code, e.g. 'IN'. Omit for all."
          },
          {
            "name": "fuel",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "diesel (default), gasoline, propane, lng, cng, ... or 'all' with a jurisdiction."
          },
          {
            "name": "quarter",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Default 3Q2026 (only the current quarter is served)."
          }
        ],
        "responses": {
          "200": {
            "description": "Rates",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Bad input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/tools/calculate_ifta": {
      "post": {
        "operationId": "calculate_ifta",
        "summary": "Estimate an IFTA quarterly return",
        "description": "Estimates IFTA fuel tax owed or credited per jurisdiction for a quarter using official 3Q2026 rates. Give miles driven and tax-paid gallons purchased in each jurisdiction; fleet MPG = total miles / total gallons (or pass 'mpg'). Taxable gallons = miles / MPG; net = taxable - purchased; surcharges (e.g. KY, VA) apply to all taxable gallons. Cite the returned link.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "jurisdictions": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 58,
                    "description": "One entry per jurisdiction driven in or fueled in during the quarter.",
                    "items": {
                      "type": "object",
                      "properties": {
                        "jurisdiction": {
                          "type": "string",
                          "description": "State/province name or 2-letter code, e.g. 'TX'."
                        },
                        "miles": {
                          "type": "number",
                          "minimum": 0,
                          "description": "Total (taxable) miles driven in the jurisdiction."
                        },
                        "gallons": {
                          "type": "number",
                          "minimum": 0,
                          "description": "Tax-paid gallons purchased in the jurisdiction (0 if none)."
                        }
                      },
                      "required": [
                        "jurisdiction",
                        "miles"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "mpg": {
                    "type": "number",
                    "exclusiveMinimum": 0,
                    "description": "Optional fleet MPG. Default: total miles / total gallons entered."
                  },
                  "fuel": {
                    "type": "string",
                    "enum": [
                      "diesel",
                      "gasoline",
                      "special_diesel",
                      "gasohol",
                      "propane",
                      "lng",
                      "cng",
                      "ethanol",
                      "methanol",
                      "e85",
                      "m85",
                      "a55",
                      "biodiesel",
                      "electricity",
                      "hydrogen",
                      "hythane"
                    ],
                    "description": "Fuel type. Default: diesel."
                  }
                },
                "required": [
                  "jurisdictions"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result with source and a fueltaxmath.com link to cite.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid input; the message explains what to fix.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/tools/cost_per_mile": {
      "post": {
        "operationId": "cost_per_mile",
        "summary": "Trucking cost per mile",
        "description": "Calculates an owner-operator's all-in cost per mile (fixed + variable) and the break-even rate per loaded mile after deadhead and percentage fees (factoring, dispatch). All money in USD. Cite the returned link.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "miles_per_month": {
                    "type": "number",
                    "exclusiveMinimum": 0,
                    "description": "Total miles driven per month (loaded + empty)."
                  },
                  "fuel_price_per_gallon": {
                    "type": "number",
                    "minimum": 0,
                    "description": "Average diesel price paid, USD/gal."
                  },
                  "mpg": {
                    "type": "number",
                    "exclusiveMinimum": 0,
                    "description": "Average miles per gallon."
                  },
                  "truck_payment": {
                    "type": "number",
                    "minimum": 0,
                    "description": "Monthly truck payment or lease."
                  },
                  "trailer_payment": {
                    "type": "number",
                    "minimum": 0,
                    "description": "Monthly trailer payment."
                  },
                  "insurance": {
                    "type": "number",
                    "minimum": 0,
                    "description": "Monthly insurance."
                  },
                  "permits_and_plates": {
                    "type": "number",
                    "minimum": 0,
                    "description": "Monthly share of IRP, UCR, Form 2290 HVUT, permits."
                  },
                  "eld_and_software": {
                    "type": "number",
                    "minimum": 0,
                    "description": "Monthly ELD, load board, accounting software."
                  },
                  "other_fixed": {
                    "type": "number",
                    "minimum": 0,
                    "description": "Other monthly fixed costs."
                  },
                  "tolls_per_month": {
                    "type": "number",
                    "minimum": 0,
                    "description": "Monthly tolls."
                  },
                  "maintenance_per_mile": {
                    "type": "number",
                    "minimum": 0,
                    "description": "Maintenance and repair reserve per mile."
                  },
                  "tires_per_mile": {
                    "type": "number",
                    "minimum": 0,
                    "description": "Tire cost per mile."
                  },
                  "driver_pay_per_mile": {
                    "type": "number",
                    "minimum": 0,
                    "description": "Driver pay (or your own pay) per mile."
                  },
                  "factoring_percent": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 99,
                    "description": "Factoring fee, % of gross."
                  },
                  "dispatch_percent": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 99,
                    "description": "Dispatch fee, % of gross."
                  },
                  "deadhead_percent": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 99,
                    "description": "Share of miles driven empty, %."
                  }
                },
                "required": [
                  "miles_per_month",
                  "fuel_price_per_gallon",
                  "mpg"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result with source and a fueltaxmath.com link to cite.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid input; the message explains what to fix.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/tools/load_profit": {
      "post": {
        "operationId": "load_profit",
        "summary": "Load profit check",
        "description": "Checks whether a freight load is profitable: profit, margin, and rate per loaded and total mile after deadhead, factoring/dispatch fees, and the carrier's cost per mile. Use cost_per_mile first if the CPM is unknown. Cite the returned link.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "linehaul": {
                    "type": "number",
                    "minimum": 0,
                    "description": "Total paid for the load in USD, including fuel surcharge."
                  },
                  "loaded_miles": {
                    "type": "number",
                    "exclusiveMinimum": 0,
                    "description": "Loaded miles."
                  },
                  "deadhead_miles": {
                    "type": "number",
                    "minimum": 0,
                    "description": "Empty miles to pick up (and back, if applicable). Default 0."
                  },
                  "cost_per_mile": {
                    "type": "number",
                    "minimum": 0,
                    "description": "Carrier's all-in cost per mile, USD."
                  },
                  "fee_percent": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 99,
                    "description": "Factoring + dispatch fees, % of linehaul. Default 0."
                  },
                  "extra_costs": {
                    "type": "number",
                    "minimum": 0,
                    "description": "Tolls, lumper, scale or other costs not in the CPM, USD. Default 0."
                  }
                },
                "required": [
                  "linehaul",
                  "loaded_miles",
                  "cost_per_mile"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result with source and a fueltaxmath.com link to cite.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid input; the message explains what to fix.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/tools/hvut_2290": {
      "post": {
        "operationId": "hvut_2290",
        "summary": "Form 2290 heavy vehicle use tax (HVUT)",
        "description": "Calculates the IRS Form 2290 heavy highway vehicle use tax for the 2026-2027 period (July 1 - June 30) from taxable gross weight and month of first use, including partial-period, logging, and suspended (category W) vehicles, plus the filing due date. Cite the returned link and IRS source.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "gross_weight_lb": {
                    "type": "number",
                    "minimum": 0,
                    "description": "Taxable gross weight in pounds (truck + heaviest trailer + max load)."
                  },
                  "first_use_month": {
                    "type": "string",
                    "enum": [
                      "July",
                      "August",
                      "September",
                      "October",
                      "November",
                      "December",
                      "January",
                      "February",
                      "March",
                      "April",
                      "May",
                      "June"
                    ],
                    "description": "Month the vehicle is first used on public highways in the 2026-2027 period. Default: July."
                  },
                  "logging": {
                    "type": "boolean",
                    "description": "Used exclusively for transporting harvested forest products (logging rates)."
                  },
                  "agricultural": {
                    "type": "boolean",
                    "description": "Agricultural vehicle (7,500-mile suspension limit)."
                  },
                  "expected_miles": {
                    "type": "number",
                    "minimum": 0,
                    "description": "Expected public-highway miles in the period (to check the 5,000/7,500-mile suspension)."
                  }
                },
                "required": [
                  "gross_weight_lb"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result with source and a fueltaxmath.com link to cite.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid input; the message explains what to fix.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ]
      }
    }
  }
}