{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/callnode-io/json-schema/callnode-io-voice-config-schema.json",
  "title": "VoiceConfig",
  "description": "Voice configuration — how inbound calls to this number are answered. Three modes: a conversational WEBHOOK agent (webhookUrl set), SIP DELIVERY to a literal endpoint (sipUri set), or SIP DELIVERY to one of your saved trunks (trunkId set). sipUri and trunkId are mutually exclusive — setting one clears the other, and either takes precedence over the webhook. Wholesale numbers must always keep at least one mode — a change that would leave none is rejected with 400.",
  "x-generated": "2026-11-03",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/callnode-io-openapi.yml#/components/schemas/VoiceConfig",
  "type": "object",
  "properties": {
    "webhookUrl": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "description": "Invoked when a call connects and once per caller utterance. Empty/null disconnects the webhook."
    },
    "sipUri": {
      "type": [
        "string",
        "null"
      ],
      "description": "BYOC / wholesale SIP delivery: when set, inbound calls bridge straight to this sip: endpoint and the webhook never runs. Format sip:user@host[:port][;transport=udp|tcp|tls], public hosts only. Null switches the number back to webhook mode (for wholesale numbers, only allowed when a webhookUrl is present)."
    },
    "srtp": {
      "type": "boolean",
      "default": false,
      "description": "Encrypt the audio on the sipUri delivery leg (SRTP with SDES key exchange, AES_CM_128_HMAC_SHA1_80 / AES_CM_128_HMAC_SHA1_32; no fallback to plain RTP). Accepted only when sipUri ends in ;transport=tls — otherwise 400. Cleared automatically when the address changes to UDP/TCP or the number switches to trunk delivery. See /docs/sip-trunking#byoc-srtp."
    },
    "trunkId": {
      "type": [
        "string",
        "null"
      ],
      "description": "Deliver inbound calls to one of your SIP trunks. A trunk with an egress host is dialed at that host; a REGISTRATION trunk is resolved to wherever your PBX is currently registered, at call time — the way to receive DID calls on equipment behind NAT. If the trunk is not registered when a call arrives, the call falls back to the number's webhook agent (if configured). Null clears trunk delivery. Mutually exclusive with sipUri."
    },
    "realtime": {
      "type": [
        "object",
        "null"
      ],
      "description": "Realtime WebSocket mode (see /docs/realtime): CallNode opens a WebSocket to `url` for every call to this number and streams transcripts (and, on request, caller audio); you stream audio back, transfer or hang up. The webhook stays the fallback when the socket cannot be reached. Null turns it off. The auth secret is write-only (reads return valueSet).",
      "properties": {
        "url": {
          "type": "string",
          "format": "uri",
          "description": "wss:// URL on a public host"
        },
        "auth": {
          "$ref": "#/$defs/WebhookAuth"
        },
        "voice": {
          "type": [
            "string",
            "null"
          ],
          "description": "Voice for `say` frames (text mode): an id from GET /api/v1/numbers/voices. Null = the platform default voice."
        }
      },
      "required": [
        "url"
      ]
    },
    "webhookAuth": {
      "$ref": "#/$defs/WebhookAuth"
    },
    "webhookTimeout": {
      "type": "integer",
      "minimum": 1000,
      "maximum": 120000,
      "default": 30000,
      "description": "Webhook response timeout in milliseconds."
    }
  },
  "$defs": {
    "WebhookAuth": {
      "type": "object",
      "description": "How CallNode authenticates to your webhook endpoint.",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "none",
            "basic",
            "bearer",
            "header"
          ]
        },
        "headerName": {
          "type": "string",
          "description": "Header name when `type` is `header`."
        },
        "value": {
          "type": "string",
          "description": "The secret, token, or `user:pass` pair, depending on `type`."
        }
      },
      "required": [
        "type"
      ]
    }
  }
}