Read a fiscal document
curl --request POST \
--url https://api.melso.ai/v1/companies/{company_id}/documents/extract \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file=@example-file \
--form 'counterparty_country=<string>'import requests
url = "https://api.melso.ai/v1/companies/{company_id}/documents/extract"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = { "counterparty_country": "<string>" }
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
form.append('counterparty_country', '<string>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.melso.ai/v1/companies/{company_id}/documents/extract', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"direction": "income",
"record": {
"supplier_name": "<string>",
"expense_date": "2023-12-25",
"subtotal": "121.00",
"vat_amount": "121.00",
"total": "121.00",
"deductible": "yes",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 123,
"created_at": "2023-11-07T05:31:56Z",
"supplier_tax_id": "<string>",
"supplier_country": "ES",
"document_number": "<string>",
"operation_date": "2023-12-25",
"description": "<string>",
"vat_rate": "<string>",
"irpf_rate": "<string>",
"irpf_amount": "121.00",
"vat_treatment": "taxable",
"category": "<string>",
"account": "<string>",
"file_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"vat_lines": [
{
"rate": "<string>",
"base": "121.00",
"vat": "121.00"
}
],
"items": [
{
"description": "<string>",
"quantity": "<string>",
"unit_price": "<string>",
"amount": "121.00"
}
],
"category_proposed": true,
"booked_account": "<string>",
"deductible_reason": "<string>",
"deductibility": {
"estimate": "likely",
"rule": "<string>"
},
"source": "upload",
"review_reasons": [
"<string>"
],
"currency": "<string>",
"exchange_rate": "<string>",
"updated_at": "2023-11-07T05:31:56Z"
},
"review": [
"totals_mismatch"
],
"duplicate": true
}{
"direction": "income",
"record": {
"supplier_name": "<string>",
"expense_date": "2023-12-25",
"subtotal": "121.00",
"vat_amount": "121.00",
"total": "121.00",
"deductible": "yes",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 123,
"created_at": "2023-11-07T05:31:56Z",
"supplier_tax_id": "<string>",
"supplier_country": "ES",
"document_number": "<string>",
"operation_date": "2023-12-25",
"description": "<string>",
"vat_rate": "<string>",
"irpf_rate": "<string>",
"irpf_amount": "121.00",
"vat_treatment": "taxable",
"category": "<string>",
"account": "<string>",
"file_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"vat_lines": [
{
"rate": "<string>",
"base": "121.00",
"vat": "121.00"
}
],
"items": [
{
"description": "<string>",
"quantity": "<string>",
"unit_price": "<string>",
"amount": "121.00"
}
],
"category_proposed": true,
"booked_account": "<string>",
"deductible_reason": "<string>",
"deductibility": {
"estimate": "likely",
"rule": "<string>"
},
"source": "upload",
"review_reasons": [
"<string>"
],
"currency": "<string>",
"exchange_rate": "<string>",
"updated_at": "2023-11-07T05:31:56Z"
},
"review": [
"totals_mismatch"
],
"duplicate": true
}{
"error": "lines[0].vat_rate must be 21, 10, 4 or 0",
"code": "invalid_invoice",
"request_id": "req_01JAB3K9X2"
}{
"error": "invalid token",
"code": "unauthorized",
"request_id": "req_01JAB3K9X2"
}{
"error": "The tax service is not active for this company",
"code": "tax_service_required",
"request_id": "req_01JAB3K9X2"
}{
"error": "The tax return changed or is not ready for approval",
"code": "version_conflict",
"request_id": "req_01JAB3K9X2"
}{
"error": "<string>",
"code": "<string>",
"request_id": "<string>"
}{
"error": "<string>",
"code": "<string>",
"request_id": "<string>"
}{
"error": "<string>",
"code": "<string>",
"request_id": "<string>"
}Documents
Read a fiscal document
Reads an invoice or a receipt (a PDF with text, or a JPEG, PNG, WebP or GIF photo, up to 15 MB), stores it in Documents and records it as an expense or an income, depending on whether the company received or issued it.
POST
/
companies
/
{company_id}
/
documents
/
extract
Read a fiscal document
curl --request POST \
--url https://api.melso.ai/v1/companies/{company_id}/documents/extract \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file=@example-file \
--form 'counterparty_country=<string>'import requests
url = "https://api.melso.ai/v1/companies/{company_id}/documents/extract"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = { "counterparty_country": "<string>" }
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
form.append('counterparty_country', '<string>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.melso.ai/v1/companies/{company_id}/documents/extract', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"direction": "income",
"record": {
"supplier_name": "<string>",
"expense_date": "2023-12-25",
"subtotal": "121.00",
"vat_amount": "121.00",
"total": "121.00",
"deductible": "yes",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 123,
"created_at": "2023-11-07T05:31:56Z",
"supplier_tax_id": "<string>",
"supplier_country": "ES",
"document_number": "<string>",
"operation_date": "2023-12-25",
"description": "<string>",
"vat_rate": "<string>",
"irpf_rate": "<string>",
"irpf_amount": "121.00",
"vat_treatment": "taxable",
"category": "<string>",
"account": "<string>",
"file_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"vat_lines": [
{
"rate": "<string>",
"base": "121.00",
"vat": "121.00"
}
],
"items": [
{
"description": "<string>",
"quantity": "<string>",
"unit_price": "<string>",
"amount": "121.00"
}
],
"category_proposed": true,
"booked_account": "<string>",
"deductible_reason": "<string>",
"deductibility": {
"estimate": "likely",
"rule": "<string>"
},
"source": "upload",
"review_reasons": [
"<string>"
],
"currency": "<string>",
"exchange_rate": "<string>",
"updated_at": "2023-11-07T05:31:56Z"
},
"review": [
"totals_mismatch"
],
"duplicate": true
}{
"direction": "income",
"record": {
"supplier_name": "<string>",
"expense_date": "2023-12-25",
"subtotal": "121.00",
"vat_amount": "121.00",
"total": "121.00",
"deductible": "yes",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 123,
"created_at": "2023-11-07T05:31:56Z",
"supplier_tax_id": "<string>",
"supplier_country": "ES",
"document_number": "<string>",
"operation_date": "2023-12-25",
"description": "<string>",
"vat_rate": "<string>",
"irpf_rate": "<string>",
"irpf_amount": "121.00",
"vat_treatment": "taxable",
"category": "<string>",
"account": "<string>",
"file_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"vat_lines": [
{
"rate": "<string>",
"base": "121.00",
"vat": "121.00"
}
],
"items": [
{
"description": "<string>",
"quantity": "<string>",
"unit_price": "<string>",
"amount": "121.00"
}
],
"category_proposed": true,
"booked_account": "<string>",
"deductible_reason": "<string>",
"deductibility": {
"estimate": "likely",
"rule": "<string>"
},
"source": "upload",
"review_reasons": [
"<string>"
],
"currency": "<string>",
"exchange_rate": "<string>",
"updated_at": "2023-11-07T05:31:56Z"
},
"review": [
"totals_mismatch"
],
"duplicate": true
}{
"error": "lines[0].vat_rate must be 21, 10, 4 or 0",
"code": "invalid_invoice",
"request_id": "req_01JAB3K9X2"
}{
"error": "invalid token",
"code": "unauthorized",
"request_id": "req_01JAB3K9X2"
}{
"error": "The tax service is not active for this company",
"code": "tax_service_required",
"request_id": "req_01JAB3K9X2"
}{
"error": "The tax return changed or is not ready for approval",
"code": "version_conflict",
"request_id": "req_01JAB3K9X2"
}{
"error": "<string>",
"code": "<string>",
"request_id": "<string>"
}{
"error": "<string>",
"code": "<string>",
"request_id": "<string>"
}{
"error": "<string>",
"code": "<string>",
"request_id": "<string>"
}Live capability. Melso runs this in production today. Partner keys reach it once your partner account is enabled. See Availability.
review lists what to check. A document already recorded
answers 200 with duplicate true and the existing record.Authorizations
Your partner secret key, mk_live_… for real companies or mk_test_…
for test companies. Keep it on your servers. See
Authentication.
Path Parameters
The company's ID. Every company-scoped call works in exactly this company.
Body
multipart/form-data
Response
The document was already recorded.
Available options:
income, expense - Option 1
- Option 2
Show child attributes
Show child attributes
What to check.
Available options:
totals_mismatch, vat_rate_mismatch, missing_number, missing_counterparty_tax_id, converted_currency, ticket_vat_not_deductible, reverse_charge, possible_duplicate, recipient_tax_id_mismatch