Skip to main content

Get a Document

Returns a document's number, a link to download its PDF, and all its details (document fields, customer and totals). The PDF link is only returned for closed or canceled documents.

POST https://bo.magnifinance.com/MagniAPI/Invoicing.asmx

tip

Right after creating a document, its PDF can take a few seconds to be ready. If you get ElementPendingProcessing, wait about 10 seconds and call DocumentGet again.

Sample Body​

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:inv="http://MagniAPI/Invoicing/">
<soapenv:Header/>
<soapenv:Body>
<inv:DocumentGet>
<inv:Authentication>
<inv:Email>api@yourcompany.pt</inv:Email>
<inv:Token>your-subscription-token</inv:Token>
</inv:Authentication>
<inv:DocumentId>67267</inv:DocumentId>
</inv:DocumentGet>
</soapenv:Body>
</soapenv:Envelope>

Request​

ParameterRequiredValue
Content-Typerequiredtext/xml; charset=utf-8
SOAPActionoptional"http://MagniAPI/Invoicing/DocumentGet"

Authentication​

ParameterRequiredDescription
Emailrequiredstring(50) The email of an API user of your company with permission to read documents. Example: api@yourcompany.pt
Tokenrequiredstring(50) The token of the company (subscription) the document belongs to.

Parameters​

ParameterRequiredDescription
DocumentIdrequiredint The id of the document, as returned by DocumentCreate. Example: 67267

Response​

The result is in <Response>; see Response Format for the fields every response has. Object holds:

ParameterDescription
DocumentNumberstring The document number: type, series and number. Example: "FT FT/47"
DownloadUrlstring A temporary link to download the PDF. It expires after a while: download the file right away, or call DocumentGet again for a new link.
DetailsObject All the document's data: Document, Receiver and Totals (below).
ErrorMessagestring Extra detail on some errors. Empty on success.

PaymentStatus, TotalAmount and UnpaidAmount are part of the same object but are not filled in by DocumentGet: use DocumentGetProperty for the payment status.

Documents that aren't closed​

SituationResponse
The document is a draftError DocumentNotInClosedState. Object still has DocumentNumber and Details, but no DownloadUrl.
The PDF is still being generatedError ElementPendingProcessing. Try again in a few seconds.
There is no document with that idError ElementDoesNotExist.

Details.Document​

The document fields as they were sent to DocumentCreate (Date, DueDate, Description, Type, Serie, Id, TaxExemptionReasonCode, DocumentReference, Currency, Retention, EuroRate, ExternalId, Lines, PurchaseOrder), plus:

ParameterDescription
DocumentStatusIdstring The document's state: D draft, C closed, A canceled.
DocumentStatusstring The state's name. Example: "Closed"
LoadDateTime, LoadAddress, DestinationAddress, VehicleLicenceOnly for waybills and delivery notes: the transport details sent to WaybillCreate.

Details.Receiver​

The customer, with the same fields as Client in DocumentCreate, except that the tax id is called TaxId instead of NIF.

Details.Totals​

Each amount comes twice: as a number (Amount) and as text in Portuguese format (AmountText, e.g. "1.234,56").

ParameterDescription
Amount / AmountTextTotal of the document, VAT included.
WithoutTax / WithoutTaxTextTotal without VAT.
Tax / TaxTextTotal VAT.
Discount / DiscountTextTotal discount.
Retention / RetentionTextTotal withholding tax.
AmountBeforeDiscountAndTax / AmountBeforeDiscountAndTaxTextTotal before discounts and VAT.
TotalAmountWithExchangeRate / TotalAmountWithExchangeRateTextThe total in the document's Currency. 0 when the document has no second currency.
TotalCreditAmount / TotalCreditAmountTextTotal credit amount, when applicable.
TotalDebitAmount / TotalDebitAmountTextTotal debit amount, when applicable.

Request Sample​

Save the Sample Body as request.xml, then:

cURL​

curl https://bo.magnifinance.com/MagniAPI/Invoicing.asmx \
--header 'Content-Type: text/xml; charset=utf-8' \
--header 'SOAPAction: "http://MagniAPI/Invoicing/DocumentGet"' \
--data-binary @request.xml

JavaScript (Node.js 18+)​

const fs = require('fs');

const body = fs.readFileSync('request.xml', 'utf8');

fetch('https://bo.magnifinance.com/MagniAPI/Invoicing.asmx', {
method: 'POST',
headers: {
'Content-Type': 'text/xml; charset=utf-8',
SOAPAction: '"http://MagniAPI/Invoicing/DocumentGet"',
},
body,
})
.then((response) => response.text())
.then((xml) => console.log(xml))
.catch((error) => console.error(error));

Node.js (axios)​

const fs = require('fs');
const axios = require('axios');

const body = fs.readFileSync('request.xml', 'utf8');

axios
.post('https://bo.magnifinance.com/MagniAPI/Invoicing.asmx', body, {
headers: {
'Content-Type': 'text/xml; charset=utf-8',
SOAPAction: '"http://MagniAPI/Invoicing/DocumentGet"',
},
})
.then((response) => console.log(response.data))
.catch((error) => console.error(error));

Example Response​

Success​

Details is shortened here.

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<DocumentGetResponse xmlns="http://MagniAPI/Invoicing/">
<Response>
<RequestId>993d5c2c-6082-4f43-b786-d186a80c5d65</RequestId>
<Type>Success</Type>
<Object>
<DocumentNumber>FT FT/21</DocumentNumber>
<DownloadUrl>https://files.example.com/FTFT_21.pdf?signature=…</DownloadUrl>
<Details>
<Document>
<Date>2026-10-08T00:00:00</Date>
<Type>I</Type>
<Serie>FT</Serie>
<DocumentStatusId>C</DocumentStatusId>
<DocumentStatus>Closed</DocumentStatus>
…
</Document>
<Receiver>
<TaxId>166737755</TaxId>
<Name>MagniFinance</Name>
…
</Receiver>
<Totals>
<Amount>110.70</Amount>
<AmountText>110,70</AmountText>
…
</Totals>
</Details>
</Object>
</Response>
</DocumentGetResponse>
</soap:Body>
</soap:Envelope>

Error​

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<DocumentGetResponse xmlns="http://MagniAPI/Invoicing/">
<Response>
<RequestId>36f6b1fe-376c-4ce9-812e-0bb6e834dd69</RequestId>
<Type>Error</Type>
<ErrorValue>
<Value>6</Value>
<Name>ElementDoesNotExist</Name>
</ErrorValue>
</Response>
</DocumentGetResponse>
</soap:Body>
</soap:Envelope>