> This page is for APIs.

> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes.

# calling.play_and_collect

GET /

Play media and collect input

Reference: https://signalwire.com/docs/apis/relay/server/calling/calling-play-and-collect

## AsyncAPI Specification

```yaml
asyncapi: 2.6.0
info:
  title: calling.play_and_collect
  version: subpackage_callingPlayAndCollect.calling.play_and_collect
  description: Play media and collect input
channels:
  /:
    description: Play media and collect input
    publish:
      operationId: subpackage_callingPlayAndCollect.calling.play_and_collect-publish
      summary: Server messages
      message:
        oneOf:
          - $ref: >-
              #/components/messages/subpackage_callingPlayAndCollect.calling.play_and_collect-server-0-onCallingPlayAndCollectCallCollectEvent
          - $ref: >-
              #/components/messages/subpackage_callingPlayAndCollect.calling.play_and_collect-server-1-onCallingPlayAndCollectCallPlayEvent
          - $ref: >-
              #/components/messages/subpackage_callingPlayAndCollect.calling.play_and_collect-server-2-onCallingPlayAndCollectResponse
    subscribe:
      operationId: subpackage_callingPlayAndCollect.calling.play_and_collect-subscribe
      summary: calling.play_and_collect
      message:
        name: callingPlayAndCollect
        title: calling.play_and_collect
        payload:
          $ref: >-
            #/components/schemas/calling.play_and_collect_callingPlayAndCollectRequest
servers:
  production:
    url: wss://relay.signalwire.com/
    protocol: wss
    x-default: true
components:
  messages:
    subpackage_callingPlayAndCollect.calling.play_and_collect-server-0-onCallingPlayAndCollectCallCollectEvent:
      name: onCallingPlayAndCollectCallCollectEvent
      title: calling.call.collect
      payload:
        $ref: '#/components/schemas/calling.play_and_collect_callCollectEvent'
    subpackage_callingPlayAndCollect.calling.play_and_collect-server-1-onCallingPlayAndCollectCallPlayEvent:
      name: onCallingPlayAndCollectCallPlayEvent
      title: calling.call.play
      payload:
        $ref: '#/components/schemas/calling.play_and_collect_callPlayEvent'
    subpackage_callingPlayAndCollect.calling.play_and_collect-server-2-onCallingPlayAndCollectResponse:
      name: onCallingPlayAndCollectResponse
      title: calling.play_and_collect response
      payload:
        $ref: >-
          #/components/schemas/calling.play_and_collect_callingPlayAndCollectResponse
  schemas:
    ChannelsCallingPlayAndCollectMessagesCallCollectEventJsonrpc:
      type: string
      enum:
        - '2.0'
      description: JSON-RPC version. Always `2.0`.
      title: ChannelsCallingPlayAndCollectMessagesCallCollectEventJsonrpc
    ChannelsCallingPlayAndCollectMessagesCallCollectEventMethod:
      type: string
      enum:
        - signalwire.event
      description: Always `signalwire.event`.
      title: ChannelsCallingPlayAndCollectMessagesCallCollectEventMethod
    ChannelsCallingPlayAndCollectMessagesCallCollectEventParamsEventType:
      type: string
      enum:
        - calling.call.collect
      description: The event type — identifies which event this is.
      title: ChannelsCallingPlayAndCollectMessagesCallCollectEventParamsEventType
    Calling.CallCollectState:
      type: string
      enum:
        - collecting
        - error
        - finished
      title: Calling.CallCollectState
    CallingCallCollectResultType:
      type: string
      enum:
        - digit
        - error
        - finished
        - no_input
        - no_match
        - speech
        - start_of_input
      title: CallingCallCollectResultType
    Calling.CallCollectResult:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/CallingCallCollectResultType'
      required:
        - type
      description: >-
        What the caller gave you. Read `type` to know which kind of result this
        is. The

        `error`, `no_input`, `no_match`, `start_of_input`, and `finished` types
        are markers

        with no extra data, while `digit` and `speech` include a `params` object
        with the

        collected input.
      title: Calling.CallCollectResult
    Calling.CallCollectParams:
      type: object
      properties:
        node_id:
          type: string
          description: >-
            Opaque identifier that, paired with `call_id`, addresses this call.
            Echo back the value you received; treat it as opaque.
        call_id:
          type: string
          description: Unique identifier of the call.
        control_id:
          type: string
          description: >-
            The `control_id` of the collection this event refers to, returned
            when you started it with `calling.collect`.
        state:
          $ref: '#/components/schemas/Calling.CallCollectState'
          description: >-
            Where the collection currently stands. `error` means it stopped
            because something went wrong. Present only when the collect was
            started with `continuous: true`; otherwise the event reports its
            `result` without a `state`.
        result:
          $ref: '#/components/schemas/Calling.CallCollectResult'
          description: >-
            What the caller gave you. Check its `type` to handle digits, speech,
            or a no-input/no-match marker.
        final:
          type: boolean
          description: >-
            Relevant when you requested partial or continuous results: `true`
            once the

            recognizer has finished the current utterance. With `continuous:
            true`, the

            collector then restarts to listen for the next one.
      required:
        - node_id
        - call_id
        - control_id
        - result
      title: Calling.CallCollectParams
    ChannelsCallingPlayAndCollectMessagesCallCollectEventParams:
      type: object
      properties:
        event_type:
          $ref: >-
            #/components/schemas/ChannelsCallingPlayAndCollectMessagesCallCollectEventParamsEventType
          description: The event type — identifies which event this is.
        event_channel:
          type: string
          description: >-
            The channel the event was delivered on — for Calling events, the
            `protocol`

            string your connection received from `signalwire.connect`.
        timestamp:
          type: number
          format: double
          description: >-
            When the event was emitted, as a Unix timestamp in seconds. Always
            present.
        project_id:
          type: string
          description: >-
            Your project ID. Present on Calling events and most Call Fabric
            events; absent on `call.joined`, `call.left`, `member.joined`, and
            `member.left`.
        space_id:
          type: string
          description: >-
            Your space ID. Present on Calling events and most Call Fabric
            events; absent on `call.joined`, `call.left`, `member.joined`, and
            `member.left`.
        params:
          $ref: '#/components/schemas/Calling.CallCollectParams'
          description: The event-specific payload.
      required:
        - event_type
        - event_channel
        - timestamp
        - params
      description: The event envelope.
      title: ChannelsCallingPlayAndCollectMessagesCallCollectEventParams
    calling.play_and_collect_callCollectEvent:
      type: object
      properties:
        jsonrpc:
          $ref: >-
            #/components/schemas/ChannelsCallingPlayAndCollectMessagesCallCollectEventJsonrpc
          description: JSON-RPC version. Always `2.0`.
        id:
          type: string
          description: >-
            Event id — a unique UUID generated for each event. Events are
            notifications: you do not reply to them.
        method:
          $ref: >-
            #/components/schemas/ChannelsCallingPlayAndCollectMessagesCallCollectEventMethod
          description: Always `signalwire.event`.
        params:
          $ref: >-
            #/components/schemas/ChannelsCallingPlayAndCollectMessagesCallCollectEventParams
          description: The event envelope.
      required:
        - jsonrpc
        - id
        - method
        - params
      description: >-
        Fires as you collect input from a caller — DTMF digits or speech —
        reporting partial and final results so you can react to what they said
        or pressed.
      title: calling.play_and_collect_callCollectEvent
    ChannelsCallingPlayAndCollectMessagesCallPlayEventJsonrpc:
      type: string
      enum:
        - '2.0'
      description: JSON-RPC version. Always `2.0`.
      title: ChannelsCallingPlayAndCollectMessagesCallPlayEventJsonrpc
    ChannelsCallingPlayAndCollectMessagesCallPlayEventMethod:
      type: string
      enum:
        - signalwire.event
      description: Always `signalwire.event`.
      title: ChannelsCallingPlayAndCollectMessagesCallPlayEventMethod
    ChannelsCallingPlayAndCollectMessagesCallPlayEventParamsEventType:
      type: string
      enum:
        - calling.call.play
      description: The event type — identifies which event this is.
      title: ChannelsCallingPlayAndCollectMessagesCallPlayEventParamsEventType
    Calling.CallPlayState:
      type: string
      enum:
        - playing
        - paused
        - error
        - finished
      title: Calling.CallPlayState
    Calling.CallPlayParams:
      type: object
      properties:
        node_id:
          type: string
          description: >-
            Opaque identifier that, paired with `call_id`, addresses this call.
            Echo back the value you received; treat it as opaque.
        call_id:
          type: string
          description: Unique identifier of the call.
        control_id:
          type: string
          description: >-
            The `control_id` of the playback this event refers to, as set on the
            `calling.play` or `calling.play_and_collect` that started it.
        state:
          $ref: '#/components/schemas/Calling.CallPlayState'
          description: Where the playback currently stands.
      required:
        - node_id
        - call_id
        - control_id
        - state
      title: Calling.CallPlayParams
    ChannelsCallingPlayAndCollectMessagesCallPlayEventParams:
      type: object
      properties:
        event_type:
          $ref: >-
            #/components/schemas/ChannelsCallingPlayAndCollectMessagesCallPlayEventParamsEventType
          description: The event type — identifies which event this is.
        event_channel:
          type: string
          description: >-
            The channel the event was delivered on — for Calling events, the
            `protocol`

            string your connection received from `signalwire.connect`.
        timestamp:
          type: number
          format: double
          description: >-
            When the event was emitted, as a Unix timestamp in seconds. Always
            present.
        project_id:
          type: string
          description: >-
            Your project ID. Present on Calling events and most Call Fabric
            events; absent on `call.joined`, `call.left`, `member.joined`, and
            `member.left`.
        space_id:
          type: string
          description: >-
            Your space ID. Present on Calling events and most Call Fabric
            events; absent on `call.joined`, `call.left`, `member.joined`, and
            `member.left`.
        params:
          $ref: '#/components/schemas/Calling.CallPlayParams'
          description: The event-specific payload.
      required:
        - event_type
        - event_channel
        - timestamp
        - params
      description: The event envelope.
      title: ChannelsCallingPlayAndCollectMessagesCallPlayEventParams
    calling.play_and_collect_callPlayEvent:
      type: object
      properties:
        jsonrpc:
          $ref: >-
            #/components/schemas/ChannelsCallingPlayAndCollectMessagesCallPlayEventJsonrpc
          description: JSON-RPC version. Always `2.0`.
        id:
          type: string
          description: >-
            Event id — a unique UUID generated for each event. Events are
            notifications: you do not reply to them.
        method:
          $ref: >-
            #/components/schemas/ChannelsCallingPlayAndCollectMessagesCallPlayEventMethod
          description: Always `signalwire.event`.
        params:
          $ref: >-
            #/components/schemas/ChannelsCallingPlayAndCollectMessagesCallPlayEventParams
          description: The event envelope.
      required:
        - jsonrpc
        - id
        - method
        - params
      description: >-
        Fires when audio playback on a call starts, pauses, resumes, finishes,
        or errors, so you can track a `calling.play` (or the prompt of a
        `calling.play_and_collect`) through to completion.
      title: calling.play_and_collect_callPlayEvent
    ChannelsCallingPlayAndCollectMessagesCallingPlayAndCollectResponseJsonrpc:
      type: string
      enum:
        - '2.0'
      description: JSON-RPC version. Always `2.0`.
      title: >-
        ChannelsCallingPlayAndCollectMessagesCallingPlayAndCollectResponseJsonrpc
    Calling.PlayAndCollectResult:
      type: object
      properties:
        code:
          type: string
          description: >-
            Result code as a string. `"200"` means success. Failures use an
            HTTP-style code

            such as `"400"` (bad request), `"403"`, `"404"` (call not found),
            `"405"`, `"409"`

            (conflict, for example another operation is still running), `"410"`
            (call gone),

            or `"500"`. If the call could not be reached in time, `code` is a
            lowercase error

            identifier instead, such as `response_timeout`, `not_available`, or

            `internal_error`.
        message:
          type: string
          description: >-
            Human-readable description of the result. On failure, it explains
            what went wrong. Always check `code`; `message` may be omitted when
            there is nothing extra to report.
        call_id:
          type: string
          description: The call this result is for, echoed from your request.
        control_id:
          type: string
          description: >-
            Your control identifier for the started action, echoed from your
            request.
      required:
        - code
      title: Calling.PlayAndCollectResult
    JsonRpcErrorCode0:
      type: string
      enum:
        - '-32000'
      title: JsonRpcErrorCode0
    JsonRpcErrorCode1:
      type: string
      enum:
        - '-32001'
      title: JsonRpcErrorCode1
    JsonRpcErrorCode2:
      type: string
      enum:
        - '-32002'
      title: JsonRpcErrorCode2
    JsonRpcErrorCode3:
      type: string
      enum:
        - '-32003'
      title: JsonRpcErrorCode3
    JsonRpcErrorCode4:
      type: string
      enum:
        - '-32004'
      title: JsonRpcErrorCode4
    JsonRpcErrorCode5:
      type: string
      enum:
        - '-32005'
      title: JsonRpcErrorCode5
    JsonRpcErrorCode6:
      type: string
      enum:
        - '-32600'
      title: JsonRpcErrorCode6
    JsonRpcErrorCode7:
      type: string
      enum:
        - '-32601'
      title: JsonRpcErrorCode7
    JsonRpcErrorCode8:
      type: string
      enum:
        - '-32602'
      title: JsonRpcErrorCode8
    JsonRpcErrorCode9:
      type: string
      enum:
        - '-32603'
      title: JsonRpcErrorCode9
    JsonRpcErrorCode10:
      type: string
      enum:
        - '-32700'
      title: JsonRpcErrorCode10
    JsonRpcErrorCode:
      oneOf:
        - $ref: '#/components/schemas/JsonRpcErrorCode0'
        - $ref: '#/components/schemas/JsonRpcErrorCode1'
        - $ref: '#/components/schemas/JsonRpcErrorCode2'
        - $ref: '#/components/schemas/JsonRpcErrorCode3'
        - $ref: '#/components/schemas/JsonRpcErrorCode4'
        - $ref: '#/components/schemas/JsonRpcErrorCode5'
        - $ref: '#/components/schemas/JsonRpcErrorCode6'
        - $ref: '#/components/schemas/JsonRpcErrorCode7'
        - $ref: '#/components/schemas/JsonRpcErrorCode8'
        - $ref: '#/components/schemas/JsonRpcErrorCode9'
        - $ref: '#/components/schemas/JsonRpcErrorCode10'
      title: JsonRpcErrorCode
    JsonRpcError:
      type: object
      properties:
        code:
          $ref: '#/components/schemas/JsonRpcErrorCode'
          description: >-
            The error code — a negative integer identifying the failure. See
            `JsonRpcErrorCode` for the full list of values and meanings.
        message:
          type: string
          description: A human-readable description of what went wrong.
        original_request:
          type: object
          additionalProperties:
            description: Any type
          description: >-
            An echo of the request that failed — the full JSON-RPC frame you
            sent

            (`jsonrpc`, `id`, `method`, `params`). Always present.
        requester_nodeid:
          type: string
          description: >-
            The node that sent the failed request. Present only on some routing
            errors.
        requester_identity:
          type: string
          description: >-
            The identity of the requester. Present only on some routing errors;
            same value as `requester_nodeid`.
        responder_nodeid:
          type: string
          description: >-
            The node that was handling the request. Present only on some routing
            errors.
        responder_identity:
          type: string
          description: >-
            The identity of the responder. Present only on some routing errors;
            same value as `responder_nodeid`.
        last_hop_timeout:
          type: boolean
          description: >-
            `true` when the request timed out on its final hop inside
            SignalWire. Present only on some timeout errors.
      required:
        - code
        - message
        - original_request
      description: >-
        A JSON-RPC 2.0 error object, delivered on the `error` field of a
        `JsonRpcResponse` when

        a request fails at the protocol level (bad version, authentication,
        scope, params, or

        your project's connection limit). It replaces `result` — a frame carries
        one or the other, never both.
      title: JsonRpcError
    calling.play_and_collect_callingPlayAndCollectResponse:
      type: object
      properties:
        jsonrpc:
          $ref: >-
            #/components/schemas/ChannelsCallingPlayAndCollectMessagesCallingPlayAndCollectResponseJsonrpc
          description: JSON-RPC version. Always `2.0`.
        id:
          type: string
          description: The id of the request this responds to.
        result:
          $ref: '#/components/schemas/Calling.PlayAndCollectResult'
          description: The method result. Present when the request succeeded.
        error:
          $ref: '#/components/schemas/JsonRpcError'
          description: >-
            Present instead of `result` when the request failed at the protocol
            level.
      required:
        - jsonrpc
        - id
      description: >-
        A JSON-RPC response frame correlated to a request by `id`. On success
        the frame carries

        `result` (the method result). If the request fails at the protocol level
        — an

        incompatible version, failed authentication, insufficient scope, invalid
        params, or your

        project's connection limit — the frame carries `error` instead of
        `result`. Many

        method-level failures (for example most Calling failures) are reported
        the other way: a

        normal `result` whose own `code` is not `"200"`. Each method documents
        which form its

        failures take.


        An `error` returned for `signalwire.connect` is followed by the service
        closing the

        WebSocket; open a new connection to try again. The same happens when

        `signalwire.reauthenticate` sends credentials that are rejected, except
        for a

        Subscriber Access Token. Errors on any other request leave the
        connection open.
      title: calling.play_and_collect_callingPlayAndCollectResponse
    ChannelsCallingPlayAndCollectMessagesCallingPlayAndCollectRequestJsonrpc:
      type: string
      enum:
        - '2.0'
      description: JSON-RPC version. Always `2.0`.
      title: ChannelsCallingPlayAndCollectMessagesCallingPlayAndCollectRequestJsonrpc
    ChannelsCallingPlayAndCollectMessagesCallingPlayAndCollectRequestMethod:
      type: string
      enum:
        - calling.play_and_collect
      description: The name of the JSON-RPC method being invoked.
      title: ChannelsCallingPlayAndCollectMessagesCallingPlayAndCollectRequestMethod
    CallingPlayMediaType:
      type: string
      enum:
        - audio
        - tts
        - silence
        - ringtone
      title: CallingPlayMediaType
    Calling.PlayMedia:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/CallingPlayMediaType'
      required:
        - type
      description: A media element to play. Discriminated on `type`.
      title: Calling.PlayMedia
    Calling.PlayAndCollectDigits:
      type: object
      properties:
        min:
          type: integer
          minimum: 0
          description: >-
            Minimum number of digits to collect before collection can finish.
            Must be a non-negative integer.
        max:
          type: integer
          minimum: 1
          description: >-
            Maximum number of digits to collect before collection finishes. Must
            be a positive integer.
        terminators:
          type: string
          description: >-
            Keys that end collection early when pressed, such as `"#*"`. Not set
            by default.
        digit_timeout:
          type: number
          format: double
          minimum: 1
          default: 5
          description: >-
            How long to wait, in seconds, for the next key press after one is
            received

            before giving up. Must be at least `1`. Defaults to `5.0`.
      required:
        - max
      description: >-
        Settings that control how the caller's DTMF (touch-tone) key presses are
        collected for a

        `calling.play_and_collect`. Unlike the standalone `calling.collect`,
        this also

        accepts a `min` digit count.
      title: Calling.PlayAndCollectDigits
    Calling.PlayAndCollectSpeechModel:
      type: string
      enum:
        - default
        - enhanced
        - enhanced.phone_call
        - enhanced.video
      title: Calling.PlayAndCollectSpeechModel
    Calling.PlayAndCollectSpeech:
      type: object
      properties:
        end_silence_timeout:
          type: number
          format: double
          minimum: 1
          default: 0.5
          description: >-
            How much silence, in seconds, to wait for before treating the caller
            as

            finished speaking. Defaults to `0.5`. A value you send must be at
            least `1`,

            so leave it unset to keep the sub-second default.
        speech_timeout:
          type: number
          format: double
          minimum: 1
          default: 60
          description: >-
            Maximum time, in seconds, to spend collecting speech. Must be at
            least `1`. Defaults to `60`.
        language:
          type: string
          default: en-US
          description: >-
            Language to recognize, as a BCP-47 tag such as `en-US`. To pin the
            engine for

            this language, use the form `<engine>:<tag>`, where `<engine>` is
            `Google`,

            `Google.V2`, or `Deepgram` (for example `Deepgram:en-US`). Defaults
            to `en-US`.
        hints:
          type: array
          items:
            type: string
          description: >-
            Words or phrases you expect to hear, used to bias recognition toward
            them. Not set by default.
        model:
          $ref: '#/components/schemas/Calling.PlayAndCollectSpeechModel'
          description: Recognition model to use. Not set by default.
      description: >-
        Settings that control how the caller's speech is recognized for a

        `calling.play_and_collect`. Same as the `speech` settings of
        `calling.collect`,

        except that `model` must be one of the listed values.
      title: Calling.PlayAndCollectSpeech
    Calling.PlayAndCollectCollect:
      type: object
      properties:
        initial_timeout:
          type: number
          format: double
          minimum: 1
          default: 4
          description: >-
            How long to wait, in seconds, for the caller to start giving input.
            Must be at least `1`. Defaults to `4.0`.
        digits:
          $ref: '#/components/schemas/Calling.PlayAndCollectDigits'
          description: >-
            How to collect DTMF key presses. Provide this, `speech`, or both; at
            least one is required.
        speech:
          $ref: '#/components/schemas/Calling.PlayAndCollectSpeech'
          description: >-
            How to collect spoken input. Provide this, `digits`, or both; at
            least one is required.
      description: >-
        The `collect` settings for a `calling.play_and_collect`, describing what
        to listen for while the media plays. Provide `digits`, `speech`, or
        both.
      title: Calling.PlayAndCollectCollect
    Calling.PlayAndCollectParams:
      type: object
      properties:
        node_id:
          type: string
          description: >-
            Opaque identifier that, paired with `call_id`, addresses this call.
            Echo back the value you received; treat it as opaque.
        call_id:
          type: string
          description: Unique identifier of the call.
        control_id:
          type: string
          description: >-
            Your own identifier for this play-and-collect. It is attached to
            every event it produces so you can match events back to this
            request.
        volume:
          type: number
          format: double
          minimum: -40
          maximum: 40
          description: >-
            Playback volume in dB, from `-40` (muted) to `+40`; `0` keeps the
            original audio level.
        play:
          type: array
          items:
            $ref: '#/components/schemas/Calling.PlayMedia'
          description: >-
            The media to play, in order — audio files, text-to-speech, silence,
            or ringtone.
        collect:
          $ref: '#/components/schemas/Calling.PlayAndCollectCollect'
          description: What to listen for from the caller while the media plays.
      required:
        - node_id
        - call_id
        - control_id
        - play
        - collect
      title: Calling.PlayAndCollectParams
    calling.play_and_collect_callingPlayAndCollectRequest:
      type: object
      properties:
        jsonrpc:
          $ref: >-
            #/components/schemas/ChannelsCallingPlayAndCollectMessagesCallingPlayAndCollectRequestJsonrpc
          description: JSON-RPC version. Always `2.0`.
        id:
          type: string
          description: Request id, echoed on the correlated response.
        method:
          $ref: >-
            #/components/schemas/ChannelsCallingPlayAndCollectMessagesCallingPlayAndCollectRequestMethod
          description: The name of the JSON-RPC method being invoked.
        params:
          $ref: '#/components/schemas/Calling.PlayAndCollectParams'
          description: The method's input parameters.
      required:
        - jsonrpc
        - id
        - method
        - params
      description: >-
        A JSON-RPC request frame. `Method` is the method name; `Params` is the
        method's input.
      title: calling.play_and_collect_callingPlayAndCollectRequest

```