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
Header
| Parameter | Required | Value |
|---|---|---|
| required | string(50) The email of an API user of your company. Example: api@yourcompany.pt | |
| Token | required | Your subscription token. |
note
*These parameters must be HTTP headers within the request.
Query
| Parameter | Required | Description |
|---|---|---|
| taxId | required | string The tax id to check. Example: ?taxId=599138645 |
| countryCode | required | string(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.
| Parameter | Description |
|---|---|
| RequestId | Unique Id for the request to have a way to identify the request |
| Type | int 0 = Success; 1 = Error. Example value: "0" |
| ErrorValue | MagniEnum Only on errors. |
| - Value | int Identifies the error with a number. See Error Codes. Example value: "4" |
| - Name | string Identifies the error with a token. Example value: "InvalidTaxId" |
| ErrorHumanReadable | string Text that explains the error found. |
| ValidationErrors | List of ValidationError Only when taxId or countryCode is missing. |
| - Type | string Identifies the error with a token. Example value: "EmptyField" |
| - Field | string Name of the field in which validation failed. Example value: "TaxId" |
| - ElementNumber | int 0 for this operation. |
| - Detail | string Detailed error explanation. |
| IsError | boolean Whether the request failed or not. Example value: "false" |
| IsSuccess | boolean Whether the request succeeded or not. Example value: "true" |
Errors
| ErrorValue | When |
|---|---|
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
}