# Which Service type is my code?

A Service type describes how the code receives work and when the process should stop. Tokay detects the type from the code, and the distinction helps when reviewing or changing how a detected process should run.

Start with the behavior of the code rather than the framework it uses.

## Use a web app for HTTP traffic

Choose a **web app** when people or other software open a URL and expect a response. Websites, dashboards, REST APIs, and static HTML all fit this type.

Tokay keeps the process available, gives it an HTTPS URL, and moves traffic only after a new version passes health checks. See [Web apps](web-apps.md).

## Use a scheduled job for work that finishes

Choose a **scheduled job** when a script should start at a particular time, do its work, and exit. Reports, backups, data syncs, and cleanup scripts fit this type.

Tokay runs the script on the chosen schedule and records each run. See [Scheduled jobs](scheduled-jobs.md).

## Use a webhook for incoming events

Choose a **webhook** when another service needs an endpoint for events such as payments, form submissions, or repository pushes.

Tokay gives the Service a stable webhook URL and records each request with its payload and result. See [Webhooks](webhooks.md).

## Use a background worker for a process that stays alive

Choose a **background worker** when the process loops, watches, polls, or consumes a queue and should not exit after one unit of work.

Tokay starts the worker with a deploy and restarts it after a crash. See [Background workers](background-workers.md).

## Resolve the close calls by process behavior

A worker and a scheduled job may run similar code. The deciding question is whether the process exits when the current work is done. A scheduled job should exit. A worker should wait for more work.

A webhook and a web app both receive HTTP requests. Use a webhook when the Service exists mainly to receive machine events and the request history is useful. Use a web app when it serves a broader site or API.

A repository can contain more than one Service. A web app and queue worker often share one Project while running as separate processes. A frontend and backend that build and start as one application can stay one web app.
