Get Invoice

Get the e-Invoice details for any invoice present in ClearTax database using unique identifiers or concatenation of unique identifiers.

Request Method

GET

Request URL

{{BASE_URL}}/v2/einvoices/data

Replace the {{BASE_URL}} with the one mentioned here based on whether you are using sandbox or production.

Rate Limit : 1000 API requests per minute

Request Headers

ParametersData TypeField ValidationsDescription

x-cleartax-auth-token

String

Cannot be empty

Mandatory. User auth token.

vat

String

Cannot be empty

Mandatory. User auth token.

branch

String

Should be a valid branch from the user account.

Optional. Branch name (store name) added in the user account which maps to a VAT or Group VAT of the entity.

Request Path Params

There are no path parameters for this API.

Request Query Params

ParametersData TypeField ValidationsDescription

uniqueId

String

Should be present if 4 parameters are absent.

Conditional.Concat of seller vat + invoice id + invoice type code + issue date. All these entities are separated by underscore.

invoiceNumber

String

NA

Conditional. Document Number (Invoice Reference Number).

invoiceType

String

Enum: INV, CRN, DBN, RECEIPT

Conditional. INV - Invoice, CRN - Credit Note, DBN - Debit Note, RECEIPT - Receipt

issueDate

String

yyyy-mm-dd

Conditional. Document Date

vat

String

NA

Conditional. VAT Number.

Request Body

Sample Request

https://api-sandbox.cleartax.com/middle-east/ksa/einvoicing/v2/einvoices/data?invoiceNumber=A0108211%2F01&invoiceType=INV&vat=300459805100003&issueDate=2021-11-12

Response Status Codes

HTTP Status CodeDescription

200

For successful retrieval.

401

If the user is not authenticated for the operation.

403

If the user is not authorized for the operation.

429

Too many requests

5XX

Unhandled exception.

Response Schema

ParameterData TypeField ValidationsDescription

DeviceId

String

MaxLength: 36

Optional. Device ID used to generate invoices.

Status

String

Enum:GENERATED,NOT_GENERATED,GENERATION_FAILED, IN_PROGRESS

Mandatory. Status of E-Invoice QR Code. This is the same as QrCodeStatus below. Provided only for backward compatibility for Phase I API.

IN_PROGRESS, NOT_GENERATED, GENERATION_FAILED

QrCodeStatus

String

Enum: GENERATED, NOT_GENERATED, GENERATION_FAILED

Mandatory. Status of E-Invoice QR Code.

GENERATED, NOT_GENERATED, GENERATION_FAILED

InvoiceStatus

String

Enum: NOT_SUBMITTED, FAILED, NOT_REPORTED, REPORTED, CLEARED, NOT_CLEARED, ACCEPTED_WITH_WARNING, PENDING, DISCARDED

Mandatory. Status of submission to ZATCA.

NOT_SUBMITTED

QRCode

String

Optional. Rendered QR Code image in base64 encoded PNG format.

If clearance fails, this will be null.

RawQRCode

String

Optional. QR Code payload in base64 encoded TLV format.

For reporting, this will be generated by ClearTax. Except when complete XML is generated by ERP and sent in the input.

For clearance, this will be generated by ZATCA. If clearance fails, this will be null.

InvoiceXml

String

Optional. In the case of Standard invoices, the XML is returned by ZATCA.

In the case of Simplified invoices, it is the XML used for reporting.

UUID

String

Optional. UUID sent to ZATCA

ClearTax generates this before sending to ZATCA, if not sent in input.

ICV

String

Optional. Invoice counter value sent to ZATCA ClearTax generates this before sending it to ZATCA.

PIH

String

Optional. Previous hash value, Invoice hash value of previous invoice reported/cleared for same deviceId.

InvoiceHash

String

Optional. Current invoice hash.

Hash value of current invoice xml by removing tags ext:UBLExtensions, cac:AdditionalDocumentReference:QRCode

InvoiceType

String

Enum: INV, CRN, DBN

Mandatory.

Document Type: INV-INVOICE, CRN-CREDIT NOTE, DBN-DEBIT NOTE.

InvoiceNumber

String

Cannot be null

Mandatory. Invoice number (ID) as per the input.

IssueDate

String

Cannot be null

Mandatory. Issue Date as per the input.

IssueTime

String

Format: HH:mm:ss (24 hr format)

Mandatory. Invoice issue time. The time when the invoice was issued.

GeneratedDate

String

Cannot be null

Mandatory. Date on which the invoice is generated.

GeneratedTime

String

Format: HH:mm:ss (24 hr format)

Mandatory. Invoice generation time. The time when the invoice is generated.

SellerVatNumber

String

Cannot be null

Mandatory. Seller VAT identification number.

BuyerVatNumber

String

Cannot be null

Optional. Buyer VAT identification number.

ErrorList

Array<Error Detail>

Error details from zatca

Optional.Error list from zatca (6.8.1)

Message

String

NA

Optional.Message received from zatca

Error Details Object

ParametersData TypeField ValidationsDescription

ErrorCode

String

Cannot be null

A code to identify the error. Error codes are published above.

ErrorMessage

String

Cannot be null

Human readable error message.

ErrorSource

String

ZATCA, CLEARTAX

Source of the error.

Path

String

-

If it is a validation error of a request data, it will point to the request data field. Example below.

Sample Response

Success for Simplified Document - HTTP Status Code - 200

{
    "DeviceId": "625410e387173015f7e5a4c6",
    "Status": "GENERATED",
    "QrCodeStatus": "GENERATED",
    "InvoiceStatus": "REPORTED",
    "QRCode": "MjAsSIy1….",
    "RawQRCode": "ARlBb….",
    "InvoiceXml": "ASsdfkf...",
    "UUID": "03779160-c140-4a32-9f9a-7b429149c0ef",
    "ICV": "61",
    "PIH": "KILyvZqPxblzStkif5UsaEtMhLDZUgU/VudKsBFxQN0=",
    "InvoiceHash": "HDlSmFWBE+9LHLrg6X0moqr3fQU677tFbrITarslOZI=",
    "InvoiceType": "INV",
    "InvoiceNumber": "315",
    "IssueDate": "2021-04-25",
    "IssueTime": "13:26:45",
    "GeneratedDate": "2022-10-23",
    "GeneratedTime": "12:26:45",
    "SellerVatNumber": "300492946900003",
    "BuyerVatNumber": null,
    "ErrorList": [],
    "WarningList":[],
    "Message": null
}

Success for Standard Document - HTTP Status Code - 200

{
    "DeviceId": "625410e387173015f7e5a4c6",
    "Status": "GENERATED",
    "QrCodeStatus": "GENERATED",
    "InvoiceStatus": "CLEARED",
    "QRCode": "iBU5ul8ZaHcbmWYy3zL.....",
    "RawQRCode": "ARlBbCBTYWxhbSBTdXB.......",
    "InvoiceXml": "PD94PC....",
    "UUID": "ed7d6a63-e650-425d-b1eb-f54187a0ccca",
    "ICV": "62",
    "PIH": "HDlSmFWBE+9LHLrg6X0moqr3fQU677tFbrITarslOZI=",
    "InvoiceHash": "u+zU7f/JDKpjoKrNUMF5Z3Kho3cqb1VUoNSCIphyZu8=",
    "InvoiceType": "INV",
    "InvoiceNumber": "130",
    "IssueDate": "2021-04-25",
    "IssueTime": "13:26:45",
    "GeneratedDate": "2022-10-23",
    "GeneratedTime": "12:26:45",
    "SellerVatNumber": "300492946900003",
    "BuyerVatNumber": null,
    "ErrorList":[],
    "WarningList": [],
    "Message": null
}

Success with Warning - HTTP Status Code - 200

{
    "DeviceId": "625410e387173015f7e5a4c6",
    "Status": "GENERATED",
    "QrCodeStatus": "GENERATED",
    "InvoiceStatus": "ACCEPTED_WITH_WARNING",
    "QRCode": "i+GdAUnzMJS.....",
    "RawQRCode": "ARlBbCBTYWxhbSBTdXBwbGllcyBDby4g.....",
    "InvoiceXml": "ASsdfkf...",
    "UUID": "03779160-c140-4a32-9f9a-7b429149c0ef",
    "ICV": "61",
    "PIH": "KILyvZqPxblzStkif5UsaEtMhLDZUgU/VudKsBFxQN0=",
    "InvoiceHash": "HDlSmFWBE+9LHLrg6X0moqr3fQU677tFbrITarslOZI=",
    "InvoiceType": "INV",
    "InvoiceNumber": "315",
    "IssueDate": "2021-04-25",
    "IssueTime": "13:26:45",
    "GeneratedDate": "2022-10-23",
    "GeneratedTime": "12:26:45",
    "SellerVatNumber": "300492946900003",
    "BuyerVatNumber": null,
    "ErrorList": [],
    "WarningList": [
        {
            "ErrorCode": "BR-KSA-09",
            "ErrorMessage": "Seller address must contain additional number (KSA-23), street name (BT-35), building number (KSA-17), postal code (BT-38), city (BT-37), Neighborhood (KSA-3), country code (BT-40). \n  For more information please access this link: https://www.address.gov.sa/en/address-format/overview",
            "ErrorSource": "ZATCA"
        }
    ],
   "Message": null
}

Error from ClearTax - HTTP Status Code - 400

{
    "InvoiceType": "INV",
    "InvoiceNumber": "2022",
    "IssueDate": "2021-04-25",
    "IssueTime": "14:34:45",
    "SellerVatNumber": "300492946900003",
    "Status": "GENERATION_FAILED",
    "QrCodeStatus": "GENERATION_FAILED",
    "InvoiceStatus": "FAILED",
    "ErrorList": [
        {
            "ErrorCode": "6002",
            "ErrorMessage": "If Supplier Group Vat number is provided, scheme id must be HQ",
            "ErrorSource": "CLEARTAX",
            "Path": "EInvoice.AccountingSupplierParty.Party.PartyIdentification.ID.schemeID"
        },
        {
            "ErrorCode": "6002",
            "ErrorMessage": "Payment means code in an invoice must contain one of the values (10, 30, 42, 48, 1). In the simplified tax invoice and associated credit notes and debit notes this value is optional.",
            "ErrorSource": "CLEARTAX",
            "Path": "EInvoice.PaymentMeans.PaymentMeansCode"
        }
    ],
}

Error from ZATCA - HTTP Status Code - 200 (Sample Simplified invoice where QR code is generated by ClearTax and then sent to ZATCA for reporting which is not approved by ZATCA).

Note: In case a document is validated by ClearTax but failed at ZATCA, then the HTTP Status Code will be 200 and not 400.

{
    "DeviceId": "625410e387173015f7e5a4c6",
    "Status": "GENERATED",
    "QrCodeStatus": "GENERATED",
    "InvoiceStatus": "NOT_REPORTED",
    "QRCode": "i+GdAUnzMJS.....",
    "RawQRCode": "ARlBbCBTYWxhbSBTdXBwbGllcyBDby4g.....",
    "InvoiceXml": null,
    "UUID": "03779160-c140-4a32-9f9a-7b429149c0ef",
    "ICV": "61",
    "PIH": "KILyvZqPxblzStkif5UsaEtMhLDZUgU/VudKsBFxQN0=",
    "InvoiceHash": "HDlSmFWBE+9LHLrg6X0moqr3fQU677tFbrITarslOZI=",
    "InvoiceType": "INV",
    "InvoiceNumber": "315",
    "IssueDate": "2021-04-25",
    "IssueTime": "13:43:34",
    "SellerVatNumber": "300492946900003",
    "BuyerVatNumber": null,
    "ErrorList": [
        {
            "ErrorCode": "Invalid-Invoice-Hash",
            "ErrorMessage": "The provided invoice hash is invalid",
            "ErrorSource": "ZATCA"
        }
    ],
    "WarningList": [],
    "Message": null
}

Error from ZATCA - Sample Standard invoice with multiple errors which is not approved by Zatca and hence the InvoiceStatus will be "NOT_CLEARED" and QrCodeStatus will be "NOT_GENERATED".

{
    "DeviceId": "09569f97-dd87-4b50-b226-a644b0cb0ab8",
    "Status": "NOT_GENERATED",
    "QrCodeStatus": "NOT_GENERATED",
    "InvoiceStatus": "NOT_CLEARED",
    "QRCode": null,
    "RawQRCode": null,
    "InvoiceXml": null,
    "UUID": "e6791446-844d-4fd1-b4d3-1ae2d111abf8",
    "ICV": "36",
    "PIH": "a+ae0fY+MBboXiFPkZicCIF8ceL2sEnU/fBeQpWEPP4=",
    "InvoiceHash": "+EYiXktJtVeAEqitiJBxNGlO9Hm29/r8l21Z8LGTbCQ=",
    "InvoiceType": "INV",
    "InvoiceNumber": "S-INV-0004",
    "IssueDate": "2022-06-23",
    "IssueTime": "13:43:34",
    "SellerVatNumber": "300492946900003",
    "BuyerVatNumber": "300526201800003",
    "ErrorList": [
        {
            "ErrorCode": "BR-CO-15",
            "ErrorMessage": "Invoice total amount with VAT (BT-112) ",
            "ErrorSource": "ZATCA"
        },
        {
            "ErrorCode": "BR-DEC-20",
            "ErrorMessage": "The allowed maximum number of decimals for the VAT category tax amount (BT-117) is 2.",
            "ErrorSource": "ZATCA"
        },
        {
            "ErrorCode": "BR-DEC-13",
            "ErrorMessage": "The allowed maximum number of decimals for the Invoice total VAT amount (BT-110) is 2.-BR-DEC-15",
            "ErrorSource": "ZATCA"
        },
        {
            "ErrorCode": "BR-DEC-14",
            "ErrorMessage": "The allowed maximum number of decimals for the Invoice total amount with VAT (BT-112) is 2.",
            "ErrorSource": "ZATCA"
        },
        {
            "ErrorCode": "BR-CO-14",
            "ErrorMessage": "Invoice total VAT amount (BT-110) ",
            "ErrorSource": "ZATCA"
        },
        {
            "ErrorCode": "BR-DEC-18",
            "ErrorMessage": "The allowed maximum number of decimals for the Amount due for payment (BT-115) is 2.",
            "ErrorSource": "ZATCA"
        }
    ],
    "WarningList": [],
    "Message": null
}

API Validations

  1. The uniqueIdentifier passed in request params should be valid and must be present in ClearTax datastore.

  2. 4 fields passed should belong to the user.

API Constraints

  1. This API needs to be authenticated with a valid user authentication token. If the auth token is not present or is invalid, the API will return HTTP Status Code 401.

  2. Each customer is allowed to send a limited number of requests per minute to prevent server overload. If the limit is exceeded, the server will respond with a 429 Too Many Requests status code.

  3. Taxpayers can request details of only one invoice per request.

  4. The API will only return details of those invoices present in the ClearTax data store.

Last updated