API docs
Base URL https://baytelmal.com. JSON in, JSON out. No key is needed on the free tier (100 calls a day per IP address, reset at 00:00 UTC). Machine-readable: openapi.json.
Quick start
curl -s https://baytelmal.com/v1/samples/ksa \
| curl -s -X POST https://baytelmal.com/v1/ksa/check \
-H "Content-Type: application/json" --data-binary @-
Endpoints
| Method and path | What it does |
|---|---|
POST /v1/ksa/invoice | Builds an unsigned ZATCA UBL 2.1 invoice, credit note, debit note or prepayment invoice. Returns xml, invoiceHash, qrPayload (TLV tags 1 to 6, base64), counterValue (ICV), previousHash (PIH), subtype, warnings, notes. |
POST /v1/uae/invoice | Builds a PINT-AE UBL invoice or credit note (customization urn:peppol:pint:billing-1@ae-1). Returns xml, documentHash, warnings, notes. |
POST /v1/ksa/checkPOST /v1/uae/check | Pre-flight check of the invoice data. Returns passed, errors, warnings, notes, checksRun and scope. |
POST /v1/ksa/qr/decode | Body {"qr": "<base64>"}. Returns the decoded fields, the phase and any problems. |
POST /v1/ksa/qr/encode | Body with sellerName, vatNumber, timestamp, totalWithVat, vatTotal and optional invoiceHash. Returns qrPayload (tags 1 to 5, or 1 to 6). |
GET /v1/tax-number?country=SA&value=… | Format check for a Saudi VAT number (SA) or UAE TRN (AE). Not a registry lookup. |
GET /v1/uae/deadline?revenue_aed=… | The UAE provider-appointment date and mandatory date for a business of that size. |
GET /v1/samples/ksaGET /v1/samples/uae | A complete sample invoice to start from (does not count against the limit). |
POST /mcp | MCP server (Streamable HTTP, JSON responses). See MCP server. |
GET /health | Service status. |
The invoice JSON
Amounts are decimal strings ("46200.00") or numbers, with no more decimals than the currency allows. Dates are YYYY-MM-DD, times HH:MM:SS.
| Field | Required | Notes |
|---|---|---|
invoiceNumber | yes | Your invoice number. |
uuid | recommended | RFC 4122 UUID. Generated if missing (store it). |
typeCode | no | invoice (default), credit_note, debit_note, prepayment. |
transactionType | no | b2b (default), b2c, b2g, export. In Saudi Arabia B2C gives a simplified invoice. |
issueDate, issueTime | yes | dueDate optional. |
currency | yes | For example SAR, AED. |
supplier, customer | yes | legalNameEn, address {street, city, countryCode, optional buildingNumber, postalCode, district, additionalNumber, province}; optional legalNameAr, taxRegistrationNumber, registrationNumber, networkId (UAE Peppol ID). |
lines[] | yes | descriptionEn, quantity, unitPrice, netAmount, taxCategory (standard, zero_rated, exempt, out_of_scope, reverse_charge), taxRate, taxAmount; optional discountAmount, unitCode (default PCE), taxExemptionReasonCode, taxExemptionReasonText, itemCode, descriptionAr. |
totalNet, totalTax, totalGross | yes | prepaidAmount optional. |
counterValue, previousDocumentHash | Saudi | Your running invoice counter (ICV) and the previous invoice's hash (PIH). Defaults: 1 and the hash of "0". |
correctedInvoiceNumber, correctionReason | credit/debit notes | The original invoice and why it is corrected. |
Errors and limits
400with{"error":"invalid_input","problems":[…]}lists every problem in the input at once.429when the free daily limit is used up. HeadersX-RateLimit-LimitandX-RateLimit-Remainingshow where you are.- Bodies up to 1 MB and 500 lines per invoice.
- Invoices are processed in memory and not stored. We keep daily counts per endpoint, not invoice content.
Questions or a field you need: [email protected] (English).