Skip to main content

TaxIdValidation (SOAP)

Checks whether a tax id is valid for a country. Today only Portugal (PT) is supported; see Supported countries.

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

note

This operation is only on the v1.1 endpoint. Its namespace is http://MagniAPI/v1.1/Invoicing/ (WSDL: v1.1/Invoicing.asmx?WSDL).

Sample Body​

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:inv="http://MagniAPI/v1.1/Invoicing/">
<soapenv:Header/>
<soapenv:Body>
<inv:TaxIdValidation>
<inv:Authentication>
<inv:Email>api@yourcompany.pt</inv:Email>
<inv:Token>your-subscription-token</inv:Token>
</inv:Authentication>
<inv:CountryCode>PT</inv:CountryCode>
<inv:TaxId>599138645</inv:TaxId>
</inv:TaxIdValidation>
</soapenv:Body>
</soapenv:Envelope>

Request​

ParameterRequiredValue
Content-Typerequiredtext/xml; charset=utf-8
SOAPActionoptional"http://MagniAPI/v1.1/Invoicing/TaxIdValidation"

Body​

Authentication​

ParameterRequiredDescription
Emailrequiredstring(50) The email of an API user of your company. Example: api@yourcompany.pt
Tokenrequiredstring(50) Your subscription token.

Parameters​

ParameterRequiredDescription
CountryCoderequiredstring(2) The country the tax id belongs to, as an ISO 3166-1 alpha-2 code. Only PT is supported today. Example: "PT"
TaxIdrequiredstring The tax id to check. Example: "599138645"

Response​

The result is in <ResponseTaxIdValidation>. It has no Object: Type is Success when the tax id is valid, and Error (with ErrorValue InvalidTaxId) when it isn't. See Response Format for the other fields.

Errors​

ErrorValueWhen
InvalidTaxId (4)The tax id isn't valid for that country.
ElementDoesNotExist (6)The country isn't supported (anything other than PT).
ValidationError (2)TaxId or CountryCode is missing.
AuthenticationError (1)The email or token is wrong.

Request Sample​

Save the Sample Body as request.xml, then:

cURL​

curl https://bo.magnifinance.com/MagniAPI/v1.1/Invoicing.asmx \
--header 'Content-Type: text/xml; charset=utf-8' \
--header 'SOAPAction: "http://MagniAPI/v1.1/Invoicing/TaxIdValidation"' \
--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/v1.1/Invoicing.asmx', {
method: 'POST',
headers: {
'Content-Type': 'text/xml; charset=utf-8',
SOAPAction: '"http://MagniAPI/v1.1/Invoicing/TaxIdValidation"',
},
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/v1.1/Invoicing.asmx', body, {
headers: {
'Content-Type': 'text/xml; charset=utf-8',
SOAPAction: '"http://MagniAPI/v1.1/Invoicing/TaxIdValidation"',
},
})
.then((response) => console.log(response.data))
.catch((error) => console.error(error));

Example Response​

Success​

<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>
<TaxIdValidationResponse xmlns="http://MagniAPI/v1.1/Invoicing/">
<ResponseTaxIdValidation>
<RequestId>74146a14-63b9-4335-abf2-a7cc8a5cda03</RequestId>
<Type>Success</Type>
</ResponseTaxIdValidation>
</TaxIdValidationResponse>
</soap:Body>
</soap:Envelope>

Error​

<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>
<TaxIdValidationResponse xmlns="http://MagniAPI/v1.1/Invoicing/">
<ResponseTaxIdValidation>
<RequestId>0b3ae75f-47dc-4f12-befd-89a1203e99fb</RequestId>
<Type>Error</Type>
<ErrorValue>
<Value>4</Value>
<Name>InvalidTaxId</Name>
</ErrorValue>
</ResponseTaxIdValidation>
</TaxIdValidationResponse>
</soap:Body>
</soap:Envelope>