Function to create a new invoice
https://rest.crmango.com/api/CreateNewInvoice
Bearer
varchar
Auth token
name
varchar
Invoice name
inv_type
varchar
Invoice type ("issued", "received")
subtype
varchar
Invoice subtype ("regular","proforma", "credit_note")
created_at
timestamp
Created date ("Y-m-d H:i:s")
status_id
integer
Invoice status
0 - Created
1 - Fully paid
2 - Completely credited
3 - Partially paid
4 - Paid
5 - Cancelled
var_symbol
varchar
Variable symbol. If left empty, Mango will generate it automatically.
invoice_due
timestamp
Due date. If left empty, Mango will generate it automatically.
taxable_date
timestamp
Taxable date. If left empty, Mango will generate it automatically.
note
varchar
Note - header of the invoice
note_after
varchar
Note under the products.
paid
integer|float
Already paid
notif
integer
Notification level
0 - Off
1 - Notification to creator
2 - Notification to user
3 - Notification to creator & user
is_ord_name
varchar
Generated invoice code. If left empty, Mango will generate it automatically.
supplier_invoice_code
varchar
Original invoice code from supplier - only for received invoices
invoice_receipt_date
date
Receipt date - only for received invoices (Y-m-d)
exchange_rate
decimal
Currency exchange rate DECIMAL (15.4). If left empty, Mango will generate it automatically
fully_paid_date
date
Date when invoice was fully paid (Y-m-d). Only if the invoice is fully paid.
lang
varchar
Language (sk, cz, en, es, de, pl, hu)
accounting_center
varchar
Accounting center code
multiple_orders
array
Related orders
bank_data
array
Bank info array with keys:
bank_iban,
bank_note,
swift_bic,
bank_account,
bank_connection.
If left empty, Mango will generate it automatically by the supplier or purchaser - depend by the invoice type.
Can be inserted numeric index for chose one bank. 0 means first bank connection, 1 means second etc.
products[][name]
varchar
Product name
products[][product_description]
varchar
Product description
products[][quantity]
integer
Quantity
products[][price]
integer|float
Quantity
products[][vat]
integer
VAT
products[][discount]
integer
Discount %
Function to create a new invoice
code
integer
Return code
message
varchar
Info message
created_id
integer
Id of the created resource
curl --request POST \
--url 'https://rest.crmango.com/api/CreateNewInvoice' \
--header 'Authorization: Bearer auth_token' \
--header 'Content-Type: application/json' \
--data '{
{
"data": {
"name": "Invoice for services",
"inv_type": "issued",
"subtype": "",
"rad_code": "FV",
"supplier_id": 123,
"purchaser_fa_id": 456,
"created_at": "2025-07-25 13:00:00",
"currency_id": 202,
"status_id": 0,
"user_id": 2,
"created_by": 1,
"active_service_id": 3,
"var_symbol": "F20251232025",
"invoice_due": "2025-08-10",
"taxable_date": "2025-07-25",
"note": "This invoice includes service fees",
"note_after": "Thank you for your business.",
"paid": 100,
"visual_id": 0,
"notif": 1,
"is_tax_document": 1,
"is_ord_name": "F2025-001",
"supplier_invoice_code": "SUP20250725",
"invoice_receipt_date": "2025-07-25",
"exchange_rate": 1.0,
"fully_paid_date": "2025-07-26",
"transporter_id": 0,
"vehicle_id": 0,
"trailer_id": 0,
"driver1_id": 0,
"driver2_id": 0,
"lang": "en",
"accounting_center": "AC01",
"multiple_orders": ["10","15","245"],
"bank_data": [
{
"bank_iban": "SK6802000000000000000000",
"bank_note": "Payment for invoice",
"swift_bic": "SUBASKBX",
"bank_account": "2000000000",
"bank_connection": "FIO"
}
],
"products": [
{
"product_id": 101,
"product_code": "PRD001",
"name": "Consulting services",
"quantity": 2,
"price": 150.0,
"cost_price": 100.0,
"vat": 20,
"discount": 0,
"measurement_unit_id": 1,
"measurement_unit_code": "h"
},
{
"product_id": 102,
"product_code": "PRD002",
"name": "Cloud license",
"quantity": 5,
"price": 50.0,
"cost_price": 30.0,
"vat": 20,
"discount": 5,
"measurement_unit_id": 2,
"measurement_unit_code": "pcs"
}
]
}
}
}'
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://rest.crmango.com/api/CreateNewInvoice',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{
{
"data": {
"name": "Invoice for services",
"inv_type": "issued",
"subtype": "",
"rad_code": "FV",
"supplier_id": 123,
"purchaser_fa_id": 456,
"created_at": "2025-07-25 13:00:00",
"currency_id": 202,
"status_id": 0,
"user_id": 2,
"created_by": 1,
"active_service_id": 3,
"var_symbol": "F20251232025",
"invoice_due": "2025-08-10",
"taxable_date": "2025-07-25",
"note": "This invoice includes service fees",
"note_after": "Thank you for your business.",
"paid": 100,
"visual_id": 0,
"notif": 1,
"is_tax_document": 1,
"is_ord_name": "F2025-001",
"supplier_invoice_code": "SUP20250725",
"invoice_receipt_date": "2025-07-25",
"exchange_rate": 1.0,
"fully_paid_date": "2025-07-26",
"transporter_id": 0,
"vehicle_id": 0,
"trailer_id": 0,
"driver1_id": 0,
"driver2_id": 0,
"lang": "en",
"accounting_center": "AC01",
"multiple_orders": ["10","15","245"],
"bank_data": [
{
"bank_iban": "SK6802000000000000000000",
"bank_note": "Payment for invoice",
"swift_bic": "SUBASKBX",
"bank_account": "2000000000",
"bank_connection": "FIO"
}
],
"products": [
{
"product_id": 101,
"product_code": "PRD001",
"name": "Consulting services",
"quantity": 2,
"price": 150.0,
"cost_price": 100.0,
"vat": 20,
"discount": 0,
"measurement_unit_id": 1,
"measurement_unit_code": "h"
},
{
"product_id": 102,
"product_code": "PRD002",
"name": "Cloud license",
"quantity": 5,
"price": 50.0,
"cost_price": 30.0,
"vat": 20,
"discount": 5,
"measurement_unit_id": 2,
"measurement_unit_code": "pcs"
}
]
}
}
}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer auth_token',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
echo $response;
var data = JSON.stringify({
{
"data": {
"name": "Invoice for services",
"inv_type": "issued",
"subtype": "",
"rad_code": "FV",
"supplier_id": 123,
"purchaser_fa_id": 456,
"created_at": "2025-07-25 13:00:00",
"currency_id": 202,
"status_id": 0,
"user_id": 2,
"created_by": 1,
"active_service_id": 3,
"var_symbol": "F20251232025",
"invoice_due": "2025-08-10",
"taxable_date": "2025-07-25",
"note": "This invoice includes service fees",
"note_after": "Thank you for your business.",
"paid": 100,
"visual_id": 0,
"notif": 1,
"is_tax_document": 1,
"is_ord_name": "F2025-001",
"supplier_invoice_code": "SUP20250725",
"invoice_receipt_date": "2025-07-25",
"exchange_rate": 1.0,
"fully_paid_date": "2025-07-26",
"transporter_id": 0,
"vehicle_id": 0,
"trailer_id": 0,
"driver1_id": 0,
"driver2_id": 0,
"lang": "en",
"accounting_center": "AC01",
"multiple_orders": ["10","15","245"],
"bank_data": [
{
"bank_iban": "SK6802000000000000000000",
"bank_note": "Payment for invoice",
"swift_bic": "SUBASKBX",
"bank_account": "2000000000",
"bank_connection": "FIO"
}
],
"products": [
{
"product_id": 101,
"product_code": "PRD001",
"name": "Consulting services",
"quantity": 2,
"price": 150.0,
"cost_price": 100.0,
"vat": 20,
"discount": 0,
"measurement_unit_id": 1,
"measurement_unit_code": "h"
},
{
"product_id": 102,
"product_code": "PRD002",
"name": "Cloud license",
"quantity": 5,
"price": 50.0,
"cost_price": 30.0,
"vat": 20,
"discount": 5,
"measurement_unit_id": 2,
"measurement_unit_code": "pcs"
}
]
}
}
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://rest.crmango.com/api/CreateNewInvoice");
xhr.setRequestHeader("Authorization", "Bearer auth_token");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(data);
import requests
import json
url = "https://rest.crmango.com/api/CreateNewInvoice"
payload = json.dumps({
{
"data": {
"name": "Invoice for services",
"inv_type": "issued",
"subtype": "",
"rad_code": "FV",
"supplier_id": 123,
"purchaser_fa_id": 456,
"created_at": "2025-07-25 13:00:00",
"currency_id": 202,
"status_id": 0,
"user_id": 2,
"created_by": 1,
"active_service_id": 3,
"var_symbol": "F20251232025",
"invoice_due": "2025-08-10",
"taxable_date": "2025-07-25",
"note": "This invoice includes service fees",
"note_after": "Thank you for your business.",
"paid": 100,
"visual_id": 0,
"notif": 1,
"is_tax_document": 1,
"is_ord_name": "F2025-001",
"supplier_invoice_code": "SUP20250725",
"invoice_receipt_date": "2025-07-25",
"exchange_rate": 1.0,
"fully_paid_date": "2025-07-26",
"transporter_id": 0,
"vehicle_id": 0,
"trailer_id": 0,
"driver1_id": 0,
"driver2_id": 0,
"lang": "en",
"accounting_center": "AC01",
"multiple_orders": ["10","15","245"],
"bank_data": [
{
"bank_iban": "SK6802000000000000000000",
"bank_note": "Payment for invoice",
"swift_bic": "SUBASKBX",
"bank_account": "2000000000",
"bank_connection": "FIO"
}
],
"products": [
{
"product_id": 101,
"product_code": "PRD001",
"name": "Consulting services",
"quantity": 2,
"price": 150.0,
"cost_price": 100.0,
"vat": 20,
"discount": 0,
"measurement_unit_id": 1,
"measurement_unit_code": "h"
},
{
"product_id": 102,
"product_code": "PRD002",
"name": "Cloud license",
"quantity": 5,
"price": 50.0,
"cost_price": 30.0,
"vat": 20,
"discount": 5,
"measurement_unit_id": 2,
"measurement_unit_code": "pcs"
}
]
}
}
})
headers = {
'Authorization': 'Bearer auth_token',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
{
"code": 201,
"message": "New invoice has been added",
"created_id": 21
}
{
"code": "int",
"message": "string"
}