{
  "info": {
    "name": "TI-01 V1 Developer API",
    "_postman_id": "8a010d8f-2475-4f77-a812-2f0f90d7bf65",
    "description": "Frozen beta collection for TI-01 /v1 endpoints: upload, ask, run status, run results.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "item": [
    {
      "name": "1) Upload (JSON ingest)",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "x-api-key",
            "value": "{{apiKey}}"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"sessionId\": \"{{sessionId}}\",\n  \"input\": {\n    \"source\": \"connector\",\n    \"records\": [\n      { \"metric\": \"revenue\", \"value\": 1200000, \"period\": \"2026-Q1\" },\n      { \"metric\": \"expenses\", \"value\": 780000, \"period\": \"2026-Q1\" }\n    ]\n  },\n  \"retention_hours\": 72\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/api/models/v1/upload",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "models",
            "v1",
            "upload"
          ]
        },
        "description": "Ingest-only upload path. Returns batchId for polling run status/results."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "pm.test('Upload returns success status', function () {",
              "  pm.expect(pm.response.code).to.be.oneOf([200, 202]);",
              "});",
              "",
              "let body = {};",
              "try { body = pm.response.json(); } catch (e) {}",
              "",
              "if (body.batchId) {",
              "  pm.collectionVariables.set('runId', body.batchId);",
              "}",
              "",
              "if (body.session_id) {",
              "  pm.collectionVariables.set('sessionId', body.session_id);",
              "}"
            ],
            "type": "text/javascript"
          }
        }
      ]
    },
    {
      "name": "1b) Answer (one-call orchestrator)",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "x-api-key",
            "value": "{{apiKey}}"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"session_id\": \"{{sessionId}}\",\n  \"question\": \"What are the key findings?\",\n  \"top_k\": 5,\n  \"include_normative\": true,\n  \"wait_max_ms\": 10000\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/api/models/v1/answer",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "models",
            "v1",
            "answer"
          ]
        },
        "description": "One-call orchestrator: if session already exists, runs ask-only path and returns mode=answer_completed with workflow block."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "pm.test('Answer returns 200', function () {",
              "  pm.response.to.have.status(200);",
              "});",
              "",
              "let body = {};",
              "try { body = pm.response.json(); } catch (e) {}",
              "",
              "pm.test('Answer response includes mode', function () {",
              "  pm.expect(body).to.have.property('mode');",
              "});",
              "",
              "pm.test('Answer response includes workflow', function () {",
              "  pm.expect(body).to.have.property('workflow');",
              "});"
            ],
            "type": "text/javascript"
          }
        }
      ]
    },
    {
      "name": "2) Ask (evidence-first)",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "x-api-key",
            "value": "{{apiKey}}"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"session_id\": \"{{sessionId}}\",\n  \"question\": \"What are the main revenue and expense assumptions?\",\n  \"top_k\": 5,\n  \"retention_hours\": 72\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/api/models/v1/ask",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "models",
            "v1",
            "ask"
          ]
        },
        "description": "Evidence retrieval endpoint. Returns citations with locators."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "pm.test('Ask returns 200', function () {",
              "  pm.response.to.have.status(200);",
              "});",
              "",
              "let body = {};",
              "try { body = pm.response.json(); } catch (e) {}",
              "",
              "pm.test('Ask response includes citations array', function () {",
              "  pm.expect(body).to.have.property('citations');",
              "  pm.expect(body.citations).to.be.an('array');",
              "});"
            ],
            "type": "text/javascript"
          }
        }
      ]
    },
    {
      "name": "3) Run Status",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "x-api-key",
            "value": "{{apiKey}}"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/models/v1/runs/{{runId}}",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "models",
            "v1",
            "runs",
            "{{runId}}"
          ]
        },
        "description": "Poll run progress and metadata."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "pm.test('Run status returns 200', function () {",
              "  pm.response.to.have.status(200);",
              "});"
            ],
            "type": "text/javascript"
          }
        }
      ]
    },
    {
      "name": "4) Run Results",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "x-api-key",
            "value": "{{apiKey}}"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/models/v1/runs/{{runId}}/results",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "models",
            "v1",
            "runs",
            "{{runId}}",
            "results"
          ]
        },
        "description": "Fetch final run output. If not completed yet, endpoint can return batch_not_completed."
      }
    },
    {
      "name": "5) Analyse (deprecated smoke check)",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "x-api-key",
            "value": "{{apiKey}}"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"session_id\": \"{{sessionId}}\",\n  \"question\": \"Deprecated endpoint smoke check\"\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/api/models/v1/analyse",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "models",
            "v1",
            "analyse"
          ]
        },
        "description": "Expected HTTP 410 endpoint_deprecated."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "pm.test('Analyse is deprecated', function () {",
              "  pm.response.to.have.status(410);",
              "});"
            ],
            "type": "text/javascript"
          }
        }
      ]
    }
  ],
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://api.transientintelligence.com"
    },
    {
      "key": "apiKey",
      "value": ""
    },
    {
      "key": "sessionId",
      "value": "ti-01-session-demo"
    },
    {
      "key": "runId",
      "value": "batch_ti-01-batch-0000000000000_0000000000000"
    }
  ]
}
