apyhub
Back

Generate Arabic Invoice PDF API

What it does

The Arabic Invoice PDF API turns invoice data sent as JSON into a finished PDF invoice in Arabic, English or both. Send the invoice number, date, currency, seller and line items. The API returns the PDF with the subtotal, tax and total already worked out.

Set language to ar, en or bilingual. direction defaults to auto, which switches to right-to-left when the content has Arabic. Each item in lines takes a quantity, a unit_price, an optional tax_percent from 0 to 100, and an optional discount. The discount is a flat amount and cannot be more than the line amount. You can send up to 500 lines. Choose the page size with format (A4 by default), add your logo with logo_url, and print a QR code from any text with qr_text.

Teams use the Arabic Invoice PDF API to send bilingual invoices from online stores, add seller and buyer tax numbers to B2B invoices, and store an RTL invoice PDF with each order. Set output to binary to get the PDF file itself, or keep the default base64 JSON.

The API creates the PDF only. It does not submit invoices to a tax authority.

For a layout of your own, use Convert HTML Content to PDF API. For a separate QR image, such as a payment link in an email, use Generate QR Code API.

POST
Invoice PDF
https://api.eu.apyhub.com/odelyo/generate-arabic-invoice-pdf/invoices

QUICKSTART

GUIDE

Quickstart

Create a one-line invoice with 15% tax and get the PDF back as base64.

curl -X POST "https://api.eu.apyhub.com/odelyo/generate-arabic-invoice-pdf/invoices" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"number":"INV-1001","date":"2026-11-30","currency":"SAR","seller":{"name":"Al Nakheel Trading"},"buyer":{"name":"Mohammed Ali"},"lines":[{"description":"Consulting","quantity":2,"unit_price":500,"tax_percent":15}]}'

What you'll get back

Returns a JSON object with data and meta. data holds the PDF as base64, its size, page count and the worked-out totals.

{
  "data": {
    "pdf_base64": "JVBERi0x...",
    "bytes": 33232,
    "pages": 1,
    "totals": { "subtotal": 1000, "tax": 150, "total": 1150 }
  },
  "meta": { "request_id": "req_1567d9f22e1ec2ff", "version": "v1" }
}
TRY ITLIVE · 10 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*
Required. Invoice date, printed as sent.
lines*
Required. Invoice line items. 1 to 500 items.
lines-1*
Required. Quantity. Minimum 0.
Required. Price per unit. Minimum 0.
Required. Line description.
Required. Invoice number.
seller*
Required. Seller details printed on the document.
Required. Seller name.
Required. Currency code or label printed next to amounts.
Font family.
buyer
Buyer details printed on the document. If you send it, `name` is required.
Required. Buyer name.
Buyer email.
Buyer phone number.

About this endpoint

What it does

Creates an invoice PDF in Arabic, English or both from the invoice data you send. It returns the PDF with the subtotal, tax and total worked out from your line items.

Request Body

ParameterTypeDescription
numberStringRequired. Invoice number. 1 to 60 characters.
dateStringRequired. Invoice date, printed as sent. 1 to 40 characters.
currencyStringRequired. Currency code or label printed next to amounts, for example SAR. 1 to 10 characters.
sellerObjectRequired. Seller details printed on the invoice.
seller.nameStringRequired. Seller name. 1 to 200 characters.
seller.name_enStringSeller name in English, used in bilingual layouts. 1 to 200 characters.
seller.emailStringSeller email. 1 to 200 characters.
seller.phoneStringSeller phone number. 1 to 40 characters.
seller.addressStringSeller address. 1 to 500 characters.
seller.cr_numberStringSeller commercial registration (CR) number. 1 to 40 characters.
seller.tax_numberStringSeller tax or VAT number. 1 to 40 characters.
buyerObjectBuyer details printed on the invoice. If you send it, buyer.name is required. Same fields as seller.
linesObject ArrayRequired. Invoice line items. Min 1 item. Max 500 items.
lines[].descriptionStringRequired. Line description. 1 to 500 characters.
lines[].description_enStringLine description in English, used in bilingual layouts. 1 to 500 characters.
lines[].quantityNumberRequired. Quantity. Minimum: 0.
lines[].unit_priceNumberRequired. Price per unit. Minimum: 0.
lines[].discountNumberFlat discount amount in the invoice currency, not a percent. Minimum: 0. Must not be more than quantity × unit_price.
lines[].tax_percentNumberTax rate for this line in percent. Range: 0 to 100.
titleStringHeading printed on the invoice. 1 to 100 characters.
due_dateStringPayment due date, printed as sent. 1 to 40 characters.
notesStringFree-text notes printed near the bottom. 1 to 2,000 characters.
amount_in_wordsStringTotal in words, printed as sent. The API does not write it for you. 1 to 500 characters.
qr_textStringText to encode in a QR code on the invoice. 1 to 2,000 characters.
languageENUMLanguage of the labels. Allowed values: ar, en, bilingual.
directionENUMText direction. Allowed values: auto, rtl, ltr. Default: auto (right-to-left when the content has Arabic).
fontENUMFont family. Allowed values: naskh, kufi, sans, amiri. Default: naskh.
formatENUMPage size. Allowed values: A4, A5, Letter, Legal, receipt-80mm, receipt-58mm. Default: A4.
landscapeBooleanRender the page in landscape.
margin_mmNumberPage margin in millimetres. Range: 0 to 40.
page_numbersBooleanPrint page numbers.
decimalsIntegerNumber of decimal places for amounts. Range: 0 to 3.
accent_colorStringAccent colour as a hex value, for example #0F766E.
logo_urlStringLogo as an http(s) URL or a data:image/ URI. Up to 2,000,000 characters.
header_htmlStringCustom HTML for the page header. 1 to 20,000 characters.
footer_htmlStringCustom HTML for the page footer. 1 to 20,000 characters.
filenameStringFile name for the PDF. Letters, digits, spaces, dots, dashes and underscores, up to 100 characters.
outputENUMAllowed values: base64, binary. Default: base64. binary returns the PDF file itself.

Response

Returns a JSON object with data and meta (status 201). data holds the PDF as base64 and the totals. When output is binary, the response is the PDF file itself (status 200, application/pdf).

ParameterTypeDescription
data.pdf_base64StringThe invoice PDF, base64-encoded.
data.bytesIntegerSize of the PDF in bytes.
data.pagesIntegerNumber of pages in the PDF.
data.totals.subtotalNumberSum of quantity × unit_price minus discounts.
data.totals.taxNumberTotal tax across all lines.
data.totals.totalNumbersubtotal + tax.
meta.request_idStringRequest identifier.
meta.versionStringAPI version, for example v1.

Notes

  • Long invoices flow onto more pages.
  • Errors return status 422 with error.code, error.message, error.field and error.detail. validation_error means a field is missing or invalid. invalid_discount means a line discount is more than the line amount.
  • The API does not submit invoices to a tax authority.
▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.