# API Lấy danh sách kịch bản

**Tiền điều kiện:**

1. Đã tạo **Ứng dụng** trên hệ thống **Vbee AICall Cloud** ([*xem cách tạo*](/danh-sach-api/call-campaign/huong-dan-thiet-lap.md))
2. Đã tạo kịch bản (*xem cách tạo*)
3. Đã tạo **ACCESS\_TOKEN**  ([*xem cách tạo*](/huong-dan-khoi-tao/huong-dan-tao-access-token.md))

**Chi tiết API**

## Lấy danh sách các kịch bản

<mark style="color:blue;">`GET`</mark> `https://aicall.vbee.ai /api/v1/public-api/scenarios`

(<mark style="color:red;">\*</mark>) Trường bắt buộc

#### Query Parameters

| Name   | Type   | Description                                                                                                                                                                                                                                                                            |
| ------ | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status | String | <p>Trạng thái của kịch bản, mặc định sẽ lấy tất cả các kịch bản. </p><p>Giá trị hợp lệ: </p><p><strong>DRAFT</strong>: Đang biên tập</p><p><strong>ACTIVE</strong>: Đã được duyệt</p><p><strong>REVIEWING</strong>: Đang chờ duyệt</p><p><strong>REJECT</strong>: Không được duyệt</p> |
| fields | String | <p>Danh sách các trường muốn trả về</p><p>Ví dụ: Nếu muốn trả về chỉ tên kịch bản và mô tả của kịch bản thì truyền vào <strong>name,description</strong></p>                                                                                                                           |
| limit  | String | Số phần tử muốn lấy tối đa của mỗi truy vấn, mặc định là 10 phần tử, tối đa 50 phần tử                                                                                                                                                                                                 |
| offset | String | Vị trí bắt đầu muốn lấy kịch bản. Mặc định là 0                                                                                                                                                                                                                                        |
|        | String |                                                                                                                                                                                                                                                                                        |

#### Headers

| Name                                            | Type   | Description             |
| ----------------------------------------------- | ------ | ----------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer \<ACCESS\_TOKEN> |

{% tabs %}
{% tab title="200: OK Thành công" %}

```json
{
   "result": {
       "scenarios": Array,
       "total_count": int
   },
   "status": int
}

Trong đó: 
- result là kết quả trả về
    - scenarios là một mảng danh sách các kịch bản trả về
    - total_count là tổng số phần tử hợp lệ với yêu cầu tìm kiếm
```

{% endtab %}
{% endtabs %}

Nội dung lỗi trả về có thuộc tính `status` luôn là 0. Ví dụ:

```json
{
  "status": 0,
  "code": 401,
  "message": "Unauthorized"
}
```

**Danh sách mã lỗi**

<table><thead><tr><th width="110.33333333333331">Code</th><th width="257">Message</th><th>Mô tả</th></tr></thead><tbody><tr><td>401</td><td>Unauthorized</td><td><strong>ACCESS_TOKEN</strong> không hợp lệ</td></tr><tr><td>400</td><td>Validation Failed</td><td>Các trường đầu vào không hợp lệ</td></tr><tr><td>1201</td><td>Application is not found</td><td><p>Không tìm thấy ứng dụng</p><p><em>(kiểm tra lại thông tin <strong>API_KEY</strong>)</em></p></td></tr><tr><td>9999</td><td>Uknown error</td><td>Lỗi phát sinh trên hệ thống</td></tr></tbody></table>

**Code mẫu**

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

const ACCESS_TOKEN = '<ACCESS_TOKEN>';
const SCENARIO_ID = '<SCENARIO_ID>';

axios({
  method: 'GET',
  url: `https://aicall.vbee.ai/api/v1/public-api/scenarios`,
  headers: {
    Authorization: `Bearer ${ACCESS_TOKEN}`,
  },
});
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

ACCESS_TOKEN = '<ACCESS_TOKEN>';
SCENARIO_ID = '<SCENARIO_ID>';

requests.get(
    url=f'https://aicall.vbee.ai/api/v1/public-api/scenarios',
    headers={
        "Authorization": f'Bearer {ACCESS_TOKEN}'
    }
)
```

{% endtab %}

{% tab title="Java" %}

```java
package org.example;

import okhttp3.*;
import java.io.IOException;

public class Main {
    public static void main(String[] args) {
        OkHttpClient client = new OkHttpClient();

        String ACCESS_TOKEN = "<ACCESS_TOKEN>";
        String SCENARIO_ID = "<SCENARIO_ID>";
        
        Request request = new Request.Builder()
                .url("https://aicall.vbee.ai/api/v1/public-api/scenarios/")
                .header("Authorization", "Bearer " + ACCESS_TOKEN)
                .get()
                .build();

        try {
            Response response = client.newCall(request).execute();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$ACCESS_TOKEN = '<ACCESS_TOKEN>';
$SCENARIO_ID = '<SCENARIO_ID>';

$ch = curl_init('https://aicall.vbee.ai/api/v1/public-api/scenarios');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
   'Authorization: Bearer ' . $ACCESS_TOKEN,
   'Content-Type: application/json'
));

$response = curl_exec($ch);
curl_close($ch);

```

{% endtab %}
{% endtabs %}


---

# 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://api-docs.aicall.vbee.ai/danh-sach-api/call-scenario-apis/api-lay-danh-sach-kich-ban.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.
