Generate Invoice
Create invoice to the system that can be sent to the client through email.
POST/esws/api/invoice/new
Notes
- All decimal type fields must have 2 decimal places as default (e.g. 1.00 instead of 1 to avoid errors)
- All calculation results must be rounded up to 2 decimal places.
- If the tax rate has a value of exactly 0.00, then invoice tax details will not be shown.
Generate Invoice

Generate Invoice Request Body

Request Samples
curl -X POST "http://test.ws.e-snapped.com/esws/api/invoice/new?s=true"
-H "accept: application/json"
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJBbHRQYXlOZXQgQ29ycCIsImlhdCI6MTU2NTIyOTM4OSwiZXNrIjoiSVNqYUVRTm9aWEpzenM4Z2lpciUyQmRBJTNEJTNELmVzRXFNd2g5Zk85a0xER0dMc2lraTJzUSUzRCUzRCIsImVzcCI6Ik56UTBOcWxUeks4cmxJblRxbGowWnclM0QlM0QuZXNpRTJkY2NFenE0OGxqNGZ1MGRvRmNRJTNEJTNEIiwiZXhwIjoxNTY1MjMxMTg5fQ.YImubUouh47RZvtEjRJN3g_8wpgSLUhzsrtr_wbV4fg"
-H "Content-Type: application/json"
-d "{
"accountFName": "Abel",
"accountLName": "Maclead",
"companyName": "AltPayNet Corp.",
"address1": "#88",
"address2": "5 Boston Ave",
"cityMunicipality": "Philadelphia",
"zip": 19132,
"stateProvince": "PA",
"countryCode": "US",
"email": "amaclead@domain.com",
"phone": "+63 2 123-4567",
"mobile": "+63 917 123-4567",
"items": [
{
"order": 1,
"item": "Sample item 1",
"quantity": 1,
"amount": 100.00,
"subTotal": 100.00
},
{
"order": 2,
"item": "Sample item 2",
"quantity": 1,
"amount": 1000.00,
"subTotal": 1000.00
}
],
"taxRate": 12,
"taxDue": 120,
"totalAmount": 1100,
"totalAmountDue": 1220,
"dueDate": "2020-01-01",
"currency": "USD",
"notes": "Testing this invoice.",
"timezone": "+0800",
"merchantReference": "INV-100001_TEST"
}"
{
"accountFName": "Abel",
"accountLName": "Maclead",
"companyName": "AltPayNet Corp.",
"address1": "#88",
"address2": "5 Boston Ave",
"cityMunicipality": "Philadelphia",
"zip": 19132,
"stateProvince": "PA",
"countryCode": "US",
"email": "amaclead@domain.com",
"phone": "+63 2 123-4567",
"mobile": "+63 917 123-4567",
"items": [
{
"order": 1,
"item": "Sample item 1",
"quantity": 1,
"amount": 100.00,
"subTotal": 100.00
},
{
"order": 2,
"item": "Sample item 2",
"quantity": 1,
"amount": 1000.00,
"subTotal": 1000.00
}
],
"taxRate": 12,
"taxDue": 120,
"totalAmount": 1100,
"totalAmountDue": 1220,
"dueDate": "2020-01-01",
"currency": "USD",
"notes": "Testing this invoice.",
"timezone": "+0800",
"merchantReference": "INV-100001_TEST"
}
var settings = {
"url": "{host}/esws/api/invoice/new?s=true",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization":"Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJBbHRQYXlOZXQgQ29ycCIsImlhdCI6MTU4MTA0NTkxNCwiZXNrIjoiVThnSGElMkJDTVdieFNRMVJ0WUEyZ0FkMmN4cEtPZW8lMkJMbXh5TEwxS3k1ZW8lM0QuZXNsbFdSQ3NEbk9UalM4TG9TbHMlMkJUUkElM0QlM0QiLCJlc3AiOiI1bjE3T0dGVlpnOW5RVW5TWTRGUXZRJTNEJTNELmVzRXRvT1JUVkNXSXl0JTJCN2pWamNYRnVnJTNEJTNEIiwiZXhwIjoxNTgxMDQ3NzE0fQ.yn6_ncSr1MckNsE3BkhsMW5r1muRJlfLdSOHBpYjjeo",
"Content-Type": "application/json"
},
"data": JSON.stringify({<payload here>}),
};
$.ajax(settings).done(function (response) {
console.log(response);
});
Responses
200 Successful Request

400 Result of missing/invalid URL parameter/s

401 Result of invalid authorization token. Token must not be null, not modified, and not expired.

422 Result of missing/invalid request body.

Response Samples
{
"code": "OK.06.00.011",
"message": "Invoice generated successfully.",
"timestamp": "2020-02-07 03:53:46.308",
"reference": "INV-000001_TEST"
}
{
"code": "ER.01",
"message": "HTTP Request Error",
"timestamp": "2020-02-07 03:55:06.741",
"errors": [
"Missing request header 'Authorization' of type String"
]
}
{
"code": "ER.02",
"message": "Authentication Error",
"timestamp": "2020-02-07 03:57:27.384",
"errors": [
"Invalid authorization token. Make sure that the token is valid and not altered/modified."
]
}
{
"code": "ER.04",
"message": "Validation Error",
"timestamp": "2020-02-07 03:58:48.769",
"errors": [
"accountFName: This field is required.",
"accountLName: Invalid field format. Must be composed of letters, spaces and dots only.",
"companyName: This field is required.",
"address1: This field is required.",
"address2: This field is required.",
"cityMunicipality: This field is required.",
"stateProvince: This field is required.",
"countryCode: This field is required.",
"zip: Invalid field format. Minimum of 7 and maximum of 19 characters is allowed.",
"totalAmount: This field is required.",
"email: Invalid field format. Must be formatted as local-part@domain.",
"mobile: Either this or phone field is required.",
"phone: Either this or mobile field is required",
"dueDate: This field is required.",
"currency: Invalid field format. Must be included in ISO 4217 codes.",
"taxRate: Invalid or missing field value. Field ‘taxDue’ is required.",
"taxDue: Invalid or missing field value. Field 'totalAmount', 'taxRate' is required and result must be calculated correctly.",
"totalAmountDue: Invalid or missing field value. Field 'totalAmount' is required and result must be calculated correctly.",
"totalAmount: Invalid or missing field value. Field ‘items’ is required and result must be calculated correctly.",
"timezone: Invalid field format. Must be formatted from -1100 to +1400.",
"items: This field is required.",
"items[0].order: Invalid field range. Must be between 0 to 999999999 only.",
"items[0].quantity: Invalid field range. Must be between 0 to 999999999 only.",
"items[0].amount: Invalid field value. Must be greater than 0.00",
"items[0].subTotal: Invalid or missing field value. Field ‘quantity’, ‘amount’ is required and must be calculated correctly.",
"merchantReference: Invalid field format. Must be composed of letters, numbers, dot, dashes and hashtags only."
]
}