Cancel a Document
Cancels a closed document: its state changes to canceled and its PDF is updated to show it.
POST https://bo.magnifinance.com/MagniAPI/Invoicing.asmx
Sample Body
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:inv="http://MagniAPI/Invoicing/">
<soapenv:Header/>
<soapenv:Body>
<inv:DocumentCancel>
<inv:Authentication>
<inv:Email>api@yourcompany.pt</inv:Email>
<inv:Token>your-subscription-token</inv:Token>
</inv:Authentication>
<inv:DocumentId>68058</inv:DocumentId>
</inv:DocumentCancel>
</soapenv:Body>
</soapenv:Envelope>
Request
Header
| Parameter | Required | Value |
|---|---|---|
| Content-Type | required | text/xml; charset=utf-8 |
| SOAPAction | optional | "http://MagniAPI/Invoicing/DocumentCancel" |
Authentication
| Parameter | Required | Description |
|---|---|---|
| required | string(50) The email of an API user of your company with permission to cancel documents. Example: api@yourcompany.pt | |
| Token | required | string(50) The token of the company (subscription) the document belongs to. |
Parameters
| Parameter | Required | Description |
|---|---|---|
| DocumentId | required | int The id of the document to cancel, as returned by DocumentCreate. Example: 68058 |
Response
The result is in <Response>; see Response Format for the fields every response has. On success, Type is Success and there is nothing else to read. Object, when present, holds:
| Parameter | Description |
|---|---|
| ErrorMessage | string Extra detail on some errors. Empty on success. |
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/DocumentCancel"' \
--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/DocumentCancel"',
},
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/DocumentCancel"',
},
})
.then((response) => console.log(response.data))
.catch((error) => console.error(error));
Example Response
Success
<?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>
<DocumentCancelResponse xmlns="http://MagniAPI/Invoicing/">
<Response>
<RequestId>1a02c786-54e2-4315-b36f-6996bb5d7634</RequestId>
<Type>Success</Type>
</Response>
</DocumentCancelResponse>
</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>
<DocumentCancelResponse xmlns="http://MagniAPI/Invoicing/">
<Response>
<RequestId>15874aa7-d647-4e75-9834-b308f6a8a1f1</RequestId>
<Type>Error</Type>
<ErrorValue>
<Value>6</Value>
<Name>ElementDoesNotExist</Name>
</ErrorValue>
</Response>
</DocumentCancelResponse>
</soap:Body>
</soap:Envelope>