{
  "info": {
    "name": "LoanVault Debt Settlement API",
    "description": "Use webhooks (request 5) for status updates. Request 4 is for occasional lookups only; do not poll it. Set client_id and client_secret in the collection variables, run '1. Get access token' first, then the rest. Switch base_url/auth_url between sandbox and production.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "item": [
    {
      "name": "1. Get access token",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{auth_url}}",
          "host": [
            "{{auth_url}}"
          ]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"client_id\": \"{{client_id}}\",\n  \"client_secret\": \"{{client_secret}}\",\n  \"grant_type\": \"client_credentials\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "let j = {}; try { j = pm.response.json(); } catch (e) { console.log('Non-JSON response: ' + pm.response.text()); }",
              "if (j.access_token) pm.collectionVariables.set('access_token', j.access_token);",
              "pm.test('Got token', () => pm.expect(j.access_token).to.be.a('string'));"
            ]
          }
        }
      ]
    },
    {
      "name": "2. Submit pre-approval (POST)",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{base_url}}/api/v1/loan/debt-settlement",
          "host": [
            "{{base_url}}"
          ],
          "path": [
            "api",
            "v1",
            "loan",
            "debt-settlement"
          ],
          "query": [
            {
              "key": "_format",
              "value": "json"
            }
          ]
        },
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{access_token}}",
              "type": "string"
            }
          ]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"loan\": {\n    \"externalId\": \"DEBT-123456789\",\n    \"type\": \"individual\",\n    \"borrower\": {\n      \"email\": \"jane.sample@example.com\",\n      \"firstName\": \"Jane\",\n      \"middleName\": \"\",\n      \"lastName\": \"Sample\",\n      \"suffixName\": \"\",\n      \"dob\": \"1980-10-03\",\n      \"ssn\": \"123-45-6789\",\n      \"phoneDay\": {\n        \"type\": \"mobile\",\n        \"number\": \"910-555-0199\"\n      },\n      \"addressCurrent\": {\n        \"address\": \"100 Main St\",\n        \"city\": \"Wilmington\",\n        \"state\": \"NC\",\n        \"zipCode\": \"28403\"\n      }\n    },\n    \"customData\": {\n      \"company\": \"Example Settlement Group\",\n      \"gcsAccountNumber\": \"145784154\",\n      \"escrowAccountBalance\": 275.36,\n      \"paymentProcessing\": {\n        \"name\": \"Example Pay\",\n        \"routingNumber\": \"000000000\",\n        \"accountNumber\": \"000000000001\",\n        \"dedicatedAccount\": \"145784154\"\n      },\n      \"dscPaymentProcessing\": {\n        \"name\": \"Example Bank\",\n        \"routingNumber\": \"000000000\",\n        \"accountNumber\": \"000000000002\"\n      }\n    },\n    \"settlement\": {\n      \"fee\": 1076.0,\n      \"payment\": 191.0,\n      \"balance\": 4036.0,\n      \"programPaymentFrequency\": \"Monthly\",\n      \"originalFico\": 643,\n      \"programStartDate\": \"2025-05-23\",\n      \"lastNsfDate\": \"2025-08-23\",\n      \"accounts\": [\n        {\n          \"name\": \"Example Card Co\",\n          \"accountNumber\": \"0000000000001234\",\n          \"originalBalance\": 4289.0,\n          \"settledBalance\": 0.0\n        },\n        {\n          \"name\": \"Example Savings Bank\",\n          \"accountNumber\": \"54588301\",\n          \"originalBalance\": 2847.0,\n          \"settledBalance\": 0.0\n        }\n      ],\n      \"paymentsMade\": [\n        {\n          \"date\": \"2025-11-17\",\n          \"amount\": 358.97\n        },\n        {\n          \"date\": \"2025-12-17\",\n          \"amount\": 381.54\n        },\n        {\n          \"date\": \"2026-01-17\",\n          \"amount\": 381.54\n        },\n        {\n          \"date\": \"2026-02-17\",\n          \"amount\": 381.54\n        },\n        {\n          \"date\": \"2026-03-17\",\n          \"amount\": 405.39\n        },\n        {\n          \"date\": \"2026-04-17\",\n          \"amount\": 405.39\n        },\n        {\n          \"date\": \"2026-05-17\",\n          \"amount\": 405.39\n        },\n        {\n          \"date\": \"2026-06-17\",\n          \"amount\": 416.41\n        },\n        {\n          \"date\": \"2026-07-17\",\n          \"amount\": 416.41\n        },\n        {\n          \"date\": \"2026-08-17\",\n          \"amount\": 416.41\n        },\n        {\n          \"date\": \"2026-09-17\",\n          \"amount\": 416.41\n        },\n        {\n          \"date\": \"2026-10-17\",\n          \"amount\": 416.41\n        }\n      ]\n    }\n  }\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "let j = {}; try { j = pm.response.json(); } catch (e) { console.log('Non-JSON response: ' + pm.response.text()); }",
              "if (j.data && j.data.loanNumber) pm.collectionVariables.set('loan_number', j.data.loanNumber);"
            ]
          }
        }
      ]
    },
    {
      "name": "3. Submit final settlement (PATCH)",
      "request": {
        "method": "PATCH",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{base_url}}/api/v1/loan/debt-settlement/{{loan_number}}",
          "host": [
            "{{base_url}}"
          ],
          "path": [
            "api",
            "v1",
            "loan",
            "debt-settlement",
            "{{loan_number}}"
          ],
          "query": [
            {
              "key": "_format",
              "value": "json"
            }
          ]
        },
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{access_token}}",
              "type": "string"
            }
          ]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"loan\": {\n    \"externalId\": \"DEBT-123456789\",\n    \"type\": \"individual\",\n    \"borrower\": {\n      \"email\": \"jane.sample@example.com\",\n      \"firstName\": \"Jane\",\n      \"middleName\": \"\",\n      \"lastName\": \"Sample\",\n      \"suffixName\": \"\",\n      \"dob\": \"1980-10-03\",\n      \"ssn\": \"123-45-6789\",\n      \"phoneDay\": {\n        \"type\": \"mobile\",\n        \"number\": \"910-555-0199\"\n      },\n      \"addressCurrent\": {\n        \"address\": \"100 Main St\",\n        \"city\": \"Wilmington\",\n        \"state\": \"NC\",\n        \"zipCode\": \"28403\"\n      }\n    },\n    \"customData\": {\n      \"company\": \"Example Settlement Group\",\n      \"gcsAccountNumber\": \"145784154\",\n      \"escrowAccountBalance\": 423.36,\n      \"paymentProcessing\": {\n        \"name\": \"Example Pay\",\n        \"routingNumber\": \"000000000\",\n        \"accountNumber\": \"000000000001\",\n        \"dedicatedAccount\": \"145784154\"\n      },\n      \"dscPaymentProcessing\": {\n        \"name\": \"Example Bank\",\n        \"routingNumber\": \"000000000\",\n        \"accountNumber\": \"000000000002\"\n      }\n    },\n    \"settlement\": {\n      \"fee\": 1076.0,\n      \"payment\": 191.0,\n      \"balance\": 4532.0,\n      \"programPaymentFrequency\": \"Monthly\",\n      \"originalFico\": 643,\n      \"programStartDate\": \"2025-05-23\",\n      \"lastNsfDate\": \"2025-08-23\",\n      \"accounts\": [\n        {\n          \"name\": \"Example Card Co\",\n          \"accountNumber\": \"0000000000001234\",\n          \"originalBalance\": 6289.0,\n          \"settledBalance\": 3189.0\n        },\n        {\n          \"name\": \"Example Savings Bank\",\n          \"accountNumber\": \"54588301\",\n          \"originalBalance\": 2847.0,\n          \"settledBalance\": 1343.0\n        }\n      ],\n      \"paymentsMade\": [\n        {\n          \"date\": \"2025-11-17\",\n          \"amount\": 358.97\n        },\n        {\n          \"date\": \"2025-12-17\",\n          \"amount\": 381.54\n        },\n        {\n          \"date\": \"2026-01-17\",\n          \"amount\": 381.54\n        },\n        {\n          \"date\": \"2026-02-17\",\n          \"amount\": 381.54\n        },\n        {\n          \"date\": \"2026-03-17\",\n          \"amount\": 405.39\n        },\n        {\n          \"date\": \"2026-04-17\",\n          \"amount\": 405.39\n        },\n        {\n          \"date\": \"2026-05-17\",\n          \"amount\": 405.39\n        },\n        {\n          \"date\": \"2026-06-17\",\n          \"amount\": 416.41\n        },\n        {\n          \"date\": \"2026-07-17\",\n          \"amount\": 416.41\n        },\n        {\n          \"date\": \"2026-08-17\",\n          \"amount\": 416.41\n        },\n        {\n          \"date\": \"2026-09-17\",\n          \"amount\": 416.41\n        },\n        {\n          \"date\": \"2026-10-17\",\n          \"amount\": 416.41\n        }\n      ]\n    }\n  }\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      }
    },
    {
      "name": "4. Get application status",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{base_url}}/api/v1/loan/list",
          "host": [
            "{{base_url}}"
          ],
          "path": [
            "api",
            "v1",
            "loan",
            "list"
          ],
          "query": [
            {
              "key": "_format",
              "value": "json"
            },
            {
              "key": "loanNumber",
              "value": "{{loan_number}}"
            },
            {
              "key": "externalId",
              "value": "DEBT-123456789",
              "disabled": true
            }
          ]
        },
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{access_token}}",
              "type": "string"
            }
          ]
        }
      }
    },
    {
      "name": "5. Register webhook",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{base_url}}/api/webhook/register",
          "host": [
            "{{base_url}}"
          ],
          "path": [
            "api",
            "webhook",
            "register"
          ],
          "query": [
            {
              "key": "_format",
              "value": "json"
            }
          ]
        },
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{access_token}}",
              "type": "string"
            }
          ]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"event\": \"ApplicationStageUpdated\",\n  \"callbackUrl\": \"https://www.myportal.com/api/application-updates\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "let j = {}; try { j = pm.response.json(); } catch (e) { console.log('Non-JSON response: ' + pm.response.text()); }",
              "if (j.data && j.data.id) pm.collectionVariables.set('webhook_id', j.data.id);"
            ]
          }
        }
      ]
    },
    {
      "name": "6. View registered webhooks",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{base_url}}/api/webhook/register",
          "host": [
            "{{base_url}}"
          ],
          "path": [
            "api",
            "webhook",
            "register"
          ],
          "query": [
            {
              "key": "_format",
              "value": "json"
            }
          ]
        },
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{access_token}}",
              "type": "string"
            }
          ]
        }
      }
    },
    {
      "name": "7. Un-register webhook",
      "request": {
        "method": "DELETE",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{base_url}}/api/webhook/register",
          "host": [
            "{{base_url}}"
          ],
          "path": [
            "api",
            "webhook",
            "register"
          ],
          "query": [
            {
              "key": "_format",
              "value": "json"
            }
          ]
        },
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{access_token}}",
              "type": "string"
            }
          ]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"id\": \"{{webhook_id}}\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      }
    }
  ],
  "variable": [
    {
      "key": "base_url",
      "value": "https://stage-backend.newline.ai"
    },
    {
      "key": "auth_url",
      "value": "https://stage-backend.newline.ai/oauth/token"
    },
    {
      "key": "client_id",
      "value": ""
    },
    {
      "key": "client_secret",
      "value": ""
    },
    {
      "key": "access_token",
      "value": ""
    },
    {
      "key": "loan_number",
      "value": ""
    },
    {
      "key": "webhook_id",
      "value": ""
    }
  ]
}