{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/callnode-io/json-schema/callnode-io-phone-number-schema.json",
  "title": "PhoneNumber",
  "x-generated": "2026-11-03",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/callnode-io-openapi.yml#/components/schemas/PhoneNumber",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "phoneNumber": {
      "$ref": "#/$defs/E164"
    },
    "type": {
      "type": "string",
      "enum": [
        "local",
        "tollfree"
      ]
    },
    "friendlyName": {
      "type": [
        "string",
        "null"
      ]
    },
    "status": {
      "type": "string"
    },
    "purchaseSource": {
      "type": "string",
      "enum": [
        "web",
        "api"
      ],
      "description": "How the number was purchased — via the dashboard (`web`) or this API (`api`)."
    },
    "tags": {
      "$ref": "#/$defs/NumberTags"
    },
    "voice": {
      "type": "object",
      "properties": {
        "webhookUrl": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri"
        },
        "webhookAuth": {
          "$ref": "#/$defs/WebhookAuthStatus"
        },
        "webhookTimeout": {
          "type": "integer"
        },
        "sipUri": {
          "type": [
            "string",
            "null"
          ],
          "description": "SIP delivery target (BYOC / wholesale). Null when the number runs in webhook mode."
        },
        "srtp": {
          "type": "boolean",
          "description": "Whether the sipUri delivery leg offers SRTP (only ever true beside a ;transport=tls address)."
        },
        "trunkId": {
          "type": [
            "string",
            "null"
          ],
          "description": "SIP trunk this number delivers inbound calls to. Null unless trunk delivery is configured."
        },
        "realtime": {
          "type": [
            "object",
            "null"
          ],
          "description": "Realtime WebSocket mode (see /docs/realtime). Null when the number runs the per-turn webhook loop.",
          "properties": {
            "url": {
              "type": "string",
              "format": "uri",
              "description": "wss:// endpoint CallNode connects to per call"
            },
            "auth": {
              "$ref": "#/$defs/WebhookAuthStatus"
            },
            "voice": {
              "type": [
                "string",
                "null"
              ],
              "description": "Voice id used for say frames; null = platform default"
            }
          }
        }
      }
    },
    "messaging": {
      "type": "object",
      "properties": {
        "webhookUrl": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri"
        },
        "webhookAuth": {
          "$ref": "#/$defs/WebhookAuthStatus"
        },
        "enabled": {
          "type": "boolean"
        },
        "ready": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "Whether A2P messaging registration has completed for this number. Provisions asynchronously after purchase."
        }
      }
    },
    "monthlyRate": {
      "type": "number"
    },
    "perMinuteRate": {
      "type": "number"
    },
    "includedInSubscription": {
      "type": "boolean"
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    }
  },
  "$defs": {
    "E164": {
      "type": "string",
      "pattern": "^\\+[1-9]\\d{6,14}$",
      "description": "Plus sign followed by 7–15 digits."
    },
    "NumberTags": {
      "type": "array",
      "maxItems": 10,
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 24,
        "pattern": "^[A-Za-z0-9][A-Za-z0-9 ._-]*$"
      },
      "description": "Your own labels for the number. Trimmed, de-duplicated case-insensitively, returned on every number, filterable on the dashboard. PATCH replaces the whole list; send [] to clear."
    },
    "WebhookAuthStatus": {
      "type": [
        "object",
        "null"
      ],
      "description": "How CallNode authenticates to your webhook. The secret itself is write-only and never returned.",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "basic",
            "bearer",
            "header"
          ]
        },
        "headerName": {
          "type": "string"
        },
        "valueSet": {
          "type": "boolean"
        }
      }
    }
  }
}