apyhub
Back

ZATCA E-Invoicing API

What it does

The ZATCA E-Invoicing API handles Saudi Arabia's Phase 2 (Fatoora) e-invoicing in one place. Send invoice data as JSON and get back a signed UBL 2.1 XML invoice, its hash and the Phase 2 QR payload, ready to report or clear with ZATCA.

Start with /onboardings. Send your device details and the OTP from the Fatoora portal, and the API returns your private key and production credentials once. Build each document with /invoices. Set invoice_type to standard (B2B) or simplified (B2C), and document_type to invoice, credit_note or debit_note. Add signing to sign it. Then send the result to /clearances for standard invoices or /reports for simplified ones. Every ZATCA call takes environment: sandbox, simulation or production.

The API checks inputs before ZATCA sees them. It refuses impossible or future dates, wrong VAT rates (category S must be 15%) and keys that do not match the certificate, with a clear 422 error. Private keys and invoice data are not stored.

Teams use this ZATCA e-invoicing API to add Phase 2 compliance to a POS or ERP, onboard new billing devices, print the Fatoora QR code on receipts, and send credit and debit notes. It returns XML, not PDF.

Pair it with the Generate QR Code API to turn the qr payload into an image, and the Convert HTML Content to PDF API to make a printable invoice copy.

▣ ENDPOINT 01 / 11
POST
Onboard an EGS unit in one call: key pair, CSR, compliance CSID, all compliance checks, production CSID
https://api.eu.apyhub.com/odelyo/zatca-e-invoicing/onboardings

QUICKSTART

GUIDE

Quickstart

Onboard a test device in the sandbox (OTP 123345).

curl -X POST "https://api.eu.apyhub.com/odelyo/zatca-e-invoicing/onboardings" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"environment":"sandbox","otp":"123345","common_name":"TST-886431145-399999999900003","serial_number":"1-TST|2-TST|3-ed22f1d8-e6a2-1118-9b58-d9a8f11e445f","vat_number":"399999999900003","organization_name":"Riyadh Sweet Bakery","organization_unit":"Riyadh Branch","invoice_type":"1100","location":"RRRD2929","industry":"Bakery","country":"SA"}'

What you'll get back

Returns a JSON object with data (private key, production credentials and the check results) and meta.

{
  "data": {
    "completed": true,
    "environment": "sandbox",
    "private_key": "-----BEGIN EC PRIVATE KEY-----\n...\n-----END EC PRIVATE KEY-----\n",
    "credentials": { "certificate": "TUlJRDNqQ0NBNFNn...", "secret": "CkYsEXfV8c1g..." },
    "production_request_id": "30368",
    "compliance_checks": [
      { "document": "standard_invoice", "accepted": true, "status": "CLEARED", "errors": [] },
      { "document": "simplified_invoice", "accepted": true, "status": "REPORTED", "errors": [] }
    ]
  },
  "meta": { "request_id": "req_983c242c4a9a697e", "version": "v1" }
}
TRY ITLIVE · 600 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*
Business activity.
Branch address or code.
Saudi VAT number: 15 digits, starts and ends with 3.
Device name.
ZATCA environment. Use sandbox for testing.
4 digits of 0/1. 1st = standard (B2B), 2nd = simplified (B2C). 0000 is refused.
Format 1-<maker>|2-<model>|3-<serial>.
Taxpayer name.
Branch or unit name.
6-digit OTP from the Fatoora portal. Required outside sandbox. Sandbox: 123345.
Two-letter country code, uppercase.

About this endpoint

What it does

Onboards one EGS unit (billing device) with ZATCA in one call. It creates a key pair and CSR, gets a compliance CSID, runs the compliance checks for the document types you chose, and gets the production CSID.

Request Body

ParameterTypeDescription
environmentENUMRequired. ZATCA environment. Allowed values: sandbox, simulation, production.
otpString6-digit OTP from the Fatoora portal. Required outside sandbox. In sandbox use 123345.
common_nameStringRequired. Device name, for example TST-886431145-399999999900003. 1 to 200 characters.
serial_numberStringRequired. Format 1-<maker>|2-<model>|3-<serial>, exactly 3 parts.
vat_numberStringRequired. Saudi VAT number: 15 digits, starts and ends with 3.
organization_nameStringRequired. Taxpayer name. 1 to 200 characters.
organization_unitStringRequired. Branch or unit name. 1 to 200 characters.
invoice_typeStringRequired. 4 digits of 0/1. First digit = standard (B2B), second = simplified (B2C). Example: 1100 (both). 0000 is refused.
locationStringRequired. Branch address or code. 1 to 200 characters.
industryStringRequired. Business activity. 1 to 200 characters.
countryStringTwo-letter country code, uppercase. Example: SA.

Response

Returns a JSON object with data and meta. data holds the private key and production credentials, returned once and never stored.

ParameterTypeDescription
data.completedBooleantrue when all steps passed.
data.environmentStringThe environment used.
data.private_keyStringEC private key (secp256k1) in PEM format. Store it safely.
data.credentials.certificateStringProduction CSID, base64. Use as-is in /reports and /clearances. Decode once before using it in /invoices signing.certificate.
data.credentials.secretStringSecret that goes with the certificate.
data.production_request_idStringZATCA request ID for the production CSID.
data.compliance_checks[].documentENUMAllowed values: standard_invoice, standard_credit_note, standard_debit_note, simplified_invoice, simplified_credit_note, simplified_debit_note. Only the types allowed by invoice_type are checked.
data.compliance_checks[].acceptedBooleantrue when ZATCA accepted the test document.
data.compliance_checks[].statusENUMAllowed values: CLEARED, REPORTED, NOT_CLEARED, NOT_REPORTED.
data.compliance_checks[].errorsObject ArrayZATCA errors for this document. Empty when accepted.
meta.request_idStringRequest ID for support.
meta.versionStringAPI version, v1.

Notes

  • Errors return 422: validation_error, otp_required (no OTP outside sandbox), zatca_rejected (ZATCA refused the OTP or CSR).
  • In sandbox, ZATCA returns a fixed sample certificate that does not match the generated private key. /invoices refuses that pair (key_certificate_mismatch). To sign in sandbox, use /csrs → /compliance-csids instead.
▣ ENDPOINT 02 / 11
POST
Generate a secp256k1 key pair and a ZATCA CSR for one EGS unit (device)
https://api.eu.apyhub.com/odelyo/zatca-e-invoicing/csrs

QUICKSTART

GUIDE

Quickstart

Create a key pair and CSR for a sandbox device.

curl -X POST "https://api.eu.apyhub.com/odelyo/zatca-e-invoicing/csrs" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"environment":"sandbox","common_name":"TST-886431145-399999999900003","serial_number":"1-TST|2-TST|3-ed22f1d8-e6a2-1118-9b58-d9a8f11e445f","vat_number":"399999999900003","organization_name":"Riyadh Sweet Bakery","organization_unit":"Riyadh Branch","invoice_type":"1100","location":"RRRD2929","industry":"Bakery","country":"SA"}'

What you'll get back

Returns a JSON object with data (key and CSR) and meta.

{
  "data": {
    "private_key": "-----BEGIN EC PRIVATE KEY-----\n...\n-----END EC PRIVATE KEY-----\n",
    "csr": "-----BEGIN CERTIFICATE REQUEST-----\n...\n-----END CERTIFICATE REQUEST-----\n",
    "csr_base64": "LS0tLS1CRUdJTiBDRVJUSUZJ..."
  },
  "meta": { "request_id": "req_7cad51aacd334626", "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*
Business activity.
Branch address or code.
Saudi VAT number: 15 digits, starts and ends with 3.
Device name.
ZATCA environment. Use sandbox for testing.
4 digits of 0/1. 1st = standard (B2B), 2nd = simplified (B2C). 0000 is refused.
Format 1-<maker>|2-<model>|3-<serial>.
Taxpayer name.
Branch or unit name.
Two-letter country code, uppercase.

About this endpoint

What it does

Creates a secp256k1 key pair and a ZATCA CSR for one EGS unit. Nothing is sent to ZATCA.

Request Body

Same fields as /onboardings, without otp: environment, common_name, serial_number, vat_number, organization_name, organization_unit, invoice_type, location, industry, country. Same rules apply.

Response

Returns a JSON object with data and meta.

ParameterTypeDescription
data.private_keyStringEC private key (secp256k1) in PEM format. Returned once.
data.csrStringCSR in PEM format.
data.csr_base64StringCSR as base64. Send this to /compliance-csids.
▣ ENDPOINT 03 / 11
POST
Exchange a CSR and OTP for a compliance CSID
https://api.eu.apyhub.com/odelyo/zatca-e-invoicing/compliance-csids

QUICKSTART

GUIDE

Quickstart

Exchange the CSR from /csrs for a compliance CSID in the sandbox.

curl -X POST "https://api.eu.apyhub.com/odelyo/zatca-e-invoicing/compliance-csids" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"environment":"sandbox","otp":"123345","csr_base64":"<csr_base64 from /csrs>"}'

What you'll get back

{
  "data": { "request_id": "1234567890123", "certificate": "TUlJQ1BqQ0NB...", "secret": "GSGMv5oUC7Sx..." },
  "meta": { "request_id": "req_6fb569ce49ba15df", "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*
csr_base64 from /csrs.
ZATCA environment. Use sandbox for testing.
6-digit OTP from the Fatoora portal. Required outside sandbox. Sandbox: 123345.

About this endpoint

What it does

Sends a CSR and OTP to ZATCA and returns a compliance CSID, used to run compliance checks.

Request Body

ParameterTypeDescription
environmentENUMRequired. Allowed values: sandbox, simulation, production.
csr_base64StringRequired. csr_base64 from /csrs. Minimum 100 characters.
otpString6-digit OTP from the Fatoora portal. Required outside sandbox.

Response

Returns a JSON object with data and meta.

ParameterTypeDescription
data.request_idStringCompliance request ID. Needed by /production-csids.
data.certificateStringCompliance CSID, base64.
data.secretStringSecret that goes with the certificate.
▣ ENDPOINT 04 / 11
POST
Send one document signed with the compliance CSID to ZATCA compliance checks
https://api.eu.apyhub.com/odelyo/zatca-e-invoicing/compliance-checks

QUICKSTART

GUIDE

Quickstart

Check one document signed with the compliance certificate.

curl -X POST "https://api.eu.apyhub.com/odelyo/zatca-e-invoicing/compliance-checks" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"environment":"sandbox","credentials":{"certificate":"<compliance certificate>","secret":"<compliance secret>"},"invoice":{"xml_base64":"<from /invoices>","invoice_hash":"<from /invoices>","uuid":"<from /invoices>"}}'

What you'll get back

{
  "data": {
    "accepted": true,
    "zatca_http_status": 200,
    "status": "CLEARED",
    "validation": {
      "status": "PASS",
      "info": [{ "code": "XSD_ZATCA_VALID", "category": "XSD validation", "message": "Complied with UBL 2.1 standards in line with ZATCA specifications" }],
      "warnings": [],
      "errors": []
    }
  },
  "meta": { "request_id": "req_…", "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*
invoice*
Output of /invoices.
uuid from /invoices.
xml_base64 from /invoices.
invoice_hash from /invoices.
credentials*
Certificate (as returned, base64) and secret.
Secret for the certificate.
Certificate as returned by ZATCA (base64).
ZATCA environment. Use sandbox for testing.

About this endpoint

What it does

Sends one document signed with the compliance CSID to ZATCA's compliance checks and returns ZATCA's verdict.

Request Body

ParameterTypeDescription
environmentENUMRequired. Allowed values: sandbox, simulation, production.
credentialsObjectRequired. Compliance CSID from /compliance-csids.
credentials.certificateStringRequired. Certificate as returned (base64).
credentials.secretStringRequired. Secret.
invoiceObjectRequired. Output of /invoices, signed with the compliance certificate.
invoice.xml_base64StringRequired. xml_base64 from /invoices.
invoice.invoice_hashStringRequired. invoice_hash from /invoices.
invoice.uuidStringRequired. uuid from /invoices.

Response

Returns a JSON object with data and meta. A ZATCA rejection still returns HTTP 200, with accepted: false.

ParameterTypeDescription
data.acceptedBooleantrue when ZATCA accepted the document.
data.zatca_http_statusIntegerStatus code ZATCA returned (for example 200, 202, 400).
data.statusENUMAllowed values: CLEARED, REPORTED, NOT_CLEARED, NOT_REPORTED.
data.validation.statusENUMAllowed values: PASS, WARNING, ERROR.
data.validation.info[]Object ArrayPassed checks. Each has code, category, message.
data.validation.warnings[]Object ArrayWarnings, same shape. The document can still be accepted.
data.validation.errors[]Object ArrayErrors, same shape.
▣ ENDPOINT 05 / 11
POST
Exchange a compliance CSID for a production CSID
https://api.eu.apyhub.com/odelyo/zatca-e-invoicing/production-csids

QUICKSTART

GUIDE

Quickstart

Exchange the compliance CSID for a production CSID.

curl -X POST "https://api.eu.apyhub.com/odelyo/zatca-e-invoicing/production-csids" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"environment":"sandbox","credentials":{"certificate":"<compliance certificate>","secret":"<compliance secret>"},"compliance_request_id":"<request_id from /compliance-csids>"}'

What you'll get back

{
  "data": { "request_id": "30368", "certificate": "TUlJRDNqQ0NBNFNn...", "secret": "CkYsEXfV8c1g..." },
  "meta": { "request_id": "req_…", "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*
credentials*
Certificate (as returned, base64) and secret.
Secret for the certificate.
Certificate as returned by ZATCA (base64).
ZATCA environment. Use sandbox for testing.
request_id from /compliance-csids.

About this endpoint

What it does

Exchanges a compliance CSID for a production CSID after the compliance checks pass.

Request Body

ParameterTypeDescription
environmentENUMRequired. Allowed values: sandbox, simulation, production.
credentials.certificateStringRequired. Compliance certificate (base64).
credentials.secretStringRequired. Compliance secret.
compliance_request_idStringRequired. request_id from /compliance-csids. Digits only.

Response

Returns a JSON object with data and meta.

ParameterTypeDescription
data.request_idStringProduction request ID.
data.certificateStringProduction CSID, base64.
data.secretStringProduction secret.
▣ ENDPOINT 06 / 11
POST
Build a ZATCA UBL 2.1 invoice, credit or debit note; sign it and add the QR when signing material is sent
https://api.eu.apyhub.com/odelyo/zatca-e-invoicing/invoices

QUICKSTART

GUIDE

Quickstart

Build an unsigned B2C receipt with two lines.

curl -X POST "https://api.eu.apyhub.com/odelyo/zatca-e-invoicing/invoices" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"invoice_type":"simplified","document_type":"invoice","id":"BAKERY-0001","issue_date":"2026-11-26","issue_time":"10:30:00","counter":1,"seller":{"name":"Riyadh Sweet Bakery","vat_number":"399999999900003","address":{"street":"King Fahd Road","building_number":"1234","district":"Al Olaya","city":"Riyadh","postal_code":"12211","country":"SA"}},"lines":[{"name":"Chocolate Cake","quantity":1,"unit_price":"50.00","vat_category":"S","vat_percent":15},{"name":"Coffee","quantity":2,"unit_price":"10.00","vat_category":"S","vat_percent":15}]}'

What you'll get back

Returns a JSON object with data (the XML invoice, its hash and totals) and meta. Add signing to also get qr.

{
  "data": {
    "uuid": "a579e63a-0279-48c9-8fe1-…",
    "invoice_hash": "xkCaRQTjpP5Cl8cbqoshIyqh…",
    "signed": false,
    "xml_base64": "PD94bWwgdmVyc2lvbj0iMS4w…",
    "totals": { "line_total": "70.00", "vat_total": "10.50", "payable": "80.50" }
  },
  "meta": { "request_id": "req_…", "version": "v1" }
}
TRY ITLIVE · 120 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*
Your invoice number.
lines*
Invoice lines.
lines-1*
Item name, 3 characters or more.
Quantity.
Decimal string, up to 2 decimals.
15 for S, 0 for Z, E and O.
S standard, Z zero-rated, E exempt, O out of scope.
seller*
Seller details.
Name.
address*
Address.
City.
Street.
District.
Exactly 5 digits.
Exactly 4 digits.
15 digits, starts and ends with 3.
other_id
Other ID.
ID value.
ID scheme.
Invoice counter for this device.
YYYY-MM-DD. Real date, not in the future.
HH:MM:SS. Real time.
standard (B2B) or simplified (B2C).
Document type.
Free text note.
Invoice UUID. Generated if missing.
buyer
Buyer details. Required for standard invoices.
Name.
address*
Address.
City.
Street.
District.
Exactly 5 digits.
Exactly 4 digits.
15 digits, starts and ends with 3.
Commercial registration number.
other_id
Other ID.
ID value.
ID scheme.
signing
Add to sign the document.
Certificate decoded once from base64. Must match the private key.
PEM private key.

About this endpoint

What it does

Builds a ZATCA UBL 2.1 invoice, credit note or debit note as XML and calculates the totals. Add signing to sign it (XAdES) and get the Phase 2 QR payload.

Request Body

ParameterTypeDescription
invoice_typeENUMRequired. Allowed values: standard (B2B), simplified (B2C).
document_typeENUMRequired. Allowed values: invoice, credit_note, debit_note.
idStringRequired. Your invoice number.
issue_dateStringRequired. YYYY-MM-DD. Must be a real date and not in the future.
issue_timeStringRequired. HH:MM:SS. Must be a real time.
counterIntegerRequired. Invoice counter for this device. Minimum: 1.
uuidStringInvoice UUID. Generated if missing.
previous_hashStringHash of the previous invoice from this device. 40 to 200 characters.
currencyStringThree-letter code, uppercase. Example: SAR.
noteStringFree text note.
billing_referenceStringNumber of the original invoice. Required for credit and debit notes. 1 to 127 characters.
reasonStringReason for the note. Required for credit and debit notes. 1 to 1000 characters.
payment_means_codeStringUN payment code, 1 to 3 digits. Example: 10 (cash).
sellerObjectRequired. Seller details.
seller.nameStringRequired. 1 to 1000 characters.
seller.vat_numberStringRequired. 15 digits, starts and ends with 3.
seller.crnStringCommercial registration number. 1 to 50 characters.
seller.other_id.schemeENUMAllowed values: TIN, CRN, MOM, MLS, 700, SAG, NAT, GCC, IQA, PAS, OTH.
seller.other_id.valueString1 to 50 characters.
seller.address.streetStringRequired.
seller.address.building_numberStringRequired. Exactly 4 digits.
seller.address.districtStringRequired.
seller.address.cityStringRequired.
seller.address.postal_codeStringRequired. Exactly 5 digits.
seller.address.countryStringTwo-letter code, uppercase.
seller.address.additional_numberStringOptional.
seller.address.additional_streetStringOptional.
buyerObjectBuyer details, same fields as seller. Required when invoice_type is standard.
linesObject ArrayRequired. Invoice lines. Min 1, max 1000 items.
lines[].nameStringRequired. Item name, 3 characters or more.
lines[].quantityNumberRequired. Minimum: 0.0001.
lines[].unit_priceStringRequired. Decimal string with up to 2 decimals. Example: "100.00".
lines[].vat_categoryENUMRequired. Allowed values: S (standard), Z (zero-rated), E (exempt), O (out of scope).
lines[].vat_percentNumberRequired. 15 for S, 0 for Z, E and O.
lines[].exemption_reason_codeStringRequired for Z, E and O. Example: VATEX-SA-29.
lines[].exemption_reasonStringRequired for Z, E and O.
lines[].unit_codeStringUnit of measure code. Optional.
signingObjectAdd to sign the document.
signing.private_keyStringRequired with signing. PEM private key. Max 5000 characters.
signing.certificateStringRequired with signing. Certificate decoded once from base64. Must match the private key. Max 10000 characters.

Response

Returns a JSON object with data and meta. HTTP 201. Nothing is stored.

ParameterTypeDescription
data.uuidStringInvoice UUID.
data.invoice_hashStringSHA-256 hash of the invoice, base64. Use as previous_hash for the next invoice.
data.signedBooleantrue when signing was sent.
data.qrStringPhase 2 QR payload (TLV, base64). Only when signed. Tags 1 to 8 for standard, 1 to 9 for simplified.
data.xml_base64StringThe UBL 2.1 XML invoice, base64.
data.totals.line_totalStringSum of lines before VAT.
data.totals.vat_totalStringVAT, calculated per VAT category and rounded to 2 decimals.
data.totals.payableStringAmount to pay.

Notes

  • Errors return 422 with a code: validation_error, invalid_date, invalid_time, future_issue_date, invalid_vat_rate, exemption_reason_required, billing_reference_required, buyer_required, invalid_vat_number, invalid_amount, invalid_signing_material, key_certificate_mismatch.
  • Wrong JSON types are refused, not converted (for example "counter": "1").
  • The API returns XML only. Build a PDF copy yourself if you need one.
▣ ENDPOINT 07 / 11
POST
Report a signed simplified (B2C) document to ZATCA (within 24 hours of issue)
https://api.eu.apyhub.com/odelyo/zatca-e-invoicing/reports

QUICKSTART

GUIDE

Quickstart

Report a signed simplified invoice to the ZATCA sandbox.

curl -X POST "https://api.eu.apyhub.com/odelyo/zatca-e-invoicing/reports" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"environment":"sandbox","credentials":{"certificate":"<production certificate>","secret":"<production secret>"},"invoice":{"xml_base64":"<from /invoices>","invoice_hash":"<from /invoices>","uuid":"<from /invoices>"}}'

What you'll get back

{
  "data": { "accepted": true, "zatca_http_status": 200, "status": "REPORTED",
            "validation": { "status": "PASS", "info": [], "warnings": [], "errors": [] } },
  "meta": { "request_id": "req_…", "version": "v1" }
}
TRY ITLIVE · 120 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*
invoice*
Output of /invoices.
uuid from /invoices.
xml_base64 from /invoices.
invoice_hash from /invoices.
credentials*
Certificate (as returned, base64) and secret.
Secret for the certificate.
Certificate as returned by ZATCA (base64).
ZATCA environment. Use sandbox for testing.

About this endpoint

What it does

Reports a signed simplified (B2C) document to ZATCA. ZATCA requires this within 24 hours of issue.

Request Body

ParameterTypeDescription
environmentENUMRequired. Allowed values: sandbox, simulation, production.
credentials.certificateStringRequired. Production certificate as returned (base64).
credentials.secretStringRequired. Production secret.
invoice.xml_base64StringRequired. From /invoices.
invoice.invoice_hashStringRequired. From /invoices.
invoice.uuidStringRequired. From /invoices.

Response

Returns a JSON object with data and meta. A ZATCA rejection still returns HTTP 200, with accepted: false.

ParameterTypeDescription
data.acceptedBooleantrue when ZATCA accepted the document.
data.zatca_http_statusIntegerStatus code ZATCA returned (for example 200, 202, 400).
data.statusENUMAllowed values: CLEARED, REPORTED, NOT_CLEARED, NOT_REPORTED.
data.validation.statusENUMAllowed values: PASS, WARNING, ERROR.
data.validation.info[]Object ArrayPassed checks. Each has code, category, message.
data.validation.warnings[]Object ArrayWarnings, same shape. The document can still be accepted.
data.validation.errors[]Object ArrayErrors, same shape.
▣ ENDPOINT 08 / 11
POST
Clear a signed standard (B2B) document with ZATCA before sharing it with the buyer
https://api.eu.apyhub.com/odelyo/zatca-e-invoicing/clearances

QUICKSTART

GUIDE

Quickstart

Clear a signed standard invoice with the ZATCA sandbox.

curl -X POST "https://api.eu.apyhub.com/odelyo/zatca-e-invoicing/clearances" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"environment":"sandbox","credentials":{"certificate":"<production certificate>","secret":"<production secret>"},"invoice":{"xml_base64":"<from /invoices>","invoice_hash":"<from /invoices>","uuid":"<from /invoices>"}}'

What you'll get back

{
  "data": { "accepted": true, "zatca_http_status": 200, "status": "CLEARED",
            "validation": { "status": "PASS", "info": [], "warnings": [], "errors": [] } },
  "meta": { "request_id": "req_…", "version": "v1" }
}
TRY ITLIVE · 120 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*
invoice*
Output of /invoices.
uuid from /invoices.
xml_base64 from /invoices.
invoice_hash from /invoices.
credentials*
Certificate (as returned, base64) and secret.
Secret for the certificate.
Certificate as returned by ZATCA (base64).
ZATCA environment. Use sandbox for testing.

About this endpoint

What it does

Clears a signed standard (B2B) document with ZATCA. Share it with the buyer only after it is cleared.

Request Body

ParameterTypeDescription
environmentENUMRequired. Allowed values: sandbox, simulation, production.
credentials.certificateStringRequired. Production certificate as returned (base64).
credentials.secretStringRequired. Production secret.
invoice.xml_base64StringRequired. From /invoices.
invoice.invoice_hashStringRequired. From /invoices.
invoice.uuidStringRequired. From /invoices.

Response

Returns a JSON object with data and meta. A ZATCA rejection still returns HTTP 200, with accepted: false.

ParameterTypeDescription
data.acceptedBooleantrue when ZATCA accepted the document.
data.zatca_http_statusIntegerStatus code ZATCA returned (for example 200, 202, 400).
data.statusENUMAllowed values: CLEARED, REPORTED, NOT_CLEARED, NOT_REPORTED.
data.validation.statusENUMAllowed values: PASS, WARNING, ERROR.
data.validation.info[]Object ArrayPassed checks. Each has code, category, message.
data.validation.warnings[]Object ArrayWarnings, same shape. The document can still be accepted.
data.validation.errors[]Object ArrayErrors, same shape.
▣ ENDPOINT 09 / 11
POST
Create a ZATCA QR code payload (TLV, base64)
https://api.eu.apyhub.com/odelyo/zatca-e-invoicing/qr-codes

QUICKSTART

GUIDE

Quickstart

Create the QR payload for a receipt.

curl -X POST "https://api.eu.apyhub.com/odelyo/zatca-e-invoicing/qr-codes" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"seller_name":"Acme Trading LLC","vat_number":"310122393500003","timestamp":"2026-11-25T10:00:00Z","total_with_vat":"1150.00","vat_total":"150.00"}'

What you'll get back

{
  "data": {
    "tlv_base64": "ARBBY21lIFRyYWRpbmcgTExDAg8zMTAxMjIzOTM1MDAwMDMDFDIwMjYtMTEtMjVUMTA6MDA6MDBaBAcxMTUwLjAwBQYxNTAuMDA=",
    "fields": { "seller_name": "Acme Trading LLC", "vat_number": "310122393500003", "timestamp": "2026-11-25T10:00:00Z", "total_with_vat": "1150.00", "vat_total": "150.00" }
  },
  "meta": { "request_id": "req_3fdb4f92b5da98f0", "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*
ISO 8601 date-time. Converted to UTC.
Decimal string, up to 2 decimals. Not more than total_with_vat.
15 digits, starts and ends with 3.
Seller name, max 255 bytes.
Decimal string, up to 2 decimals.

About this endpoint

What it does

Creates a ZATCA QR payload (TLV, base64) from the five Phase 1 fields. Turn the string into a QR image with any QR generator.

Request Body

ParameterTypeDescription
seller_nameStringRequired. 1 to 200 characters, max 255 bytes in UTF-8.
vat_numberStringRequired. 15 digits, starts and ends with 3.
timestampStringRequired. ISO 8601 date-time. Offsets are converted to UTC. Must be a real date.
total_with_vatStringRequired. Decimal string, up to 2 decimals.
vat_totalStringRequired. Decimal string, up to 2 decimals. Cannot be more than total_with_vat.

Response

Returns a JSON object with data and meta. HTTP 201.

ParameterTypeDescription
data.tlv_base64StringQR payload, TLV encoded, base64.
data.fieldsObjectThe 5 values as encoded (timestamp in UTC).
▣ ENDPOINT 10 / 11
POST
Decode and check a ZATCA QR payload
https://api.eu.apyhub.com/odelyo/zatca-e-invoicing/qr-codes/decode

QUICKSTART

GUIDE

Quickstart

Decode and check a QR payload.

curl -X POST "https://api.eu.apyhub.com/odelyo/zatca-e-invoicing/qr-codes/decode" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"tlv_base64":"AQRBY21lAg8zMTAxMjIzOTM1MDAwMDMDFDIwMjYtMTEtMjVUMTA6MDA6MDBaBAcxMTUwLjAwBQYxNTAuMDA="}'

What you'll get back

{
  "data": {
    "valid": true,
    "fields": { "seller_name": "Acme", "vat_number": "310122393500003", "timestamp": "2026-11-25T10:00:00Z", "total_with_vat": "1150.00", "vat_total": "150.00" },
    "problems": [],
    "extra_tags": []
  },
  "meta": { "request_id": "req_5a9a1f520da0c84b", "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*
QR payload, base64 or base64url.

About this endpoint

What it does

Decodes a ZATCA QR payload and checks that the required fields are present and valid.

Request Body

ParameterTypeDescription
tlv_base64StringRequired. QR payload, base64 or base64url. Minimum 4 characters.

Response

Returns a JSON object with data and meta.

ParameterTypeDescription
data.validBooleantrue when tags 1 to 5 are present and valid.
data.fieldsObjectDecoded seller_name, vat_number, timestamp, total_with_vat, vat_total. Missing tags are left out.
data.problemsString ArrayProblems found, for example missing:timestamp. Empty when valid.
data.extra_tagsInteger ArrayPhase 2 tags found beyond 1 to 5, for example [6, 7, 8, 9].
▣ ENDPOINT 11 / 11
GET
Check the format of a Saudi VAT number
https://api.eu.apyhub.com/odelyo/zatca-e-invoicing/vat-numbers/:vat_number

QUICKSTART

GUIDE

Quickstart

Check the format of a Saudi VAT number.

curl -X GET "https://api.eu.apyhub.com/odelyo/zatca-e-invoicing/vat-numbers/:vat_number" \
  -H "apy-token: $APY_TOKEN"

What you'll get back

{
  "data": { "vat_number": "310122393500003", "valid_format": true, "note": "Format check only. It does not confirm the number is registered." },
  "meta": { "request_id": "req_…", "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.
VAT number to check.

About this endpoint

What it does

Checks the format of a Saudi VAT number. It does not confirm the number is registered.

Path Parameter

ParameterTypeDescription
vat_numberStringRequired. The VAT number to check.

Response

Returns a JSON object with data and meta.

ParameterTypeDescription
data.vat_numberStringThe number as sent.
data.valid_formatBooleantrue for 15 digits that start and end with 3. Spaces and other characters give false.
data.noteStringReminder that this is a format check only.
▣ 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.