> ## Documentation Index
> Fetch the complete documentation index at: https://knowledge.bitbybit.studio/llms.txt
> Use this file to discover all available pages before exploring further.

# Add an HTTP request to your AI agent

> Configure an HTTP request in AI Studio so your agent can retrieve data from an API and use its response in customer conversations.

Configure an HTTP request when you want your AI agent to retrieve data from an API without connecting an MCP server. Define when the agent should use the request, map the values it needs, test the API call, then enable it.

## Prerequisites

* You already created an AI agent in **AI Studio**. See [Set up your AI agent in AI Studio](https://knowledge.bitbybit.studio/ai-studio/how-to-setup-ai-agent-in-ai-studio.md).
* You have the API URL and any credentials the API requires.
* Your role can manage AI Studio settings.

## Step 1: Add an HTTP request

* Go to **AI Studio** and open the AI agent you want to configure.
* Open **Connectors** and find the **HTTP requests** section.
* Select **Add HTTP request**.

![HTTP requests section showing the Add HTTP request and Manage request buttons](https://mintcdn.com/asmaraku/tclJ6j1czVupYqkW/images/ai-studio/http-requests-overview.png?fit=max\&auto=format\&n=tclJ6j1czVupYqkW\&q=85\&s=cf5a4f2d1b23b3b8dfc40f1c4e7b0039)

* Enter a **Request name** and explain when the agent should use the request in **When should the agent use this?**
* Choose **GET** to read data or **POST** if the API needs a request body.
* Enter the full **Request URL**. The editor accepts `http://` and `https://` URLs without a username or password in the address. Use HTTPS when the API supports it, especially when sending credentials. Use `{{variable_name}}` for values the agent will provide, such as `https://api.example.com/orders/{{order_id}}`.
* Choose an **Authentication type**: **Bearer token**, **API key header**, or **No authentication**. Enter the credential details when required.

When editing a request, leave the credential field blank to keep its saved credential. If you change the authentication type, enter the credential for that type.

The API must accept the method and authentication type you configure. The editor does not provide other HTTP methods, authentication types, or a separate custom-header editor. If your API needs another method or a custom header, this request editor cannot configure it.

## Step 2: Define agent inputs and the request body

* Add an input variable for each value the agent must provide. Use a unique name with letters, numbers, or underscores, starting with a letter or underscore.
* Add **How should the agent get this value?** instructions and choose whether the input is **Required**. You can also set an example value. Inputs can be **Text**, **Number**, **Boolean**, or **File**.
* Use each variable as `{{variable_name}}` in the request URL or body. In a JSON or raw text body, type the template yourself and select **Insert variable** to add an existing input. Define every variable used in the request before continuing.
* For a **GET** request, add variables to the URL. GET requests do not send a body.
* For a **POST** request, choose the body format required by the API:
  * **JSON** — enter a valid JSON body template. For example:

    ```json theme={null}
    {
      "order_id": "{{order_id}}"
    }
    ```

    Select **Insert variable** to place an input into the template. The editor checks that the JSON is valid.
  * **Form URL-encoded** — add each API field and choose a fixed value or an agent input.
  * **Multipart form data** — add text fields or map file inputs to API fields.
  * **Raw text / XML** — enter a body template and its **Content-Type**. For XML, input values are escaped automatically; choose `text/plain` for plain text.
  * **Binary file** — choose a **File** input and enter the **Content-Type**.
  * **None** — send a POST request without a body. Inputs can still appear in the URL.

For Form URL-encoded and Multipart form data, the editor builds the body from the fields you add. For JSON and Raw text / XML, you enter the body template directly. The editor shows a resolved preview before you test the request.

## Step 3: Test and enable the request

* Enter sample values for the agent inputs. Choose a sample file for each **File** input.
* Select **Test request** and review the response.
* If the configuration changes after a test, test it again before saving.
* After the test passes, select **Save & enable**.

The test uses the sample values you enter. Saving is unavailable until the request passes a test and the configuration has no validation errors.
An empty successful response, such as **204 No Content**, passes the test and is shown as having no matching data.

Testing sends the request to your API. A **POST** request may change data in that system, so use test data or a test endpoint when possible. If a POST test gets no response, check whether the action completed before you try again.

The agent can use the response to answer the customer. API credentials are not included in the response shown to the customer.

## Manage an HTTP request

* Open the request and select **Manage request**.
* Turn **Enable request** off to prevent the agent from using the request. The configuration stays saved. You can enable it again after a successful test.
* Select **Test request** to test it again, or **Edit request** to change its configuration. Test the request again after making changes.
* Select **Delete HTTP request** and confirm to remove the saved configuration. This does not delete data from your external system.

## Fix request problems

If a test fails, check the message shown with the result, then review the URL, credentials, sample values, and API field mappings. A successful **2xx** response with an HTML content type, such as a sign-in page, is treated as an unexpected response. For **401**, check the credential. For **403**, check that the credential has permission to access the resource. For **404**, check the URL and sample values. For **422**, check the input mappings and required API fields. For **429**, wait before testing again and check the API rate limit.

## Related articles

* [Connect an MCP server to your AI agent](https://knowledge.bitbybit.studio/ai-studio/how-to-connect-an-mcp-server-to-your-ai-agent.md)
* [Set up your AI agent in AI Studio](https://knowledge.bitbybit.studio/ai-studio/how-to-setup-ai-agent-in-ai-studio.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.