ZatcaX
Home Documentation API Reference

API Reference

Public classes, methods, return types, builders, enums, and endpoints in the current SDK.

ZatcaClient

ZatcaX\SDK\ZatcaClient is the HTTP client and resource factory.

MethodReturnsDescription
__construct(Config|array|null $config)—Accepts Config, environment overrides, or environment defaults.
getConfig()ConfigReturns the resolved configuration.
compliance()ComplianceResourceCertificate lifecycle and activity operations.
invoice()InvoiceResourceInvoice submission and output URLs.
get($endpoint, $queryParams)ResponseSends a signed GET request.
post($endpoint, $payload)ResponseSends a signed JSON POST request.

Static Zatca entry point

MethodReturnsDescription
client(?Config $config)ZatcaClientGets or replaces the process singleton.
configure(...)ZatcaClientCreates Config and stores a singleton client.
compliance()ComplianceResourceShortcut to the singleton compliance resource.
invoice()InvoiceResourceShortcut to the singleton invoice resource.

ComplianceResource

MethodHTTP endpointDescription
credence(CredenceBuilder|array $data)POST api/zatca/compliance/credenceStarts compliance onboarding and certificate issuance.
importCertificate(array $data)POST .../certificate/importImports certificate, private key, authorization token, and optional secret.
renewCertificate($ownerUuid, $otp)POST .../certificate/renewRenews an existing completed certificate.
activities($requestId)GET .../activities/{id}Returns certificate workflow activity records.

InvoiceResource

MethodReturnsDescription
submit(InvoiceBuilder|array $invoice)ResponseSubmits an invoice for reporting or clearance.
getPdfUrl($invoiceUuid)stringBuilds /invoice/{uuid}.pdf.
getQrCodeUrl($invoiceUuid)stringBuilds /zatca/invoice/{uuid}/qr-code.png.

InvoiceBuilder

All setters return the same builder. toArray() returns owner_uuid plus the nested invoice object.

MethodInputBehavior
ownerUuid()stringAccount owner UUID; required by the API.
id()intSequential document ID. Default: 1.
uuid()stringOverrides the generated UUID v4.
issueAt()string|DateTimeInterfaceFormats dates as Y-m-d H:i:s.
invoiceType()InvoiceType|stringSets standard or simplified.
standard / simplified()—Invoice type convenience methods.
invoiceCase()InvoiceCase|stringSets invoice, credit_note, or debit_note.
creditNote / debitNote()—Invoice-case convenience methods.
billingReferenceId()string|intOriginal invoice number referenced by a credit or debit note.
previousHash()stringHash returned for the immediately preceding document in the EGS chain.
paymentCode()PaymentCode|intPayment means code. Default: cash (10).
taxableAmount()floatExplicit taxable amount.
notes()?stringInvoice text or the reason for a credit/debit adjustment.
supplier / customer()PartyBuilder|array|callableSupplier is always required. Customer is complete and required for standard invoices, but optional/null for simplified public-consumer invoices.
addItem()ItemBuilder|array|callableAppends one item; callback items get sequential IDs.
items()arrayReplaces the complete item list.
autoCalculateTaxableAmount()—Sums quantity × unit_price − discount.
toArray()—Serializes the full API payload.

Supporting builders

PartyBuilder

identificationId(), identificationType(), registrationName(), taxId(), address(), toArray().

AddressBuilder

street(), buildingNumber(), subdivision(), city(), postalZone(), country(), toArray().

ItemBuilder

id(), name(), unitCode(), quantity(), unitPrice(), discount(), toArray().

CredenceBuilder

ownerUuid(), organizationIdentifier(), solutionName(), model(), serialNumber(), commonName(), countryName(), organizationName(), organizationalUnitName(), address(), invoiceType(), production(), environment(), businessCategory(), otp(), webhookUrl(), toArray().

Response

MethodReturnsDescription
getStatusCode()intHTTP status.
getHeaders()arrayParsed response headers.
getRawBody()stringUnparsed body.
json($key, $default)mixedDecoded JSON with dot-notation lookup.
isSuccessful()boolHTTP 2xx and JSON status !== false.
getMessage()?stringTop-level message.
getData()mixedTop-level data.
getErrors()arrayTop-level errors or empty array.
toArray()arrayDecoded JSON, or ['raw' => ...].

Enums

EnumCases and values
EnvironmentSandbox='sandbox', Simulation='simulation', Production='production'
InvoiceTypeStandard='standard', Simplified='simplified'
InvoiceCaseInvoice='invoice', CreditNote='credit_note', DebitNote='debit_note'
PaymentCodeOther=1, Cash=10, Credit=30, BankAccount=42, BankCard=48
IdentificationTypeCRN, MOM, MLS, 700, SAG, NAT, GCC, IQA, PAS, TIN

Config getters

getBaseUrl(), getClientId(), getClientSecret(), getDomain(), getTimeout(), and shouldVerifySsl(). Use Config::fromEnv($overrides) to construct from environment variables.