Skip to main content

Get a Client

Gets one of the companies registered in your subscription (the one the token belongs to), found by its tax id and country. It returns the company's name, legal name, address, city, postal code, country, phone number, email and IBAN.

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:ClientGet>
<inv:Authentication>
<inv:Email>api@yourcompany.pt</inv:Email>
<inv:Token>your-subscription-token</inv:Token>
</inv:Authentication>
<inv:TaxId>599138645</inv:TaxId>
<inv:CountryCode>PT</inv:CountryCode>
</inv:ClientGet>
</soapenv:Body>
</soapenv:Envelope>

Request​

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

Body​

Authentication​

ParameterRequiredDescription
Emailrequiredstring(50) The email of an API user of your company. Example: api@yourcompany.pt
Tokenrequiredstring(50) The token of the subscription whose companies you're looking up.

Parameters​

ParameterRequiredDescription
TaxIdrequiredstring(20) The tax id of the company you want to get. Example: "599138645"
CountryCoderequiredstring(2) The company's country, as an ISO 3166-1 alpha-2 code. Example: "PT"

Response​

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

ParameterDescription
NIFstring The company's tax id. Example: "599138645"
Namestring The company's usual (trade) name. Example: "MagniFinance"
Addressstring The company's address. Example: "Rua das Barreiras"
Citystring The company's city. Example: "Lisboa"
PostCodestring The company's postal code. Example: "1000-000"
CountryCodestring The company's country code (ISO 3166-1 alpha-2). Example: "PT"
PhoneNumberstring The company's phone number. Example: "912345678"
CountryNamestring The country's name. Example: "Portugal"
LegalNamestring The company's legal name. Example: "Empresa Exemplar, Lda."
Emailstring The company's email address. Example: "email@example.com"
IBANstring The company's bank account (IBAN). Example: "PT50002700000001234567833"

Errors​

ErrorValueWhen
NoClientFound (26)There's no company with that tax id and country in your subscription.
ValidationError (2) with InvalidTaxIdThe tax id isn't valid for that country.
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/Invoicing.asmx \
--header 'Content-Type: text/xml; charset=utf-8' \
--header 'SOAPAction: "http://MagniAPI/Invoicing/ClientGet"' \
--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/ClientGet"',
},
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/ClientGet"',
},
})
.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>
<ClientGetResponse xmlns="http://MagniAPI/Invoicing/">
<ResponseClientGet>
<RequestId>14be39b8-5dea-4a82-bf8b-7a1e4a48a69b</RequestId>
<Type>Success</Type>
<Object>
<NIF>123456789</NIF>
<Name>Empresa exemplar</Name>
<Address>Rua das Barreiras</Address>
<City>Lisboa</City>
<PostCode>1234-567</PostCode>
<CountryCode>PT</CountryCode>
<PhoneNumber>999999999</PhoneNumber>
<CountryName>Portugal</CountryName>
<LegalName>Empresa Exemplar lda</LegalName>
<Email>email@exemplo.com</Email>
<IBAN>PT50002700000001234567833</IBAN>
</Object>
</ResponseClientGet>
</ClientGetResponse>
</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>
<ClientGetResponse xmlns="http://MagniAPI/Invoicing/">
<ResponseClientGet>
<RequestId>7a3db77d-20d5-4eae-a6ef-58471c3f6e8a</RequestId>
<Type>Error</Type>
<ErrorValue>
<Value>2</Value>
<Name>ValidationError</Name>
</ErrorValue>
<ValidationErrors>
<ValidationError>
<Type>InvalidTaxId</Type>
<ElementNumber>0</ElementNumber>
<Field>TaxId</Field>
<Detail>Invalid Tax Id</Detail>
</ValidationError>
</ValidationErrors>
</ResponseClientGet>
</ClientGetResponse>
</soap:Body>
</soap:Envelope>