Plan built-in direct call

POST https://z.u1v.ru/api/v1/calls/plan

Plan an authenticated built-in direct audio or video call for the active Zulip account.

This endpoint extends the same Zulip-authenticated trust boundary as POST /calls/bootstrap and POST /calls/devices/register. Clients submit only app-owned call intent data; the server remains authoritative for caller identity, target provisioning, and any broker-facing planning details.

The response always declares whether direct calling is available or must fail closed to the existing provider_link fallback contract.

Usage examples

The -u line implements HTTP Basic authentication. See the Authorization header documentation for how to get those credentials for users and bots.

curl -sSX POST https://z.u1v.ru/api/v1/calls/plan \
    -u EMAIL_ADDRESS:API_KEY \
    --data-urlencode caller_user_id=42 \
    --data-urlencode device_instance_id=device-1 \
    --data-urlencode tenant_id=realm-1 \
    --data-urlencode idempotency_key=plan-1 \
    --data-urlencode replace_session_id=session-1 \
    --data-urlencode preferred_route_mode=direct \
    --data-urlencode 'intent={"displayName": "Ophelia", "forceAnchored": false, "kind": "user", "mediaType": "video", "metadata": {"source_surface": "profile"}, "preferDirectMedia": false, "userId": "84"}' \
    --data-urlencode 'metadata={"source_surface": "profile"}'

Parameters

caller_user_id string required

Example: "42"

Authenticated Zulip user ID for the active caller.


device_instance_id string optional

Example: "device-1"

Optional active device instance identifier used for planning and later lifecycle reporting.


tenant_id string | null optional

Example: "realm-1"

Optional backend tenant identifier.


idempotency_key string | null optional

Example: "plan-1"

Optional client-generated key for deduplicating repeated call-launch taps.


replace_session_id string | null optional

Example: "session-1"

Optional existing app session to replace.


preferred_route_mode string | null optional

Example: "direct"

Optional route hint, such as direct or anchored.


intent object | object required

Example: {"kind": "user", "mediaType": "video", "userId": "84", "displayName": "Ophelia", "metadata": {"source_surface": "profile"}, "forceAnchored": false, "preferDirectMedia": false}

Structured direct-call intent describing the requested target and media mode. kind: user targets a Zulip user; kind: pstn targets an external phone number and is audio-only.

This parameter must be one of the following:

  1. An object with the following fields:

    • kind: string required

      Must be one of: "user". Example: "user"

    • mediaType: string required

      Must be one of: "audio", "video". Example: "video"

    • userId: string required

      Target Zulip user ID to call.

      Example: "84"

    • displayName: string | null optional

      Optional client display-name hint. The server may normalize or replace this value.

    • metadata: object optional

      Optional app-owned metadata for this intent.

    • forceAnchored: boolean optional

      Whether the client prefers anchored media routing.

    • preferDirectMedia: boolean optional

      Whether the client prefers direct media when available.

  2. An object with the following fields:

    • kind: string required

      Must be one of: "pstn". Example: "pstn"

    • mediaType: string required

      Must be one of: "audio". Example: "audio"

    • phoneNumber: string required

      External PSTN phone number. The server normalizes whitespace, punctuation, and formatting before broker planning.

      Example: "+78461112233"

    • displayName: string | null optional

      Optional client display-name hint. The server may normalize or replace this value.

    • metadata: object optional

      Optional app-owned metadata for this intent.


metadata object optional

Example: {"source_surface": "profile"}

Optional app-owned planning metadata.


Response

Return values

  • availability: string

    Server-authoritative availability value.

  • fallback_mode: string

    Server-authoritative fallback_mode value.

  • fallback_reason: string | null

    Server-authoritative fallback_reason value.

  • ui_error_code: string | null

    Server-authoritative ui_error_code value.

  • identity: object | null

    Server-authoritative identity details.

    • sip_identity: string

      Server-authoritative sip_identity value.

    • person_id: string

      Server-authoritative person_id value.

  • planned_call: object | null

    Server-authoritative planned_call details.

    • appCallId: string

      Server-authoritative appCallId value.

    • callTraceId: string

      Server-authoritative callTraceId value.

    • deliveryTraceId: string | null

      Server-authoritative deliveryTraceId value.

    • correlationId: string

      Server-authoritative correlationId value.

    • kind: string

      Server-authoritative kind value.

    • provider: string

      Server-authoritative provider value.

    • providerVersion: string

      Server-authoritative providerVersion value.

    • routeType: string

      Server-authoritative routeType value.

    • routeClass: string

      Server-authoritative routeClass value.

    • routeMode: string

      Server-authoritative routeMode value.

    • mediaAnchor: string

      Server-authoritative mediaAnchor value.

    • identitySource: string

      Server-authoritative identitySource value.

    • capabilities: object

      Server-authoritative capabilities details.

      • Broker-advertised call capability value.
    • callCapabilities: object

      Server-declared call media capability contract. Clients must use this as the authoritative source for whether audio, video, and conference flows can be attempted or need a user-facing fallback.

      • version: integer

        Version of the call-capability contract.

      • capabilitySourceVersion: string

        Versioned server component that produced the capability decision.

      • requestedMediaType: string

        Media type requested by the caller.

      • effectiveMediaType: string

        Media type selected by the server after capability checks.

      • routeSupportsAudio: boolean

        Whether the selected route supports audio.

      • routeSupportsVideo: boolean

        Whether the selected route supports video.

      • targetSupportsAudio: boolean

        Whether the destination supports audio calls.

      • targetSupportsVideo: boolean

        Whether the destination supports video calls.

      • localDeviceSupportsAudio: boolean

        Whether the caller device supports audio calls.

      • localDeviceSupportsVideo: boolean

        Whether the caller device supports video calls.

      • conferenceSupportsAudio: boolean

        Whether the selected conference route supports audio.

      • conferenceSupportsVideo: boolean

        Whether the selected conference route supports video.

      • unavailableReason: string | null

        Machine-readable reason the requested media is unavailable.

      • fallbackReason: string | null

        Machine-readable reason a fallback media mode was selected.

      • metadata: object

        Bounded server-authoritative capability metadata.

        • Call-capability metadata value.
    • sipUri: string

      Server-authoritative sipUri value.

    • directoryKey: string

      Server-authoritative directoryKey value.

    • displayName: string

      Server-authoritative displayName value.

    • avatarUrl: string | null

      Server-authoritative avatarUrl value.

    • mediaType: string

      Server-authoritative mediaType value.

    • roomId: string | null

      Server-authoritative roomId value.

    • inviteHeaders: (string)[]

      Server-authoritative inviteHeaders list.

    • metadata: object

      Server-authoritative metadata details.

      • Server-authoritative mapping value.
    • plannerToken: string | null

      Server-authoritative plannerToken value.

    • wakeDecision: object | null

      Broker-provided wake decision for call delivery. Provider accepted is not caller-facing ringing; clients and support tooling use the ringing gate in this object, usually call_ui_displayed.

      • wakeOwner: string

        Component responsible for waking the destination.

      • callId: string

        Canonical app call ID bound to this wake.

      • callTraceId: string

        End-to-end call trace ID bound to this wake.

      • deliveryTraceId: string

        Push delivery trace ID bound to this wake.

      • ttlSeconds: integer

        Maximum useful lifetime of the call wake.

      • requiresWake: boolean

        Whether an out-of-process wake is required.

      • waitForTargetRegistration: boolean

        Whether planning waits for the woken SIP contact.

      • reason: string

        Server-selected reason for the wake decision.

      • selectedRoutes: (string)[]

        Push routes selected to wake the destination.

      • ringingGate: string

        Delivery receipt required before reporting ringing.

      • dispatchBridge: object

        Server-side provider dispatch result for this wake.

        • mode: string

          Provider dispatch mode reported by the server.

        • status: string

          Status of the server-side dispatch attempt.

        • providerAccepted: boolean

          Whether the provider accepted this dispatch attempt.

        • routesContacted: integer

          Number of routes contacted during this dispatch attempt.

        • acceptedRoutes: integer

          Number of routes that accepted this dispatch attempt.

        • provider: string

          Provider identifier reported for this dispatch attempt.

    • requireAsteriskMedia: boolean

      Whether the server-authoritative requireAsteriskMedia condition is true.

    • preferEarlyMedia: boolean

      Whether the server-authoritative preferEarlyMedia condition is true.

    • allowDirectMedia: boolean

      Whether the server-authoritative allowDirectMedia condition is true.

    • ringingTimeoutMs: integer

      Server-authoritative ringingTimeoutMs value.

    • pushFallbackDelayMs: integer

      Server-authoritative pushFallbackDelayMs value.

    • sessionLeaseSeconds: integer

      Server-authoritative sessionLeaseSeconds value.

Example response(s)

Changes: As of Zulip 7.0 (feature level 167), if any parameters sent in the request are not supported by this endpoint, a successful JSON response will include an ignored_parameters_unsupported array.

A typical successful JSON response may look like:

{
    "availability": "available",
    "fallback_mode": "provider_link",
    "identity": {
        "person_id": "person-hamlet",
        "sip_identity": "sip:hamlet@sip.example.com"
    },
    "msg": "",
    "planned_call": {
        "appCallId": "app-call-1",
        "callTraceId": "trace-call-1",
        "correlationId": "corr-call-1",
        "deliveryTraceId": "delivery-trace-1",
        "directoryKey": "84",
        "displayName": "Ophelia",
        "inviteHeaders": [
            "X-App-Call-Id: app-call-1",
            "X-App-Trace-Id: trace-call-1"
        ],
        "kind": "user",
        "mediaType": "video",
        "metadata": {
            "source_surface": "profile"
        },
        "plannerToken": "plan-app-call-1",
        "routeClass": "direct",
        "routeMode": "direct",
        "sipUri": "sip:ophelia@sip.example.com",
        "wakeDecision": {
            "reason": "sip_registration_stale_os_push_available",
            "ringingGate": "call_ui_displayed",
            "selectedRoutes": [
                "route-apns-voip"
            ],
            "wakeOwner": "push_gateway"
        }
    },
    "result": "success"
}