Generate Receipt

POST/v1/receipt

Generate a professional receipt PDF for completed payments.

Headers

HeaderValueRequired
AuthorizationBearer YOUR_API_KEYYes
Content-Typeapplication/jsonYes

Request Body

json
{
"receipt_number": "REC-001",
"date": "2026-02-26",
"currency": "USD",
"from": {
"name": "Acme Corporation",
"email": "billing@acme.com",
"address": "123 Main Street\nBaku, Azerbaijan"
},
"to": {
"name": "John Doe",
"email": "john@example.com"
},
"items": [
{
"description": "Pro Plan - Monthly",
"quantity": 1,
"unit_price": 29.99
}
],
"tax": { "rate": 18 },
"payment_method": "Visa ending in 4242",
"payment_date": "2026-02-26",
"transaction_id": "txn_abc123xyz",
"notes": "Thank you for your purchase!"
}

Fields

FieldTypeRequiredDescription
receipt_numberstringYesUnique receipt identifier
datestringYesDate of the receipt
currencystringYesCurrency code (e.g. USD)
fromobjectYesYour company details
from.namestringYesCompany name
from.emailstringNoCompany email
from.addressstringNoCompany address
toobjectNoCustomer details
to.namestringNoCustomer name
to.emailstringNoCustomer email
itemsarrayYesLine items (min 1)
items[].descriptionstringYesItem description
items[].quantitynumberYesQuantity
items[].unit_pricenumberYesPrice per unit
items[].taxobjectNoItem-level tax. Overrides receipt-level tax for this item
items[].tax.ratenumberNoItem-level tax percentage
taxobjectNoReceipt-level tax applied to items without item-level tax
tax.ratenumberNoTax percentage (default: 0)
payment_methodstringNoPayment method used (e.g. Visa ending in 4242)
payment_datestringNoDate payment was made
transaction_idstringNoTransaction reference ID
notesstringNoAdditional notes

Response

Success (200)

  • Content-Type: application/pdf
  • Body: PDF binary data

Errors

StatusBody
400{ "error": "receipt_number is required" }
401{ "error": "Invalid API key" }
429{ "error": "Monthly limit reached. Please upgrade." }

Tax Rates

Kagyz supports flexible tax calculation with fallback logic:

  1. 1. If an item has items[].tax — that rate is used
  2. 2. If an item has no items[].tax — the receipt-level tax is used
  3. 3. If neither is set — no tax (0%)
Item-level tax overrides receipt-level tax for that item.

Mixed Tax Rates Example

json
{
"tax": { "rate": 10 },
"items": [
{ "description": "Electronics", "quantity": 1, "unit_price": 1000, "tax": { "rate": 20 } },
{ "description": "Software", "quantity": 1, "unit_price": 500 },
{ "description": "Exempt Service", "quantity": 1, "unit_price": 300, "tax": { "rate": 0 } }
]
}
ItemTax RateReason
Electronics20%Uses item-level tax
Software10%Falls back to receipt-level tax
Exempt Service0%Uses item-level tax (explicitly 0)

Example

bash
curl -X POST https://api.kagyz.com/v1/receipt \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"receipt_number": "REC-001",
"date": "2026-02-26",
"currency": "USD",
"from": {
"name": "Acme Corporation",
"email": "billing@acme.com",
"address": "123 Main Street\nBaku, Azerbaijan"
},
"to": {
"name": "John Doe",
"email": "john@example.com"
},
"items": [
{
"description": "Pro Plan - Monthly",
"quantity": 1,
"unit_price": 29.99
}
],
"tax": { "rate": 18 },
"payment_method": "Visa ending in 4242",
"payment_date": "2026-02-26",
"transaction_id": "txn_abc123xyz",
"notes": "Thank you for your purchase!"
}' \
--output receipt.pdf