Source: https://fyno.docs.pageloop.ai/documentation/advanced-features/workflows/nodes-and-actions/api-widget

# API Call Widget

The **Call an API** widget allows workflows to make outbound API requests using verified allow-listed endpoints. This widget can be used to fetch external data, trigger third-party services, or process workflow payloads dynamically.

The widget contains two primary sections:

- **Request** — Configure the outbound API request
- **Response** — Configure and simplify the API response payload

## Steps to configure Call an API Widget

1. Drag and drop the **Call an API** widget into the workflow and connect it to the required workflow step.
2. Configure the **Request** section.

   This section is used to define the API endpoint and request configuration.
3. Select the **Allowlist URL**.

   Choose the verified allow-listed endpoint that should be called from the workflow.
   | Field         | Description                                          |
   | ------------- | ---------------------------------------------------- |
   | Allowlist URL | Verified endpoint configured for outbound API calls. |
4. Select the **HTTP Method**.

   This defines the type of API request that will be executed.

   Supported methods may include:
   - GET
   - POST
   - PUT
   - PATCH
   - DELETE
   | Field       | Description                                               |
   | ----------- | --------------------------------------------------------- |
   | HTTP Method | Defines the request operation used while calling the API. |
5. Configure the **Content Type**.

   The content type determines the format of the request payload being sent to the API.

   Common content types include:
   - None
   - application/json
   - form-data
   - x-www-form-urlencoded
   | Field        | Description                                         |
   | ------------ | --------------------------------------------------- |
   | Content Type | Defines the payload format used in the API request. |
6. Configure **Query Parameters** (Optional).

   Query parameters are appended to the API URL and are typically used for filtering, searching, or passing request-specific values.

   Example:
   ```json
   {
     "userId": "$input.user.id"
   }
   ```
   | Field            | Description                                  |
   | ---------------- | -------------------------------------------- |
   | Query Parameters | Key-value pairs appended to the request URL. |
7. Configure **Headers** (Optional).

   Headers are used to send additional metadata with the API request.

   Common examples include:
   - Authorization tokens
   - API keys
   - Custom request headers
   Example:
   ```json
   {
     "Authorization": "Bearer <token>"
   }
   ```
   | Field   | Description                                          |
   | ------- | ---------------------------------------------------- |
   | Headers | Additional metadata sent along with the API request. |
8. Configure the **Response** section.

   The Response section allows users to add a sample API response payload and simplify it using the payload mapper.

   Users can provide response data in:
   - JSON format
   - FORM format
9. Use the **Simplify** option to flatten and simplify nested API response payloads for easier mapping within workflows.

   Example Response:
   ```json
   {
     "user": {
       "id": 101,
       "name": "John Doe"
     }
   }
   ```
   Simplified Output:
   ```json
   {
     "user.id": 101,
     "user.name": "John Doe"
   }
   ```

> [!NOTE]
>
> Only verified allow-listed URLs can be used inside the Call an API widget. Ensure the endpoint is configured before creating the workflow.
