# Rest API

While running the conversation flow you have the option to call any API. Just define the **Method** to be used, the API **Url**, and, if you prefer, the **Parameters** and **Type of Parameters** to be sent.

![](https://blobscdn.gitbook.com/v0/b/gitbook-28427.appspot.com/o/assets%2F-LSnqDgLbXBccdKMOdEJ%2F-LTwEBn5aIc3l6dlfomF%2F-LTwECN7NZFQCnyGdlXn%2Fimage.png?alt=media\&token=4c32428c-546c-46c0-9bba-6c0a77b856b1)

If you want to handle the API return response, you can use **Javascript** code. The response will be available through the variable: **response\_\_x**.

If the return is a Javascript object (JSON format), when treating it in the code remember to check if it is not Null to avoid errors. And if the return is a string and you want to use it in the code as JSON, remember to convert it to JSON using the **JSON.parse (response\_\_x)**

If you want to save the return in some custom object field, remember that the JSON format is not allowed as field type. So you'll have to convert it to String, using the **JSON.stringify (return\_example)** method, and then save it. Then, if you want to use this field in the future, remember to convert it back to JSON using the **JSON.parse method (return\_example)**

{% hint style="warning" %}
There is a 15-second execution timeout. So if you pass this limit the API call will be interrupted and an error will be returned that can be queried in the conversation history.
{% endhint %}


---

# 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://help-en.cosmobots.io/bot-builder/conversation-flow/rest-api.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.
