{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/nopaque-co-uk/json-schema/nopaque-co-uk-list-survey-runs-response-schema.json",
  "title": "ListSurveyRunsResponse",
  "x-generated": "2026-11-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/nopaque-co-uk-survey-tests-api-openapi.yml#/components/schemas/ListSurveyRunsResponse",
  "type": "object",
  "required": [
    "runs",
    "numbers"
  ],
  "properties": {
    "runs": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/SurveyRun"
      }
    },
    "numbers": {
      "type": "object",
      "description": "Concurrency, made visible. A run occupies a number for its window,\nso this is what to check before starting another test.\n",
      "required": [
        "total",
        "busy",
        "free"
      ],
      "properties": {
        "total": {
          "type": "integer",
          "description": "Live survey numbers this workspace owns."
        },
        "busy": {
          "type": "integer"
        },
        "free": {
          "type": "integer"
        }
      }
    }
  },
  "$defs": {
    "SurveyRun": {
      "type": "object",
      "description": "A survey test — nopaque waiting to answer one survey it did not initiate.\n\nA test occupies one of your numbers, paired with the sender it expects.\nThat pair is the only identity an inbound call or SMS carries, so while\na test is live no other test may use the same pair — which is why\nrunning more at once means owning more numbers.\n",
      "required": [
        "runId",
        "configId",
        "agentE164",
        "endUserE164",
        "state",
        "startedAt",
        "expiresAt",
        "live"
      ],
      "properties": {
        "runId": {
          "type": "string",
          "format": "uuid"
        },
        "configId": {
          "type": "string"
        },
        "agentE164": {
          "type": "string",
          "description": "The nopaque number this run answers on — point the survey here."
        },
        "endUserE164": {
          "type": "string",
          "description": "The number the survey is expected to originate from."
        },
        "state": {
          "type": "string",
          "enum": [
            "waiting",
            "in_progress",
            "complete",
            "timed_out"
          ]
        },
        "startedAt": {
          "type": "string",
          "format": "date-time"
        },
        "engagedAt": {
          "type": "string",
          "format": "date-time",
          "description": "When a conversation actually started, if one has."
        },
        "channel": {
          "type": "string",
          "enum": [
            "sms_chat",
            "phone_call"
          ],
          "description": "Observed when the conversation starts; absent until then."
        },
        "expiresAt": {
          "type": "integer",
          "description": "Epoch SECONDS. The row may outlive this value — expiry sweeps are\nlazy — so judge liveness by `live`, not by the row existing.\n"
        },
        "live": {
          "type": "boolean"
        },
        "expectedTurns": {
          "type": "integer",
          "description": "The question count in force for this test — taken from the\nrespondent unless the start call overrode it. Absent means none is\nset.\n"
        },
        "answersGiven": {
          "type": "integer",
          "description": "How many times the respondent has answered so far."
        },
        "enforcementActive": {
          "type": "boolean",
          "description": "Whether anything can stop the respondent talking.\n\n`false` means no question count is set, so it answers whatever it\nis sent until you stop the test or the window closes. That is a\nlegitimate way to run a test — but it is reported rather than left\nto be inferred, because a test that cannot be stopped otherwise\nlooks exactly like one that can.\n"
        }
      }
    }
  }
}