Agent Utilities
← Commerce data

commerce.price-components · v1.0.0

Price Components
for your agent.

Reconcile item, discount, shipping, tax and fee amounts using exact decimals; missing costs stay unknown and declared totals can be checked.

$0.0005 / call500 micro-dollar credits
131,072 bytes max input65,536 bytes max output
Works on supplied inputNo external network fetch

Example input

{
  "currency": "USD",
  "minorUnitDigits": 2,
  "items": [
    {
      "id": "1kg-bag",
      "unitPrice": "16.49",
      "quantity": 2,
      "discount": "0.00"
    }
  ],
  "orderDiscount": "2.00",
  "shipping": "4.99",
  "tax": null,
  "fees": "0.00"
}

Example output

{
  "currency": "USD",
  "minorUnitDigits": 2,
  "lines": [
    {
      "id": "1kg-bag",
      "subtotal": "32.98",
      "discount": "0.00",
      "total": "32.98"
    }
  ],
  "itemSubtotal": "32.98",
  "lineDiscounts": "0.00",
  "orderDiscount": "2.00",
  "knownTotal": "35.97",
  "total": null,
  "missingComponents": [
    "tax"
  ],
  "matchesDeclaredTotal": null,
  "difference": null,
  "scope": "Exact arithmetic on supplied amounts only. Discounts are absolute amounts; line discount applies once to the whole line. Missing shipping, tax or fees remain unknown. No tax-law calculation, checkout verification or currency-exponent lookup."
}

Generated from the actual handler using this example input; this is a preview, not a paid API call. Paid responses wrap the result with a receipt and recovery expiry.

Call it from your agent

Add credits in the workspace and keep your API key in private environment storage. Use the same request ID and exact body to recover a lost response within ten minutes.

// Node.js 22+. Read the key from your private environment.
const requestId = Date.now() + '_' + crypto.randomUUID();
const response = await fetch('https://agent-utilities.agent-utilities.workers.dev/v1/tools/commerce.price-components', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer ' + process.env.AGENT_UTILITIES_API_KEY,
    'Idempotency-Key': requestId
  },
  body: JSON.stringify({
  "currency": "USD",
  "minorUnitDigits": 2,
  "items": [
    {
      "id": "1kg-bag",
      "unitPrice": "16.49",
      "quantity": 2,
      "discount": "0.00"
    }
  ],
  "orderDiscount": "2.00",
  "shipping": "4.99",
  "tax": null,
  "fees": "0.00"
})
});
const data = await response.json();
if (!response.ok) throw new Error(data.error?.message ?? 'Request failed');
console.log(data);
// On response loss, retry this SAME requestId, tool and body.
// Do not rerun the line that generates requestId for a retry.
Input JSON Schema
{
  "type": "object",
  "properties": {
    "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$"
    },
    "minorUnitDigits": {
      "type": "integer",
      "minimum": 0,
      "maximum": 6
    },
    "items": {
      "type": "array",
      "minItems": 1,
      "maxItems": 100,
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "unitPrice": {
            "type": "string",
            "pattern": "^(0|[1-9]\\d{0,11})(\\.\\d{1,6})?$",
            "maxLength": 19
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100000
          },
          "discount": {
            "type": "string",
            "pattern": "^(0|[1-9]\\d{0,11})(\\.\\d{1,6})?$",
            "maxLength": 19
          }
        },
        "required": [
          "id",
          "unitPrice",
          "quantity",
          "discount"
        ],
        "additionalProperties": false
      }
    },
    "orderDiscount": {
      "type": "string",
      "pattern": "^(0|[1-9]\\d{0,11})(\\.\\d{1,6})?$",
      "maxLength": 19
    },
    "shipping": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^(0|[1-9]\\d{0,11})(\\.\\d{1,6})?$",
          "maxLength": 19
        },
        {
          "type": "null"
        }
      ]
    },
    "tax": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^(0|[1-9]\\d{0,11})(\\.\\d{1,6})?$",
          "maxLength": 19
        },
        {
          "type": "null"
        }
      ]
    },
    "fees": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^(0|[1-9]\\d{0,11})(\\.\\d{1,6})?$",
          "maxLength": 19
        },
        {
          "type": "null"
        }
      ]
    },
    "declaredTotal": {
      "type": "string",
      "pattern": "^(0|[1-9]\\d{0,11})(\\.\\d{1,6})?$",
      "maxLength": 19
    }
  },
  "required": [
    "currency",
    "minorUnitDigits",
    "items",
    "orderDiscount",
    "shipping",
    "tax",
    "fees"
  ],
  "additionalProperties": false
}
Output JSON Schema
{
  "type": "object",
  "properties": {
    "currency": {
      "type": "string"
    },
    "minorUnitDigits": {
      "type": "number"
    },
    "lines": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "subtotal": {
            "type": "string"
          },
          "discount": {
            "type": "string"
          },
          "total": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "subtotal",
          "discount",
          "total"
        ],
        "additionalProperties": false
      }
    },
    "itemSubtotal": {
      "type": "string"
    },
    "lineDiscounts": {
      "type": "string"
    },
    "orderDiscount": {
      "type": "string"
    },
    "knownTotal": {
      "type": "string"
    },
    "total": {
      "type": [
        "string",
        "null"
      ]
    },
    "missingComponents": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "matchesDeclaredTotal": {
      "type": [
        "boolean",
        "null"
      ]
    },
    "difference": {
      "type": [
        "string",
        "null"
      ]
    },
    "scope": {
      "type": "string"
    }
  },
  "required": [
    "currency",
    "minorUnitDigits",
    "lines",
    "itemSubtotal",
    "lineDiscounts",
    "orderDiscount",
    "knownTotal",
    "total",
    "missingComponents",
    "matchesDeclaredTotal",
    "difference",
    "scope"
  ],
  "additionalProperties": false
}

Before you integrate

Prices are experimental. The service currently allows 1,000 new calls per day across all accounts. Failed operations return reserved credits. Successful results are encrypted for ten-minute retry recovery. Review data handling and service limits.

Related tools

commerce $0.0003 / call

GTIN Validate

Validate GTIN-8, UPC/GTIN-12, EAN/GTIN-13 and GTIN-14 check digits; no product lookup.

commerce.gtin-validate

commerce $0.0005 / call

Variant Compare

Compare requested product attributes with an offered variant and list missing or mismatched fields.

commerce.variant-compare

commerce $0.0008 / call

Pack Plan

Choose the lowest-cost whole-pack combination for a required count with exact prices and explicit pack limits; up to 20 interchangeable offers.

commerce.pack-plan