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.
| Method | Returns | Description |
|---|---|---|
__construct(Config|array|null $config) | — | Accepts Config, environment overrides, or environment defaults. |
getConfig() | Config | Returns the resolved configuration. |
compliance() | ComplianceResource | Certificate lifecycle and activity operations. |
invoice() | InvoiceResource | Invoice submission and output URLs. |
get($endpoint, $queryParams) | Response | Sends a signed GET request. |
post($endpoint, $payload) | Response | Sends a signed JSON POST request. |
Static Zatca entry point
| Method | Returns | Description |
|---|---|---|
client(?Config $config) | ZatcaClient | Gets or replaces the process singleton. |
configure(...) | ZatcaClient | Creates Config and stores a singleton client. |
compliance() | ComplianceResource | Shortcut to the singleton compliance resource. |
invoice() | InvoiceResource | Shortcut to the singleton invoice resource. |
ComplianceResource
| Method | HTTP endpoint | Description |
|---|---|---|
credence(CredenceBuilder|array $data) | POST api/zatca/compliance/credence | Starts compliance onboarding and certificate issuance. |
importCertificate(array $data) | POST .../certificate/import | Imports certificate, private key, authorization token, and optional secret. |
renewCertificate($ownerUuid, $otp) | POST .../certificate/renew | Renews an existing completed certificate. |
activities($requestId) | GET .../activities/{id} | Returns certificate workflow activity records. |
InvoiceResource
| Method | Returns | Description |
|---|---|---|
submit(InvoiceBuilder|array $invoice) | Response | Submits an invoice for reporting or clearance. |
getPdfUrl($invoiceUuid) | string | Builds /invoice/{uuid}.pdf. |
getQrCodeUrl($invoiceUuid) | string | Builds /zatca/invoice/{uuid}/qr-code.png. |
InvoiceBuilder
All setters return the same builder. toArray() returns owner_uuid plus the nested invoice object.
| Method | Input | Behavior |
|---|---|---|
ownerUuid() | string | Account owner UUID; required by the API. |
id() | int | Sequential document ID. Default: 1. |
uuid() | string | Overrides the generated UUID v4. |
issueAt() | string|DateTimeInterface | Formats dates as Y-m-d H:i:s. |
invoiceType() | InvoiceType|string | Sets standard or simplified. |
standard / simplified() | — | Invoice type convenience methods. |
invoiceCase() | InvoiceCase|string | Sets invoice, credit_note, or debit_note. |
creditNote / debitNote() | — | Invoice-case convenience methods. |
billingReferenceId() | string|int | Original invoice number referenced by a credit or debit note. |
previousHash() | string | Hash returned for the immediately preceding document in the EGS chain. |
paymentCode() | PaymentCode|int | Payment means code. Default: cash (10). |
taxableAmount() | float | Explicit taxable amount. |
notes() | ?string | Invoice text or the reason for a credit/debit adjustment. |
supplier / customer() | PartyBuilder|array|callable | Supplier is always required. Customer is complete and required for standard invoices, but optional/null for simplified public-consumer invoices. |
addItem() | ItemBuilder|array|callable | Appends one item; callback items get sequential IDs. |
items() | array | Replaces 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
| Method | Returns | Description |
|---|---|---|
getStatusCode() | int | HTTP status. |
getHeaders() | array | Parsed response headers. |
getRawBody() | string | Unparsed body. |
json($key, $default) | mixed | Decoded JSON with dot-notation lookup. |
isSuccessful() | bool | HTTP 2xx and JSON status !== false. |
getMessage() | ?string | Top-level message. |
getData() | mixed | Top-level data. |
getErrors() | array | Top-level errors or empty array. |
toArray() | array | Decoded JSON, or ['raw' => ...]. |
Enums
| Enum | Cases and values |
|---|---|
Environment | Sandbox='sandbox', Simulation='simulation', Production='production' |
InvoiceType | Standard='standard', Simplified='simplified' |
InvoiceCase | Invoice='invoice', CreditNote='credit_note', DebitNote='debit_note' |
PaymentCode | Other=1, Cash=10, Credit=30, BankAccount=42, BankCard=48 |
IdentificationType | CRN, 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.