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 Simplified buyer object

Optional person on a simplified invoice or on a note for one. No VAT number and no national address. Required, with id_scheme NAT, when a line uses VATEX-SA-HEA or VATEX-SA-EDU.

AttributeTypePresenceDescription
namestringRequired—
name_arstringOptional—
id_scheme"NAT" | "IQA" | "GCC" | "PAS" | "OTH"RequiredNAT national ID (10 digits, starts with 1). IQA Iqama (10 digits, starts with 2). GCC, PAS, OTH for other personal IDs.
id_numberstringRequiredMust match id_scheme or the API returns INVALID_BUYER_ID.

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, VATEX-SA-HEA, VATEX-SA-35). VATEX-SA-HEA and VATEX-SA-EDU require a simplified buyer with id_scheme NAT (BUYER_NATIONAL_ID_REQUIRED). Other missing or wrong codes are validated by Fatoora, not API validation errors.

Create simplified invoice

AttributeTypePresenceDescription
egs_unit_idstringRequiredActive EGS unit.
invoice_numberstringRequired—
metadataobjectOptionalYour own key-value data. Up to 20 string values. Returned on the API and webhooks. Not written into the ZATCA XML. Example: { loan_reference, contract_id }.
invoice_datestringRequiredYYYY-MM-DD
invoice_timestringRequiredHH:mm or HH:mm:ss.
sellerSellerRequired—
buyerSimplified buyerOptionalPerson (name, id_scheme, id_number). Required with NAT when a line uses VATEX-SA-HEA or VATEX-SA-EDU.
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—
metadataobjectOptionalYour own key-value data. Up to 20 string values. Returned on the API and webhooks. Not written into the ZATCA XML. Example: { loan_reference, contract_id }.
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—
metadataobjectOptionalYour own key-value data. Up to 20 string values. Returned on the API and webhooks. Not written into the ZATCA XML. Example: { loan_reference, contract_id }.
invoice_datestringRequiredYYYY-MM-DD
invoice_timestringRequiredHH:mm or HH:mm:ss.
original_invoice_uuidstringRequiredUUID of the original invoice.
reasonstringRequired—
reason_arstringOptional—
sellerSellerRequired—
buyerBuyerOptionalCompany buyer when the original was standard (name, vat_number, address). Person buyer when it was simplified (name, id_scheme, id_number). NAT is required for VATEX-SA-HEA and VATEX-SA-EDU.
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.
metadataobject | nullRequiredThe metadata object sent on create, or null. Also on list and invoice webhooks. Older invoices that only stored a loan reference return it here as loan_reference.
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