{
  "info": {
    "name": "Berti Graf NL Website API",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "description": " All order endpoints return the stored customer context. Optional customer.externalCustomerId on updates verifies identity; mismatched context returns 409."
  },
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://backend.bertigraf.nl"
    },
    {
      "key": "token",
      "value": ""
    },
    {
      "key": "externalOrderId",
      "value": "WEB-10001"
    },
    {
      "key": "productId",
      "value": "12345"
    },
    {
      "key": "clientId",
      "value": ""
    },
    {
      "key": "clientSecret",
      "value": ""
    },
    {
      "key": "mailId",
      "value": ""
    }
  ],
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{token}}",
        "type": "string"
      }
    ]
  },
  "item": [
    {
      "name": "Obtain or renew access token",
      "request": {
        "auth": {
          "type": "noauth"
        },
        "method": "POST",
        "url": "{{baseUrl}}/api/v1/auth/token",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"grant_type\": \"client_credentials\",\n  \"client_id\": \"{{clientId}}\",\n  \"client_secret\": \"{{clientSecret}}\"\n}"
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "if (pm.response.code === 200) {",
              "  const body = pm.response.json();",
              "  pm.collectionVariables.set(\"token\", body.access_token);",
              "}"
            ]
          }
        }
      ]
    },
    {
      "name": "Mappings",
      "request": {
        "method": "GET",
        "url": "{{baseUrl}}/api/v1/mappings",
        "header": []
      }
    },
    {
      "name": "Accept Order",
      "request": {
        "method": "POST",
        "url": "{{baseUrl}}/api/v1/orders",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Idempotency-Key",
            "value": "web-10001-attempt-v1"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"portal\": \"bertigraf\",\n  \"account\": \"bertigraf.de\",\n  \"region\": \"DE\",\n  \"externalOrderId\": \"WEB-10001\",\n  \"currency\": \"EUR\",\n  \"lines\": [\n    {\n      \"externalLineId\": \"1\",\n      \"sku\": \"YOUR-WEBSITE-VARIANT-SKU\",\n      \"quantity\": 2,\n      \"unitPriceGross\": 11.9,\n      \"vatPercent\": 19\n    }\n  ],\n  \"customer\": {\n    \"externalCustomerId\": \"WEB-CUSTOMER-123\",\n    \"firstName\": \"Anna\",\n    \"lastName\": \"Example\",\n    \"email\": \"anna@example.com\",\n    \"phone\": \"+49 30 1234567\"\n  },\n  \"shippingAddress\": {\n    \"firstName\": \"Anna\",\n    \"lastName\": \"Example\",\n    \"street\": \"Example Street 12\",\n    \"postalCode\": \"10115\",\n    \"city\": \"Berlin\",\n    \"countryCode\": \"DE\"\n  },\n  \"billingAddress\": {\n    \"firstName\": \"Anna\",\n    \"lastName\": \"Example\",\n    \"street\": \"Example Street 12\",\n    \"postalCode\": \"10115\",\n    \"city\": \"Berlin\",\n    \"countryCode\": \"DE\"\n  }\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      }
    },
    {
      "name": "Order Status",
      "request": {
        "method": "GET",
        "url": "{{baseUrl}}/api/v1/orders/{{externalOrderId}}",
        "header": []
      }
    },
    {
      "name": "Website combined inventory (NL warehouse 12)",
      "request": {
        "method": "GET",
        "url": "{{baseUrl}}/api/v1/website/inventory?productId={{productId}}"
      }
    },
    {
      "name": "Confirm website order",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": "{{baseUrl}}/api/v1/orders/{{externalOrderId}}/confirm",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"confirmationId\": \"WEB-CONFIRM-10001\",\n  \"customer\": {\n    \"externalCustomerId\": \"WEB-CUSTOMER-123\"\n  }\n}"
        }
      }
    },
    {
      "name": "Save product card mapping",
      "request": {
        "method": "POST",
        "url": "{{baseUrl}}/api/v1/website/mappings",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"productId\": \"12345\",\n  \"sku\": \"WEB-NAMUR\",\n  \"articleId\": \"2391\",\n  \"factor\": 2.5,\n  \"buffer\": 0,\n  \"unit\": \"qutu\",\n  \"revision\": 0\n}"
        }
      }
    },
    {
      "name": "List orders",
      "request": {
        "method": "GET",
        "url": "{{baseUrl}}/api/v1/orders?limit=20&offset=0"
      }
    },
    {
      "name": "Order details",
      "request": {
        "method": "GET",
        "url": "{{baseUrl}}/api/v1/orders/{{externalOrderId}}"
      }
    },
    {
      "name": "Post status event",
      "request": {
        "method": "POST",
        "url": "{{baseUrl}}/api/v1/orders/{{externalOrderId}}/events",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"eventId\": \"accept-10001\",\n  \"status\": \"accepted\",\n  \"expectedVersion\": 1,\n  \"customer\": {\n    \"externalCustomerId\": \"WEB-CUSTOMER-123\"\n  }\n}"
        }
      }
    },
    {
      "name": "Link JTL order",
      "request": {
        "method": "POST",
        "url": "{{baseUrl}}/api/v1/orders/{{externalOrderId}}/jtl-link",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"jtlOrderId\": 12345,\n  \"expectedVersion\": 1,\n  \"customer\": {\n    \"externalCustomerId\": \"WEB-CUSTOMER-123\"\n  }\n}"
        }
      }
    },
    {
      "name": "Website mail",
      "item": [
        {
          "name": "Queue email",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "website-contact-10001"
              }
            ],
            "url": "{{baseUrl}}/api/v1/mail/messages",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"to\": [\n    \"info@bertigraf.nl\"\n  ],\n  \"subject\": \"Website contact request\",\n  \"textBody\": \"A customer has submitted a website enquiry.\",\n  \"replyTo\": \"customer@example.com\"\n}"
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if ([200, 202].includes(pm.response.code)) { pm.collectionVariables.set(\"mailId\", pm.response.json().mailId); }"
                ]
              }
            }
          ]
        },
        {
          "name": "Mail delivery status",
          "request": {
            "method": "GET",
            "url": "{{baseUrl}}/api/v1/mail/messages/{{mailId}}"
          }
        }
      ]
    }
  ]
}