Nova aplicação de telemóvel | Experimente grátis!
Faturar no iphone com MagniFinance. Aceda ao link da Apple store Faturar no Android com MagniFinance. Aceda ao link para Android Store
 
API documentation Menu

API 2.0 | Go to the latest documentation arrow_forward

WaybillCreate


Creates a Waybill or DeliveryNote 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

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:inv="http://MagniAPI/Invoicing/"> <soapenv:Header/> <soapenv:Body> <inv:WaybillCreate> <inv:Authentication> <inv:Email> </inv:Email> <inv:Token> </inv:Token> </inv:Authentication> <inv:Client> <inv:NIF> </inv:NIF> <inv:Name> </inv:Name> <inv:Address> </inv:Address> <inv:CountryCode> </inv:CountryCode> </inv:Client> <inv:Waybill> <inv:Date> </inv:Date> <inv:Description> </inv:Description> <inv:Type> </inv:Type> <inv:Serie> </inv:Serie> <inv:TaxExemptionReasonCode> </inv:TaxExemptionReasonCode> <inv:Currency> </inv:Currency> <inv:Retention> </inv:Retention> <inv:Lines> <inv:APIInvoicingProduct> <inv:Code> </inv:Code> <inv:Description> </inv:Description> <inv:UnitPrice> </inv:UnitPrice> <inv:Quantity> </inv:Quantity> <inv:Unit> </inv:Unit> <inv:Type> </inv:Type> <inv:TaxValue> </inv:TaxValue> <inv:ProductDiscount> </inv:ProductDiscount> <inv:CostCenter> </inv:CostCenter> </inv:APIInvoicingProduct> </inv:Lines> <inv:LoadDateTime> </inv:LoadDateTime> <inv:LoadAddress> <inv:AddressDetail> </inv:AddressDetail> <inv:City> </inv:City> <inv:PostalCode> </inv:PostalCode> <inv:CountryCode> </inv:CountryCode> </inv:LoadAddress> <inv:DestinationAddress> <inv:AddressDetail> </inv:AddressDetail> <inv:City> </inv:City> <inv:PostalCode> </inv:PostalCode> <inv:CountryCode> </inv:CountryCode> </inv:DestinationAddress> <inv:VehicleLicence> </inv:VehicleLicence> </inv:Waybill> <inv:IsToClose> </inv:IsToClose> </inv:WaybillCreate> </soapenv:Body> </soapenv:Envelope>


Request

Header

Parameter Required value
Content-Type required text/xml


Body

Authentication

Parameter Required Description
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 string(50) The token of the subscription in which the document will be generated.


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. 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.
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 adress 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: "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"
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"
ATDocCode String When closing a waybill the document could be automatically reported to the Tax Authority which returns a ATDocCode. This code is integrated in the PDF making the waybill immediately ready for shipment. If the client has a valid Tax Authority credentials, has the Tax Communication feature activated and the option: "Send automatically transport guides AT" checked, the document will be reported to the Tax Authority and the document updated with the ATCode. In this case the API will return the AT document Code. Example value: "67204"
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/MagniAPI/Invoicing.asmx' \ --header 'Host: bo.magnifinance.com' \ --header 'Content-Type: text/xml' \ --data-raw '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:inv="http://MagniAPI/Invoicing/"> <soapenv:Header/> <soapenv:Body> <inv:WaybillCreate> <inv:Authentication> <inv:Email></inv:Email> <inv:Token></inv:Token> </inv:Authentication> <inv:Client> <inv:NIF></inv:NIF> <inv:Name></inv:Name> <inv:Address></inv:Address> <inv:CountryCode></inv:CountryCode> </inv:Client> <inv:Waybill> <inv:Date></inv:Date> <inv:Description></inv:Description> <inv:Type></inv:Type> <inv:Serie></inv:Serie> <inv:TaxExemptionReasonCode></inv:TaxExemptionReasonCode> <inv:Currency></inv:Currency> <inv:EuroRate></inv:EuroRate> <inv:Retention></inv:Retention> <inv:ExternalId></inv:ExternalId> <inv:Lines> <inv:APIInvoicingProduct> <inv:Code></inv:Code> <inv:Description></inv:Description> <inv:UnitPrice></inv:UnitPrice> <inv:Quantity></inv:Quantity> <inv:Unit></inv:Unit> <inv:Type></inv:Type> <inv:TaxValue></inv:TaxValue> <inv:ProductDiscount></inv:ProductDiscount> <inv:CostCenter>teste</inv:CostCenter> </inv:APIInvoicingProduct> </inv:Lines> <inv:LoadDateTime></inv:LoadDateTime> <inv:LoadAddress> <inv:AddressDetail></inv:AddressDetail> <inv:City>lisboa</inv:City> <inv:PostalCode></inv:PostalCode> <inv:CountryCode></inv:CountryCode> </inv:LoadAddress> <inv:DestinationAddress> <inv:AddressDetail></inv:AddressDetail> <inv:City>lisboa</inv:City> <inv:PostalCode></inv:PostalCode> <inv:CountryCode></inv:CountryCode> </inv:DestinationAddress> <inv:VehicleLicence></inv:VehicleLicence> </inv:Waybill> <inv:IsToClose></inv:IsToClose> </inv:WaybillCreate> </soapenv:Body> </soapenv:Envelope>'


Javascript (fetch)
var myHeaders = new Headers(); myHeaders.append("Host", "bo.magnifinance.com"); myHeaders.append("Content-Type", "text/xml"); var raw = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:inv=\"http://MagniAPI/Invoicing/\">\r\n <soapenv:Header/>\r\n <soapenv:Body>\r\n <inv:WaybillCreate>\r\n <inv:Authentication>\r\n <inv:Email></inv:Email>\r\n <inv:Token></inv:Token>\r\n </inv:Authentication>\r\n <inv:Client>\r\n <inv:NIF></inv:NIF>\r\n <inv:Name>n</inv:Name> \r\n <inv:Address></inv:Address>\r\n <inv:CountryCode></inv:CountryCode>\r\n </inv:Client>\r\n <inv:Waybill>\r\n <inv:Date></inv:Date>\r\n <inv:Description></inv:Description>\r\n <inv:Type></inv:Type>\r\n <inv:Serie></inv:Serie>\r\n <inv:TaxExemptionReasonCode></inv:TaxExemptionReasonCode>\r\n <inv:Currency></inv:Currency>\r\n <inv:EuroRate></inv:EuroRate>\r\n <inv:Retention></inv:Retention>\r\n <inv:ExternalId></inv:ExternalId>\r\n <inv:Lines>\r\n <inv:APIInvoicingProduct>\r\n <inv:Code></inv:Code>\r\n <inv:Description></inv:Description>\r\n <inv:UnitPrice></inv:UnitPrice>\r\n <inv:Quantity></inv:Quantity>\r\n <inv:Unit></inv:Unit>\r\n <inv:Type></inv:Type>\r\n <inv:TaxValue></inv:TaxValue>\r\n <inv:ProductDiscount></inv:ProductDiscount>\r\n <inv:CostCenter></inv:CostCenter>\r\n </inv:APIInvoicingProduct>\r\n </inv:Lines>\r\n <inv:LoadDateTime></inv:LoadDateTime>\r\n <inv:LoadAddress>\r\n <inv:AddressDetail></inv:AddressDetail>\r\n <inv:City></inv:City>\r\n <inv:PostalCode></inv:PostalCode>\r\n <inv:CountryCode></inv:CountryCode>\r\n </inv:LoadAddress>\r\n <inv:DestinationAddress>\r\n <inv:AddressDetail></inv:AddressDetail>\r\n <inv:City></inv:City>\r\n <inv:PostalCode></inv:PostalCode>\r\n <inv:CountryCode></inv:CountryCode>\r\n </inv:DestinationAddress>\r\n <inv:VehicleLicence></inv:VehicleLicence>\r\n </inv:Waybill>\r\n <inv:IsToClose></inv:IsToClose>\r\n </inv:WaybillCreate>\r\n </soapenv:Body>\r\n</soapenv:Envelope>"; var requestOptions = { method: 'POST', headers: myHeaders, body: raw, redirect: 'follow' }; fetch("https://bo.magnifinance.com/MagniAPI/Invoicing.asmx", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error));


NodeJs (axios)
var axios = require('axios'); var data = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:inv="http://MagniAPI/Invoicing/">\r\n <soapenv:Header/>\r\n <soapenv:Body>\r\n <inv:WaybillCreate>\r\n <inv:Authentication>\r\n <inv:Email>magniteste+101@outlook.pt</inv:Email>\r\n <inv:Token>m3f2xj3ik3odb641oa01</inv:Token>\r\n </inv:Authentication>\r\n <inv:Client>\r\n <inv:NIF>508358647</inv:NIF>\r\n <inv:Name>nome da empreesa</inv:Name> \r\n <inv:Address>Rua das madres 100</inv:Address>\r\n <inv:CountryCode>PT</inv:CountryCode>\r\n </inv:Client>\r\n <inv:Waybill>\r\n <inv:Date>2022-06-21</inv:Date>\r\n <inv:Description>descricao</inv:Description>\r\n <inv:Type>W</inv:Type>\r\n <inv:Serie>W2</inv:Serie>\r\n <inv:TaxExemptionReasonCode></inv:TaxExemptionReasonCode>\r\n <inv:Currency>ALL</inv:Currency>\r\n <inv:EuroRate>1.1</inv:EuroRate>\r\n <inv:Retention>12</inv:Retention>\r\n <inv:ExternalId></inv:ExternalId>\r\n <inv:Lines>\r\n <inv:APIInvoicingProduct>\r\n <inv:Code>554</inv:Code>\r\n <inv:Description>554</inv:Description>\r\n <inv:UnitPrice>10</inv:UnitPrice>\r\n <inv:Quantity>1</inv:Quantity>\r\n <inv:Unit>un</inv:Unit>\r\n <inv:Type>P</inv:Type>\r\n <inv:TaxValue>23</inv:TaxValue>\r\n <inv:ProductDiscount>0</inv:ProductDiscount>\r\n <inv:CostCenter>teste</inv:CostCenter>\r\n </inv:APIInvoicingProduct>\r\n </inv:Lines>\r\n <inv:LoadDateTime>2022-06-21T08:22:54</inv:LoadDateTime>\r\n <inv:LoadAddress>\r\n <inv:AddressDetail>beco mirante</inv:AddressDetail>\r\n <inv:City>lisboa</inv:City>\r\n <inv:PostalCode>1100-353</inv:PostalCode>\r\n <inv:CountryCode>PT</inv:CountryCode>\r\n </inv:LoadAddress>\r\n <inv:DestinationAddress>\r\n <inv:AddressDetail>beco mirante</inv:AddressDetail>\r\n <inv:City>lisboa</inv:City>\r\n <inv:PostalCode>1100-353</inv:PostalCode>\r\n <inv:CountryCode>SPT</inv:CountryCode>\r\n </inv:DestinationAddress>\r\n <inv:VehicleLicence>MD-AD-54</inv:VehicleLicence>\r\n </inv:Waybill>\r\n <inv:IsToClose>true</inv:IsToClose>\r\n </inv:WaybillCreate>\r\n </soapenv:Body>\r\n</soapenv:Envelope>'; var config = { method: 'post', url: 'https://bo.magnifinance.com/MagniAPI/Invoicing.asmx', headers: { 'Host': 'bo.magnifinance.com', 'Content-Type': 'text/xml' }, data : data }; axios(config) .then(function (response) { console.log(JSON.stringify(response.data)); }) .catch(function (error) { console.log(error); }); ;


Example Response


Success

<?xml version="1.0" encoding="utf-8"?> <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> <WaybillCreateResponse xmlns="http://MagniAPI/Invoicing/"> <ResponseWaybillCreate> <RequestId>5ed21421-4b62-4043-95fa-28a73b605163 </RequestId> <Type>Success </Type> <Object> <DocumentId>72569 </DocumentId> <DocumentNumber>GT W2/239 </DocumentNumber> <ATDocCode>????????</ATDocCode> </Object> </ResponseWaybillCreate> </WaybillCreateResponse> </soap:Body> </soap:Envelope>


Error

<?xml version="1.0" encoding="utf-8"?> <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> <WaybillCreateResponse xmlns="http://MagniAPI/Invoicing/"> <ResponseWaybillCreate> <RequestId>e4d9bc16-2631-41b2-aad2-a6e56ee45ff2 </RequestId> <Type>Error </Type> <ErrorValue> <Value>2 </Value> <Name>ValidationError </Name> </ErrorValue> <ErrorHumanReadable>ValidationError </ErrorHumanReadable> <ValidationErrors> <ValidationError> <Type>EmptyField </Type> <ElementNumber>0 </ElementNumber> <Field>DocumentDetailDeliveryCountry </Field> <Detail>Mandatory field </Detail> </ValidationError> </ValidationErrors> </ResponseWaybillCreate> </WaybillCreateResponse> </soap:Body> </soap:Envelope>

Este site usa cookies para melhorar o desempenho e experiência. Ao continuar, declara aceitar todos os cookies. Fechar