# Create Stream

API create stream dùng để khởi tạo cuộc gọi từ PSR, cho phép thiết lập websocket server linh động theo từng cuộc gọi, cho phép tích hợp nhiều voicebot khác nhau trên cùng một tenant.

```json
curl --location 'https://{{base_url}}/psr/v1/call/stream' \
--header 'Authorization: Bearer {{token}}' \
--form 'url="wss://demo-psr.ws/server/ws"' \
--form 'destination="0899999999"' \
--form 'app="bot"' \
--form 'audio_file=@"audio/audio.wav"' \
--form 'is_silence="true"' \
--form 'channel="mono_a"'
--form 'parameter="{\"value\":\"test\"}"'
```

### Form Data <a href="#form-data" id="form-data"></a>

| Key         | Description                                                                                                                                                                                                              | Required              |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------- |
| url         | Url tương đối hoặc tuyệt đối nơi kết nối WebSocket sẽ được thiết lập.                                                                                                                                                    | x                     |
| destination | Số điện thoại hoặc extension được gọi tới                                                                                                                                                                                | x                     |
| app         | <p>Có 2 app hiện tại: (Mặc định là dial)<br>- dial: Thực hiện cuộc gọi tới extension, sau khi kết nối sẽ tiến hành dial tới destination.<br>- bot: Thực hiện cuộc gọi tới destination, stream và phát file âm thanh.</p> |                       |
| channel     | <p>Kênh thoại dùng cho stream, mặc định sẽ là stereo (2 kênh).<br>- stereo: Stream cả 2 kênh.<br>- mono\_a: Chỉ stream kênh thoại của đầu người gọi.<br>- mono\_b: Chỉ stream kênh thoại của đầu người nhận. (Done)</p>  |                       |
| extension   | Dùng cho app dial. Extension của tổng đài.                                                                                                                                                                               | x (khi dùng app dial) |
| is\_silence | (true, false) Dùng cho app bot. Phát file silence sau khi kết nối tới destination. Dùng is\_silence=true khi bạn không cần bot phát file âm thanh khi kết nối cuộc.                                                      |                       |
| audio\_file | (file) Dùng cho app bot. Phát file sau khi kết nối tới destination. Nếu `is_silence=true` audio\_file sẽ được bỏ qua.                                                                                                    |                       |
| parameter   | <p>Metadata cần truyền đến bot khi thiết lập cuộc gọi.<br>Ví dụ: {"danh\_xung":"anh"}</p>                                                                                                                                |                       |

> Response trả về:

```json
{
	"code": "OK",
	"data": {
		"call_id": "60fb0716-87cf-437a-91e6-cdcecae21b43",
		"full_recording_url": "https://{{base_url}}/psr/v1/call/record/full_60fb0716-87cf-437a-91e6-cdcecae21b43.wav",
		"recording_url": "https://{{base_url}}/psr/v1/call/record/60fb0716-87cf-437a-91e6-cdcecae21b43.wav",
		"status": "in-progress"
	},
	"message": "OK"
}
```

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documents.sentechcorp.vn/psr/create-stream.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
