API objects

Request and response shapes used by the invoice API. Required means Esnad rejects the request (HTTP 400) if the value is missing or invalid. Optional fields may still be needed for a clean Fatoora result — missing or wrong formats often become zatca_warnings on HTTP 200.

How to read this page

Each section is a reusable shape. Create endpoints compose these objects. Presence reflects what Esnad enforces today — not ZATCA’s ideal document. Compliance fields on responses are under Responses.

The Address object

Used for seller and buyer national addresses. When you send an address object, street, city, and country are required. Building, district, and postal code are optional for Esnad; Fatoora may still return BR-KSA-09 / BR-KSA-37 / BR-KSA-66 warnings if they are missing or wrong.

AttributeTypePresenceDescription
streetstringRequiredStreet name.
building_numberstringOptionalZATCA expects 4 digits for SA (BR-KSA-37). Omitted or short values are accepted by Esnad and passed to Fatoora.
districtstringOptionalDistrict / CitySubdivisionName. Recommended for SA.
citystringRequiredCity name.
postal_codestringOptionalZATCA expects 5 digits for SA (BR-KSA-66). Invalid formats pass through to Fatoora.
countrystringRequiredISO country code, typically "SA".

The Seller object

AttributeTypePresenceDescription
namestringRequiredSeller legal name.
name_arstringOptionalArabic name.
vat_numberstringRequired15-digit VAT starting and ending with 3. Must match the company profile when profile VAT is set (SELLER_VAT_MISMATCH).
cr_numberstringOptionalCommercial Registration for schemeID=CRN. Do not send VAT here. Falls back to company profile; one of the two must be present (SELLER_CRN_REQUIRED).
addressAddressOptionalOptional on the request when a Saudi address is already on the company profile (invoice fields override profile per field). Otherwise Esnad returns MISSING_SELLER_ADDRESS.

The Buyer object

Required on standard (B2B) invoices. VAT goes in PartyTaxScheme; optional cr_number is PartyIdentification CRN.

AttributeTypePresenceDescription
namestringRequired
name_arstringOptional
vat_numberstringRequired15-digit VAT starting and ending with 3.
cr_numberstringOptionalBuyer CRN. VAT-shaped values may yield Fatoora BR-KSA-F-08 warnings.
addressAddressRequiredBuyer national address.

The Line item object

AttributeTypePresenceDescription
descriptionstringRequiredItem description.
description_arstringOptional
quantitynumberRequiredMust be greater than 0.
unit_pricenumberRequiredUnit price in SAR.
vat_category"S" | "Z" | "E" | "O"OptionalDefault S (15%). Z/E/O use 0%. Unknown letters → INVALID_VAT_CATEGORY.
vat_exemption_codestringOptionalRecommended for Z/E/O (e.g. VATEX-SA-32). Missing/wrong codes are validated by Fatoora (e.g. BR-KSA-69), not API validation errors.

Create simplified invoice

AttributeTypePresenceDescription
egs_unit_idstringRequiredActive EGS unit.
invoice_numberstringRequired
invoice_datestringRequiredYYYY-MM-DD
invoice_timestringRequiredHH:mm or HH:mm:ss.
sellerSellerRequired
line_itemsLine item[]RequiredAt least one line (EMPTY_LINE_ITEMS).
currencystringOptionalDefaults to SAR when omitted.

Create standard invoice

Body for POST /v1/invoices/standard. Extends simplified create with a required buyer for B2B clearance.

AttributeTypePresenceDescription
egs_unit_idstringRequiredActive EGS unit.
invoice_numberstringRequired
invoice_datestringRequiredYYYY-MM-DD
invoice_timestringRequiredHH:mm or HH:mm:ss.
sellerSellerRequired
buyerBuyerRequiredBuyer party. Must include name, vat_number, and address (MISSING_BUYER_DATA / INVALID_BUYER_VAT).
line_itemsLine item[]RequiredAt least one line (EMPTY_LINE_ITEMS).
currencystringOptionalDefaults to SAR when omitted.

Credit / debit note

AttributeTypePresenceDescription
egs_unit_idstringRequiredActive EGS unit.
invoice_numberstringRequired
invoice_datestringRequiredYYYY-MM-DD
invoice_timestringRequiredHH:mm or HH:mm:ss.
original_invoice_uuidstringRequiredUUID of the original invoice.
reasonstringRequired
reason_arstringOptional
sellerSellerRequired
buyerBuyerOptionalOptional on the request shape; required when the original invoice was standard/B2B (BUYER_REQUIRED_FOR_B2B_NOTE).
line_itemsLine item[]RequiredAt least one line (EMPTY_LINE_ITEMS).
currencystringOptionalDefaults to SAR when omitted.

Invoice response (create / GET)

Always includes compliance fields. See Responses.

AttributeTypePresenceDescription
invoice_idstringRequiredEsnad invoice id.
uuidstringRequiredInvoice UUID (ZATCA).
statusstringRequiredqueued | submitted | reported | cleared | failed | …
zatca_compliantbooleanRequiredfalse when Fatoora returned warnings.
zatca_warning_countnumberRequired
zatca_warningsarrayRequired{ code, message, category? }[]
resubmitbooleanRequiredfalse when accepted with warnings — do not resend same number/uuid.
messagestringOptionalPresent when warnings exist or when queued (202).
Warning object
{
  "code": "BR-KSA-37",
  "message": "The seller address building number must contain 4 digits.",
  "category": "KSA"
}

EGS & keys

Create EGS
AttributeTypePresenceDescription
unit_namestringRequired
invoice_type"standard" | "simplified" | "both"OptionalDefault simplified.
otpstringOptional
phase1 | 2OptionalDefault 2.
environment"sandbox" | "production"OptionalMust match API key mode if set.
Create API key
AttributeTypePresenceDescription
labelstringOptionalMax 100 chars.
prefix"zatca_live_" | "zatca_test_"OptionalDefault zatca_test_.

Endpoint reference: Invoices