{
  "info": {
    "name": "LMN History API — Sandbox",
    "description": "Prepared history integration. Requires History API access. Saved Sportage example is free in sandbox; other live identifiers can consume test credits. Confirm mode before filling the plate template. Does not configure or send webhooks.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "base_url",
      "value": "https://sandbox-api.lmnauto.com"
    },
    {
      "key": "api_key",
      "value": ""
    },
    {
      "key": "history_lookup_id",
      "value": ""
    },
    {
      "key": "history_plate",
      "value": ""
    },
    {
      "key": "history_idempotency_key",
      "value": "history-v2-example-001"
    }
  ],
  "item": [
    {
      "name": "Submit saved Sportage sandbox example",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "x-api-key",
            "value": "{{api_key}}"
          },
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": "{{base_url}}/v1/history-lookups",
        "description": "This exact saved historical sandbox example makes no provider calls and consumes no credit. Supplemental data may be not_collected.",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"vin\": \"KNAPM813BHK185630\",\n  \"reference\": \"history-example-001\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Lookup accepted or reused', () => pm.expect([200, 202]).to.include(pm.response.code));",
              "if ([200, 202].includes(pm.response.code)) { const value = pm.response.json(); if (value.id) pm.collectionVariables.set('history_lookup_id', value.id); }"
            ]
          }
        }
      ]
    },
    {
      "name": "Read accepted lookup",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "x-api-key",
            "value": "{{api_key}}"
          },
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": "{{base_url}}/v1/history-lookups/{{history_lookup_id}}",
        "description": "Run after submission. Failed processing is still an HTTP200 read; retain aggregate and sources."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Read succeeded', () => pm.response.to.have.status(200));"
            ]
          }
        }
      ]
    },
    {
      "name": "List history lookups",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "x-api-key",
            "value": "{{api_key}}"
          },
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": "{{base_url}}/v1/history-lookups?limit=10",
        "description": "Returns data[] and next_cursor; each entry uses the current environment HTTP projection."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Read succeeded', () => pm.response.to.have.status(200));"
            ]
          }
        }
      ]
    },
    {
      "name": "List failed lookups",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "x-api-key",
            "value": "{{api_key}}"
          },
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": "{{base_url}}/v1/history-lookups?status=failed&limit=10",
        "description": "A failed primary can retain supplemental data and consumes no new history credit."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Read succeeded', () => pm.response.to.have.status(200));"
            ]
          }
        }
      ]
    },
    {
      "name": "Plate template — fill only after confirming access and credit policy",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "x-api-key",
            "value": "{{api_key}}"
          },
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Idempotency-Key",
            "value": "{{history_idempotency_key}}"
          }
        ],
        "url": "{{base_url}}/v1/history-lookups",
        "description": "Blank plate intentionally fails input validation. Set history_plate only for a vehicle you intend to query. Keep history_idempotency_key stable for retries; change it only for an intentionally new lookup. Live success can consume a credit.",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"plate\": \"{{history_plate}}\",\n  \"reference\": \"history-plate-example-001\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Lookup accepted or reused', () => pm.expect([200, 202]).to.include(pm.response.code));",
              "if ([200, 202].includes(pm.response.code)) { const value = pm.response.json(); if (value.id) pm.collectionVariables.set('history_lookup_id', value.id); }"
            ]
          }
        }
      ]
    }
  ]
}
