FAQ

שאלות נפוצות בעניין מודול חשבוניות לישראל

How to start?

1. Register to the Tax Authority SandBox.
2. Create an App in the Sandbox.
3. USe this site to test your App.

Where are the Tax Authority Sandbox and Production?

Sandbox: https://openapi-portal.taxes.gov.il/sandbox
End points are at: https://openapi.taxes.gov.il/shaam/tsandbox
E.g: https://openapi.taxes.gov.il/shaam/tsandbox/longtimetoken/oauth2/authorize?response_type=code&client_id=b4fdcbc8307386180bd735305a2027ee&scope=scope

Production: https://openapi-portal.taxes.gov.il/shaam/production
End points are at: https://openapi.taxes.gov.il/shaam/production
E.g: https://openapi.taxes.gov.il/shaam/production/longtimetoken/oauth2/authorize?response_type=code&client_id=9c83a7320fecabd55319a63a82f34d7a&scope=scope

What is the flow to get an Allocation Number?

Get Authorization Code 🡆 Get Access Token 🡆 POST the invoice details and receive an Allocation Number.

The Access Token is valid for 10 minutes. So after 10 minutes:
Refresh Access Token 🡆 POST the invoice details and receive an Allocation Number.

The Refresh Token is valid for 1 month. So after 1 month:
Get new Authorization Code 🡆 Get a new Access Code 🡆 POST the invoice details and receive an Allocation Number.

When I try to get an Authorization Code I receive this error:
{"error":"unauthorized_client","error_description":"Invalid client ID or secret, or client not subscribed to this API"}

Either your client id, or secret are incorrect.
Or your redirect URI is incorrect. Note that it must match the URI you defined in the App (that you created in the Sandbox) and that it is CASE SENSITIVE.

When I try to get an Authorization Code I receive this error:
{"error":"invalid_request","error_description":"Redirect URI missing"}

Verify that you defined only ONE redirect URI for the app. Technically you can define more than
onr redirect uri. But if you do, you will get this error.

How can I identify the invoice or the client id that requested the Authorization Code?

In the GET request add a state parameter. It will be appended to the redirect call.
https://openapi.taxes.gov.il/shaam/tsandbox/longtimetoken/oauth2/authorize?response_type=code&client_id=6d2e5958492712a68a9a126377ca9ae1&scope=scope &state=123456%24%40!%26%5e%25%24
==>
https://localhost:44327/OpenAPI?code=847837487389478a66e &state=123456%24%40!%26%5e%25%24

When I try to get an Access Token I receive this error:
{"error":"invalid_request","error_description":"Missing authorization code"}

You did not send an Authorization Code.
For example, the body of the POST request is

grant_type=authorization_code&code=&redirect_uri=https%3a%2f%2flocalhost%3a44327%2fOpenAPI

Get an Authorization Code and try again.

When I try to get an Access Token I receive this error:
{"error":"invalid_request","error_description":"Redirect URI specified in the request is not configured in the client subscription"}

The App key and App secret are correct but the Redirect URI is incorrect.
Note that the Redirect URI is CASE SENSITIVE. Correct the URI here or in the App (in the "Sandbox") and try again.

When I try to get an Access Token I receive the following error:
{ "error": "invalid_grant", "error_description": "*[6d2e5958492712a68a9a126377ca9ae0] Failed to verify oauth request signature*" }

You sent an invalid Authorization Code.

When I try to get an Access Token I receive the following error:
{"error":"invalid_grant","error_description":"*[6d2e5958492712a68a9a126377ca9ae0] Authorization code was used before, message rejected*"}

The Authorization Code was used to get an Access Token. It can only be used once. Get a new Access Token and try again.

How does an Access Token response look like?

A valid token response looks as follows:

{"token_type":"Bearer","access_token":"AAIgNmQyZTU5NTg0OTI3MTJhNjhhOWExMjYzNzdjYTlhZTBwejkse8kay4psasYyhLcdChQSqErHZK6ONCFyQj5WiEWrAbx_FEG5xdXQ4qegBA2k-pNXZ6rpQpvCCk5hXZEljyLLxZ0OdHyig2w5BVDkVQ","scope":"scope","expires_in":601,"consented_on":1692529475,"refresh_token":"AAKnqps7fHqrG7GbzZqdgZz4kxPEC1LnUvZ5tPJ6bEBOxa8YnOjBD0uvz8qPvYreMaNjVNB67sAd166eIw2YuqrMQabVFdXNWvD8F_2ctNcKGw","refresh_token_expires_in":2592000}

What is a Refresh Token?

The Access Token is valid for only 10 minutes.
After 10 minutes you can either get a new Access Token (possibly you will need to login into the Sandbox),
or you can get a new Access Token via the Refresh Token:

POST /shaam/tsandbox/longtimetoken/oauth2/token Content-Type: application/x-www-form-urlencoded Host: openapi.taxes.gov.il Content-Length: 239 Expect: 100-continue Connection: Keep-Alive grant_type=refresh_token&client_id=6e2e5955692712a68a9ea22377ca9ae0&client_secret=79b2e2343bba7650e59a202d42ce98aff&refresh_token=AAKnqps2fHqrG7GbzAqdgZz4kxPEC1LnUvZ5tPJ6bEBOxa8YnOjBD0uvz8qPvYreMaNjVNB67sAd166eIw2YuqrMQabVFdXNWvD8F_2ctNcKGw

How does the Invoice JSON look like?

Here is a very simple example:

{"Invoice_ID":"1", "Invoice_Type": 305, "Vat_Number": 57508855, "Invoice_Date": "2023-08-27", "Invoice_Issuance_Date": "2023-08-27", "Accounting_Software_Number": 207703, "Amount_Before_Discount": 100, "Discount": 0, "Payment_Amount_Including_VAT": 117.00, "Payment_Amount": 117.00, "VAT_Amount": 17.00 }

Here is a more elaborate example:

{ "Invoice_ID":"987654321", "Invoice_Type":320, "Vat_Number":777777715, "Union_Vat_Number":125847553, "Invoice_Reference_Number":"975626515", "Customer_VAT_Number": 18, "Customer_Name":"שם הלקוח", "Invoice_Date":"2023-08-13", "Invoice_Issuance_Date":"2023-08-13", "Branch_ID":"533", "Accounting_Software_Number":36955574, "Client_Software_Key":"76857", "Amount_Before_Discount":543.75, "Discount": 1, "Payment_Amount":4456.23, "VAT_Amount": 129.78, "Payment_Amount_Including_VAT": 585.32, "Invoice_Note":"הערות", "Action":0, "Vehicle_License_Number":584752145, "Phone_Of_Driver":"0505674235", "Arrival_Date":"2023-02-26", "Estimated_Arrival_Time":"13:25", "Transition_Location":12, "Delivery_Address":"כתובת אספקה", "Additional_Information":0, "Items": [ { "Index":7446, "Catalog_ID":"5569875437", "Category":15, "Description": "תיאור הפריט", "Measure_Unit_Description":"קילו", "Quantity":100.5, "Price_Per_Unit":5.50, "Discount": 52.75, "Total_Amount": 500.00, "VAT_Rate": 17.00, "VAT_Amount":85 } ] }

How can I validate the Invoice JSON?

You can validate your JSON using https://www.jsonschemavalidator.net/.
Here is the schema file. Download it and copy the schema to the validator.

When I try to get an Allocation Number I get the following error:
{ "httpCode": "401", "httpMessage": "Unauthorized", "moreInformation": "Cannot pass the security checks that are required by the target API or operation, Enable debug headers for more details." }

You sent an invalid token. The token is sent in the request headers:
Authorization: Bearer AAIgNmQyZTU5NTg0OTI3MTJhNjhhOWExMjYzNzdjYTlhZTDslQtGLXNTRZw77kL0yeXpUu4c3d7QzX1mt2_vTIEQbyBmeGNyAb1f635ZwC41GLq9XqaIwS7-XLJ7eINW0phDLMUIZ008MC5zGbnr_Oo2CQ

When I try to get an Allocation Number I receive this error:
{ "Status": 500, "Message": "Internal Server Error", "Error_Id": "71989079303" }

If you are testing against the Sandbox:
You may have used an invalid VAT number.
Note that as of today (20-AUG-2023) you can only use the following VAT numbers for the "VAT_Number" field in the Sandbox:
777777715, 777777723, 777777731, 777777749

If you get the error when working with the Production system there is no way for you to know :-(
Send an e-mail with the error to invoices@taxes.gov.il and hopefully someone there will help you.

When I try to get an Allocation Number I receive this error:
{"Status":406,"Message":"Not Acceptable","Error_Id":"83189028997"}

You are not allowed to get an Allocation Number for the "Vat_Number" you sent.
Either you sent the wrong "Vat_Number" or the owner of this "Vat_Number" did not grant you the authrization in איזור אישי.

How does an Allocation Number response look like?

A valid Allocation Number response looks like this:
{ "Status": 200, "Message": "Invoice approved", "Confirmation_Number": "20230820112155830232010517" }

How does an Invoice validation error look like?

You either get a 422 error code. For example, here is a validation error in the "Items"/"Category" field. You will need to find the error using a schema validator:

{ "httpCode": "422", "httpMessage": "Unprocessable Entity", "moreInformation": "Validate: temporary:///swagger/shaam_tsandbox_invoices_v1.json:313: [JSV0009] Invalid number: 295656445 should be less than or equal to 999999." }
or you get a 400 error code with an "errors" field. For example: an error in the "Customer_VAT_Number" field:
{ "Status": 200, "Message": [ { "errors": [ { "code": 432, "message": "Customer VAT Number is incorrect", "param": "Customer_VAT_Number", "location": "validation" } ] } ], "Confirmation_Number": 0 }

Can I get a token using Implicit Grant?

Implicit Grant means that you send the following request:
. https://openapi.taxes.gov.il/shaam/tsandbox/longtimetoken/oauth2/authorize?response_type=token&client_id=b4fdcbc8307386180bd735305a2027ee&scope=scope
bypassing the user login stage. You can not do that. You wll get the following error:
Response status 400 { "error": "unsupported_response_type", "error_description": "Implicit grant not supported" }

Where is the manual Invoice Number Allocation site?

https://www.gov.il/he/service/request-assignment-number-for-tax-invoice

How can I receive the Authorization Code in desktop applications?

You can either:
Implement a Web Server in your application. Listen on some port and receive the authorization rediect there.
That is, if you listen on port 8888 then the redirect URI will be "http://localhost:8888"

Or you can implement a Web site (on a Web server not on the desktop) specifically to receive the Authorization Code and then display it to the user.
When there is a need to receive an Allocation Number (and there is no valid Access Token) you will open a Web browser from your desktop application,
and display your site.
The user will click a link with your App details and the redirect will be into your site.
Then the user will copy the Authorization Code into your desktop application. From there you will need to implement the ability to POST
requests to the open-api Sandbox in order to receive the Access Token.

Note that you will need to implement the POST ability anyway to receive the Allocation Number.

See an example here: https://demo.open-api.co.il/desktop

I am testing my application. I receive an Authorization Code but when I try to get an Access Token I receive the following error: {"error":"invalid_request","error_description":"Redirect URI specified in the request is not configured in the client subscription"}

Are you using a redirect URI containing localhost?
It looks like you ca not user a redirect URI containing local host in the production portal.

The VAT number (מספר עוסק מורשה) of the vendor starts with 0. How to send it?

If you try to send "Vat_Number": 011111115 you will receive an error since numbers starting with 0 are considered to be Octal.
Send it as "Vat_Number": 11111115

Do my users need to register to the Tax Authority Personal Area (איזור אישי)?

Yes, your user need to register to the Tax Authority Personal Area (איזור אישי).
When they try to get an Allocation Number they will need to identify themselves to the Tax Authority system,
which is done via the Tax Authority Personal Area.

What are Permissions (הרשאות) in the Personal Area (איזור אישי)?

The הרשאות in איזור אישי are there to allow one user to allow another user to get Allocation Number in his heahlf.
A typical example is a business owner who wants to allow one or more of his employees to issue invoices in his behalf.

אני מנהל שכיר בעמותה. העמותה מפיקה חש/קבלה לפעילות המסחרית שלה. מה אני צריך לעשות?

מאחר שהעמותה מפיקה חש/קבלה לפעילות המסחרית שלה, ובהנחה שבחש/קבלה אתה גובה מע"מ אז החובה לקבלת מספר הקצאה חלה גם על העמותה.
עליך לפנות לאחד הדירקטורים של העמותה ולבקש ממנו להרשם לאיזור האישי.
לאחר מכן עליו להקים את העמותה דרך כפתור "רישום/עדכון פרטי תאגיד"
בשלב הבא עליו ניתן להיכנס למערכת ההרשאות דרך כפתור "הרשאה לפעולות דיגיטליות" שנמצא באיזור האישי שלו. עליו לתת לך הרשאה לקבל מספרי הקצאה.
רשות המיסים תשלח לך הודעה שהתקבלה בקשת הרשאה.
היכנס לאיזור האישי שלך, ואשר את הבקשה.
הדירקטור יקבל הודעה שהבקשה שלו אושרה.
מעתה תוכל אתה לקבל מספר הקצאה דרך ההזדהות שלך במערכת של רשות המיסים.

הקצאת מספרי חשבוניות

מודול חשבוניות לישראל