{
  "info": {
    "name": "Aigentrix – E-Invoice Entry (External API)",
    "_postman_id": "aigentrix-einvoice-external-v1",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "description": "Full E-Invoice API collection using the External Gateway (X-API-KEY header).\n\nAuthentication: set the 'apiKey' collection variable to your API key.\n\nVariables to configure:\n  baseUrl   — e.g. http://localhost:8095\n  apiKey    — your X-API-KEY value\n  companyId — your company ID\n  entryId   — an existing entry ID (for GET / PUT / DELETE / PDF)"
  },
  "variable": [
    { "key": "baseUrl",   "value": "http://localhost:8095", "type": "string" },
    { "key": "apiKey",    "value": "<your-api-key>",        "type": "string" },
    { "key": "companyId", "value": "1",                     "type": "string" },
    { "key": "entryId",   "value": "1",                     "type": "string" }
  ],
  "item": [
    {
      "name": "1. Create E-Invoice Entry (Full JSON)",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "application/json" },
          { "key": "X-API-KEY",    "value": "{{apiKey}}" }
        ],
        "url": {
          "raw": "{{baseUrl}}/external/api/v1/eInvoiceEntry/createFull",
          "host": ["{{baseUrl}}"],
          "path": ["external", "api", "v1", "eInvoiceEntry", "createFull"]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"companyId\": {{companyId}},\n  \"invoiceRef\": \"INV-001\",\n\n  \"documentId\":                 \"INV-2024-001\",\n  \"issueDate\":                  \"2024-01-15\",\n  \"invoiceTypeCode\":            \"380\",\n  \"invoiceTransactionType\":     \"B2B\",\n  \"documentCurrencyCode\":       \"AED\",\n  \"noteEN\":                     \"Standard invoice\",\n  \"taxPointDate\":               \"2024-01-15\",\n  \"invoiceSupplyDate\":          \"2024-01-14\",\n  \"paymentDueDate\":             \"2024-02-15\",\n  \"orderReference\":             \"PO-2024-001\",\n  \"contractDocumentReference\":  \"CTR-001\",\n  \"originalInvoiceReference\":   null,\n  \"originalInvoiceReferenceDate\": null,\n  \"buyerReference\":             \"BR-001\",\n  \"invoicePeriodStartDate\":     \"2024-01-01\",\n  \"invoicePeriodEndDate\":       \"2024-01-31\",\n\n  \"sellerName\":                 \"ABC Trading LLC\",\n  \"sellerVatTrn\":               \"100123456700003\",\n  \"sellerVatScheme\":            \"VAT\",\n  \"sellerRegisteredName\":       \"ABC Trading LLC\",\n  \"sellerAddressLine1\":         \"Office 101, Business Bay\",\n  \"sellerAddressLine2\":         null,\n  \"sellerCity\":                 \"Dubai\",\n  \"sellerPostalZone\":           \"00000\",\n  \"sellerCountrySubdivision\":   \"DU\",\n  \"sellerCountryCode\":          \"AE\",\n  \"sellerTelephone\":            \"+971501234567\",\n  \"sellerEmail\":                \"info@abctrading.ae\",\n  \"sellerPoBox\":                \"12345\",\n\n  \"buyerName\":                  \"XYZ Corp\",\n  \"buyerVatTrn\":                \"100987654300003\",\n  \"buyerVatScheme\":             \"VAT\",\n  \"buyerRegisteredName\":        \"XYZ Corporation\",\n  \"buyerAddressLine1\":          \"Floor 5, DIFC Gate Building\",\n  \"buyerAddressLine2\":          null,\n  \"buyerCity\":                  \"Dubai\",\n  \"buyerPostalZone\":            \"00000\",\n  \"buyerCountrySubdivision\":    \"DU\",\n  \"buyerCountryCode\":           \"AE\",\n  \"buyerTelephone\":             \"+971507654321\",\n  \"buyerEmail\":                 \"ap@xyzcorp.ae\",\n  \"buyerPoBox\":                 null,\n  \"buyerContact\":               \"John Doe\",\n\n  \"lineExtensionTotal\":         1000.00,\n  \"docLevelDiscount\":           50.00,\n  \"docLevelCharges\":            0.00,\n  \"taxAmount\":                  47.50,\n  \"totalIncludingTax\":          997.50,\n  \"payableAmount\":              997.50,\n  \"roundingAmount\":             0.00,\n\n  \"accountingCost\":             null,\n  \"specialTaxTreatment\":        null,\n  \"despatchDocRef\":             null,\n  \"receiptDocRef\":              null,\n  \"projectDocRef\":              null,\n  \"originatorDocRef\":           null,\n\n  \"prepaidAmount\":              null,\n  \"taxCurrencyCode\":            null,\n  \"vatInAccountingCurrency\":    null,\n  \"exchangeRate\":               null,\n  \"totalInLocalCurrency\":       null,\n\n  \"deliveryLocation\":           \"Warehouse A\",\n  \"deliveryAddressLine1\":       \"Jebel Ali Free Zone\",\n  \"deliveryAddressLine2\":       null,\n  \"deliveryAddressLine3\":       null,\n  \"deliveryCity\":               \"Dubai\",\n  \"deliveryPostalZone\":         \"15000\",\n  \"deliveryCountrySubdivision\": \"DU\",\n  \"deliveryCountryCode\":        \"AE\",\n  \"deliverySchemeId\":           null,\n  \"deliveryPartyId\":            null,\n  \"deliveryPartyName\":          \"XYZ Corp Warehouse\",\n  \"deliveryIncoterms\":          \"DDP\",\n\n  \"taxRepName\":                 null,\n  \"taxRepAddressLine1\":         null,\n  \"taxRepAddressLine2\":         null,\n  \"taxRepAddressLine3\":         null,\n  \"taxRepCity\":                 null,\n  \"taxRepPostalZone\":           null,\n  \"taxRepCountrySubdivision\":   null,\n  \"taxRepCountryCode\":          null,\n  \"taxRepTaxScheme\":            null,\n  \"taxRepTaxId\":                null,\n\n  \"supplierParticipantId\":      null,\n  \"customerParticipantId\":      null,\n\n  \"lines\": [\n    {\n      \"lineNumber\":            1,\n      \"itemName\":              \"Consulting Services\",\n      \"itemDescription\":       \"Monthly IT consulting - Jan 2024\",\n      \"sellerItemId\":          \"SVC-001\",\n      \"itemTypeGoodsServices\": \"S\",\n      \"itemCountryOrigin\":     \"AE\",\n      \"quantity\":              10,\n      \"quantityUom\":           \"HUR\",\n      \"unitPrice\":             95.00,\n      \"priceBaseQty\":          1,\n      \"priceBaseQtyUom\":       \"HUR\",\n      \"lineDiscountAmount\":    50.00,\n      \"lineDiscountPercent\":   5.26,\n      \"lineChargeAmount\":      0,\n      \"lineNetAmount\":         900.00,\n      \"taxCategory\":           \"S\",\n      \"taxRatePercent\":        5,\n      \"taxScheme\":             \"VAT\",\n      \"lineTaxAmount\":         45.00,\n      \"inclVatAmount\":         945.00,\n      \"rcmCode\":               null,\n      \"accountingCost\":        null,\n      \"orderLineRef\":          \"PO-2024-001-L1\",\n      \"periodStart\":           \"2024-01-01\",\n      \"periodEnd\":             \"2024-01-31\",\n      \"vatExemptReasonCode\":   null,\n      \"vatExemptReasonText\":   null\n    },\n    {\n      \"lineNumber\":            2,\n      \"itemName\":              \"Software License\",\n      \"itemDescription\":       \"Annual software license fee\",\n      \"sellerItemId\":          \"SW-LIC-001\",\n      \"itemTypeGoodsServices\": \"S\",\n      \"itemCountryOrigin\":     \"AE\",\n      \"quantity\":              1,\n      \"quantityUom\":           \"ANN\",\n      \"unitPrice\":             100.00,\n      \"priceBaseQty\":          1,\n      \"priceBaseQtyUom\":       \"ANN\",\n      \"lineDiscountAmount\":    0,\n      \"lineDiscountPercent\":   0,\n      \"lineChargeAmount\":      0,\n      \"lineNetAmount\":         100.00,\n      \"taxCategory\":           \"S\",\n      \"taxRatePercent\":        5,\n      \"taxScheme\":             \"VAT\",\n      \"lineTaxAmount\":         5.00,\n      \"inclVatAmount\":         105.00,\n      \"rcmCode\":               null,\n      \"accountingCost\":        null,\n      \"orderLineRef\":          null,\n      \"periodStart\":           null,\n      \"periodEnd\":             null,\n      \"vatExemptReasonCode\":   null,\n      \"vatExemptReasonText\":   null\n    }\n  ],\n\n  \"allowances\": [\n    {\n      \"level\":               \"Header\",\n      \"lineNumber\":          null,\n      \"isCharge\":            false,\n      \"reasonCode\":          \"95\",\n      \"reason\":              \"Promotional discount\",\n      \"amount\":              50.00,\n      \"baseAmount\":          1000.00,\n      \"percent\":             5,\n      \"taxCategory\":         \"S\",\n      \"taxPercent\":          5,\n      \"taxScheme\":           \"VAT\",\n      \"taxExemptReasonCode\": null,\n      \"taxExemptReason\":     null\n    }\n  ],\n\n  \"payments\": [\n    {\n      \"paymentMeansCode\":   \"30\",\n      \"paymentId\":          \"PAY-001\",\n      \"remittanceInfo\":     null,\n      \"creditAccountIban\":  \"AE070331234567890123456\",\n      \"creditAccountScheme\": \"IBAN\",\n      \"creditAccountName\":  \"ABC Trading LLC\",\n      \"cardNumberLast4\":    null,\n      \"cardHolderName\":     null,\n      \"bankBicSwift\":       \"CBAUAEADXXX\",\n      \"bankAddressLine1\":   \"Commercial Bank of Dubai, Main Branch\",\n      \"bankCity\":           \"Dubai\",\n      \"bankCountry\":        \"AE\",\n      \"mandateReferenceId\": null\n    }\n  ],\n\n  \"terms\": [\n    {\n      \"termId\":          \"TERM-001\",\n      \"termNote\":        \"Net 30 days\",\n      \"termAmount\":      997.50,\n      \"termCurrency\":    \"AED\",\n      \"termInstallDate\": \"2024-02-15\"\n    }\n  ]\n}"
        },
        "description": "Creates a full e-invoice entry with lines, allowances, payments, and terms in a single JSON call.\nAll dates: yyyy-MM-dd. For taxCategory='E' the vatExemptReasonCode is mandatory ([ibr-167-ae]).\n\nPeppol routing:\n  supplierParticipantId — seller's Peppol participant ID (e.g. '0088:1234567890123')\n  customerParticipantId — buyer's Peppol participant ID (e.g. '0088:9876543210987')\n  Both fields are optional (nullable)."
      },
      "response": [
        {
          "name": "Success",
          "status": "OK",
          "code": 200,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "body": "{\n  \"success\":           true,\n  \"invoiceRef\":        \"INV-001\",\n  \"entryId\":           1042,\n  \"documentId\":        \"INV-2024-001\",\n  \"linesCreated\":      2,\n  \"allowancesCreated\": 1,\n  \"paymentsCreated\":   1,\n  \"termsCreated\":      1\n}",
          "_postman_previewlanguage": "json"
        },
        {
          "name": "Validation Error (ibr-167-ae)",
          "status": "Bad Request",
          "code": 400,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "body": "{\n  \"success\": false,\n  \"error\": \"[ibr-167-ae] Line 1: vatExemptReasonCode is mandatory when taxCategory is 'E'.\"\n}",
          "_postman_previewlanguage": "json"
        },
        {
          "name": "Unauthorized",
          "status": "Unauthorized",
          "code": 401,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "body": "{\n  \"errorKey\": \"API key missing\"\n}",
          "_postman_previewlanguage": "json"
        }
      ]
    },
    {
      "name": "2. Get E-Invoice Entry by ID",
      "request": {
        "method": "GET",
        "header": [
          { "key": "X-API-KEY", "value": "{{apiKey}}" }
        ],
        "url": {
          "raw": "{{baseUrl}}/external/api/v1/eInvoiceEntry/{{entryId}}",
          "host": ["{{baseUrl}}"],
          "path": ["external", "api", "v1", "eInvoiceEntry", "{{entryId}}"]
        },
        "description": "Retrieves the full EInvoiceEntry response DTO for the given entry ID."
      },
      "response": [
        {
          "name": "Success",
          "status": "OK",
          "code": 200,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "body": "{\n  \"id\":                       1042,\n  \"documentIdEN\":             \"INV-2024-001\",\n  \"invoiceTypeCode\":          \"380\",\n  \"documentCurrencyCode\":     \"AED\",\n  \"issueDateEN\":              \"2024-01-15T00:00:00\",\n  \"paymentDueDate\":           \"2024-02-15T00:00:00\",\n  \"status\":                   \"DRAFT\",\n  \"taxStatus\":                \"NOT_INITIATED\",\n  \"supplyPartyNameEN\":        \"ABC Trading LLC\",\n  \"supplyVatIdEN\":            \"100123456700003\",\n  \"customerPartyNameEN\":      \"XYZ Corp\",\n  \"customerVatIdEN\":          \"100987654300003\",\n  \"legalTaxInclusiveAmountEN\": 997.50,\n  \"legalFinalPayableEN\":       997.50,\n  \"taxTotalTaxAmount\":         47.50,\n  \"createdAt\":                \"2024-01-15T10:30:00\"\n}",
          "_postman_previewlanguage": "json"
        }
      ]
    },
    {
      "name": "3. List E-Invoice Entries",
      "request": {
        "method": "GET",
        "header": [
          { "key": "X-API-KEY", "value": "{{apiKey}}" }
        ],
        "url": {
          "raw": "{{baseUrl}}/external/api/v1/eInvoiceEntry?companyId={{companyId}}&startDate=2024-01-01&endDate=2024-12-31&page=0&perPage=10&sortBy=createdAt&orderBy=desc",
          "host": ["{{baseUrl}}"],
          "path": ["external", "api", "v1", "eInvoiceEntry"],
          "query": [
            { "key": "companyId",    "value": "{{companyId}}" },
            { "key": "startDate",    "value": "2024-01-01" },
            { "key": "endDate",      "value": "2024-12-31" },
            { "key": "page",         "value": "0" },
            { "key": "perPage",      "value": "10" },
            { "key": "sortBy",       "value": "createdAt" },
            { "key": "orderBy",      "value": "desc" },
            { "key": "status",       "value": "DRAFT",   "disabled": true },
            { "key": "type",         "value": "OUTBOUND","disabled": true },
            { "key": "searchString", "value": "",        "disabled": true }
          ]
        },
        "description": "Paginated list of entries. Enable optional query params as needed."
      },
      "response": [
        {
          "name": "Success",
          "status": "OK",
          "code": 200,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "body": "{\n  \"content\": [\n    {\n      \"id\":                  1042,\n      \"documentIdEN\":        \"INV-2024-001\",\n      \"status\":              \"DRAFT\",\n      \"issueDateEN\":         \"2024-01-15T00:00:00\",\n      \"supplyPartyNameEN\":   \"ABC Trading LLC\",\n      \"customerPartyNameEN\": \"XYZ Corp\",\n      \"legalFinalPayableEN\": 997.50\n    }\n  ],\n  \"totalElements\": 1,\n  \"totalPages\":    1,\n  \"pageNumber\":    0,\n  \"pageSize\":      10\n}",
          "_postman_previewlanguage": "json"
        }
      ]
    },
    {
      "name": "4. Status Timeline",
      "request": {
        "method": "GET",
        "header": [
          { "key": "X-API-KEY", "value": "{{apiKey}}" }
        ],
        "url": {
          "raw": "{{baseUrl}}/external/api/v1/eInvoiceEntry/{{entryId}}/statusTimeline?type=OUTBOUND",
          "host": ["{{baseUrl}}"],
          "path": ["external", "api", "v1", "eInvoiceEntry", "{{entryId}}", "statusTimeline"],
          "query": [
            { "key": "type", "value": "OUTBOUND", "description": "OUTBOUND or INBOUND" }
          ]
        },
        "description": "Returns the full status transition history. type must be OUTBOUND or INBOUND."
      },
      "response": [
        {
          "name": "Success",
          "status": "OK",
          "code": 200,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "body": "{\n  \"statusTimeline\": {\n    \"entryId\":    1042,\n    \"documentId\": \"INV-2024-001\",\n    \"type\":       \"OUTBOUND\",\n    \"timeline\": [\n      { \"status\": \"DRAFT\",     \"timestamp\": \"2024-01-15T10:30:00\", \"updatedBy\": \"user@example.com\" },\n      { \"status\": \"VALID\",     \"timestamp\": \"2024-01-15T10:35:00\", \"updatedBy\": \"system\" },\n      { \"status\": \"SUBMITTED\", \"timestamp\": \"2024-01-15T10:36:00\", \"updatedBy\": \"system\" }\n    ]\n  }\n}",
          "_postman_previewlanguage": "json"
        }
      ]
    },
    {
      "name": "5. PDF Download (Peppol)",
      "request": {
        "method": "GET",
        "header": [
          { "key": "X-API-KEY", "value": "{{apiKey}}" }
        ],
        "url": {
          "raw": "{{baseUrl}}/external/api/v1/print/xml/{{entryId}}?fileName=outbound_sent",
          "host": ["{{baseUrl}}"],
          "path": ["external", "api", "v1", "print", "xml", "{{entryId}}"],
          "query": [
            {
              "key": "fileName",
              "value": "outbound_sent",
              "description": "Document type: outbound_sent | outbound_ack | outbound_report_fta | outbound_confirm_fta | inbound_receive | inbound_ack | inbound_report_fta | inbound_confirm_fta"
            }
          ]
        },
        "description": "Generates and streams the Peppol e-invoice as a PDF (via Jasper Reports). Save the response body as a .pdf file.\n\nSupported fileName values:\n  outbound_sent, outbound_ack, outbound_report_fta, outbound_confirm_fta,\n  inbound_receive, inbound_ack, inbound_report_fta, inbound_confirm_fta"
      },
      "response": [
        {
          "name": "Success (binary PDF)",
          "status": "OK",
          "code": 200,
          "header": [
            { "key": "Content-Type",        "value": "application/pdf" },
            { "key": "Content-Disposition", "value": "attachment; filename=\"outbound_sent_1042.pdf\"" }
          ],
          "body": "",
          "_postman_previewlanguage": "text"
        },
        {
          "name": "Not Found",
          "status": "Not Found",
          "code": 404,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "body": "{\n  \"errorKey\": \"Document not found for entryId: 1042 with fileName: outbound_sent\"\n}",
          "_postman_previewlanguage": "json"
        }
      ]
    },
    {
      "name": "6. Download Raw XML",
      "request": {
        "method": "GET",
        "header": [
          { "key": "X-API-KEY", "value": "{{apiKey}}" }
        ],
        "url": {
          "raw": "{{baseUrl}}/external/api/v1/print/orgxml/{{entryId}}?fileName=outbound_sent",
          "host": ["{{baseUrl}}"],
          "path": ["external", "api", "v1", "print", "orgxml", "{{entryId}}"],
          "query": [
            {
              "key": "fileName",
              "value": "outbound_sent",
              "description": "Document type: outbound_sent | outbound_ack | outbound_report_fta | outbound_confirm_fta | inbound_receive | inbound_ack | inbound_report_fta | inbound_confirm_fta"
            }
          ]
        },
        "description": "Downloads the raw (pretty-printed) Peppol XML file stored in OCI for the given entry. Save the response body as a .xml file.\n\nSupported fileName values:\n  outbound_sent, outbound_ack, outbound_report_fta, outbound_confirm_fta,\n  inbound_receive, inbound_ack, inbound_report_fta, inbound_confirm_fta"
      },
      "response": [
        {
          "name": "Success (XML)",
          "status": "OK",
          "code": 200,
          "header": [
            { "key": "Content-Type",        "value": "application/xml; charset=UTF-8" },
            { "key": "Content-Disposition", "value": "attachment; filename=\"outbound_sent_1042.xml\"" }
          ],
          "body": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Invoice xmlns=\"urn:oasis:names:specification:ubl:schema:xsd:Invoice-2\"\n         xmlns:cac=\"urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2\"\n         xmlns:cbc=\"urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2\">\n  <cbc:UBLVersionID>2.1</cbc:UBLVersionID>\n  <cbc:CustomizationID>urn:cen.eu:en16931:2017#conformant#urn:fdc:peppol.eu:2017:poacc:billing:international:ubl:3.0</cbc:CustomizationID>\n  <cbc:ID>INV-2024-001</cbc:ID>\n  <cbc:IssueDate>2024-01-15</cbc:IssueDate>\n  ...\n</Invoice>",
          "_postman_previewlanguage": "xml"
        },
        {
          "name": "Not Found",
          "status": "Not Found",
          "code": 404,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "body": "{\n  \"errorKey\": \"Document not found for entryId: 1042 with fileName: outbound_sent\"\n}",
          "_postman_previewlanguage": "json"
        }
      ]
    },
    {
      "name": "7. Update E-Invoice Entry",
      "request": {
        "method": "PUT",
        "header": [
          { "key": "Content-Type", "value": "application/json" },
          { "key": "X-API-KEY",    "value": "{{apiKey}}" }
        ],
        "url": {
          "raw": "{{baseUrl}}/external/api/v1/eInvoiceEntry/{{entryId}}",
          "host": ["{{baseUrl}}"],
          "path": ["external", "api", "v1", "eInvoiceEntry", "{{entryId}}"]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"status\": \"SUBMITTED\" \n}"
        },
        "description": "Updates header fields of an existing DRAFT or VALIDATION_FAILED entry."
      },
      "response": [
        {
          "name": "Success",
          "status": "OK",
          "code": 200,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "body": "{\n  \"id\":           1042,\n  \"documentIdEN\": \"INV-2024-001-REV\",\n  \"status\":       \"DRAFT\"\n}",
          "_postman_previewlanguage": "json"
        }
      ]
    },
    {
      "name": "8. Delete E-Invoice Entries",
      "request": {
        "method": "DELETE",
        "header": [
          { "key": "Content-Type", "value": "application/json" },
          { "key": "X-API-KEY",    "value": "{{apiKey}}" }
        ],
        "url": {
          "raw": "{{baseUrl}}/external/api/v1/eInvoiceEntry",
          "host": ["{{baseUrl}}"],
          "path": ["external", "api", "v1", "eInvoiceEntry"]
        },
        "body": {
          "mode": "raw",
          "raw": "[{{entryId}}]"
        },
        "description": "Deletes one or more entries by ID."
      },
      "response": [
        {
          "name": "Success",
          "status": "OK",
          "code": 200,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "body": "{\n  \"deleted\": 1,\n  \"success\": true\n}",
          "_postman_previewlanguage": "json"
        }
      ]
    },
    {
      "name": "9. Bulk Upload (Excel)",
      "request": {
        "method": "POST",
        "header": [
          { "key": "X-API-KEY", "value": "{{apiKey}}" }
        ],
        "url": {
          "raw": "{{baseUrl}}/external/api/v1/eInvoiceEntry/upload",
          "host": ["{{baseUrl}}"],
          "path": ["external", "api", "v1", "eInvoiceEntry", "upload"]
        },
        "body": {
          "mode": "formdata",
          "formdata": [
            { "key": "companyId", "value": "{{companyId}}", "type": "text" },
            { "key": "file",      "type": "file", "src": "", "description": "Select sample_einvoice_entry.xlsx" }
          ]
        },
        "description": "Bulk-creates invoices from the Excel template. Existing DRAFT/VALIDATION_FAILED/REJECTED entries with matching companyId+documentId are overwritten."
      },
      "response": [
        {
          "name": "Success",
          "status": "OK",
          "code": 200,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "body": "{\n  \"success\":        true,\n  \"totalProcessed\": 3,\n  \"totalSuccess\":   2,\n  \"totalFailed\":    1,\n  \"results\": [\n    { \"invoiceRef\": \"INV-001\", \"status\": \"SUCCESS\",     \"entryId\": 1042, \"linesCreated\": 2, \"allowancesCreated\": 1, \"paymentsCreated\": 1 },\n    { \"invoiceRef\": \"INV-002\", \"status\": \"OVERWRITTEN\", \"entryId\": 1001, \"linesCreated\": 3, \"allowancesCreated\": 0, \"paymentsCreated\": 1 },\n    { \"invoiceRef\": \"INV-003\", \"status\": \"SKIPPED\",     \"error\": \"Entry already exists with status SUBMITTED\" }\n  ]\n}",
          "_postman_previewlanguage": "json"
        }
      ]
    },
    {
      "name": "10. Download Upload Template",
      "request": {
        "method": "GET",
        "header": [
          { "key": "X-API-KEY", "value": "{{apiKey}}" }
        ],
        "url": {
          "raw": "{{baseUrl}}/external/api/v1/eInvoiceEntry/upload/template",
          "host": ["{{baseUrl}}"],
          "path": ["external", "api", "v1", "eInvoiceEntry", "upload", "template"]
        },
        "description": "Downloads sample_einvoice_entry.xlsx. Save the response body as a .xlsx file."
      }
    },
    {
      "name": "11. Download Error Log (CSV)",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "application/json" },
          { "key": "X-API-KEY",    "value": "{{apiKey}}" }
        ],
        "url": {
          "raw": "{{baseUrl}}/external/api/v1/eInvoiceEntry/upload/errorLog",
          "host": ["{{baseUrl}}"],
          "path": ["external", "api", "v1", "eInvoiceEntry", "upload", "errorLog"]
        },
        "body": {
          "mode": "raw",
          "raw": "[\n  { \"invoiceRef\": \"INV-001\", \"status\": \"SUCCESS\",  \"entryId\": 1042, \"linesCreated\": 2, \"allowancesCreated\": 1, \"paymentsCreated\": 1 },\n  { \"invoiceRef\": \"INV-003\", \"status\": \"SKIPPED\",  \"error\": \"Entry already exists with status SUBMITTED\" },\n  { \"invoiceRef\": \"INV-004\", \"status\": \"FAILED\",   \"error\": \"[ibr-167-ae] Line 1: vatExemptReasonCode is mandatory when taxCategory is 'E'.\" }\n]"
        },
        "description": "Pass the results array from a /upload response to receive a CSV error log download."
      },
      "response": [
        {
          "name": "CSV Download",
          "status": "OK",
          "code": 200,
          "header": [
            { "key": "Content-Type",        "value": "text/csv" },
            { "key": "Content-Disposition", "value": "attachment; filename=\"einvoice_upload_errors.csv\"" }
          ],
          "body": "invoiceRef,status,entryId,linesCreated,allowancesCreated,paymentsCreated,error\nINV-001,SUCCESS,1042,2,1,1,\nINV-003,SKIPPED,,,,,Entry already exists with status SUBMITTED\nINV-004,FAILED,,,,,\"[ibr-167-ae] Line 1: vatExemptReasonCode is mandatory when taxCategory is 'E'.\"",
          "_postman_previewlanguage": "text"
        }
      ]
    },
    {
      "name": "12. Validate Invoices – JSON (no DB write)",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "application/json" },
          { "key": "X-API-KEY",    "value": "{{apiKey}}" }
        ],
        "url": {
          "raw": "{{baseUrl}}/external/api/v1/eInvoiceEntry/validate",
          "host": ["{{baseUrl}}"],
          "path": ["external", "api", "v1", "eInvoiceEntry", "validate"],
          "query": [
            {
              "key": "includeXml",
              "value": "true",
              "description": "Set to true to receive the generated UBL XML per result",
              "disabled": true
            }
          ]
        },
        "body": {
          "mode": "raw",
          "raw": "[\n  {\n    \"companyId\": {{companyId}},\n    \"invoiceRef\": \"INV-001\",\n\n    \"documentId\":                 \"INV-2024-001\",\n    \"issueDate\":                  \"2024-01-15\",\n    \"invoiceTypeCode\":            \"380\",\n    \"invoiceTransactionType\":     \"B2B\",\n    \"documentCurrencyCode\":       \"AED\",\n    \"noteEN\":                     \"Standard invoice\",\n    \"taxPointDate\":               \"2024-01-15\",\n    \"invoiceSupplyDate\":          \"2024-01-14\",\n    \"paymentDueDate\":             \"2024-02-15\",\n    \"orderReference\":             \"PO-2024-001\",\n    \"contractDocumentReference\":  \"CTR-001\",\n    \"buyerReference\":             \"BR-001\",\n    \"invoicePeriodStartDate\":     \"2024-01-01\",\n    \"invoicePeriodEndDate\":       \"2024-01-31\",\n\n    \"sellerName\":                 \"ABC Trading LLC\",\n    \"sellerVatTrn\":               \"100123456700003\",\n    \"sellerVatScheme\":            \"VAT\",\n    \"sellerRegisteredName\":       \"ABC Trading LLC\",\n    \"sellerAddressLine1\":         \"Office 101, Business Bay\",\n    \"sellerCity\":                 \"Dubai\",\n    \"sellerPostalZone\":           \"00000\",\n    \"sellerCountrySubdivision\":   \"DU\",\n    \"sellerCountryCode\":          \"AE\",\n    \"sellerTelephone\":            \"+971501234567\",\n    \"sellerEmail\":                \"info@abctrading.ae\",\n\n    \"buyerName\":                  \"XYZ Corp\",\n    \"buyerVatTrn\":                \"100987654300003\",\n    \"buyerVatScheme\":             \"VAT\",\n    \"buyerRegisteredName\":        \"XYZ Corporation\",\n    \"buyerAddressLine1\":          \"Floor 5, DIFC Gate Building\",\n    \"buyerCity\":                  \"Dubai\",\n    \"buyerPostalZone\":            \"00000\",\n    \"buyerCountrySubdivision\":    \"DU\",\n    \"buyerCountryCode\":           \"AE\",\n    \"buyerTelephone\":             \"+971507654321\",\n    \"buyerEmail\":                 \"ap@xyzcorp.ae\",\n\n    \"lineExtensionTotal\":         1000.00,\n    \"docLevelDiscount\":           50.00,\n    \"docLevelCharges\":            0.00,\n    \"taxAmount\":                  47.50,\n    \"totalIncludingTax\":          997.50,\n    \"payableAmount\":              997.50,\n    \"roundingAmount\":             0.00,\n\n    \"deliveryLocation\":           \"Warehouse A\",\n    \"deliveryAddressLine1\":       \"Jebel Ali Free Zone\",\n    \"deliveryCity\":               \"Dubai\",\n    \"deliveryPostalZone\":         \"15000\",\n    \"deliveryCountrySubdivision\": \"DU\",\n    \"deliveryCountryCode\":        \"AE\",\n    \"deliveryPartyName\":          \"XYZ Corp Warehouse\",\n    \"deliveryIncoterms\":          \"DDP\",\n\n    \"lines\": [\n      {\n        \"lineNumber\":            1,\n        \"itemName\":              \"Consulting Services\",\n        \"itemDescription\":       \"Monthly IT consulting - Jan 2024\",\n        \"sellerItemId\":          \"SVC-001\",\n        \"itemTypeGoodsServices\": \"S\",\n        \"itemCountryOrigin\":     \"AE\",\n        \"quantity\":              10,\n        \"quantityUom\":           \"HUR\",\n        \"unitPrice\":             95.00,\n        \"priceBaseQty\":          1,\n        \"priceBaseQtyUom\":       \"HUR\",\n        \"lineDiscountAmount\":    50.00,\n        \"lineDiscountPercent\":   5.26,\n        \"lineNetAmount\":         900.00,\n        \"taxCategory\":           \"S\",\n        \"taxRatePercent\":        5,\n        \"taxScheme\":             \"VAT\",\n        \"lineTaxAmount\":         45.00,\n        \"inclVatAmount\":         945.00\n      },\n      {\n        \"lineNumber\":            2,\n        \"itemName\":              \"Software License\",\n        \"itemDescription\":       \"Annual software license fee\",\n        \"sellerItemId\":          \"SW-LIC-001\",\n        \"itemTypeGoodsServices\": \"S\",\n        \"itemCountryOrigin\":     \"AE\",\n        \"quantity\":              1,\n        \"quantityUom\":           \"ANN\",\n        \"unitPrice\":             100.00,\n        \"priceBaseQty\":          1,\n        \"priceBaseQtyUom\":       \"ANN\",\n        \"lineDiscountAmount\":    0,\n        \"lineNetAmount\":         100.00,\n        \"taxCategory\":           \"S\",\n        \"taxRatePercent\":        5,\n        \"taxScheme\":             \"VAT\",\n        \"lineTaxAmount\":         5.00,\n        \"inclVatAmount\":         105.00\n      }\n    ],\n\n    \"allowances\": [\n      {\n        \"level\":               \"Header\",\n        \"isCharge\":            false,\n        \"reasonCode\":          \"95\",\n        \"reason\":              \"Promotional discount\",\n        \"amount\":              50.00,\n        \"baseAmount\":          1000.00,\n        \"percent\":             5,\n        \"taxCategory\":         \"S\",\n        \"taxPercent\":          5,\n        \"taxScheme\":           \"VAT\"\n      }\n    ],\n\n    \"payments\": [\n      {\n        \"paymentMeansCode\":    \"30\",\n        \"paymentId\":           \"PAY-001\",\n        \"creditAccountIban\":   \"AE070331234567890123456\",\n        \"creditAccountScheme\": \"IBAN\",\n        \"creditAccountName\":   \"ABC Trading LLC\",\n        \"bankBicSwift\":        \"CBAUAEADXXX\",\n        \"bankAddressLine1\":    \"Commercial Bank of Dubai, Main Branch\",\n        \"bankCity\":            \"Dubai\",\n        \"bankCountry\":         \"AE\"\n      }\n    ],\n\n    \"terms\": [\n      {\n        \"termId\":          \"TERM-001\",\n        \"termNote\":        \"Net 30 days\",\n        \"termAmount\":      997.50,\n        \"termCurrency\":    \"AED\",\n        \"termInstallDate\": \"2024-02-15\"\n      }\n    ]\n  }\n]"
        },
        "description": "Validates one or more invoices against Peppol schematron rules WITHOUT creating any database records.\n\nRequest body: JSON array of invoice objects (same shape as /createFull, wrapped in [ ]).\n\nOptional query parameter:\n  includeXml=true — returns the generated UBL XML per result.\n\nResponse:\n{\n  \"validatedAt\":   \"2024-01-15T10:30:00\",\n  \"totalInvoices\": 1,\n  \"passedCount\":   1,\n  \"failedCount\":   0,\n  \"results\":       [...]\n}"
      },
      "response": [
        {
          "name": "All Passed",
          "status": "OK",
          "code": 200,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "body": "{\n  \"validatedAt\":   \"2024-01-15T10:30:00\",\n  \"totalInvoices\": 1,\n  \"passedCount\":   1,\n  \"failedCount\":   0,\n  \"results\": [\n    {\n      \"invoiceRef\":  \"INV-001\",\n      \"documentId\": \"INV-2024-001\",\n      \"passed\":      true,\n      \"errors\":      [],\n      \"warnings\":    []\n    }\n  ]\n}",
          "_postman_previewlanguage": "json"
        },
        {
          "name": "Validation Failed",
          "status": "OK",
          "code": 200,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "body": "{\n  \"validatedAt\":   \"2024-01-15T10:30:00\",\n  \"totalInvoices\": 1,\n  \"passedCount\":   0,\n  \"failedCount\":   1,\n  \"results\": [\n    {\n      \"invoiceRef\":  \"INV-001\",\n      \"documentId\": \"INV-2024-001\",\n      \"passed\":      false,\n      \"errors\": [\n        \"[ibr-167-ae] Line 1: vatExemptReasonCode is mandatory when taxCategory is 'E'.\"\n      ],\n      \"warnings\": []\n    }\n  ]\n}",
          "_postman_previewlanguage": "json"
        },
        {
          "name": "Unauthorized",
          "status": "Unauthorized",
          "code": 401,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "body": "{\n  \"errorKey\": \"API key missing\"\n}",
          "_postman_previewlanguage": "json"
        }
      ]
    },
    {
      "name": "13. Validate Upload – Excel 4-sheet (no DB write)",
      "request": {
        "method": "POST",
        "header": [
          { "key": "X-API-KEY", "value": "{{apiKey}}" }
        ],
        "url": {
          "raw": "{{baseUrl}}/external/api/v1/eInvoiceEntry/upload/validate",
          "host": ["{{baseUrl}}"],
          "path": ["external", "api", "v1", "eInvoiceEntry", "upload", "validate"],
          "query": [
            {
              "key": "includeXml",
              "value": "true",
              "description": "Set to true to receive the generated UBL XML per result",
              "disabled": true
            }
          ]
        },
        "body": {
          "mode": "formdata",
          "formdata": [
            {
              "key": "file",
              "type": "file",
              "src": "",
              "description": "Select sample_einvoice_entry.xlsx (4-sheet bulk upload template)"
            }
          ]
        },
        "description": "Parses a 4-sheet bulk-upload Excel workbook and validates all invoices against Peppol schematron rules WITHOUT saving anything to the database.\n\nUse the same Excel template as item 9 (Bulk Upload). Only the 'file' form field is required — no companyId needed.\n\nOptional query parameter: includeXml=true\n\nResponse: AP validation response."
      },
      "response": [
        {
          "name": "All Passed",
          "status": "OK",
          "code": 200,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "body": "{\n  \"validatedAt\":   \"2024-01-15T10:30:00\",\n  \"totalInvoices\": 2,\n  \"passedCount\":   2,\n  \"failedCount\":   0,\n  \"results\": [\n    { \"invoiceRef\": \"INV-001\", \"documentId\": \"INV-2024-001\", \"passed\": true, \"errors\": [], \"warnings\": [] },\n    { \"invoiceRef\": \"INV-002\", \"documentId\": \"INV-2024-002\", \"passed\": true, \"errors\": [], \"warnings\": [] }\n  ]\n}",
          "_postman_previewlanguage": "json"
        },
        {
          "name": "Partial Failure",
          "status": "OK",
          "code": 200,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "body": "{\n  \"validatedAt\":   \"2024-01-15T10:30:00\",\n  \"totalInvoices\": 2,\n  \"passedCount\":   1,\n  \"failedCount\":   1,\n  \"results\": [\n    { \"invoiceRef\": \"INV-001\", \"documentId\": \"INV-2024-001\", \"passed\": true,  \"errors\": [], \"warnings\": [] },\n    { \"invoiceRef\": \"INV-002\", \"documentId\": \"INV-2024-002\", \"passed\": false, \"errors\": [\"[ibr-167-ae] Line 1: vatExemptReasonCode is mandatory when taxCategory is 'E'.\"], \"warnings\": [] }\n  ]\n}",
          "_postman_previewlanguage": "json"
        }
      ]
    },
    {
      "name": "14. Validate Simple Upload – Excel 1-sheet (no DB write)",
      "request": {
        "method": "POST",
        "header": [
          { "key": "X-API-KEY", "value": "{{apiKey}}" }
        ],
        "url": {
          "raw": "{{baseUrl}}/external/api/v1/eInvoiceEntry/upload/simple/validate",
          "host": ["{{baseUrl}}"],
          "path": ["external", "api", "v1", "eInvoiceEntry", "upload", "simple", "validate"],
          "query": [
            {
              "key": "includeXml",
              "value": "true",
              "description": "Set to true to receive the generated UBL XML per result",
              "disabled": true
            }
          ]
        },
        "body": {
          "mode": "formdata",
          "formdata": [
            {
              "key": "file",
              "type": "file",
              "src": "",
              "description": "Select sample_einvoice_simple.xlsx (single-sheet simplified template)"
            }
          ]
        },
        "description": "Parses a simplified single-sheet Excel workbook and validates all invoices against Peppol schematron rules WITHOUT saving anything to the database.\n\nUse the same Excel template as the Simple Upload (Download via item 10 with template=simple). Only the 'file' form field is required.\n\nOptional query parameter: includeXml=true\n\nResponse: AP validation response."
      },
      "response": [
        {
          "name": "All Passed",
          "status": "OK",
          "code": 200,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "body": "{\n  \"validatedAt\":   \"2024-01-15T10:30:00\",\n  \"totalInvoices\": 1,\n  \"passedCount\":   1,\n  \"failedCount\":   0,\n  \"results\": [\n    { \"invoiceRef\": \"INV-001\", \"documentId\": \"INV-2024-001\", \"passed\": true, \"errors\": [], \"warnings\": [] }\n  ]\n}",
          "_postman_previewlanguage": "json"
        }
      ]
    },
    {
      "name": "15. Get Validation Errors for Entry",
      "request": {
        "method": "GET",
        "header": [
          { "key": "X-API-KEY", "value": "{{apiKey}}" }
        ],
        "url": {
          "raw": "{{baseUrl}}/external/api/v1/eInvoiceEntry/{{entryId}}/validationErrors",
          "host": ["{{baseUrl}}"],
          "path": ["external", "api", "v1", "eInvoiceEntry", "{{entryId}}", "validationErrors"]
        },
        "description": "Returns the stored Peppol schematron validation errors for a specific entry (typically entries in VALIDATION_FAILED status).\n\nNo request body or extra query params required."
      },
      "response": [
        {
          "name": "Success – Errors Present",
          "status": "OK",
          "code": 200,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "body": "{\n  \"entryId\":    1042,\n  \"documentId\": \"INV-2024-001\",\n  \"status\":     \"VALIDATION_FAILED\",\n  \"errors\": [\n    \"[ibr-167-ae] Line 1: vatExemptReasonCode is mandatory when taxCategory is 'E'.\",\n    \"[BR-CO-15] Amount due for payment (BT-115) = Invoice total amount with VAT (BT-112) - Paid amount (BT-113) + Rounding amount (BT-114).\"\n  ],\n  \"warnings\": []\n}",
          "_postman_previewlanguage": "json"
        },
        {
          "name": "Success – No Errors",
          "status": "OK",
          "code": 200,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "body": "{\n  \"entryId\":    1042,\n  \"documentId\": \"INV-2024-001\",\n  \"status\":     \"VALID\",\n  \"errors\":     [],\n  \"warnings\":   []\n}",
          "_postman_previewlanguage": "json"
        },
        {
          "name": "Not Found",
          "status": "Not Found",
          "code": 404,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "body": "{\n  \"errorKey\": \"Entry not found: 1042\"\n}",
          "_postman_previewlanguage": "json"
        }
      ]
    }
  ]
}
