# API Endpoints

An API Endpoint exposes a [Flow](/reference/flows.md) [action](/reference/actions.md) as an HTTP endpoint that can be called by external systems. API Endpoints allow Flows to receive requests from outside the solution — for example, webhook callbacks from third-party integrations or queries from external applications.

Each API Endpoint is a Flow action with its own endpoint configuration. When the endpoint is called, the action runs and (optionally) returns a response.

{% hint style="warning" %}
**Important**

For API Endpoints to be reachable in a given environment, the **Enable Flow Service** checkbox must be selected in the [Environment Configuration](/reference/configuration/environments.md#general-settings).
{% endhint %}

### Usage

To create a Flow with API Endpoints:

* Click **Create Flow**.
* Select **API Endpoints**.
* Set the API root path. This becomes part of the endpoint URL.

To add an API Endpoint to an existing Flow:

* Open the Flow.
* Click **+ Create API Endpoint** in the **Actions** panel.
* Enter a name for the endpoint.

To call an endpoint from an external system, including tools like [Postman](https://www.postman.com/), construct an endpoint URL as follows:\
https\://`SOLUTION-HOSTNAME`/api/`API-ROOT-PATH/ENDPOINT-PATH`.

For example, if the API root path is `orders` and the endpoint path is `create`, the URL would be:\
<https://your-solution.appfarm.app/api/orders/create>.

To authenticate the request, include an API key as a Bearer token in the `Authorization` header. Read more on how to access a Flow endpoint from an external system [here](/how-to/integrations/integrate-with-external-systems.md).

To view and test your API Endpoints, use the [API Explorer](/reference/flows/api-explorer.md).

### Endpoint config

When you create an API Endpoint, the action has a separate **Endpoint config** tab where the HTTP configuration is defined.

#### General

| Property    | Description                                                                                                                                                                                                                                                                                    |
| ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Methods** | The HTTP request methods that the endpoint will support. The available options are: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`. Read more about [HTTP request methods on MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods).                                                |
| **Path**    | <p>The path used in the endpoint URL. If not set, we will fall back to a technical ID, which is not very human-readable. Must consist of valid URL characters.<br><br><strong>Note:</strong> We automatically enforce uniqueness and remove illegal characters after the value is entered.</p> |

#### Path params

| Property        | Description                                                                                                                                                                                                          |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Path Params** | Add variable path segments that are required parts of the endpoint URL. For example `/customer/{customerId}` has a path param `customerId` Path params are available as contextual parameters in the action's logic. |

#### Inputs

These properties enable you to parse and map data sent as part of a request to the endpoint.

| Property            | Description                                                                                                                                                                                                             |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Query Params**    | Map values from query string parameters.                                                                                                                                                                                |
| **Request Headers** | Map values from request headers.                                                                                                                                                                                        |
| **Body Parser**     | Parse body data into JSON. If the request contains body data that is not in JSON format, you can use the function editor to create a JSON object containing the data so that it can be mapped. Not available for *GET*. |
| **Body Data**       | Map request body data in JSON format. Body data must use the [schema](/reference/platform-concepts/schemas.md) data type. Not available for *GET*.                                                                      |

{% hint style="info" %}
**Good to know**

API Endpoint actions receive their input from the endpoint configuration — path params, query params, request headers, and body data — rather than from [action params](/reference/actions/action-params.md). Action params are not shown on API Endpoint actions.
{% endhint %}

#### Response

These properties enable you to configure the headers and data sent in the response.

| Property                 | Description                                                                                                              |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------ |
| **Response Headers**     | Add custom headers or override default headers in the response. Response headers are evaluated after the action has run. |
| **Custom Response Body** | Construct a custom response body using the function editor. This can be used instead of the default response format.     |

By default, the response includes all [action variables](/reference/actions/action-variables.md) and [action data sources](/reference/actions/action-data-sources.md) that are marked **Return from action**, serialized as JSON. A **Custom Response Body** overrides this.

#### Advanced

| Property                | Description                                                                                                                                                   |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Cache Response Data** | Enable caching for this endpoint. If the endpoint returns data that is static or not time-sensitive, you can cache the response data to increase performance. |
| **Enable Rate Limit**   | Set restrictions on how many parallel connections a single IP may have towards this endpoint, within a given time window.                                     |


---

# 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.appfarm.io/reference/flows/api-endpoints.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.
