ZatcaX
Home Documentation Configuration

Configuration

Configure the platform endpoint and credentials issued from the ZatcaX owner dashboard.

Environment variables

ZATCAX_BASE_URL=https://zatcax.example.com
ZATCAX_CLIENT_ID=zx_xxxxxxxxxxxxxxxxxxxxxxxx
ZATCAX_CLIENT_SECRET=sk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ZATCAX_CLIENT_DOMAIN=erp.example.com
ZATCAX_TIMEOUT=30
ZATCAX_VERIFY_SSL=true

Variable reference

VariablePurposeDefault
ZATCAX_BASE_URLServer base URL without a trailing slash.http://localhost:8000
ZATCAX_CLIENT_IDIdentifier sent in X-Client-Id.null
ZATCAX_CLIENT_SECRETSecret used to calculate the HMAC signature.Empty string
ZATCAX_CLIENT_DOMAINAuthorized domain sent in domain and Origin headers.Current host
ZATCAX_TIMEOUTcURL timeout in seconds.30
ZATCAX_VERIFY_SSLEnable peer certificate verification.true

Create a Config object

use ZatcaX\SDK\Config;
use ZatcaX\SDK\ZatcaClient;

$config = new Config(
    baseUrl: 'https://zatcax.example.com',
    clientSecret: 'sk_your_secret',
    clientId: 'zx_your_client_id',
    domain: 'erp.example.com',
    timeout: 30,
    verifySsl: true,
);

$client = new ZatcaClient($config);

Environment overrides

$config = Config::fromEnv([
    'timeout' => 60,
    'domain' => 'worker.example.com',
]);

$client = new ZatcaClient($config);

The ZatcaClient constructor accepts the same override array directly, or no argument to read all values from the environment.

Laravel dependency injection

The provider registers Config and ZatcaClient as singletons. If no domain is configured, Laravel derives it from APP_URL.

final class InvoiceService
{
    public function __construct(
        private \ZatcaX\SDK\ZatcaClient $zatca
    ) {}
}
Production rule: Keep SSL verification enabled. Disable it only in a controlled local environment.