{"asyncapi":"3.0.0","info":{"title":"Patch AMD stream","version":"1.0.0","description":"Stream the callee's audio from the moment the call is answered; receive one decision. Accepts Telnyx media streaming, Twilio Media Streams, or raw binary audio. The socket closes after the decision.\n\nAuthenticate with `?token=` (from POST /v1/streams), `Authorization: Bearer pamd_live_…`, or for Twilio a `<Parameter name=\"token\">` (or `api_key`) in the start message."},"servers":{"production":{"host":"api.patchamd.com","protocol":"wss","pathname":"/v1/stream"}},"channels":{"stream":{"address":"/v1/stream","parameters":{},"bindings":{"ws":{"query":{"type":"object","properties":{"token":{"type":"string","description":"Signed stream token."},"api_key":{"type":"string","description":"Discouraged: prefer the Authorization header."},"encoding":{"type":"string","enum":["mulaw","alaw","linear16"],"description":"Raw mode: binary frames in this codec. Omit for Telnyx/Twilio JSON streams."},"sample_rate":{"type":"integer","default":8000},"webhook_url":{"type":"string","description":"With an API key: where to send amd.decided."},"events":{"type":"string","enum":["1"],"description":"Send events on Telnyx/Twilio sockets too."},"transcripts":{"type":"string","enum":["1"],"description":"Also send `transcript` events with the words heard so far (when events are on)."}}}}},"messages":{"telnyxStart":{"name":"Telnyx start","payload":{"type":"object","properties":{"event":{"const":"start"},"start":{"type":"object","properties":{"call_control_id":{"type":"string"},"media_format":{"type":"object","properties":{"encoding":{"type":"string","enum":["PCMU","PCMA","L16"]},"sample_rate":{"type":"integer"}}}}}}}},"twilioStart":{"name":"Twilio start","payload":{"type":"object","properties":{"event":{"const":"start"},"start":{"type":"object","properties":{"callSid":{"type":"string"},"streamSid":{"type":"string"},"customParameters":{"type":"object","additionalProperties":{"type":"string"}},"mediaFormat":{"type":"object","properties":{"encoding":{"const":"audio/x-mulaw"},"sampleRate":{"const":8000}}}}}}}},"media":{"name":"media (Telnyx and Twilio)","payload":{"type":"object","properties":{"event":{"const":"media"},"media":{"type":"object","properties":{"track":{"const":"inbound"},"payload":{"type":"string","contentEncoding":"base64"}}}}}},"stop":{"name":"stop","payload":{"type":"object","properties":{"event":{"const":"stop"}}}},"rawAudio":{"name":"raw audio frame","contentType":"application/octet-stream","payload":{"type":"string","format":"binary","description":"Headerless audio in the declared codec; 20 ms frames recommended. The first frame marks the answer."}},"connected":{"name":"connected","payload":{"type":"object","properties":{"type":{"const":"connected"},"detection_id":{"type":"string"}}}},"started":{"name":"started","payload":{"type":"object","properties":{"type":{"const":"started"},"detection_id":{"type":"string"},"carrier":{"type":"string"},"encoding":{"type":"string"}}}},"transcript":{"name":"transcript","payload":{"type":"object","properties":{"type":{"const":"transcript"},"detection_id":{"type":"string"},"text":{"type":"string"},"finished":{"type":"boolean"}}}},"decision":{"name":"decision","payload":{"type":"object","required":["type","detection_id","result","reason","at_ms","heard"],"properties":{"type":{"const":"decision"},"detection_id":{"type":"string","example":"det_4f9Qm2LxV7cT1bZr8KpA"},"result":{"type":"string","enum":["human","voicemail","ivr","unavailable","silence","not_sure"],"description":"Who picked up. `human`: a live person. `voicemail`, `ivr` (phone menu, hold queue, call screening), `unavailable` (number not in service, mailbox full): a recording. `silence`: nobody spoke after the answer. `not_sure`: the detector could not tell or failed; treat as a person."},"reason":{"type":"string","enum":["person_waiting","recording_detected","inconclusive","no_speech","time_limit","detector_failed"],"description":"Why. `person_waiting`: a person spoke and is waiting for a reply. `recording_detected`: what was said could only come from a recording or automated system. `inconclusive`: speech that could not be placed either way (result `not_sure`). `no_speech`: nobody spoke. `time_limit`: the listening window ended before the speaker stopped. `detector_failed`: something broke on our side (never billed)."},"at_ms":{"type":"integer","description":"Milliseconds from the start of the stream (the answer) to the decision.","example":1840},"heard":{"type":"string","description":"The words heard when the decision was made. Sent to you, never stored by us.","example":"Hello?"}}}}}}},"operations":{"sendAudio":{"action":"receive","channel":{"$ref":"#/channels/stream"},"summary":"You send carrier messages or raw audio.","messages":[{"$ref":"#/channels/stream/messages/telnyxStart"},{"$ref":"#/channels/stream/messages/twilioStart"},{"$ref":"#/channels/stream/messages/media"},{"$ref":"#/channels/stream/messages/stop"},{"$ref":"#/channels/stream/messages/rawAudio"}]},"receiveEvents":{"action":"send","channel":{"$ref":"#/channels/stream"},"summary":"We send events, then close with 1000 after the decision.","messages":[{"$ref":"#/channels/stream/messages/connected"},{"$ref":"#/channels/stream/messages/started"},{"$ref":"#/channels/stream/messages/transcript"},{"$ref":"#/channels/stream/messages/decision"}]}}}