# Test\_Script

On selecting required project from project dashboard, you'll arrive at the Collections Dashboard. If you've already created collections, they will be listed here. Otherwise, [let's begin by creating a new collection](https://docs.qyrus.com/api-monitoring/collections/collections). Now Let's get started with creating **Test Script**.

You will be provided with below mentioned options to create Test Script in respective collection.

![Test Script Creation Options](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-4ec3efbd8b63f37aa37d43f5c7d1c717f8272957%2FTest_Script_Create_Options.png?alt=media)

### Contents

* [Options to create Test Scripts.](#options-to-create-test-scripts)
  * [Import from API Testing.](#import-from-api-testing)
  * [Creating Monitored API Manually.](#creating-monitored-api-manually)
  * [Importing APIs from a Swagger JSON URL.](#importing-apis-from-a-swagger-json-url)
  * [Importing APIs from a Swagger JSON File.](#importing-apis-from-a-swagger-json-file)
  * [Importing from a Postman Collection URL.](#importing-from-a-postman-collection-url)
  * [Importing from a Postman Collection File.](#importing-from-a-postman-collection-file)
* [Cloning Test Scripts.](#cloning-test-scripts)
* [Editing Test Script.](#editing-test-script)
* [Deleting Test Script.](#deleting-test-script)
* [What's next?](#whats-next)

***

#### Options to create Test Scripts:

#### Import from API Testing:

To bring APIs from the **Qyrus API Testing Service** into your Test scripts, follow these steps. Choose the **Import from API Testing** option and then proceed to click on the **Import** button, as depicted below.

![Import APIs from API Testing](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-b889d7158df9ec71563b9f5dba529c10e316a335%2FTest_Script_Create_From_API_Testing_Options.png?alt=media)

At this point, you will see a list of all the teams and their associated projects that are accessible to the current user. Choose the **Project** from which you want to import scripts.

![List of Teams and respective Projects](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-cdee20e5c2c8eba818e94171a5597aad3f2f04c1%2FList_of_Project_To_Import_From_API.png?alt=media)

Now, you will be presented with a list of all the available Test Suites within the selected Project. Please select the **Test Suite** from which you want to import scripts.

![List of Test Suites from selected Project](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-3c524485e7484382ee68d0362d833e47fe290888%2FList_of_Test_Suits_From_API_Testing.png?alt=media)

Now, you will be listed will all the Test Scripts available in selected Test Suite.

![List of Test Scipts](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-f7167d54c1fb8b7d0a59910d391ebf3f8f243b08%2FList_of_Test_Scripts_From_API_Testing.png?alt=media)

*Note: API Monitoring does not support Parameterized Test Scripts, as a result related data will be not imported.*

Now, choose the **Test Script** you want to import, then click on the **Create Monitored APIs** button.

![Selected Test Scipt to Import](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-06056a641a086d8261d7c8cd3b4b39e0bbde8b27%2FSelect_API_To_Import_And_Generate_Button.png?alt=media)

After successfully importing the Test Script, you will be directed back to the **Test Scripts** dashboard, accompanied by a confirmation message for Collection Creation saying **APIs imported Successfully**.

![Imported Test Script](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-82574e74ec80b73838e2d1ac0f541b15915ef11e%2FImported_Script_From_API_Testing.png?alt=media)

***

#### Creating Monitored API Manually:

To create a API manually, follow these steps. Choose the **Create Monitored API Manually** option and then proceed to click on the **Create Monitored API Manually** button, as depicted below.

![Create Scripts Manually](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-c8978e5059f6b6d2d21c9594519d6eb132dadd10%2FCreate_Test_Script_Manually.png?alt=media)

You can provide required details to create the Script, listed below.

* [Monitored API Form.](#monitored-api-form)
* [Authorization.](#authorization)
* [Headers.](#headers)
* [Prerequisite API Form.](#prerequisite-api-form)

#### Monitored API Form:

Details required to be provided in Monitored API Form.

![Info Section](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-50dd7a5669454cf714301835cc46471a60bb81f0%2FManual_TestScript_Info_Section.png?alt=media)

| Field                                                                                                                                                   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| API type                                                                                                                                                | Select REST, SOAP or GraphQL.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| Monitor Name                                                                                                                                            | This is the name of your Monitored API.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| URL                                                                                                                                                     | This is your API's URL. Please incorporate any path and query parameters as needed. If you are utilizing the output from a prerequisite API as input for a path parameter, enclose the path parameter within curly braces. Example: <https://www.yourURL.com/test/this/{airport}> When employing a prerequisite API, the output of the prerequisite will be inserted into the {airport} field.                                                                                                                                                                                             |
| Time Period( Minimum 10 mins)                                                                                                                           | These fields allow you to specify the time interval between your API calls. You can select the time unit (minutes, hours, or days) from the dropdown menu. The shortest permissible time between calls is 10 minutes.                                                                                                                                                                                                                                                                                                                                                                      |
| Time Unit                                                                                                                                               | You can select the time unit (minutes, hours, or days) from the dropdown menu.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| Single Response Time Threshold( ms)                                                                                                                     | Set this value to the maximum acceptable response time for your API call. The API monitoring service will monitor how many times this threshold is exceeded.                                                                                                                                                                                                                                                                                                                                                                                                                               |
| Receive Alert When Single Threshold Exceeded                                                                                                            | If you select the 'Yes' option for the radio button, you will receive an email notification when a previous response call exceeds the specified threshold.                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| Average Response Time Threshold( ms)                                                                                                                    | The maximum acceptable average response time across a specified number of calls.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| Receive Alert When Average Threshold Exceeded                                                                                                           | If you select the 'Yes' option for the radio button, you will receive an email notification when a previous response call exceeds the specified threshold.                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| Rolling Average                                                                                                                                         | Define this value as the maximum acceptable average response time over a specified number of calls. The API monitoring service keeps a record of how many times this threshold is breached. From a dropdown menu, users can select to calculate the average from the last 10, 15, 20, 25, or 30 calls. If the radio button is set to 'Yes,' the system will send an email notification to the user when the rolling average exceeds the defined threshold. Users will receive one alert when the threshold is surpassed and another alert when the average falls back below the threshold. |
| Expected Status Code                                                                                                                                    | This is the anticipated value that the user is looking to receive from the API call. The user will be notified by email whenever the status code deviates from the expected value or when it returns to the expected value. When the API call is returning the expected status code, a thumbs-up icon will be displayed to indicate that the API call is functioning as intended.                                                                                                                                                                                                          |
| \_\_\_\_                                                                                                                                                |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ### Authorization:                                                                                                                                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| Authorization in the context of APIs refers to the process of granting or denying access to specific resources, data, or functionalities within an API. |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| You will be provided with the list of authorization options like:                                                                                       |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |

![Authorization list](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-0f4f4050d761b41f54d6391dd77cceb023c0c6a4%2FAuthorization_List_In_Test_Script.png?alt=media)

You can choose **None** if the API does not require any authorization, or you can select one of the supported authorization methods from the dropdown menu displayed.

* [Basic Auth.](#basic-auth)
* [OAuth 2.0.](#oauth-20)

#### Basic Auth:

Basic Authentication (Basic Auth) is a method of securing web resources by transmitting a username and password with each HTTP request.

![Basic Authorization of Test Script](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-376f9877ceedd66382032fcc28e3211ef2e5d4eb%2FBasic_Auth_Authorization_Test_Script.png?alt=media)

You can now provide username and password for the API.

***

#### OAuth 2.0:

OAuth 2.0 is an industry-standard protocol for authorization, allowing secure access to resources on behalf of a user or application without sharing the users credentials.

![OAuth 2.0](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-c20a29af2445fd9c2c0fe156c046254d238b03f0%2FOAuth_2_Authorization_Test_Scripts.png?alt=media)

You can now provide access token for the API.

***

#### Headers:

Headers in an API are metadata or key-value pairs included in the HTTP request to provide additional information or instructions for the server.

![Headers of Test Script](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-7d91c625d8331dd03a8ea8c67456cfec50a0fd19%2FHeaders_Test_Script.png?alt=media) You can provide the API header in a key-value format.

***

#### Importing APIs from a Swagger JSON URL:

To generate Test Scripts from swagger URL, select **Importing APIs from a Swagger JSON URL** option as shown below.

![Swagger URL Option](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-860a36f2606a6200a4d485a8357bc84149bc5178%2FImport_From_Swagger_URL.png?alt=media)

Now provide swagger URL and click on **Get APIs**

![Swagger URL with example](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-169c3363bde92f9d25ca7bec8db75ad1c47f630a%2FImport_From_Swagger_URL_With_Example.png?alt=media)

*For example, <https://petstore.swagger.io/v2/swagger.json>.*

Now you will be listed with APIs as shown below.

![APIs List](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-64767a5a80f91bb8ecd4a8f0dad533493c7250ac%2FSwagger_URL_Listed_APIs.png?alt=media)

Now select the APIs that you would wish to import and click on **Create Monitored APIs** button.

![Selected APIs](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-c0ba83f4ef23b9c0ea99cfc167a6aa30d4d440ab%2FSelected_API_From_Swagger_URL.png?alt=media)

On successfully importing the API and creating the Test Script you will be able to see the script created as shown below.

![Imported From Swagger URL](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-6286915d1291dc068a3f9db959a0fc4c350e4b59%2FImported_Test_Scripts_From_Swagger_URL.png?alt=media)

***

#### Importing APIs from a Swagger JSON File:

To generate Test Scripts from swagger URL, select **Importing APIs from a Swagger JSON File** option as shown below.

![Swagger File](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-4fdd1f026c59798c309c354db0e47bb3f802b5c2%2FImport_From_Swagger_File_Option.png?alt=media)

Now you will be listed with APIs as shown below.

![APIs List](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-64767a5a80f91bb8ecd4a8f0dad533493c7250ac%2FSwagger_URL_Listed_APIs.png?alt=media)

Now select the APIs that you would wish to import and click on **Create Monitored APIs** button.

![Selected APIs](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-c0ba83f4ef23b9c0ea99cfc167a6aa30d4d440ab%2FSelected_API_From_Swagger_URL.png?alt=media)

On successfully importing the API and creating the Test Script you will be able to see the script created as shown below.

![Imported From Swagger URL](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-6286915d1291dc068a3f9db959a0fc4c350e4b59%2FImported_Test_Scripts_From_Swagger_URL.png?alt=media)

***

#### Importing from a Postman Collection URL:

To generate Test Scripts from Postman Collection URL, select **Importing from a Postman Collection URL** option as shown below.

![Postman Collection URL Option](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-284bb029865d66dd91dad8fba5d512f7b84ae9c2%2FPostman_Collection_URL_Import_Option.png?alt=media)

Now provide swagger URL and click on **Get APIs**

![Alt text](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-2a9538b6bdeda61b8df753be883c9179cfa7fef9%2FPostman_Collection_URL_Example.png?alt=media)

Now you will be listed with APIs as shown below.

![APIs List](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-64767a5a80f91bb8ecd4a8f0dad533493c7250ac%2FSwagger_URL_Listed_APIs.png?alt=media)

Now select the APIs that you would wish to import and click on **Create Monitored APIs** button.

![Selected APIs](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-c0ba83f4ef23b9c0ea99cfc167a6aa30d4d440ab%2FSelected_API_From_Swagger_URL.png?alt=media)

On successfully importing the API and creating the Test Script you will be able to see the script created as shown below.

![Imported From Swagger URL](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-6286915d1291dc068a3f9db959a0fc4c350e4b59%2FImported_Test_Scripts_From_Swagger_URL.png?alt=media)

***

#### Importing from a Postman Collection File:

To generate Test Scripts from Postman Collection URL, select **Importing from a Postman Collection File** option as shown below.

![Postman Collection File Import Option](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-f549d3602d5610f2e90cc3301828cba232bf567a%2FPostman_Collection_File_Import_Option.png?alt=media)

Now you will be listed with APIs as shown below.

![APIs List](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-64767a5a80f91bb8ecd4a8f0dad533493c7250ac%2FSwagger_URL_Listed_APIs.png?alt=media)

Now select the APIs that you would wish to import and click on **Create Monitored APIs** button.

![Selected APIs](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-c0ba83f4ef23b9c0ea99cfc167a6aa30d4d440ab%2FSelected_API_From_Swagger_URL.png?alt=media)

On successfully importing the API and creating the Test Script you will be able to see the script created as shown below.

![Imported From Swagger URL](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-6286915d1291dc068a3f9db959a0fc4c350e4b59%2FImported_Test_Scripts_From_Swagger_URL.png?alt=media)

***

#### Editing Test Script:

To modify the details of a manually created or imported API, simply click the **Edit** button, make your desired changes, and then click the **Save** icon. ![Edit Test Script](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-c06ab63cf81b24c3374ca21fab3c443f7dd0bb93%2FEdit_Test_Script_Option.png?alt=media)

*NOTE: It's important to keep in mind that if your API was in monitoring mode when you updated its information, the monitoring process will be temporarily halted to incorporate the changes.*

***

#### Cloning Test Script:

To clone the Test Script, click on the **Clone API** icon as shown below.

![Cloning Test Script](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-24e0cf3819d146c0085411f18926afc7d1f75aca%2FCloning_Test_Script.png?alt=media)

Once the script is cloned you should be able to view the clonned script in the Test Scripts list.

![Cloned Test Script](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-b6b7e5d63476826ba407c02cbccf30c8a059b8b7%2FCloned_Test_Script.png?alt=media)

***

#### Deleting Test Script:

If you want to delete any of your Test Script, Hover on the desired Test Script and click on **Delete** icon.

![Delete Test Script](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-396b77f4c7005f59c4913bdf6673c24b3fb923b0%2FDelete_Test_Script.png?alt=media)

You will receive a confirmation prompt for test script deletion. If you still wish to delete the test script, click Yes; otherwise, click No.

![Delete Test Script Confirmation](https://1658030817-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69UIIR3YErzKiN7uLdZh%2Fuploads%2Fgit-blob-48123a7f889fb05f5f7de49d2b7999170fbb9581%2FDelete_Test_Script_Confirmation.png?alt=media)

When you successfully delete the test script, you will receive a confirmation message saying **API deleted successfully!**.

***

#### What's next?

* [Prerequiste API](https://docs.qyrus.com/api-monitoring/pre_requisites/pre_requisite_forms)
* [Monitoring Test Script](https://docs.qyrus.com/api-monitoring/monitoring/monitoring_test_script)
* [Global Variables](https://docs.qyrus.com/api-monitoring/global_variables/global_variables)
