# Services

Services are used to enable workflow automation in your solution. Services can be thought of as apps without a user interface.

A service can be used to:

* Receive data from an external service, for example sensor data, or new orders.
* Send data to an external service, for example to update inventory or generate invoices.
* Process data on a set [schedule](https://docs.appfarm.io/reference/operations/schedules), for example to generate reports or send notifications.

As with apps, services have [data sources](#data) and [actions](#actions) to process data and perform logical operations. In order to trigger these actions, services are exposed via an interface known as [endpoints](#endpoints).

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

For services to run in a given environment, the **Enable API Services** checkbox must be selected in the [Environment configuration](https://docs.appfarm.io/reference/configuration/environments).
{% endhint %}

## Endpoints

Endpoints are the external interface of a service. They parse the request, trigger an action, and facilitate which data is returned.

An endpoint can be called from an external application or by a [schedule](https://docs.appfarm.io/reference/operations/schedules) configured to run at specific times. Service endpoints can also be called [from apps and other services](https://docs.appfarm.io/library/action-nodes/run-service) in your solution.

An endpoint has a URL and one or more HTTP methods which together make it unique in your solution. The URL and appropriate method are used by external services to call the endpoint.&#x20;

{% content-ref url="services/service-endpoints" %}
[service-endpoints](https://docs.appfarm.io/reference/services/service-endpoints)
{% endcontent-ref %}

## Data

[Data sources](https://docs.appfarm.io/reference/apps/data) are configured in the same way as for apps. Both database-connected and runtime-only data sources are supported. They can be referenced in [actions](#actions), as well as used to map request and response data in an [endpoint](#endpoints).

One key difference to be aware of compared to apps is around performance. Each time one of the service's endpoints is called, all database-connected data sources are filtered and re-evaluated. If you need to use database-connected data sources in your service, you should limit the number of endpoints and instead spread the functionality across multiple services. We recommend using runtime-only data sources to read data from the database in order to limit the performance impact of this pattern.

Service variables, the equivalent of [app variables](https://docs.appfarm.io/reference/apps/data/app-variables), can also be created. The built-in variables expose the active environment and hostname.

{% content-ref url="apps/data" %}
[data](https://docs.appfarm.io/reference/apps/data)
{% endcontent-ref %}

## Actions

Actions for services work in the same way as [actions for apps](https://docs.appfarm.io/reference/apps/actions) and are primarily used to process data and send web requests. One key difference is that actions in services are run on the server, while actions in apps are almost always run in the browser. There are some [action nodes](https://docs.appfarm.io/library/action-nodes) that are exclusive to services, such as Update secret and others that are not available, for example [Navigate](https://docs.appfarm.io/library/action-nodes/navigate).

In a service an action is triggered by specifying it as the **Process Action** in an [endpoint](https://docs.appfarm.io/reference/services/service-endpoints). This primary action can also trigger other actions using the Run Other Action action node.

{% content-ref url="apps/actions" %}
[actions](https://docs.appfarm.io/reference/apps/actions)
{% endcontent-ref %}

## Testing and debugging

You may inspect execution logs and test Services with the [DevTools for Services](https://docs.appfarm.io/reference/appfarm-client/developer-tools-for-services). Also, all Service Endpoints are automatically documented in a Swagger inteface, as documented in the [API explorer article](https://docs.appfarm.io/reference/services/api-explorer).\
\
You may also find this guide on [Testing and Debugging](https://docs.appfarm.io/how-to/security-testing-and-deployment/test-and-debug) helpful.
