{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/bitfreighter/json-schema/bitfreighter-internal-rate-request-response-schema-schema.json",
  "title": "Internal Rate Request Response Schema",
  "x-generated": "2026-11-15",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/bitfreighter-openapi.yml#/components/schemas/Internal Rate Request Response Schema",
  "properties": {
    "data": {
      "description": "Additional data about the quote. Will include rate information if available.",
      "properties": {
        "fuel": {
          "description": "The estimated fuel cost for this shipment. If the rate_type is 'all_in', subtract this cost from total_rate to get the 'line_haul' rate. If the rate_type is 'line_haul', add this cost to it to get the 'all_in' rate.",
          "type": "double"
        },
        "miles": {
          "description": "The total distance in miles for this shipment.",
          "type": "double"
        },
        "quote_id": {
          "description": "A unique identifier from Bitfreighter for this quote. This should be saved.",
          "type": "string"
        },
        "rate_expiration_datetime": {
          "description": "The date and time the rate will expire. Not included if no rate is returned.",
          "format": "date-time",
          "type": "string"
        },
        "rate_type": {
          "description": "The type of rate returned. This is determined by the 'is_all_in' flag and 'buy_it_now_price' sent in the request. Not included if no rate is returned.",
          "enum": [
            "line_haul",
            "all_in",
            "accept_buy_it_now"
          ],
          "type": "string"
        },
        "total_rate": {
          "description": "The total rate for the shipment. Not included if no rate is returned.",
          "type": "integer"
        },
        "truck_price": {
          "description": "The estimated cost to procure a truck for this opportunity. Not included if the shipper profile is disabled.",
          "type": "double"
        }
      },
      "required": [
        "quote_id",
        "miles",
        "fuel"
      ],
      "type": "object"
    },
    "matching_rules": {
      "description": "Rules that applied to this opportunity and affected the quote.",
      "properties": {
        "global_rules": {
          "description": "Global rules that matched for this opportunity.",
          "items": {
            "description": "Test",
            "properties": {
              "adjustment_amount": {
                "description": "The amount that was added to the quote price by this rule (calculated as a flat rate or a percentage of the previous price)",
                "type": [
                  "integer",
                  "null"
                ]
              },
              "adjustment_type": {
                "description": "Indicates if this rule added a flat amount to the quote or marked it up by a percentage",
                "enum": [
                  "flat_rate",
                  "percentage"
                ],
                "type": "string"
              },
              "maximum_margin": {
                "description": "The maximum margin that this quote will add. If the calculated adjustment is more\nthan this amount, this amount will be used for the adjustment instead.\n",
                "type": [
                  "integer",
                  "null"
                ]
              },
              "minimum_margin": {
                "description": "The minimum margin that this quote will add. If the calculated adjustment is less\nthan this amount, this amount will be used for the adjustment instead.\n",
                "type": [
                  "integer",
                  "null"
                ]
              },
              "post_adjustment_action": {
                "description": "The resulting effect of the rule, either continue or stop processing",
                "enum": [
                  "continue_processing",
                  "stop_processing"
                ],
                "type": "string"
              },
              "rule_action": {
                "description": "The resulting effect of the rule, adjust the quote amount or reject the request (no quote)",
                "enum": [
                  "adjust_margin_price",
                  "no_quote"
                ],
                "type": "string"
              },
              "rule_name": {
                "description": "The name of the rule",
                "type": "string"
              },
              "rule_order": {
                "description": "The sequence number of the rule. Can be used to order the rules in chronological order if needed.",
                "type": "integer"
              },
              "total_amount": {
                "description": "The margin that was added to the quote price by this rule. For flat rate rules,\nthis will be the same as the adjustment_amount. For percentage rules this will\nbe the adjustment_amount as a percentage multiplied by the running quote rate\nwhen this rule was processed (in sequential order by rule_order).\n",
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "rule_order",
              "rule_name",
              "rule_action",
              "post_adjustment_action"
            ],
            "title": "Rule",
            "type": "object"
          },
          "type": "array"
        },
        "shipper_profile_rules": {
          "description": "Rules on the associated shipper profile that matched for this opportunity.",
          "items": {
            "description": "Test",
            "properties": {
              "adjustment_amount": {
                "description": "The amount that was added to the quote price by this rule (calculated as a flat rate or a percentage of the previous price)",
                "type": [
                  "integer",
                  "null"
                ]
              },
              "adjustment_type": {
                "description": "Indicates if this rule added a flat amount to the quote or marked it up by a percentage",
                "enum": [
                  "flat_rate",
                  "percentage"
                ],
                "type": "string"
              },
              "maximum_margin": {
                "description": "The maximum margin that this quote will add. If the calculated adjustment is more\nthan this amount, this amount will be used for the adjustment instead.\n",
                "type": [
                  "integer",
                  "null"
                ]
              },
              "minimum_margin": {
                "description": "The minimum margin that this quote will add. If the calculated adjustment is less\nthan this amount, this amount will be used for the adjustment instead.\n",
                "type": [
                  "integer",
                  "null"
                ]
              },
              "post_adjustment_action": {
                "description": "The resulting effect of the rule, either continue or stop processing",
                "enum": [
                  "continue_processing",
                  "stop_processing"
                ],
                "type": "string"
              },
              "rule_action": {
                "description": "The resulting effect of the rule, adjust the quote amount or reject the request (no quote)",
                "enum": [
                  "adjust_margin_price",
                  "no_quote"
                ],
                "type": "string"
              },
              "rule_name": {
                "description": "The name of the rule",
                "type": "string"
              },
              "rule_order": {
                "description": "The sequence number of the rule. Can be used to order the rules in chronological order if needed.",
                "type": "integer"
              },
              "total_amount": {
                "description": "The margin that was added to the quote price by this rule. For flat rate rules,\nthis will be the same as the adjustment_amount. For percentage rules this will\nbe the adjustment_amount as a percentage multiplied by the running quote rate\nwhen this rule was processed (in sequential order by rule_order).\n",
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "required": [
              "rule_order",
              "rule_name",
              "rule_action",
              "post_adjustment_action"
            ],
            "title": "Rule",
            "type": "object"
          },
          "type": "array"
        },
        "shipper_profile_settings": {
          "description": "Settings on the shipper profile that adjust the amount that is quoted.",
          "properties": {
            "margin_adjustment": {
              "description": "The amount that the quote price was changed by because of a maximum\nor minimum shipper profile margin being applied to the quote.\n",
              "type": [
                "number",
                "null"
              ]
            },
            "maximum_margin": {
              "description": "Maximum amount of margin that can be added to the base cost of a quote.\nIf the margin that is calculated by the rules is greater than this margin,\nthis amount will be used instead.\n",
              "type": [
                "integer",
                "null"
              ]
            },
            "maximum_revenue": {
              "description": "The maximum quote price that can be submitted after margins and adjustments\nhave been applied and the base cost included. If the generated quote is greater\nthan this maximum, this maximum will be used instead.\n",
              "type": [
                "integer",
                "null"
              ]
            },
            "minimum_margin": {
              "description": "Minimum amount of margin that must be added to the base cost of a quote.\nIf the margin that is calculated by the rules is less than this margin,\nthis amount will be used instead.\n",
              "type": [
                "integer",
                "null"
              ]
            },
            "minimum_revenue": {
              "description": "The minimum quote price that can be submitted after margins and adjustments\nhave been applied and the base cost included. If the generated quote is less\nthan this minimum, this minimum will be used instead.\n",
              "type": [
                "integer",
                "null"
              ]
            },
            "revenue_adjustment": {
              "description": "The amount that the quote price was changed by because of a maximum\nor minimum shipper profile revenue being applied to the quote.\n",
              "type": [
                "number",
                "null"
              ]
            }
          },
          "title": "ShipperProfileSetting",
          "type": "object"
        }
      },
      "required": [
        "global_rules",
        "shipper_profile_rules",
        "shipper_profile_settings"
      ],
      "type": "object"
    },
    "message": {
      "description": "A message describing the outcome of the rate request. This is only provided when the outcome is 'no_rate_available' or 'error'",
      "type": "string"
    },
    "outcome": {
      "description": "The outcome of the rate request",
      "enum": [
        "success",
        "no_rate_available"
      ],
      "type": "string"
    }
  },
  "required": [
    "data",
    "outcome",
    "matching_rules"
  ],
  "type": "object"
}