E-Invoice API Documentation


TABLE OF CONTENTS



Invoice Flow


This document outlines the API endpoints and their functionalities related to the generation and status checking of e-invoices compliant with ZATCA standards. The provided endpoints facilitate the submission of invoice data, tracking of processing status, and retrieval of generated invoices.

These endpoints offer a seamless workflow for clients to efficiently manage their invoicing processes, ensuring compliance and transparency throughout the invoicing lifecycle.

 

Endpoint 1: Generate E-Invoice


URL{{base_url}}/api/v2/einvoices/zatca/generate

HTTP MethodPOST

Description:

This endpoint allows clients to submit data for generating an e-invoice that is compliant with ZATCA. The data will be added to a queue system for processing.

Payload:

This is additional data on the existing payload. 

  • webhook_url (url, optional) : endpoint where the invoice response will be received

  • webhook_token : (string , required with webhook_url) secret token we'll be utilizing it in the request header under the API_AUTHENTICATION key

Response:

  • Status Code: 200 OK

  • Content Type: JSON

  • Body:  

id (integer): The unique identifier for the invoice generation request.

status (string): The current status of the request (e.g., "IN QUEUE").

message (string): A message indicating the status of the request.

qr_string (string): The QR code string associated with the generated invoice.


Sample response:

{   "id": 90,   "status": "IN QUEUE",   "message": "Invoice has been received",   "qr_string": "AQZLdXphbWECDzMxMDE0NTQ1MzgwMDAwMwMTMjAyNC0wNC0wMVQxMTo1NToxNwQDMTU4BQUyMC42MQYsOTM1b3hDaVl3VnNyeVdkam0vNjBadldqVUZQUTVkQ2NSeXlnbTFGejJZST0HYE1FWUNJUURIVFROMTgwaGhJRkdsMDZXamNhWVEycURMRzdJUndEaXBqaXhTSWhDRXlBSWhBTHk4UWE4RFFmMEU4WW56S0hhcW0yOWVYd21ibjZpM05pY3dPbXhQa1pHUghYMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE+R7mUm9nok7lfwb44GG0cW79nNxD0jVlNhiG04fN/ca/hsNOxw1u/7vjzNWFFSOqeEu5XQJpQ6gnWe4K3YF2LwlGMEQCIBh7wnM3mvtJuG0q7CGeW6HLir7Ixpo5jHc9xaCQ3XkLAiA7dZWP7VuWAHvyeZ79Z7CnuVEbSlZ0o8rKIVflNkdK5w==" }


Endpoint 2: Check E-Invoice Status


URL{{base_url}}/api/v2/einvoices/zatca/ask

HTTP MethodGET

Description:

This endpoint allows clients to check the status of the previously submitted e-invoice by generation request identified by {id}.

Query Parameter:

  • {invoices} (array): The unique identifier for the invoice generation request.

Response:

  • Status Code: 200 OK

  • Content Type: JSON

  • Body:  

id (integer): The unique identifier for the invoice generation request.

status (string): The current status of the request (e.g., "IN QUEUE", "IN PROCESSING", "COMPLETED").

qr_string (string): The QR code string associated with the generated invoice.

data (object): Zatca response, if available. It may vary based on the status of the invoice.

Sample Request


Sample response if the request is still in queue:

{     "id": 91,     "status": "IN QUEUE",     "qr_string": "AQZLdXphbWECDzMxMDE0NTQ1MzgwMDAwMwMTMjAyNC0wNC0wMVQxMTo1NToxNwQDMTU4BQUyMC42MQYsZXo5NzFYNzZuKzVZaHZZbzZVTS9xRVFBL0o1QXM1MzFLV0xLUy8zQndsdz0HYE1FVUNJUUMrTGNWK0NNdEVraExHSUlKRlY1Yi94Wk5QWTRkcWthUzduZDEvUUgzTEJnSWdGQS9ENTNxVUhLYTFQSVhwZGdpMHlSeFFxVmdjWFZYZi9NdjZSYmlINGpVPQhYMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE+R7mUm9nok7lfwb44GG0cW79nNxD0jVlNhiG04fN/ca/hsNOxw1u/7vjzNWFFSOqeEu5XQJpQ6gnWe4K3YF2LwlGMEQCIBh7wnM3mvtJuG0q7CGeW6HLir7Ixpo5jHc9xaCQ3XkLAiA7dZWP7VuWAHvyeZ79Z7CnuVEbSlZ0o8rKIVflNkdK5w==",     "data": null }

 

Sample response if the request processing has started but not finished:

{     "id": 91,     "status": "IN PROCESSING",     "qr_string": "AQZLdXphbWECDzMxMDE0NTQ1MzgwMDAwMwMTMjAyNC0wNC0wMVQxMTo1NToxNwQDMTU4BQUyMC42MQYsQm8xSzcrODN2Qkd6UkFEMkxueFBzeU5LZ1JkTnhoZit0NE5VUTB2cnZBWT0HYE1FUUNJR1h3UlMvNkk3aXNqajBmVWtYdTJxRi9QZnZGa21lU2FQTnVRL0trNzVUUUFpQTRQN0Y4VC9FT0lGSDVJRlVRZEVqS2RPa08yZDhmSVRKc0tiTUM0U1BZU1E9PQhYMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE+R7mUm9nok7lfwb44GG0cW79nNxD0jVlNhiG04fN/ca/hsNOxw1u/7vjzNWFFSOqeEu5XQJpQ6gnWe4K3YF2LwlGMEQCIBh7wnM3mvtJuG0q7CGeW6HLir7Ixpo5jHc9xaCQ3XkLAiA7dZWP7VuWAHvyeZ79Z7CnuVEbSlZ0o8rKIVflNkdK5w==",     "data": null }

 

Sample response if the request has been completed:

{     "id": 91,     "status": "COMPLETED",     "qr_string": "AQZLdXphbWECDzMxMDE0NTQ1MzgwMDAwMwMTMjAyNC0wNC0wMVQxMTo1NToxNwQDMTU4BQUyMC42MQYsQW9yVWlqUzB1NkFXcTFXSXA4Z3loa1ZRZUtidzNDNGcrTVdkNVRSY3R3QT0HYE1FVUNJRy9BVVlPNTR5YTdkUm1HSWxSQXpwbWo4bUowbWo3VXlWVWl4WTltTzdBd0FpRUFrVzllR2dOVnZHQnAxbHFUcEpKNHhJa3pqWjhOcndlUlp2Z0JnTG5Wd1VzPQhYMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE+R7mUm9nok7lfwb44GG0cW79nNxD0jVlNhiG04fN/ca/hsNOxw1u/7vjzNWFFSOqeEu5XQJpQ6gnWe4K3YF2LwlGMEQCIBh7wnM3mvtJuG0q7CGeW6HLir7Ixpo5jHc9xaCQ3XkLAiA7dZWP7VuWAHvyeZ79Z7CnuVEbSlZ0o8rKIVflNkdK5w==",     "data": {         "invoice_status": 200,         "result": {             "validationResults": {                 "infoMessages": [                     {                         "type": "INFO",                         "code": "XSD_ZATCA_VALID",                         "category": "XSD validation",                         "message": "Complied with UBL 2.1 standards in line with ZATCA specifications",                         "status": "PASS"                     }                 ],                 "warningMessages": [],                 "errorMessages": [],                 "status": "PASS"             },             "reportingStatus": "REPORTED"         },         "invoice_hash": "AorUijS0u6AWq1WIp8gyhkVQeKbw3C4g+MWd5TRctwA=",         "UUID": "d56870eb-16e8-4981-8ef3-7756c3b62a2c",         "reportingStatus": "REPORTED",         "qr_string": "AQZLdXphbWECDzMxMDE0NTQ1MzgwMDAwMwMTMjAyNC0wNC0wMVQxMTo1NToxNwQDMTU4BQUyMC42MQYsQW9yVWlqUzB1NkFXcTFXSXA4Z3loa1ZRZUtidzNDNGcrTVdkNVRSY3R3QT0HYE1FVUNJRy9BVVlPNTR5YTdkUm1HSWxSQXpwbWo4bUowbWo3VXlWVWl4WTltTzdBd0FpRUFrVzllR2dOVnZHQnAxbHFUcEpKNHhJa3pqWjhOcndlUlp2Z0JnTG5Wd1VzPQhYMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE+R7mUm9nok7lfwb44GG0cW79nNxD0jVlNhiG04fN/ca/hsNOxw1u/7vjzNWFFSOqeEu5XQJpQ6gnWe4K3YF2LwlGMEQCIBh7wnM3mvtJuG0q7CGeW6HLir7Ixpo5jHc9xaCQ3XkLAiA7dZWP7VuWAHvyeZ79Z7CnuVEbSlZ0o8rKIVflNkdK5w==",         "invoice_url": "https://e-invoice-dev.reachware.io/display-invoice/9bd1f542-adee-4433-8813-cfb1a1e85caa",         "completed_at": "2024-04-16T09:44:12.642771Z",         "invoice_id": 167103     } }


Webhook Data

The following Json sample shows what will be sent via webhooks to the receiving URLs.

Once the invoice is completed, the invoice response data will be sent out.

{     "id": 91,     "status": "COMPLETED",     "qr_string": "AQZLdXphbWECDzMxMDE0NTQ1MzgwMDAwMwMTMjAyNC0wNC0wMVQxMTo1NToxNwQDMTU4BQUyMC42MQYsQW9yVWlqUzB1NkFXcTFXSXA4Z3loa1ZRZUtidzNDNGcrTVdkNVRSY3R3QT0HYE1FVUNJRy9BVVlPNTR5YTdkUm1HSWxSQXpwbWo4bUowbWo3VXlWVWl4WTltTzdBd0FpRUFrVzllR2dOVnZHQnAxbHFUcEpKNHhJa3pqWjhOcndlUlp2Z0JnTG5Wd1VzPQhYMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE+R7mUm9nok7lfwb44GG0cW79nNxD0jVlNhiG04fN/ca/hsNOxw1u/7vjzNWFFSOqeEu5XQJpQ6gnWe4K3YF2LwlGMEQCIBh7wnM3mvtJuG0q7CGeW6HLir7Ixpo5jHc9xaCQ3XkLAiA7dZWP7VuWAHvyeZ79Z7CnuVEbSlZ0o8rKIVflNkdK5w==",     "data": {         "invoice_status": 200,         "result": {             "validationResults": {                 "infoMessages": [                     {                         "type": "INFO",                         "code": "XSD_ZATCA_VALID",                         "category": "XSD validation",                         "message": "Complied with UBL 2.1 standards in line with ZATCA specifications",                         "status": "PASS"                     }                 ],                 "warningMessages": [],                 "errorMessages": [],                 "status": "PASS"             },             "reportingStatus": "REPORTED"         },         "invoice_hash": "AorUijS0u6AWq1WIp8gyhkVQeKbw3C4g+MWd5TRctwA=",         "UUID": "d56870eb-16e8-4981-8ef3-7756c3b62a2c",         "reportingStatus": "REPORTED",         "qr_string": "AQZLdXphbWECDzMxMDE0NTQ1MzgwMDAwMwMTMjAyNC0wNC0wMVQxMTo1NToxNwQDMTU4BQUyMC42MQYsQW9yVWlqUzB1NkFXcTFXSXA4Z3loa1ZRZUtidzNDNGcrTVdkNVRSY3R3QT0HYE1FVUNJRy9BVVlPNTR5YTdkUm1HSWxSQXpwbWo4bUowbWo3VXlWVWl4WTltTzdBd0FpRUFrVzllR2dOVnZHQnAxbHFUcEpKNHhJa3pqWjhOcndlUlp2Z0JnTG5Wd1VzPQhYMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE+R7mUm9nok7lfwb44GG0cW79nNxD0jVlNhiG04fN/ca/hsNOxw1u/7vjzNWFFSOqeEu5XQJpQ6gnWe4K3YF2LwlGMEQCIBh7wnM3mvtJuG0q7CGeW6HLir7Ixpo5jHc9xaCQ3XkLAiA7dZWP7VuWAHvyeZ79Z7CnuVEbSlZ0o8rKIVflNkdK5w==",         "invoice_url": "https://e-invoice-dev.reachware.io/display-invoice/9bd1f542-adee-4433-8813-cfb1a1e85caa",         "completed_at": "2024-04-16T09:44:12.642771Z",         "invoice_id": 167103     } }




Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article