# Chatbot API

Go to API documentation 👇

{% embed url="<https://app.flochat.ai/api>" %}

### Intro to API

Flochat's API is used to retrieve data from the flow you build. Here are some examples that you could do with the API.

* Pull the flow you have built from Flochat.
* Create, delete or obtain data including flow tag, flow field.
* Dealing with the data about the subscribers, involving getting the subscribers' information, editing their tag or field as well as sending sub flows to the subscribers.
* Configure all the data used in e-commerce such as carts or products.

If you need to deal with the data below, the next sections will introduce the steps to use the API.

### Authorization

Since the protection of the data is important to the API, it needs to use several attribute to authorize your identity. Therefore, the first step you must do is to enter the authorized information. You need to click the **Authorize** button.

<figure><img src="https://2836971782-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRaLazqQDW4JMiGe2iyKg%2Fuploads%2FMNQrWqmZbv786ipTe275%2FCapture.PNG?alt=media&#x26;token=d09eed32-03f0-49b6-9a95-ee0d5e7d5cc0" alt=""><figcaption></figcaption></figure>

Then paste in your API Key

<div align="left"><figure><img src="https://2836971782-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRaLazqQDW4JMiGe2iyKg%2Fuploads%2Fm20AxoCunagtmgdUgIaS%2FCapture.PNG?alt=media&#x26;token=cf4671e7-94c5-49c8-8f8f-2ee046e44b86" alt=""><figcaption></figcaption></figure></div>

### Find Your API Key

Navigate to the top right of your dashboard and select the drop down menu as shown below.

<div align="left"><figure><img src="https://2836971782-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRaLazqQDW4JMiGe2iyKg%2Fuploads%2FNRTIJfRcqjdEcBHUezKC%2Ftempsnip.png?alt=media&#x26;token=a5233f28-539c-408f-8642-04b6becf535d" alt=""><figcaption></figcaption></figure></div>

### Create Your API Key

To generate your API key, simply add the details to the create API token screen.

* [x] Name your token
* [x] Select Workspace
* [x] Select Chatbot

<figure><img src="https://2836971782-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRaLazqQDW4JMiGe2iyKg%2Fuploads%2F3nhhkuBcMJjSus071LwV%2FCapture.PNG?alt=media&#x26;token=17b6eeb3-db64-49fc-8953-d7fd7ebf8614" alt=""><figcaption></figcaption></figure>

Once you have filled in your details, select the create button. You will now see your API key in the next pop up.

<figure><img src="https://2836971782-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRaLazqQDW4JMiGe2iyKg%2Fuploads%2FJt3qfrqlnOC0717SMWK3%2FCapture1.PNG?alt=media&#x26;token=3cfac3ea-9896-405a-85dc-8f619d9a58a6" alt=""><figcaption></figcaption></figure>

{% hint style="danger" %}
**WARNING**

This is the only time the key will ever be displayed, so be sure not to lose it! You may revoke the key at any time from your API settings.
{% endhint %}

### Get the Curl and Request URL <a href="#get-the-curl-and-request-url" id="get-the-curl-and-request-url"></a>

Curl is used in API requests. In Flochat's API documentation, you need some operation before getting the curl in the api documentation.

Here, we use **Get Flow Tag** as an example.

<figure><img src="https://2836971782-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRaLazqQDW4JMiGe2iyKg%2Fuploads%2F8RoXjKgdWRLC9JiTPS9u%2FCapture.PNG?alt=media&#x26;token=b7eb015d-b849-4c41-afd7-015cd5d75e33" alt=""><figcaption></figcaption></figure>

**Step 1.** Click the expand operation of category, the **Flow Tag** in this case. Then find the action and the feature, **Get /flow/tags**. Click the row and a page will dropdown shown as following.

<figure><img src="https://2836971782-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRaLazqQDW4JMiGe2iyKg%2Fuploads%2FmUxxC2KHEDlX1V6PSA14%2FCapture.PNG?alt=media&#x26;token=659d51c4-11f0-401a-a0e4-5bc1d7584186" alt=""><figcaption></figcaption></figure>

**Step 2**. This padlock means **authorized**. If you have done this before, this step is not required. Or, you just do the same as it was mentioned before in the Authorize section.

**Step 3**. Click Try it out. Then you will see that the **Parameters or Request body part** could be inputted and the **Execute Button** is shown at the bottom of this part.

<figure><img src="https://2836971782-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRaLazqQDW4JMiGe2iyKg%2Fuploads%2FUJiP1epzEiGG5z7x57CG%2FCapture.PNG?alt=media&#x26;token=540bd849-9360-4550-9891-1003bb1030bb" alt=""><figcaption></figcaption></figure>

**Step 4**. Enter the parameters or request body required and click the **Execute Button**. Finally you will get the **Curl** and **Request URL**.

<figure><img src="https://2836971782-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRaLazqQDW4JMiGe2iyKg%2Fuploads%2FXoHU0FohBUDrBhAihKvO%2FCapture.PNG?alt=media&#x26;token=d240094f-8775-4ad2-b7d1-414052340c77" alt=""><figcaption></figcaption></figure>

### Response

This part display the Json result you will get from the API. Normally if the code is 200, it means that you get the response successfully. If the code is 400, it means that there is error in your response.

<figure><img src="https://2836971782-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRaLazqQDW4JMiGe2iyKg%2Fuploads%2FWKw7b876U1GEwacEW4tr%2FCapture.PNG?alt=media&#x26;token=7115480e-38f0-4f41-aea3-59c151056c74" alt=""><figcaption></figcaption></figure>

### Example Value / Schema <a href="#example-value-schema" id="example-value-schema"></a>

Apart from example value, you can click on "Schema" to view more details like which value is mandatory. Denoted by the red Asterix <mark style="color:red;">\*</mark>

<figure><img src="https://2836971782-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRaLazqQDW4JMiGe2iyKg%2Fuploads%2FQ9uVtMIC3EGgMabhflQl%2Ftempsnip.png?alt=media&#x26;token=7170dd2d-2fe9-4969-ab03-f4b818062663" alt=""><figcaption></figcaption></figure>
