EZcount Document Creation API

Index

EZcount Document Creation API

API Version: 1.3.8

📌 Note: Required fields are marked with blue color or Required badge

Introduction

General Information

  • EZcount API is a REST API that works for both POST and JSON requests
    • JSON requests must be sent with application/json header (recommended)
    • POST requests can be sent as normal POST
  • The API has a demo environment – please register freely and get your API key
  • API connection must be established through SSL (port 443)
  • Make sure your connection timeout settings are above 30 seconds. Generally responses return in several milliseconds, but when the server is busy it might take several seconds

⚠️ IMPORTANT:

  • The API is asynchronous – we create the document AFTER you get the response. If you wish to automatically download documents, it’s advised to wait at least 5 minutes to ensure all background processes have finished
  • The API has a rate limit of 1,500 requests/minute. If you’re doing batch document creation, please take this into consideration
  • If you pass 4,000 requests/minute, you might hit our firewall DOS mitigation rate limiter and will be blocked for 1 minute
💡 NOTE: We made the API very easy for you to use, so you’ll be able to create documents with minimum effort. There are only a few fields which are mandatory, colored with this blue color.

API Domains

  • demo.ezcount.co.il – used for testing
  • api.ezcount.co.il – used for production
⚠️ Warning: The API key is different between domains, so you’ll have to get a new one when going to production.

Requirements

  1. Fully setup account with digital signature in EZcount.co.il / demo
  2. API key from the system settings → API menu

Testing API Key

To acquire an API key for testing, you may register (for free, forever) to demo.ezcount.co.il and get an API key and customize your account.

If you want quick and dirty, and you don’t care about the UI/look of the invoices during development, you may use the following testing API key:

f1c85d16fc1acd369a93f0489f4615d93371632d97a9b0a197de6d4dc0da51bf

Code Samples (SDKs)

We’ve built SDKs to make your life much easier. You can now connect with simple copy-paste from the SDK demo.

You may download the SDKs from the following links:

  • C#.NET
  • VB.NET
  • PHP
  • JAVA
  • ASP
  • Python
  • Ruby
  • Node.js

Creating a New Document

POST https://[api domain]/api/createDoc

Base Document Parameters

Requirement Notation:

  • V – always required
  • !R – required in all documents except receipt
  • ?R – optional in all documents except receipt
API Key Value Type Req Comment
api_key sha256 V Your API key
api_email email V Your valid email
developer_email email V The developer email, we use it to contact the developer/contact person in case of any API problems/updates
type numeric V Document types:
100 – Order (הזמנה)
200 – Delivery (תעודת משלוח)
210 – Return (תעודת החזרה)
300 – Proforma Invoice (חשבונית עסקה)
305 – Tax Invoice (חשבונית מס)
320 – Invoice Receipt (חשבונית מס קבלה)
330 – Credit Invoice (חשבונית זיכוי)
400 – Receipt (קבלה)
405 – Receipt for donation (קבלה על תרומה)
500 – Purchase order (הזמנת רכש)
9999 – Bid (הצעת מחיר)
9998 – Deposit Approval (קבלת פקדון)
9997 – Deposit Release (קבלת פקדון)
transaction_id string/number/uuid Recommended VERY Recommended! A system-wide unique identifier that indicates this doc creation. Will help you to mark the document with your own unique ID. Default is document UUID given by the system.
If you send the same transaction_id again, we will not create a new doc and instead will give you link to the original doc
parent string Optional Parent doc UUID (in case you want to link between 2 documents)
date date (dd/mm/yyyy) Optional Document date, current date will be applied if not set
lang string Optional ‘he’ for Hebrew doc (this is default)
‘en’ for English
Note: According to the Israeli IRS, the original doc must be in ILS and in Hebrew
main_currency_iso string Optional Default ‘ILS’. 3 letters of currency ISO (‘USD’/’EUR’/’GBP’ etc…)
main_currency_rate number Optional Default 1 (ILS). If you don’t send this field, the system will calculate the currency based on our rate tables. If your currency ISO doesn’t exist in our system, the rate will be mandatory
create_org_as_foreign boolean 0/1 Optional Default 0. Use when you have permission to create original documents in English or foreign currency. Israelis can’t create original documents in English or not in ILS, so we create a copy and send a translated copy to the customer
description string Optional Document description
customer_name string V Customer name
customer_email string Required* Required when dont_send_email is not 1
customer_crn numeric Optional The customer company number/ID (ח.פ. בעברית). Required by law when document value is greater than 5,000 ILS
customer_address string Optional Customer address
customer_phone string Optional Customer phone
item array !R Please refer to item table described below for more details
price_discount numeric (negative) ?R The discount in currency, the discount must be given in negative value
vat float (positive) ?R The document VAT, if not supplied the current VAT will be used
price_total float (positive) ! Mandatory in invoice_receipt, should contain the actual total payments. Can be used for adding discount as total, or validating the data. I.e. if the total is 110, and you set this field as 100, we will recalculate the price so total will be 100 and move the remaining to VAT and discount fields
tax_deduction float (positive) Optional Amount of tax deduction. Should be positive number in currency (not in percent). Relevant only in documents with payments (receipts/invoice receipt etc…)
pay_until date (dd/mm/yyyy) Optional When this document should been paid
comment text Optional Comment inside the document
email_text text Optional Email additional text
dont_send_email boolean 0/1 Optional Default 0. When set, the system will not send email to the client and will only create a document
send_copy boolean 0/1 ? Send copy of the document to the owner of the document. The default value can be controlled from system settings
print_type const (‘PDF’,’PRINTER’) Optional ‘PDF’ by default. If you want this document to be printed only and not created as a PDF or sent by email, use ‘PRINTER’. You will NOT get any links as response, and your client would have to manually login into the system and click on “print” to print this document
forceItemsIntoNonItemsDocument Boolean 0/1 Optional If you want to create a document where the items are not mandatory (like receipt/donation etc…), please add this field in addition to the items array
auto_balance Boolean 0/1 Optional In case you are having items & payments, but there is mismatch between them, we will add discount to overcome it. For example: if the total payments is 1.9 and the total items is 2, we will add a discount of 0.1 to the items. And if the total payments is 2 and the total items is 1.9, then we will have a negative discount (extra charge) of 0.1 to the items

📦 Create Document – Add Item

item must be an array of items. For example, if we want to send 2 items, we will send the following array as JSON:

{
  "item": [
    {
      "catalog_number": "MKT1",
      "details": "1 kg of Internet",
      "amount": 1,
      "price": 12.44
    },
    {
      "details": "infinite amount of love",
      "amount": 1,
      "price": 99,
      "vat_type": "INC"
    }
  ]
}
API Key Value Type Required Comment
catalog_number String Optional May be a numeric as well
details String V Item description
amount Float V Item quantity
price Float V Item price will be rounded to 2 decimal places:
1.454 → 1.45
1.455 → 1.46
1.456 → 1.46
currency String Optional ‘ILS’ is the default
Note: use main_currency_iso instead of this field, it will make your life much easier. This field is good only when you have multiple currencies…
currency_rate Float Optional Currency rate relative to Israeli Shekel. Will be rounded to 4 decimal places. Used only when main_currency_iso is ILS
vat_type String (PRE/INC/NON) Optional PRE – default (Price is before VAT)
INC – Price included VAT
NON – The document is a mixed document, and this item is a Non VAT item. Please use it only in mixed VAT documents, while in zero VAT documents just send “VAT 0”
comment String Optional Open text field, used to add extra data regarding the item
discount_price Float Optional If you want to give a discount specific on this line and not on the document, set here a number
discount_type String (PERCENTAGE, NUMBER) Optional PERCENTAGE – discount_price must be a number between 1 to 100
NUMBER – discount_price can be any number between 0 to the sum value of the field

Create Document – Add Payment

Must be an array of payment with the following values as JSON:

{
  "payment": [
    {
      "payment_type": "1",
      "date": "10/10/2010",
      "payment": 250
    },
    {
      "payment_type": 3,
      "date": "10/10/2010",
      "payment": 250,
      "cc_type": 0,
      "cc_type_name": "ויזה"
    }
  ]
}

!PT[n] – required for payment type n. For example, a field which is required for checks will be marked as !PT2 because checks is payment type 2

API Key Value Type Required Comment
payment_type integer V The type of the payment:
1 – cash
2 – check
3 – credit card
4 – bank transfer
9 – Other
91 – Paypal
date date (dd/mm/yyyy) V The date of the payment, can be different from the document date
payment_sum decimal V The actual payment sum
currency String Optional ‘ILS’ is the default
currency_rate Float Optional Currency rate relative to Israeli Shekel, default is ‘1’
checks_bank_account any Optional Bank account number
checks_bank_branch any Optional Bank branch
checks_bank_name any !PT2 Bank name (required for checks)
checks_number any !PT2 Check number (required for checks)
bt_bank_account any !PT4 Bank transfer – bank account
bt_bank_branch any !PT4 Bank transfer – bank branch
bt_bank_name any !PT4 Bank transfer – bank name
cc_type integer !PT3 0 – not in this list
1 – ישראכרט (Isracart)
2 – ויזה (Visa)
3 – דיינרס (Diners)
4 – אמריקן אקספרס (American express)
6 – לאומי קארד (Leumi card)
99 – מאסטרקארד (Mastercard)
cc_type_name string !PT3 The name of the credit card
cc_number numeric !PT3 Last 4 digits
cc_deal_type integer !PT3 1 – רגיל (Normal)
2 – תשלומים (Payments)
3 – קרדיט (Credit)
4 – חיוב נדחה (Delayed)
5 – אחר (other)
cc_num_of_payments integer !PT3 How many payment total for this CC
auto_calc_payments Boolean (0/1) Optional Wizard: If you send this parameter you won’t need to set line for each payment, and we will calculate the payments and the future dates for you.
Note: When calculating the payments:

  • Dates are calculated this way: if the payment is on 31.12.2017, the next date will be 28.01.2018… So we calculate month as 28 days
  • The total sum will be divided by total payments. If the total sum is 4 and we have 9 payments: 4/9=0.44, but 0.44*9=3.96, so we add 4 cents to the first payment (0.48) and the rest are 0.44
cc_payment_num integer !PT3 This is payment N / payments. If not supplied or set to 0 you will get תשלומים: cc_num_of_payments instead of תשלום cc_payment_num / cc_num_of_payments
wt_transaction_id string Optional Paypal transaction id
wt_payer_account string Optional Paypal payer account id
other_payment_type_name String Optional Payment of type other – name

Document Creation API Response

API response will be a JSON string

On Error:

The API will return error number and related message, for example:

{
  "errNum": 1,
  "errMsg": "api key is malformatted"
}

On Success:

{
  "pdf_link": "https://demo.ezcount.co.il/front/documents/get/0f2a3f82-afe0-41e9-8235-adb5f17bdfb6",
  "pdf_link_copy": "https://demo.ezcount.co.il/front/documents/get/0f2a3f82-afe0-41e9-8235-adb5f17bdfb6/copy",
  "doc_number": "60002",
  "doc_uuid": "0f2a3f82-afe0-41e9-8235-adb5f17bdfb6",
  "sent_mails": [
    "demo@example.com"
  ],
  "success": true
}
  • pdf_link – link to the origin document, this link been sent to client if ordered to
  • pdf_link_copy – the copy document (העתק נאמן למקור)
  • doc_number – the document number
  • doc_uuid – each document in the system has a unique ID
  • sent_mails – the emails this document has been sent to

Moving to Production

In order to move to production:

  1. Create an account in production and fetch the api_key for this account
  2. If you are sending docs on behalf of other EZcount accounts which are not you, please add a dev_master_key field and set there your account api_key
  3. Set your requests to https://api.ezcount.co.il/api/createDoc...
⚠️ Important: Please make sure your timeout settings are set correctly on your production environment. Please set your timeout to be at least 30 seconds.

Debugging Tools

In order to debug your code we’ve built some quick tools:

  1. Use https://demo.ezcount.co.il to create some documents from the UI. Our UI uses the API, so you will understand easily and more intuitively the API’s full features
  2. Check how the server sees your request:
    1. When you are sending a request, add the debug_key parameter with any value you wish to the request URL:
      https://demo.ezcount.co.il/api/createDoc?debug_key=A1B2C3
    2. After the request been sent, go to:
      https://demo.ezcount.co.il/api/getLastAPIRequestData?debug_key=A1B2C3&api_key=[your api key]&developer_email=your_email@demo.com
      Here you will get a dump of what the server received:

      • POST – the POST array
      • RAWDATA – the RAW data (used mainly when you send a JSON request)
      • REQUEST_HEADERS – the request headers as the server sees them

Advanced API Methods

The methods described here are more advanced and are not part of our code samples and SDKs, but we do maintain them.

Creating Doc on Behalf of Non-Owner Account

How to Use It:

It is possible to create a document on behalf of one of the accounts of the company (in case you have multiple businesses under the same user ID)

  1. Create another business and set the invoice details for this business
  2. Now go to this address:
    https://[demo\www].ezcount.co.il/backoffice/accounts?show_hidden_fields=1
  3. You will see a unique identifier (UUID) next to each of the accounts
  4. Add the ua_uuid field to the invoice creation and set the value to be the UUID of the account you want to create on behalf of (XXXX-XXXX-XXXX-XXXXXXXX)
  5. Now the invoice will be created with the details of that user

Common Errors:

  1. Calling the API with wrong credentials:
    The account UUIDs in the demo are different from the accounts in production. Please make sure you have separation between the environments.

 

No data was found