curl --request POST \
--url https://api.melso.ai/v1/companies/{company_id}/book-imports \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"book": "received",
"rows": [
{
"invoice_number": "FD-2026-0418",
"date": "2026-10-21",
"counterparty_tax_id": "B12345674",
"counterparty_name": "Papelería Delta S.L.",
"base": "200.00",
"vat_rate": "21",
"vat_amount": "42.00",
"total": "242.00"
},
{
"invoice_number": "2026/311",
"date": "2026-10-28",
"counterparty_tax_id": "00000000T",
"counterparty_name": "Lucía Martín Pérez",
"base": "450.00",
"vat_rate": "21",
"vat_amount": "94.50",
"total": "544.50"
}
]
}
'import requests
url = "https://api.melso.ai/v1/companies/{company_id}/book-imports"
payload = {
"book": "received",
"rows": [
{
"invoice_number": "FD-2026-0418",
"date": "2026-10-21",
"counterparty_tax_id": "B12345674",
"counterparty_name": "Papelería Delta S.L.",
"base": "200.00",
"vat_rate": "21",
"vat_amount": "42.00",
"total": "242.00"
},
{
"invoice_number": "2026/311",
"date": "2026-10-28",
"counterparty_tax_id": "00000000T",
"counterparty_name": "Lucía Martín Pérez",
"base": "450.00",
"vat_rate": "21",
"vat_amount": "94.50",
"total": "544.50"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
book: 'received',
rows: [
{
invoice_number: 'FD-2026-0418',
date: '2026-10-21',
counterparty_tax_id: 'B12345674',
counterparty_name: 'Papelería Delta S.L.',
base: '200.00',
vat_rate: '21',
vat_amount: '42.00',
total: '242.00'
},
{
invoice_number: '2026/311',
date: '2026-10-28',
counterparty_tax_id: '00000000T',
counterparty_name: 'Lucía Martín Pérez',
base: '450.00',
vat_rate: '21',
vat_amount: '94.50',
total: '544.50'
}
]
})
};
fetch('https://api.melso.ai/v1/companies/{company_id}/book-imports', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"id": "9e8d7c6b-5a4f-4e3d-8c2b-1a0f9e8d7c6b",
"book": "received",
"period": {
"from": "2026-10-21",
"to": "2026-10-28"
},
"rows": 2,
"created": [
{
"row": 2,
"invoice_number": "2026/311",
"expense_id": "3d2c1b0a-9f8e-4d7c-8b6a-5f4e3d2c1b0a",
"income_id": null
}
],
"skipped": [
{
"row": 1,
"invoice_number": "FD-2026-0418",
"reason": "duplicate",
"expense_id": "7b1e4c2a-9d3f-4e6a-8b5c-1f2e3d4c5b6a",
"income_id": null
}
],
"refused": [],
"created_at": "2026-11-03T12:00:05Z"
}Import a VAT book
Imports the VAT book a company kept in another program: its received invoices as expenses, or its issued invoices as income.
curl --request POST \
--url https://api.melso.ai/v1/companies/{company_id}/book-imports \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"book": "received",
"rows": [
{
"invoice_number": "FD-2026-0418",
"date": "2026-10-21",
"counterparty_tax_id": "B12345674",
"counterparty_name": "Papelería Delta S.L.",
"base": "200.00",
"vat_rate": "21",
"vat_amount": "42.00",
"total": "242.00"
},
{
"invoice_number": "2026/311",
"date": "2026-10-28",
"counterparty_tax_id": "00000000T",
"counterparty_name": "Lucía Martín Pérez",
"base": "450.00",
"vat_rate": "21",
"vat_amount": "94.50",
"total": "544.50"
}
]
}
'import requests
url = "https://api.melso.ai/v1/companies/{company_id}/book-imports"
payload = {
"book": "received",
"rows": [
{
"invoice_number": "FD-2026-0418",
"date": "2026-10-21",
"counterparty_tax_id": "B12345674",
"counterparty_name": "Papelería Delta S.L.",
"base": "200.00",
"vat_rate": "21",
"vat_amount": "42.00",
"total": "242.00"
},
{
"invoice_number": "2026/311",
"date": "2026-10-28",
"counterparty_tax_id": "00000000T",
"counterparty_name": "Lucía Martín Pérez",
"base": "450.00",
"vat_rate": "21",
"vat_amount": "94.50",
"total": "544.50"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
book: 'received',
rows: [
{
invoice_number: 'FD-2026-0418',
date: '2026-10-21',
counterparty_tax_id: 'B12345674',
counterparty_name: 'Papelería Delta S.L.',
base: '200.00',
vat_rate: '21',
vat_amount: '42.00',
total: '242.00'
},
{
invoice_number: '2026/311',
date: '2026-10-28',
counterparty_tax_id: '00000000T',
counterparty_name: 'Lucía Martín Pérez',
base: '450.00',
vat_rate: '21',
vat_amount: '94.50',
total: '544.50'
}
]
})
};
fetch('https://api.melso.ai/v1/companies/{company_id}/book-imports', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"id": "9e8d7c6b-5a4f-4e3d-8c2b-1a0f9e8d7c6b",
"book": "received",
"period": {
"from": "2026-10-21",
"to": "2026-10-28"
},
"rows": 2,
"created": [
{
"row": 2,
"invoice_number": "2026/311",
"expense_id": "3d2c1b0a-9f8e-4d7c-8b6a-5f4e3d2c1b0a",
"income_id": null
}
],
"skipped": [
{
"row": 1,
"invoice_number": "FD-2026-0418",
"reason": "duplicate",
"expense_id": "7b1e4c2a-9d3f-4e6a-8b5c-1f2e3d4c5b6a",
"income_id": null
}
],
"refused": [],
"created_at": "2026-11-03T12:00:05Z"
}books:write. Send an Idempotency-Key to retry safely. Send a row for each VAT rate of each invoice, as the libro registro de facturas recibidas or expedidas has them: rows with the same invoice number and counterparty NIF are one invoice. At most 50,000 rows: split a larger book by quarter.
Each invoice is created, skipped or refused. skipped are the invoices Melso already has, by counterparty NIF and invoice number, with the record that has them. refused names each row and why, such as invalid_date, missing_number, vat_mismatch or conflicting_invoice (the same invoice with another date or NIF); fix them in your program and import those rows again. The rest are created, and the tax returns count them.Authorizations
A company API key, mk_live_…, that the company's owner creates in the
Melso app under Settings, Connect your AI, API keys. It works in that
one company with the owner's authority. Test keys (mk_test_…) are not
issued. Keep the key on your servers. See
Authentication.
Headers
A unique key of yours, such as a UUID, that makes a retried create
safe. For 24 hours a retry with the same key and body gets the first
answer again, with Idempotent-Replayed: true. The same key with
another body answers 422 idempotency_key_reused; while the first
request runs, 409 idempotency_key_in_use. A 5xx answer is not
kept, so its retry runs again. See Conventions.
255Path Parameters
Body
Response
The import, with each invoice created, skipped or refused.