About this endpoint
What it does
Onboards one EGS unit (billing device) with ZATCA in one call. It creates a key pair and CSR, gets a compliance CSID, runs the compliance checks for the document types you chose, and gets the production CSID.
Request Body
| Parameter | Type | Description |
|---|---|---|
| environment | ENUM | Required. ZATCA environment. Allowed values: sandbox, simulation, production. |
| otp | String | 6-digit OTP from the Fatoora portal. Required outside sandbox. In sandbox use 123345. |
| common_name | String | Required. Device name, for example TST-886431145-399999999900003. 1 to 200 characters. |
| serial_number | String | Required. Format 1-<maker>|2-<model>|3-<serial>, exactly 3 parts. |
| vat_number | String | Required. Saudi VAT number: 15 digits, starts and ends with 3. |
| organization_name | String | Required. Taxpayer name. 1 to 200 characters. |
| organization_unit | String | Required. Branch or unit name. 1 to 200 characters. |
| invoice_type | String | Required. 4 digits of 0/1. First digit = standard (B2B), second = simplified (B2C). Example: 1100 (both). 0000 is refused. |
| location | String | Required. Branch address or code. 1 to 200 characters. |
| industry | String | Required. Business activity. 1 to 200 characters. |
| country | String | Two-letter country code, uppercase. Example: SA. |
Response
Returns a JSON object with data and meta. data holds the private key and production credentials, returned once and never stored.
| Parameter | Type | Description |
|---|---|---|
| data.completed | Boolean | true when all steps passed. |
| data.environment | String | The environment used. |
| data.private_key | String | EC private key (secp256k1) in PEM format. Store it safely. |
| data.credentials.certificate | String | Production CSID, base64. Use as-is in /reports and /clearances. Decode once before using it in /invoices signing.certificate. |
| data.credentials.secret | String | Secret that goes with the certificate. |
| data.production_request_id | String | ZATCA request ID for the production CSID. |
| data.compliance_checks[].document | ENUM | Allowed values: standard_invoice, standard_credit_note, standard_debit_note, simplified_invoice, simplified_credit_note, simplified_debit_note. Only the types allowed by invoice_type are checked. |
| data.compliance_checks[].accepted | Boolean | true when ZATCA accepted the test document. |
| data.compliance_checks[].status | ENUM | Allowed values: CLEARED, REPORTED, NOT_CLEARED, NOT_REPORTED. |
| data.compliance_checks[].errors | Object Array | ZATCA errors for this document. Empty when accepted. |
| meta.request_id | String | Request ID for support. |
| meta.version | String | API version, v1. |
Notes
- Errors return 422:
validation_error,otp_required(no OTP outside sandbox),zatca_rejected(ZATCA refused the OTP or CSR). - In
sandbox, ZATCA returns a fixed sample certificate that does not match the generated private key./invoicesrefuses that pair (key_certificate_mismatch). To sign in sandbox, use/csrs→/compliance-csidsinstead.



