{
  "info": {
    "name": "MagniFinance SOAP API - Invoicing & Waybills",
    "description": "Create, read and cancel invoices, credit/debit notes and waybills over SOAP 1.1. Every request already has the envelope, `Content-Type` and `SOAPAction` set.\n\n1. Open the collection's **Variables** tab and fill in `email` and `token` (see https://developer.magnifinance.com/finance/getting-started/authentication/).\n2. Send **DocumentCreate** or **WaybillCreate**. The returned `DocumentId` is stored in the `documentId` variable, so **DocumentGet**, **DocumentGetProperty** and **DocumentCancel** work right after.\n\nDates are filled in at send time (`today`, `dueDate`, `now`).\n\nWSDL: https://bo.magnifinance.com/MagniAPI/Invoicing.asmx?WSDL\nDocs: https://developer.magnifinance.com/finance/invoicing-waybills/soap/",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "baseUrl", "value": "https://bo.magnifinance.com" },
    { "key": "email", "value": "", "description": "Your API user email" },
    { "key": "token", "value": "", "type": "secret", "description": "Your subscription token" },
    { "key": "documentId", "value": "", "description": "Filled in by DocumentCreate / WaybillCreate" }
  ],
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "type": "text/javascript",
        "exec": [
          "const d = new Date();",
          "pm.variables.set('now', d.toISOString().slice(0, 19));",
          "pm.variables.set('today', d.toISOString().slice(0, 10));",
          "d.setDate(d.getDate() + 30);",
          "pm.variables.set('dueDate', d.toISOString().slice(0, 10));"
        ]
      }
    },
    {
      "listen": "test",
      "script": {
        "type": "text/javascript",
        "exec": [
          "pm.test('HTTP 200', () => pm.response.to.have.status(200));",
          "const text = pm.response.text();",
          "const error = (text.match(/<ErrorValue>[\\s\\S]*?<Name>([^<]*)<\\/Name>/) || [])[1] || '';",
          "const detail = (text.match(/<Detail>([^<]*)<\\/Detail>/) || [])[1] || '';",
          "pm.test('Type is Success', () => pm.expect(text, `${error} ${detail}`.trim()).to.include('<Type>Success</Type>'));",
          "const id = text.match(/<DocumentId>(\\d+)<\\/DocumentId>/);",
          "if (id) pm.collectionVariables.set('documentId', id[1]);"
        ]
      }
    }
  ],
  "item": [
    {
      "name": "DocumentCreate",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "text/xml; charset=utf-8" },
          { "key": "SOAPAction", "value": "\"http://MagniAPI/Invoicing/DocumentCreate\"" }
        ],
        "url": { "raw": "{{baseUrl}}/MagniAPI/Invoicing.asmx", "host": ["{{baseUrl}}"], "path": ["MagniAPI", "Invoicing.asmx"] },
        "body": {
          "mode": "raw",
          "options": { "raw": { "language": "xml" } },
          "raw": "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:inv=\"http://MagniAPI/Invoicing/\">\n  <soapenv:Header/>\n  <soapenv:Body>\n    <inv:DocumentCreate>\n      <inv:Authentication>\n        <inv:Email>{{email}}</inv:Email>\n        <inv:Token>{{token}}</inv:Token>\n      </inv:Authentication>\n      <inv:Client>\n        <inv:NIF>166737755</inv:NIF>\n        <inv:Name>MagniFinance</inv:Name>\n        <inv:Address>Av. Sidónio Pais, n.º 2, 2.º Esq. A</inv:Address>\n        <inv:City>Lisboa</inv:City>\n        <inv:PostCode>1050-215</inv:PostCode>\n        <inv:CountryCode>PT</inv:CountryCode>\n        <inv:Email>info@magnifinance.com</inv:Email>\n      </inv:Client>\n      <inv:Document>\n        <inv:Date>{{today}}</inv:Date>\n        <inv:DueDate>{{dueDate}}</inv:DueDate>\n        <inv:Description>Consulting services</inv:Description>\n        <inv:Type>T</inv:Type>\n        <inv:ExternalId>order-{{$timestamp}}</inv:ExternalId>\n        <inv:Lines>\n          <inv:APIInvoicingProduct>\n            <inv:Code>CONSULT-H</inv:Code>\n            <inv:Description>Consulting hour</inv:Description>\n            <inv:UnitPrice>45.00</inv:UnitPrice>\n            <inv:Quantity>2</inv:Quantity>\n            <inv:Unit>Hour</inv:Unit>\n            <inv:Type>S</inv:Type>\n            <inv:TaxValue>23</inv:TaxValue>\n            <inv:ProductDiscount>0</inv:ProductDiscount>\n          </inv:APIInvoicingProduct>\n        </inv:Lines>\n      </inv:Document>\n      <inv:IsToClose>true</inv:IsToClose>\n    </inv:DocumentCreate>\n  </soapenv:Body>\n</soapenv:Envelope>"
        },
        "description": "Creates and closes an invoice-receipt (type `T`). Change `Type` for other document types: https://developer.magnifinance.com/finance/getting-started/appendix/#document-types\n\nDocs: https://developer.magnifinance.com/finance/invoicing-waybills/soap/create-document/"
      }
    },
    {
      "name": "DocumentGet",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "text/xml; charset=utf-8" },
          { "key": "SOAPAction", "value": "\"http://MagniAPI/Invoicing/DocumentGet\"" }
        ],
        "url": { "raw": "{{baseUrl}}/MagniAPI/Invoicing.asmx", "host": ["{{baseUrl}}"], "path": ["MagniAPI", "Invoicing.asmx"] },
        "body": {
          "mode": "raw",
          "options": { "raw": { "language": "xml" } },
          "raw": "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:inv=\"http://MagniAPI/Invoicing/\">\n  <soapenv:Header/>\n  <soapenv:Body>\n    <inv:DocumentGet>\n      <inv:Authentication>\n        <inv:Email>{{email}}</inv:Email>\n        <inv:Token>{{token}}</inv:Token>\n      </inv:Authentication>\n      <inv:DocumentId>{{documentId}}</inv:DocumentId>\n    </inv:DocumentGet>\n  </soapenv:Body>\n</soapenv:Envelope>"
        },
        "description": "Number, PDF link, payment status and details of a document.\n\nDocs: https://developer.magnifinance.com/finance/invoicing-waybills/soap/get-document/"
      }
    },
    {
      "name": "DocumentGetProperty",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "text/xml; charset=utf-8" },
          { "key": "SOAPAction", "value": "\"http://MagniAPI/Invoicing/DocumentGetProperty\"" }
        ],
        "url": { "raw": "{{baseUrl}}/MagniAPI/Invoicing.asmx", "host": ["{{baseUrl}}"], "path": ["MagniAPI", "Invoicing.asmx"] },
        "body": {
          "mode": "raw",
          "options": { "raw": { "language": "xml" } },
          "raw": "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:inv=\"http://MagniAPI/Invoicing/\">\n  <soapenv:Header/>\n  <soapenv:Body>\n    <inv:DocumentGetProperty>\n      <inv:Authentication>\n        <inv:Email>{{email}}</inv:Email>\n        <inv:Token>{{token}}</inv:Token>\n      </inv:Authentication>\n      <inv:DocumentId>{{documentId}}</inv:DocumentId>\n      <inv:DocumentProperty>paymentstatus</inv:DocumentProperty>\n    </inv:DocumentGetProperty>\n  </soapenv:Body>\n</soapenv:Envelope>"
        },
        "description": "Docs: https://developer.magnifinance.com/finance/invoicing-waybills/soap/get-document-property/"
      }
    },
    {
      "name": "DocumentCancel",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "text/xml; charset=utf-8" },
          { "key": "SOAPAction", "value": "\"http://MagniAPI/Invoicing/DocumentCancel\"" }
        ],
        "url": { "raw": "{{baseUrl}}/MagniAPI/Invoicing.asmx", "host": ["{{baseUrl}}"], "path": ["MagniAPI", "Invoicing.asmx"] },
        "body": {
          "mode": "raw",
          "options": { "raw": { "language": "xml" } },
          "raw": "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:inv=\"http://MagniAPI/Invoicing/\">\n  <soapenv:Header/>\n  <soapenv:Body>\n    <inv:DocumentCancel>\n      <inv:Authentication>\n        <inv:Email>{{email}}</inv:Email>\n        <inv:Token>{{token}}</inv:Token>\n      </inv:Authentication>\n      <inv:DocumentId>{{documentId}}</inv:DocumentId>\n    </inv:DocumentCancel>\n  </soapenv:Body>\n</soapenv:Envelope>"
        },
        "description": "Cancels a closed document.\n\nDocs: https://developer.magnifinance.com/finance/invoicing-waybills/soap/cancel-document/"
      }
    },
    {
      "name": "WaybillCreate",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "text/xml; charset=utf-8" },
          { "key": "SOAPAction", "value": "\"http://MagniAPI/Invoicing/WaybillCreate\"" }
        ],
        "url": { "raw": "{{baseUrl}}/MagniAPI/Invoicing.asmx", "host": ["{{baseUrl}}"], "path": ["MagniAPI", "Invoicing.asmx"] },
        "body": {
          "mode": "raw",
          "options": { "raw": { "language": "xml" } },
          "raw": "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:inv=\"http://MagniAPI/Invoicing/\">\n  <soapenv:Header/>\n  <soapenv:Body>\n    <inv:WaybillCreate>\n      <inv:Authentication>\n        <inv:Email>{{email}}</inv:Email>\n        <inv:Token>{{token}}</inv:Token>\n      </inv:Authentication>\n      <inv:Client>\n        <inv:NIF>166737755</inv:NIF>\n        <inv:Name>MagniFinance</inv:Name>\n        <inv:Address>Av. Sidónio Pais, n.º 2, 2.º Esq. A</inv:Address>\n        <inv:City>Lisboa</inv:City>\n        <inv:PostCode>1050-215</inv:PostCode>\n        <inv:CountryCode>PT</inv:CountryCode>\n      </inv:Client>\n      <inv:Waybill>\n        <inv:Date>{{today}}</inv:Date>\n        <inv:Description>Delivery of order 10045</inv:Description>\n        <inv:Type>W</inv:Type>\n        <inv:Lines>\n          <inv:APIInvoicingProduct>\n            <inv:Code>BOX-12</inv:Code>\n            <inv:Description>Box of 12 bottles</inv:Description>\n            <inv:UnitPrice>18.50</inv:UnitPrice>\n            <inv:Quantity>4</inv:Quantity>\n            <inv:Unit>Box</inv:Unit>\n            <inv:Type>P</inv:Type>\n            <inv:TaxValue>23</inv:TaxValue>\n            <inv:ProductDiscount>0</inv:ProductDiscount>\n          </inv:APIInvoicingProduct>\n        </inv:Lines>\n        <inv:LoadDateTime>{{now}}</inv:LoadDateTime>\n        <inv:LoadAddress>\n          <inv:AddressDetail>Rua do Armazém, 10</inv:AddressDetail>\n          <inv:City>Lisboa</inv:City>\n          <inv:PostalCode>1000-001</inv:PostalCode>\n          <inv:CountryCode>PT</inv:CountryCode>\n        </inv:LoadAddress>\n        <inv:DestinationAddress>\n          <inv:AddressDetail>Av. Sidónio Pais, n.º 2, 2.º Esq. A</inv:AddressDetail>\n          <inv:City>Lisboa</inv:City>\n          <inv:PostalCode>1050-215</inv:PostalCode>\n          <inv:CountryCode>PT</inv:CountryCode>\n        </inv:DestinationAddress>\n        <inv:VehicleLicence>AA-16-AA</inv:VehicleLicence>\n      </inv:Waybill>\n      <inv:IsToClose>true</inv:IsToClose>\n    </inv:WaybillCreate>\n  </soapenv:Body>\n</soapenv:Envelope>"
        },
        "description": "Creates and closes a waybill (type `W`; `Y` for a delivery note).\n\nDocs: https://developer.magnifinance.com/finance/invoicing-waybills/soap/create-waybill/"
      }
    },
    {
      "name": "ClientGet",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "text/xml; charset=utf-8" },
          { "key": "SOAPAction", "value": "\"http://MagniAPI/Invoicing/ClientGet\"" }
        ],
        "url": { "raw": "{{baseUrl}}/MagniAPI/Invoicing.asmx", "host": ["{{baseUrl}}"], "path": ["MagniAPI", "Invoicing.asmx"] },
        "body": {
          "mode": "raw",
          "options": { "raw": { "language": "xml" } },
          "raw": "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:inv=\"http://MagniAPI/Invoicing/\">\n  <soapenv:Header/>\n  <soapenv:Body>\n    <inv:ClientGet>\n      <inv:Authentication>\n        <inv:Email>{{email}}</inv:Email>\n        <inv:Token>{{token}}</inv:Token>\n      </inv:Authentication>\n      <inv:TaxId>599138645</inv:TaxId>\n      <inv:CountryCode>PT</inv:CountryCode>\n    </inv:ClientGet>\n  </soapenv:Body>\n</soapenv:Envelope>"
        },
        "description": "Docs: https://developer.magnifinance.com/finance/invoicing-waybills/soap/get-client/"
      }
    }
  ]
}
