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

# API Call

The **API Call** action allows your AI assistant to interact with external systems, services, or databases by sending HTTP requests. It supports all major HTTP methods and allows for custom pre/post-processing logic in Python.

This action is ideal for dynamic integrations like sending data, retrieving external information, triggering backend processes, or interacting with third-party APIs.

***

## What It Does

When triggered, this action performs a direct HTTP request to the specified API endpoint. You can define the method, payload, and optionally include pre-processing and post-processing logic to manipulate the request or handle the response.

> Use this for real-time data exchange or logic branching based on external API responses.

***

## Action Interface

<Frame>
  <img src="https://mintcdn.com/monobot-0e0ffe36/yVZ9w6FeuKr7UZXp/images/settings/actions/api-call-interface.jpg?fit=max&auto=format&n=yVZ9w6FeuKr7UZXp&q=85&s=23f0f3bb48e917990027510d8c67e26f" alt="API Call Action UI" className="block" width="1309" height="680" data-path="images/settings/actions/api-call-interface.jpg" />
</Frame>

***

## Configuration Options

<AccordionGroup>
  <Accordion icon="link" title="API Endpoint (required)">
    **Type**: `string`
    The complete URL of the API endpoint to call.

    *Example:* `https://api.example.com/users`
  </Accordion>

  <Accordion icon="send" title="Method Type (required)">
    **Type**: `string`
    HTTP method used for the request. Choose from:

    * `GET`
    * `POST`
    * `PUT`
    * `DELETE`

    *Default:* `GET`
  </Accordion>

  <Accordion icon="key" title="Headers">
    **Type**: `object`\
    Key-value pairs sent with the request to provide metadata such as authentication, content type, or API configuration.

    *Example:*

    ```json theme={null}
    {
      "Authorization": "Bearer YOUR_TOKEN",
      "Content-Type": "application/json"
    }
    ```
  </Accordion>

  <Accordion icon="code" title="Payload">
    **Type**: `object`
    Key-value pairs to include in the request body or query params.

    *Example:*

    ```json theme={null}
    {
      "email": "@userEmail",
      "status": "active"
    }
    ```
  </Accordion>

  <Accordion icon="wand" title="Pre Process Function">
    **Type**: `python`
    Python function that runs **before** the API call. Useful for preparing parameters or transforming data.

    *Example:*

    ```python theme={null}
    def preprocess(params):
        return {"email": params["email"].lower()}
    ```
  </Accordion>

  <Accordion icon="wand2" title="Post Process Function">
    **Type**: `python`
    Python function that runs **after** receiving the API response. Use this to extract data or format it for the next step.

    *Example:*

    ```python theme={null}
    def handle(response):
        return response.get("data", {})
    ```
  </Accordion>

  <Accordion icon="check-circle" title="Only if everything was successful">
    **Type**: `boolean`
    When checked, the next action will only execute if this API call completes successfully.
  </Accordion>
</AccordionGroup>

***

## Tips

* Use `@parameter` in the endpoint, payload, or code for dynamic inputs.
* Chain this with message generation or conditional actions based on response data.
* Return JSON or structured data to power follow-up tools like decision branches or summaries.

Let us know if you'd like ready-to-use API templates!
