Skip to main content

TaxId Validation (REST)

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

Endpoint​

GET https://bo.magnifinance.com/api/v1.1/taxIdValidation?countryCode={CountryCode}&taxId={TaxId}

Request​

ParameterRequiredValue
Emailrequiredstring(50) The email of an API user of your company. Example: api@yourcompany.pt
TokenrequiredYour subscription token.
note

*These parameters must be HTTP headers within the request.

Query​

ParameterRequiredDescription
taxIdrequiredstring The tax id to check. Example: ?taxId=599138645
countryCoderequiredstring(2) The country the tax id belongs to, as an ISO 3166-1 alpha-2 code. Only PT is supported today. Example: ?countryCode=PT

Response​

There's no Object: Type is 0 (Success) when the tax id is valid, and 1 (Error) when it isn't.

ParameterDescription
RequestIdUnique Id for the request to have a way to identify the request
Typeint 0 = Success; 1 = Error. Example value: "0"
ErrorValueMagniEnum Only on errors.
- Valueint Identifies the error with a number. See Error Codes. Example value: "4"
- Namestring Identifies the error with a token. Example value: "InvalidTaxId"
ErrorHumanReadablestring Text that explains the error found.
ValidationErrorsList of ValidationError Only when taxId or countryCode is missing.
- Typestring Identifies the error with a token. Example value: "EmptyField"
- Fieldstring Name of the field in which validation failed. Example value: "TaxId"
- ElementNumberint 0 for this operation.
- Detailstring Detailed error explanation.
IsErrorboolean Whether the request failed or not. Example value: "false"
IsSuccessboolean Whether the request succeeded or not. Example value: "true"

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​

Below you can check some examples of the REST request in some technologies.

cURL​

curl --location --request GET 'https://bo.magnifinance.com/api/v1.1/taxIdValidation?countryCode=PT&taxId=599138645' \
--header 'email: api@yourcompany.pt' \
--header 'token: your-subscription-token'

Javascript (fetch)​

var myHeaders = new Headers();
myHeaders.append("email", "api@yourcompany.pt");
myHeaders.append("token", "your-subscription-token");

var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};

fetch("https://bo.magnifinance.com/api/v1.1/taxIdValidation?countryCode=PT&taxId=599138645", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));

NodeJs (axios)​

var axios = require('axios');

var config = {
method: 'get',
url: 'https://bo.magnifinance.com/api/v1.1/taxIdValidation?countryCode=PT&taxId=599138645',
headers: {
'email': 'api@yourcompany.pt',
'token': 'your-subscription-token'
}
};

axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});

Python (requests)​

import requests

url = "https://bo.magnifinance.com/api/v1.1/taxIdValidation"
headers = {
"email": "api@yourcompany.pt",
"token": "your-subscription-token"
}
params = {
"countryCode": "PT",
"taxId": "599138645"
}

response = requests.get(url, headers=headers, params=params)
print(response.json())

PHP (cURL)​

<?php
$countryCode = "PT";
$taxId = "599138645";
$ch = curl_init("https://bo.magnifinance.com/api/v1.1/taxIdValidation?countryCode=" . $countryCode . "&taxId=" . $taxId);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"email: api@yourcompany.pt",
"token: your-subscription-token"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>

C# (HttpClient)​

using System.Net.Http;

var client = new HttpClient();
client.DefaultRequestHeaders.Add("email", "api@yourcompany.pt");
client.DefaultRequestHeaders.Add("token", "your-subscription-token");

var response = await client.GetAsync("https://bo.magnifinance.com/api/v1.1/taxIdValidation?countryCode=PT&taxId=599138645");
Console.WriteLine(await response.Content.ReadAsStringAsync());

Java (HttpClient)​

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://bo.magnifinance.com/api/v1.1/taxIdValidation?countryCode=PT&taxId=599138645"))
.header("email", "api@yourcompany.pt")
.header("token", "your-subscription-token")
.GET()
.build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());

Example Response​

Success​

{
"RequestId": "65d21065-115c-4766-964e-d31412e37461",
"Type": 0,
"ErrorValue": null,
"ErrorHumanReadable": null,
"ValidationErrors": null,
"IsSuccess": true,
"IsError": false
}

Error​

{
"RequestId": "7869d1d8-599c-451f-add5-f2f7d1c565a9",
"Type": 1,
"ErrorValue": {
"Value": 4,
"Name": "InvalidTaxId"
},
"ErrorHumanReadable": null,
"ValidationErrors": null,
"IsSuccess": false,
"IsError": true
}