{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/nopaque-co-uk/json-schema/nopaque-co-uk-create-mapping-job-request-schema.json",
  "title": "CreateMappingJobRequest",
  "description": "Request body for `POST /mapping`.\n\n`config` is required, because `config.mappingMode` is required — the handler reads\nthe mode from inside `config` and rejects the request without it. A top-level\n`mappingMode` is ignored.\n\nTwo further rules are conditional and cannot be expressed in JSON Schema:\n  - `config.vertical` is REQUIRED whenever `config.mappingMode` is not `dtmf`.\n  - `config.probeMode: true` is REJECTED when `config.mappingMode` is `dtmf`.\n\nThe workspace is taken from the API key, never from the body.\n",
  "x-generated": "2026-11-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/nopaque-co-uk-mapping-api-openapi.yml#/components/schemas/CreateMappingJobRequest",
  "type": "object",
  "required": [
    "name",
    "phoneNumber",
    "config"
  ],
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 255,
      "description": "Job display name."
    },
    "phoneNumber": {
      "type": "string",
      "description": "Target phone number in E.164 format."
    },
    "profileId": {
      "type": "string",
      "description": "Data profile used to supply scripted input values during the run. A profile id is\n`profile_` followed by base-36 characters, not a UUID.\n"
    },
    "tags": {
      "type": "array",
      "maxItems": 10,
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 32,
        "pattern": "^[a-z0-9][a-z0-9-]*$"
      },
      "description": "Up to 10 lowercase kebab-case labels for filtering and organisation.\nNormalised server-side (trimmed, lowercased, de-duplicated).\n"
    },
    "config": {
      "allOf": [
        {
          "$ref": "#/$defs/MappingJobConfig"
        }
      ],
      "required": [
        "mappingMode"
      ]
    }
  },
  "$defs": {
    "EnrichmentConfig": {
      "type": "object",
      "description": "Enrichment pipeline configuration. Controls whether async post-map enrichment\nruns after a mapping run completes (quality scoring, transcript analysis, etc.).\n",
      "required": [
        "enabled"
      ],
      "properties": {
        "enabled": {
          "type": "boolean",
          "description": "Whether enrichment runs automatically after each mapping run completes."
        },
        "types": {
          "type": "array",
          "maxItems": 20,
          "items": {
            "type": "string"
          },
          "description": "Which enrichment types to run. Defaults to `[\"quality_scoring\"]`."
        }
      }
    },
    "MappingJobConfig": {
      "type": "object",
      "description": "Per-job configuration knobs that govern exploration shape and call orchestration.\nSensible defaults are applied server-side when fields are omitted on create.\n",
      "properties": {
        "maxDepth": {
          "type": "integer",
          "minimum": 0,
          "maximum": 10,
          "default": 3,
          "description": "Maximum tree depth to explore (0 = root only)."
        },
        "maxCalls": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 50,
          "description": "Maximum total calls per run."
        },
        "maxDurationMinutes": {
          "type": "integer",
          "minimum": 1,
          "maximum": 60,
          "default": 30,
          "description": "Maximum run duration in minutes."
        },
        "maxConcurrency": {
          "type": "integer",
          "minimum": 1,
          "maximum": 5,
          "default": 1,
          "description": "Maximum concurrent calls."
        },
        "language": {
          "allOf": [
            {
              "$ref": "#/$defs/TranscriptionLanguage"
            }
          ],
          "description": "Transcription language for this mapping run. Omitted means `en-GB`.\nMust be one of the `TranscriptionLanguage` codes — NOT a\n`CallLanguage`: bare `en` is rejected with 400.\n"
        },
        "voiceProfileId": {
          "type": "string",
          "format": "uuid",
          "description": "Voice profile for TTS responses (full-audio / dtmf-audio modes)."
        },
        "dataProfileId": {
          "type": "string",
          "format": "uuid",
          "description": "Data profile for variable substitution in scripted inputs."
        },
        "retryConfig": {
          "$ref": "#/$defs/RetryConfig"
        },
        "repeatConfig": {
          "$ref": "#/$defs/RepeatConfig"
        },
        "enrichmentConfig": {
          "$ref": "#/$defs/EnrichmentConfig"
        },
        "mappingMode": {
          "type": "string",
          "enum": [
            "dtmf",
            "dtmf-audio",
            "full-audio"
          ],
          "description": "Mapping mode. `dtmf` is keypad-only; `dtmf-audio` mixes DTMF + voice;\n`full-audio` is voice-first (no keypad).\n"
        },
        "vertical": {
          "type": "string",
          "enum": [
            "FSI",
            "Healthcare",
            "EnergyUtilities",
            "Telecoms",
            "General"
          ],
          "description": "Industry vertical used for prompt-library lookup."
        },
        "probeMode": {
          "type": "boolean",
          "description": "Phase 31 security-probe mode flag. Requires a prior attestation via\n`POST /mapping/attest` for the target phone number.\n"
        },
        "carrierRouteId": {
          "type": "string",
          "maxLength": 128,
          "description": "Bring-your-own-carrier (invite-only). Dial this map's calls through one of the\nworkspace's carrier routes, over the workspace's own SIP trunk, instead of nopaque's\nnetwork. Checked when the map is created or updated (400 when it cannot be dialled, 503\nwhen it could not be looked up). Each run records the route it started through\n(`carrier`), and every call of the run checks it again, with the trunk's daily minutes:\na start that cannot dial is refused (409, 429 for today's minutes, 403 or 503), and a\ncall later in the map that cannot (the route was disabled, or the trunk used today's\nminutes) fails that step with the reason, so the map stops dialling. Never a normal\ncall instead. Send `null` on update to clear it. Carrier calls are metered as\n`carrier_mapping` (`carrier_s2s` for full-audio maps), from answer.\n"
        }
      }
    },
    "RepeatConfig": {
      "type": "object",
      "description": "Repeat-detection configuration. Controls how the orchestrator handles\nsituations where a discovered menu is revisited via a different DTMF path\n(a loop). `skip` ignores the revisit entirely; `explore_once` explores it\nthe first time only; `explore_n` explores up to `maxExplorations` times.\n",
      "required": [
        "behavior"
      ],
      "properties": {
        "behavior": {
          "type": "string",
          "enum": [
            "skip",
            "explore_once",
            "explore_n"
          ],
          "description": "Behaviour when a repeated menu is detected."
        },
        "maxExplorations": {
          "type": "integer",
          "minimum": 1,
          "maximum": 10,
          "description": "Maximum explorations when `behavior` is `explore_n` (default 2)."
        }
      }
    },
    "RetryConfig": {
      "type": "object",
      "description": "Retry configuration for failed mapping calls. Controls whether transient call\nfailures (no answer, busy, telephony errors) are retried before being marked failed.\n",
      "required": [
        "enabled",
        "maxRetries"
      ],
      "properties": {
        "enabled": {
          "type": "boolean",
          "description": "Whether retries are enabled for this job."
        },
        "maxRetries": {
          "type": "integer",
          "minimum": 1,
          "maximum": 5,
          "description": "Maximum retry attempts per failed call (1-5)."
        }
      }
    },
    "TranscriptionLanguage": {
      "type": "string",
      "description": "The transcription language of a STANDARD test or a MAPPING run — the\nlanguage the callee is expected to speak, used to transcribe the call.\nAbsent means `en-GB`: every omit path is unchanged, so an existing\nconfig without the field transcribes as British English exactly as\nbefore. Anything outside this set is rejected with 400.\n\nThe English variants lead, then `multi` (code-switching), then the\nremaining languages alphabetically by display label. Mirrors\n`api/packages/core/transcription/languages.ts` (Zod) — the single\nsource of truth; a drift test keeps this enum equal to it.\n\nDISTINCT from `CallLanguage`, which is the language a MISSION test\ncall is held in. The two lists do not overlap cleanly and are not\ninterchangeable: bare `en` is a valid `CallLanguage` and is INVALID\nhere (use `en-GB` or `en-US`), and most codes here are not call\nlanguages at all.\n",
      "enum": [
        "en-GB",
        "en-US",
        "en-AU",
        "en-IN",
        "en-NZ",
        "multi",
        "ar",
        "be",
        "bn",
        "bs",
        "bg",
        "ca",
        "zh-HK",
        "zh",
        "hr",
        "cs",
        "da",
        "nl",
        "et",
        "fi",
        "nl-BE",
        "fr",
        "de",
        "el",
        "gu",
        "he",
        "hi",
        "hu",
        "id",
        "it",
        "ja",
        "kn",
        "ko",
        "lv",
        "lt",
        "mk",
        "ms",
        "mr",
        "no",
        "fa",
        "pl",
        "pt",
        "ro",
        "ru",
        "sr",
        "sk",
        "sl",
        "es",
        "sv",
        "tl",
        "ta",
        "te",
        "th",
        "tr",
        "uk",
        "ur",
        "vi"
      ]
    }
  }
}