Generate a Receipt Document with Itemized Totals
Turn purchase details into a consistent receipt document without building calculation and formatting rules into every application.
Run — free
Provide the merchant name, at least one line item, and the payment method. The generator calculates each line subtotal, applies an optional tax rate, adds the final totals, and assigns a stable receipt number derived from the supplied data. The result is structured JSON that can be stored directly, rendered into a customer-facing layout, attached to an order record, or passed to another document workflow.
Prepare complete receipt details
Start with the merchant name exactly as it should appear in the finished record, then add every purchased product or service as a separate line item. Each line needs a description, a quantity, and a unit price. Quantity may include decimals, which is useful for measured goods, hours, weight, or distance. Unit prices are interpreted in the selected currency and rounded to the nearest minor unit before calculations begin. If a line is taxable, provide its tax rate as a percentage; omit the rate for a tax-free item. Finally, enter a payment method suitable for display, such as cash, bank transfer, or a masked card label. Avoid sending complete card numbers or other sensitive payment credentials because the field is descriptive only. A three-letter currency code is optional and defaults to USD. Keeping descriptions concise and payment labels masked produces a document that is both readable and appropriate for long-term order records. The request must contain at least one line item, because an empty purchase cannot produce a meaningful receipt.
Understand the calculations and receipt number
The generator converts every unit price to integer minor units before multiplying it by the quantity. This approach avoids the familiar floating-point artifacts that can make ordinary decimal arithmetic display values such as 10.0000000002. Each line subtotal is rounded to the nearest minor unit, and its tax is then calculated from that rounded subtotal and the supplied percentage. The document subtotal is the sum of all line subtotals; the tax total is the sum of all line taxes; and the final total is their sum. The payment amount always matches that final total. A deterministic receipt number is created from the normalized merchant, item, payment, and currency data. Sending the same normalized request again therefore returns the same receipt number, which supports idempotent retries and duplicate detection. Changing a material receipt field produces a different number. The number is an application identifier, not a government sequence, tax invoice authorization, or accounting ledger counter. Organizations subject to statutory numbering requirements should store their official sequence separately or map this generated document into their compliant invoicing system.
Use the structured document in a workflow
The response separates identity, merchant details, itemized calculations, payment information, and aggregate totals. That structure makes it straightforward to render a printable receipt, save a normalized purchase record, populate an email template, or feed a later PDF generation step. Applications can show each returned line exactly as calculated instead of reimplementing arithmetic in a presentation layer. For automated order processing, save the complete response beside the original request so later reconciliation can compare inputs and calculated values. The stable receipt number can serve as a convenient lookup key when requests may be retried, although a database should still enforce its own uniqueness and ownership rules. Validation failures are explicit: missing merchant or payment text, malformed prices, invalid tax rates, invalid currencies, and empty line-item arrays are rejected rather than silently repaired. This is intentional because quietly inventing purchase data would make a receipt unreliable. The endpoint performs no network requests, stores no data, and uses neither the current date nor randomness, so results do not drift between executions. At $0.002 per request, it is suitable for small transactional workflows that need predictable receipt data before rendering or archival.
What you can do with it
Create an order receipt
Convert checkout line items and a masked payment label into a consistent receipt record for storage or display.
Prepare data for a PDF
Calculate authoritative line and grand totals before passing structured receipt data into a separate PDF renderer.
Normalize manual sales
Turn point-of-sale or back-office entries into one predictable schema for reconciliation and customer support.
FAQ
What does it cost?
Each API request costs $0.002.
Can I generate a receipt without line items?
No. At least one line item is required, and an empty array returns an invalid input error.
How are taxes calculated?
Tax is calculated independently for each line from its rounded subtotal and optional percentage rate, then all line taxes are added.
Is the receipt number random?
No. It is deterministically derived from normalized receipt data, so identical inputs produce the same number.
Does this create a legally compliant tax invoice?
No. It creates a structured receipt document; jurisdiction-specific numbering, registration, and disclosure rules remain your responsibility.
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/doc/receipt-generate \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"merchant_name":"Northwind Coffee","line_items":[{"description":"Cappuccino","quantity":2,"unit_price":4.5,"tax_rate":8.25},{"description":"Blueberry muffin","quantity":1,"unit_price":3.25}],"payment_method":"Visa ending 4242"}'const res = await fetch("https://api.kit.forhosting.com/doc/receipt-generate", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"merchant_name": "Northwind Coffee",
"line_items": [
{
"description": "Cappuccino",
"quantity": 2,
"unit_price": 4.5,
"tax_rate": 8.25
},
{
"description": "Blueberry muffin",
"quantity": 1,
"unit_price": 3.25
}
],
"payment_method": "Visa ending 4242"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/doc/receipt-generate",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"merchant_name": "Northwind Coffee",
"line_items": [
{
"description": "Cappuccino",
"quantity": 2,
"unit_price": 4.5,
"tax_rate": 8.25
},
{
"description": "Blueberry muffin",
"quantity": 1,
"unit_price": 3.25
}
],
"payment_method": "Visa ending 4242"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/doc/receipt-generate", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"merchant_name":"Northwind Coffee","line_items":[{"description":"Cappuccino","quantity":2,"unit_price":4.5,"tax_rate":8.25},{"description":"Blueberry muffin","quantity":1,"unit_price":3.25}],"payment_method":"Visa ending 4242"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"merchant_name":"Northwind Coffee","line_items":[{"description":"Cappuccino","quantity":2,"unit_price":4.5,"tax_rate":8.25},{"description":"Blueberry muffin","quantity":1,"unit_price":3.25}],"payment_method":"Visa ending 4242"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/doc/receipt-generate", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"merchant_name": "Northwind Coffee",
"line_items": [
{
"description": "Cappuccino",
"quantity": 2,
"unit_price": 4.5,
"tax_rate": 8.25
},
{
"description": "Blueberry muffin",
"quantity": 1,
"unit_price": 3.25
}
],
"payment_method": "Visa ending 4242"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "doc.receipt_generate",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_mb | 25 |
max_pages | 200 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |