How to use Postman to generate e-Tax Invoice & e-Receipt via Leceipt API?
If you want to create e-Tax Invoice & e-Receipt documents through your system. This guide will teach you how to create a simple etax document via Postman with sample code for easy understanding.
You can import the collection using the link below.
https://www.getpostman.com/collections/e42fe4deea6b7517f7ab
1. Generate API Key
This API key will be used to connect the API to the Leceipt system. The method for generating it is in the link below.
How to generate an API Key: https://www.leceipt.com/docs/etax/api-key
2. Provide information
Provide important information in order to create documents on Leceipt. You can see examples of information on Github
Customer
Structure
Parameters | Require | Type | Meaning |
---|---|---|---|
name | yes | string | Seller name |
buildingNumber | yes | string | Building Number |
address | yes | string | Address |
streetprefix | no | string | Street Prefix |
streetName | no | string | Street Name |
subDistrictPrefix | no | string | Sub-District Prefix |
subDistrictCode | yes | string | Sub-District Code |
districtPrefix | no | string | District Prefix |
districtCode | yes | string | District Code |
provincePrefix | no | string | Province Prefix |
provinceCode | yes | string | Province Code |
postcode | yes | string | Postcode |
branchNumber | yes | string | Branch Number |
taxNumberType | yes | string | Tax Number Type |
taxId | yes | string | Tax Id |
phone | no | string | Phone number |
no | string | ||
unstructure | yes | boolean | Specify “false” if it is a structure address. |
Example
{
"customer": {
"name": "Buyer Test Co.,LTD.",
"addressLineOne": "999 Moo 999 Sathorn Rd. 99",
"addressLineTwo": "Silom BanRak Bangkok",
"countryName": "Thailand",
"postcode": "10500",
"branchNumber": "00000",
"taxNumberType": "TXID",
"taxId": "1234567890123",
"phone": "0812345678",
"email": "test@test.com",
"unstructure": true
}
}
Unstructure
Parameters | Require | Type | Meaning |
---|---|---|---|
name | yes | string | Seller name |
addressLineOne | yes | string | Address Line One |
addressLineTwo | no | string | Address Line Two |
postcode | yes | string | Postcode |
countryName | no | string | Country |
branchNumber | yes | string | Branch Number |
taxNumberType | yes | string | Tax Number Type |
taxId | yes | string | Tax Id |
phone | no | string | Phone number |
no | string | ||
unstructure | no | string | Specify “true” if it is an unstructure address. |
Example
{
"customer": {
"name": "Buyer Test Co.,LTD.",
"buildingNumber": "99",
"address": "Moo 99",
"streetName": "Sathorn 99",
"branchNumber": "00000",
"subDistrictCode": "100402",
"districtCode": "1004",
"provinceCode": "10",
"postcode": "10500",
"taxNumberType": "TXID",
"taxId": "1234567890123",
"phone": "0812345678",
"email": "test@test.com",
"unstructure": false
}
}
items
This parameter is an Array. If the document contains multiple items or services, add an Object to this Array manually.
Parameters | Require | Type | Meaning |
---|---|---|---|
number | yes | number | Order of goods or services |
description | yes | string | Product or service details |
quantity | yes | number | Number of products |
unitName | no | string | Product unit |
price | yes | number | Price of goods or services |
discount | no | number | Product or service discounts |
percentVat | yes | number | The item’s tax percentage includes, if it’s a tax-exempt item, indicate -1, if it’s a 0% tax item, indicate 0, if it’s a 7% tax item, specify 7. |
Example
{
"items": [
{
"number": 1,
"description": "Food and beverage",
"quantity": 1,
"unitName": "EA",
"price": 1500,
"discount": 0,
"percentVat": 0
},
{
"number": 2,
"description": "Food and beverage",
"quantity": 1,
"unitName": "",
"price": 1000,
"discount": 0,
"percentVat": 7
}
]
}
refer
Refer here refers to the reference document. If no documents are issued in lieu of the original This section is not required to be filled out.
Parameters | Require | Type | Meaning | |
---|---|---|---|---|
number | yes | string |
|
|
dateBE | yes | string | Date, month, year (B.E.) the document was issued to refer to. | |
reasonCode | yes | string | Reason Code | |
specificReason | yes (ถ้า reasonCode เป็น TIVC99) | string | Other reason |
ตัวอย่าง
{
"refer": {
"number": "TIV20210300000",
"dateBE": "18/03/2564",
"reasonCode": "TIVC01"
}
}
data
Parameters | Require | Type | Meaning |
---|---|---|---|
number | yes | string | Receipt/Tax Invoice No. |
reference | no | string | เลขที่อ้างอิง |
dateBE | yes | string | วัน เดือน ปี (พ.ศ.) ที่ออกใบเสร็จรับเงิน/ใบกำกับภาษี |
includeVat | no | boolean | ราคาสินค้าหรือบริการรวม Vat แล้ว includeVat=true, ราคาสินค้าหรือบริการยังไม่รวม Vat includeVat=false (default) |
customer | yes | object | รายละเอียดผู้ซื้อสินค้าหรือบริการ |
items | yes | array | รายละเอียดสินค้าหรือบริการ |
language | no | string | ภาษา (ประกอบด้วย th (ภาษาไทย) (default) กับ en (ภาษาอังกฤษ) |
discount | no | number | ส่วนลดรวม |
note | no | string | หมายเหตุ ที่ต้องการแสดงในใบเสร็จรับเงิน/ใบกำกับภาษี |
receivedBy | no | string | ชื่อผู้รับเงิน |
reIssue | no | boolean | หากออกเอกสารแทนใบเดิม ให้ระบุเป็น true หากไม่ ให้ระบุเป็น false (default) |
refer | yes (ถ้า reIssue เป็น true) | object | เอกสารอ้างถึง |
ตัวอย่าง
{
"number": "TIV20210300001",
"dateBE": "23/03/2564",
"includeVat": false,
"items": [
{
"number": 1,
"description": "Food and beverage",
"quantity": 1,
"unitName": "EA",
"price": 1500,
"discount": 0,
"percentVat": 0
},
{
"number": 2,
"description": "Food and beverage",
"quantity": 1,
"unitName": "",
"price": 1000,
"discount": 0,
"percentVat": 7
}
],
"discount": 0,
"language": "th",
"customer": {
"name": "Buyer Test Co.,LTD.",
"buildingNumber": "99",
"address": "Moo 99",
"streetName": "Sathorn 99",
"branchNumber": "00000",
"subDistrictCode": "100402",
"districtCode": "1004",
"provinceCode": "10",
"postcode": "10500",
"taxNumberType": "TXID",
"taxId": "1234567890123",
"phone": "0812345678",
"email": "test@test.com",
"unstructure": false
},
"note": "Test Notes
",
"receivedBy": "Somchai",
"reIssue": true,
"refer": {
"number": "TIV20210300000",
"dateBE": "18/03/2564",
"reasonCode": "TIVC01"
},
"reference": ""
}
3. Send Request to Postman
Endpoint: https://api.leceipt.com/etax/documents/receipts-taxinvoices?api-version=2022-07-12
Method: Post
Copy the endpoint above and put it in the Postman, put the API-Key in the Headers and the data in step 2. Put it in the Body and select raw.
Example
Response:
Once the request has been submitted successfully, the Leceipt system will create a document. Deemed to be completed.
But if you want to download the pdf file, see the next step.
4. Save FileId for Download
Endpoint: https://api.leceipt.com/etax/jobs/{id}
Method: Get
Send a get request to the endpoint above with the id taken from the response in step 3.
Example
Put this id at the end of the endpoint (don’t put ” around the id).
Response:
When you get a response, use fileId in the next step.
5. Download PDF file
Endpoint: https://api.leceipt.com/etax/files/{fileId}/?api-version=2022-07-12
Method: Get
The fileId is taken from the response in clause 4.
Example
Example
Response: