# API

<figure><img src="/files/4CfxJIZ4iH6C3wcZEK6I" alt=""><figcaption></figcaption></figure>

Other systems can use Gaio's analytical intelligence through APIs. This feature allows you to connect Gaio flows to external services via RESTful APIs, using secure authentication through API Keys.

***

## **How to Use**

***

### **1.** Access the API Tab

* On the left-hand panel, click the **API icon**.
* Use the **API Key** tab to create and manage your keys.
* Use the **API** tab to configure API calls to external services.

***

### 2. Create an API Key

<figure><img src="/files/ikFpcf6GcuLxIobWHz3h" alt=""><figcaption></figcaption></figure>

1. Click the **"+"** button in the upper right corner of the `API Key` tab.
2. Fill out the fields:
   * **Name**: Name of the key (e.g., `Doc`).
   * **Status**: Select `Active`.
3. Click **generate**.
4. Once the key is generated, **copy and save** it securely.
5. To view or renew the key, use the **eye** icon or the **renew** button.
6. Click **Save**.

***

### 3. Configure an API Integration

<figure><img src="/files/lOo12rx1Ntfag4zcbDAO" alt=""><figcaption></figcaption></figure>

1. Go to the **API** tab and click **"+"** to add a new integration.
2. Fill in the fields:
   * **Name**: Integration name (e.g., `SendToCRM`).
   * **Endpoint**: Only the final endpoint name (e.g., `https://api.example.com/send`).
3. **Configure authorization token:**&#x20;
   1. Choose where the authorization token will be read from.
      1. Supported locations:
         * **Header** (recommended)
         * Query parameters (if required)
4. **Select flow** (optional)**:** choose the Gaio flow to be executed when the API is called.
5. **Input data in a table** (optional): Optionally, map incoming API data into a table.
   1. When defined:
      1. Incoming request data is stored as rows
      2. The table becomes available to the executed flow
      3. Enables batch processing, auditing, and traceability
6. **Output type:** Define how the API response will be generated.
   1. **Table** → Return data from a table
   2. **Custom** → This enables a manual response body definition.

**Example Custom Response:**

```json
{
  "status": "success",
  "message": "Request processed successfully",
  "data": {
    "execution_id": "{{ params.execution_id }}"
  }
}

```

7. **Return table:** select the table that contains the data that will be consumed via API.
8. Go to the **API Key** tab and check the previously created key.
9. Click **Save**.

***

### 4. API Task · MCP Tool

<figure><img src="/files/E52FwTfwa5IrUZqJx6lE" alt=""><figcaption></figcaption></figure>

The **MCP Tool** tab allows you to expose an existing API Task as a **callable tool for AI agents**.\
Once enabled, the API can be invoked programmatically by agents during reasoning and execution. This transforms your API into a first-class AI tool, usable within chat agents, flow agents, and automated decision-making pipelines.

The MCP Tool configuration defines:

* How the API is presented to AI agents.
* What input the agent must provide.
* Whether the tool is available for execution.
* How the agent understands when and why to call it.

### How to configure MCP Tool

1. Enter a clear and action-oriented tool name.
2. Describe what the tool does and when it should be used.
3. Define the expected input schema for the tool.

```json
{
  "review_text": "string",
  "language": "string"
}

```

4. Click **Generate** to auto-create an input schema based on the API configuration.
5. Toggle the Status switch to enable or disable the tool.

***

## 5. Execution and Results

After saving the configuration:

* The API can be triggered manually or as part of an automated process in Gaio.
* If a process is selected, it is executed whenever a Gaio API endpoint is called. This means that any analysis can be performed through calls external to Gaio, such as creating/applying a predictive model, inserting, deleting, calling external APIs (REST), accessing data sources external to Gaio, and all other features.
* **Row limit** : It is possible to limit the number of rows to be returned by the Gaio API, even if the generated table has millions of rows.

```
https://your_url/endpoint?limit=10
```

* Use limit and offset parameters to implement pagination and navigate through large datasets.

{% code overflow="wrap" %}

```
https://your_url/endpoint?limit=10&offset=10
```

{% endcode %}

* Retrieve data in pages using the limit and page parameters for better user experience with large datasets.

```
https://your_url/endpoint?limit=10&page=1
```

* Add custom parameters to filter and customize API responses based on specific criteria. If the query that precedes the API task filters the table with this parameter, only the requested data will be sent in the API result. Example: enter the client code in the API call and Gaio will return the products to offer for that specific client.

{% code overflow="wrap" %}

```
https://your_url/endpoint?limit=10&page=1&param_name_one=sales&param_name_two=male
```

{% endcode %}

{% hint style="warning" %}
&#x20;For each Gaio API, a unique access key is generated, which in the image above was masked.
{% endhint %}

### API Task · Live Requests

<figure><img src="/files/rMOP4TlIdI3VRLTmgZK3" alt=""><figcaption></figcaption></figure>

The **Live Requests** tab allows you to **monitor API calls in real time** after the API Task is executed.\
It provides visibility into incoming requests, execution behavior, and runtime data, making it an essential tool for debugging and observability.

#### What You Can See

After the API is called, each request appears in the Live Requests panel with:

* Incoming request data
* Parameters and payload
* Execution context
* Response or execution result
* Errors (when applicable)

This information is displayed **in real time**, without requiring redeployment or restarts.

#### Typical Use Cases

* Debugging authentication issues
* Validating request payloads
* Monitoring flow execution behavior
* Verifying custom output responses
* Observing agent-triggered API calls
* Troubleshooting external integrations

***

#### Best Practices

* **Security**: Never share your API Key. Use the `Inactive` status to temporarily disable access.
* **Versioning**: Create new entries for APIs with structural changes.
* **Validation**: Test endpoints manually before embedding in automation flows.


---

# 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://docs.gaiodataos.com/tools/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.
