WaybillCreate
Creates a Waybill or Delivery Note according to the input parameters. After successful processing, the DocumentId and Document Number are returned in the result. If the client has valid Tax Authority credentials and has the Tax Communication feature activated and the option: "Send automatically transport guides AT" checked, the document is reported to the Tax Authority and the document updated with the ATCode.
POST https://bo.magnifinance.com/MagniAPI/Invoicing.asmx
Sample Body
{
"IsToClose" : "",
"SendTo" : "",
"Client" :
{
"NIF": "",
"Name":" ",
"Address":"",
"City":"",
"PostCode":"",
"CountryCode":"",
"PhoneNumber":"",
"CountryName":"",
"LegalName":""
},
"Waybill" :
{
"Type": "",
"Serie": "",
"Date": "",
"DueDate": "",
"Description": "",
"DocumentReference": "",
"TaxExemptionReasonCode": "",
"Currency": "",
"EuroRate": "",
"Retention": "",
"Lines" :
[
{
"Code": "",
"Description": "",
"UnitPrice": "",
"Quantity": "",
"Unit": "",
"Type": "",
"TaxValue": "",
"ProductDiscount": "",
"CostCenter": ""
}
],
"LoadDateTime": "",
"LoadAddress": {
"AddressDetail": "",
"City": "",
"PostalCode": "",
"CountryCode": ""
},
"DestinationAddress": {
"AddressDetail": "",
"City": "",
"PostalCode": "",
"CountryCode": ""
},
"VehicleLicence": ""
}
}
Request
Header
Parameter |
Required |
Value |
Email |
required |
string(50) The API user with specific permission to create documents and get information about your own documents into a company Example: api@magnifinance.com
|
Token |
required |
The token of the subscription in which the document will be generated.
|
*These parameters must be an HTTP headers within the request.
Body
Client
Parameter |
Required |
Description |
Name |
required |
string(75) Client familiar name. Example value: "MagniFinance"
|
NIF |
required |
string(20) Client Tax ID. The tax id must be valid. Example value: "166737755"
|
Address |
optional |
string(200) Client address. Example value: "Av. Sidónio Pais, Nº 2, 2 Esq. A 1050 - 215"
|
City |
optional |
string(50) Client city. Example value: "Lisboa"
|
PostCode |
optional |
string(50) Client post code. The post code must be valid. Example value: "1050-214"
|
CountryCode |
required |
string(2) Client country (To consult the code list for each country, access the link: ISO 3166-1 alpha-2. Example value: "PT"
|
CountryName |
optional |
string Name of the country. Example value: "Portugal"
|
PhoneNumber |
optional |
string(50) Client phone number. Example value "999999999"
|
Legal Name |
optional |
string(500) Client legal name, client’s name on invoices, whether not informed, ‘Name’ will be considered. Example value: "MagniFin lda"
|
Email |
optional |
string(255) Client email address. Example value: "info@magnifinance.com"
|
IBAN |
optional |
string(300) Client international bank account number. Example value: "PT50002700000001234567833"
|
Waybill
Parameter |
Required |
Description |
Type |
required |
string(1) Type of the document to be created. The possible type is “W” to Waybill and "Y" to Delivery Note. Example value:"W"
|
Date |
required |
date Document date. This date must be posterior to the previously closed document date for this series. Format: yyyy-mm-dd. Example value: "2022-03-20"
|
Description |
optional |
string(300) Description to be included in the waybill Example value: "Here you put the description"
|
Serie |
optional |
string(30) Document series (sequence) in which the document will be created. The series have a unique name per document type. If not sent, the default series for that type of document in that subscription will be used. Basically, the series corresponds to the name of an existing series associated with the type of indication in the Type field, document within the Document structure. You can view a list of series for each type of document following the path in the system: Settings -> General -> Document series Example value: "FR"
|
TaxExemptionReasonCode |
optional |
string(3) Required if there is at least one line with 0% tax. Justifies why 0% tax was used. To access the complete list, click here. Are the values of the column: code. Example value: "M01"
|
Currency |
optional |
string(3) Currency to be used additionally to EUR. (ISO 4217) Example value: "BRL"
|
EuroRate |
optional |
decimal Number by which to multiply the amounts to get then alternative currency amount. Example value: "1"
|
Retention |
optional |
decimal Percentage of the document total amount that will be retained as tax with this operation. Example value: "8"
|
ExternalId |
optional |
string(50) Your identifier for this document. Used to prevent document duplication. Uniqueness is verified in combination with the client information. Example value: "test51519125"
|
Lines |
required |
(Object) List of APIInvoicingProduct This is the list of products that will appear in the document.
|
|
|
Code |
required |
string(60) Identifies the product. Example value: "PRODUCT CODE 123"
|
Description |
required |
string(200) Description of the product. Example value: "My Product Description"
|
UnitPrice |
required |
decimal Amount per unit. Example value: "2.45"
|
Quantity |
required |
decimal Number of units. Example value: "1"
|
Unit |
required |
string(50) Unit name. Example value: Example value: "KG"
|
Type |
required |
string(1) “S” for services, “P” for product. Once the product is created you cannot change the type.Example value: Example value: "P"
|
TaxValue |
required |
decimal Percentage of tax. Example value: Example value: "23"
|
ProductDiscount |
required |
decimal Percentage of discount. Example value: Example value: "0"
|
CostCenter |
optional |
string(50) Cost center to be used for the line. Example value: Example value: "Espanha"
|
|
LoadDateTime |
required |
Date The date and time that the Waybill will be used. Should be equal or greater than the waybill date. Example value: "2022-06-21T08:22:54"
|
LoadAddress |
required |
(Object) All the LoadAddress data.
|
|
|
AddressDetail |
required |
string(100) The address of the starting point of the waybill. Example value: "Av. Sidónio Pais, Nº 2, 2 Esq. A"
|
City |
required |
string(50) The city of the starting point of the waybill. Example value: "Lisboa"
|
PostalCode |
required |
string(20) The postal-code of the starting point of the waybill. Example value: "1050-215"
|
CountryCode |
required |
string(2) Client country (To consult the code list for each country, access the link: ISO 3166-1 alpha-2. Example value: "PT"
|
|
DestinationAddress |
required |
(Object) All the DestinationAddress data.
|
|
|
AddressDetail |
required |
string(100) The destination address of the waybill. Example value: "Rua das madres 100"
|
City |
required |
string(50) The destination city of the waybill. Example value: "Lisboa"
|
PostalCode |
required |
string(20) The postal-code destination of the waybill. Example value: "1000-000"
|
CountryCode |
required |
string(2) Client country (To consult the code list for each country, access the link: ISO 3166-1 alpha-2 Example value: "PT"
|
|
VehicleLicence |
optional |
string(30) The license plate of the vehicle using the waybill. Example value: "AA 16 AA"
|
Parameter |
Required |
Description |
IsToClose |
required |
boolean Should the document be closed (true) in which case it cannot be later changed, and a PDF and document number are generated or should the document be created as a draft (false) in which case no PDF or document number are generated. Example value:"true"
|
Response
Parameter |
Description |
RequestId |
Unique Id for the request to have a way to identify the request |
Type |
string Description to inform if the request was a success or error. Example value: "Success"
|
Object |
|
|
DocumentId |
int If the request for successful queries and the waybill create is returned the Id of the document for future queries. Example value: "67204"
|
DocumentNumber |
string In case of success the number of the document is returned Example value: "GT GT/238"
|
ErrorMessage |
string Unprocessed error message.
|
|
ErrorValue |
MagniEnum |
|
Value |
int Identifies the error with a number. To identify the types of errors in more detail click here Example value: "14"
|
Name |
string Identifies the error with a token. Example value: "SaveFailed"
|
|
ErrorHumanReadable |
string Text that explains the error found. Example value: "ValidationError"
|
ValidationErrors |
List of ValidationError
|
|
Type |
string Identifies the error with a token. Example value: "MustBePosteriorToMostCurrentClosedDocument"
|
ElementNumber |
int Identifies index of the field in which validation failed. Example value: "0"
|
Field |
string Name of the field in which validation failed. Example value: "DocumentDetailDate"
|
Detail |
string Detailed error explanation. Example value: "A closed document already exists with a date after this with this Series. You must change series or enter a date equal or after to 2021-11-10"
|
|
Request Sample
Below you can check some examples of the SOAP request in some technologies.
cURL
curl --location --request POST 'https://bo.magnifinance.com/api/v1.1/document/waybill' \
--header 'email: XXX@example.com ' \
--header 'token: XXX' \
--header 'Content-Type: application/json' \
--data-raw '{
"IsToClose" : "",
"SendTo" : "",
"Client" :
{
"NIF": "",
"Name":"",
"Address":"",
"City":"",
"PostCode":"",
"CountryCode":"",
"PhoneNumber":"",
"CountryName":"",
"LegalName":""
},
"Waybill" :
{
"Type": "",
"Serie": "",
"Date": "",
"DueDate": "",
"Description": "",
"DocumentReference": "",
"TaxExemptionReasonCode": "",
"Currency": "",
"EuroRate": "",
"Retention": "",
"Lines" :
[
{
"Code": "",
"Description": "",
"UnitPrice": "",
"Quantity": "",
"Unit": "",
"Type": "",
"TaxValue": "",
"ProductDiscount": "",
"CostCenter": ""
}
],
"LoadDateTime": "",
"LoadAddress": {
"AddressDetail": "",
"City": "",
"PostalCode": "",
"CountryCode": ""
},
"DestinationAddress": {
"AddressDetail": "",
"City": "",
"PostalCode": "",
"CountryCode": ""
},
"VehicleLicence": ""
}
}'
Javascript (fetch)
var myHeaders = new Headers();
myHeaders.append("Host", "bo.magnifinance.com");
myHeaders.append("email", "XXX@example.com");
myHeaders.append("token", "XXX");
myHeaders.append("Content-Type", "application/json");
var raw = "{
"IsToClose" : "",
"SendTo" : "",
"Client" :
{
"NIF": "",
"Name":"",
"Address":"",
"City":"",
"PostCode":"",
"CountryCode":"",
"PhoneNumber":"",
"CountryName":"",
"LegalName":""
},
"Waybill" :
{
"Type": "",
"Serie": "",
"Date": "",
"DueDate": "",
"Description": "",
"DocumentReference": "",
"TaxExemptionReasonCode": "",
"Currency": "",
"EuroRate": "",
"Retention": "",
"Lines" :
[
{
"Code": "",
"Description": "",
"UnitPrice": "",
"Quantity": "",
"Unit": "",
"Type": "",
"TaxValue": "",
"ProductDiscount": "",
"CostCenter": ""
}
],
"LoadDateTime": "",
"LoadAddress": {
"AddressDetail": "",
"City": "",
"PostalCode": "",
"CountryCode": ""
},
"DestinationAddress": {
"AddressDetail": "",
"City": "",
"PostalCode": "",
"CountryCode": ""
},
"VehicleLicence": ""
}
}";
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://bo.magnifinance.com/api/v1.1/document/waybil", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
NodeJs (axios)
var axios = require('axios');
var data = '{
"IsToClose" : "",
"SendTo" : "",
"Client" :
{
"NIF": "",
"Name":"",
"Address":"",
"City":"",
"PostCode":"",
"CountryCode":"",
"PhoneNumber":"",
"CountryName":"",
"LegalName":""
},
"Waybill" :
{
"Type": "",
"Serie": "",
"Date": "",
"DueDate": "",
"Description": "",
"DocumentReference": "",
"TaxExemptionReasonCode": "",
"Currency": "",
"EuroRate": "",
"Retention": "",
"Lines" :
[
{
"Code": "",
"Description": "",
"UnitPrice": "",
"Quantity": "",
"Unit": "",
"Type": "",
"TaxValue": "",
"ProductDiscount": "",
"CostCenter": ""
}
],
"LoadDateTime": "",
"LoadAddress": {
"AddressDetail": "",
"City": "",
"PostalCode": "",
"CountryCode": ""
},
"DestinationAddress": {
"AddressDetail": "",
"City": "",
"PostalCode": "",
"CountryCode": ""
},
"VehicleLicence": ""
}
}';
var config = {
method: 'post',
url: 'https://bo.magnifinance.com/api/v1.1/document/waybil',
headers: {
'email': 'XXX@example.com',
'token': 'XXX',
'Content-Type': 'application/json'
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
;
Example Response
Success
{
"RequestId": "98c3bc62-911d-4f14-a5f4-d610c66e8b8b",
"Object": {
"DocumentId": 67195,
"ErrorMessage": null
},
"Type": 0,
"ErrorValue": null,
"ErrorHumanReadable": null,
"ValidationErrors": null,
"IsSuccess": true,
"IsError": false
}
Error
{
"RequestId": "2661fa10-c92d-4015-bef0-30f5e94e3c88",
"Object": null,
"Type": 1,
"ErrorValue": {
"Value": 2,
"Name": "ValidationError"
},
"ErrorHumanReadable": "ValidationError",
"ValidationErrors": [
{
"Type": "InvalidTaxId",
"ElementNumber": 0,
"Field": "CompanyTaxId",
"Detail": "Invalid Tax Id"
}
],
"IsSuccess": false,
"IsError": true
}