# YouTrack JavaScript API

Apps can provide several types of backend JavaScript modules. Pure workflows use the same backend platform for workflow rules. YouTrack runs these modules in a restricted runtime. These modules use packages under `@jetbrains/youtrack-scripting-api` to read and update YouTrack entities, search for data, send HTTP requests, display messages, and perform other backend operations.

The same API modules are available to workflow rules and to supported backend modules in apps. The object exported by a script and the context passed to its functions depend on the module type.

## Supported Backend Modules

| Module | Execution model | Start here |
| --- | --- | --- |
| Workflow rule in an app or pure workflow | Runs when an entity changes, on a schedule, when a user invokes an action, or as part of a state machine or SLA policy. | [Workflow Rule Types](Workflow-Rules.html) |
| HTTP handler | Handles requests sent to an app-defined endpoint. | [HTTP Handlers](apps-reference-http-handlers.html) |
| Custom MCP tool | Handles a tool call sent through the YouTrack MCP server. | [Custom MCP Tools](custom-ai-tools.html) |
| Utility module | Exports reusable functions that another backend module imports. | [Custom Scripts](custom-scripts.html) |

## Shared API Concepts

* Import API modules with `require('@jetbrains/youtrack-scripting-api/<module>')`.

* Use the `entities` module to work with issues, projects, users, articles, and other YouTrack entities.

* Declare [requirements](requirements.html) when a workflow rule or HTTP handler depends on specific fields, values, or entities.

* Use [async functions](async-functions.html) for supported work that should run after the current transaction.

* Use the [http module](JS-Workflow-REST-API.html) to send requests to external services.

For practical entity and collection examples, see [Use the YouTrack JavaScript API](using-workflow-api.html). For a complete list of packages, types, properties, and functions, see the [YouTrack Workflow API](YouTrack-Api-Documentation.html).

## Component-specific Behavior

API availability does not make all backend modules interchangeable. Each module type has its own export, invocation context, lifecycle, and permission model.

Workflow rules use the same constructors and transaction engine whether they belong to an app or a pure workflow. Pure workflow rules run as trusted automation and can perform changes that the triggering user cannot perform directly. HTTP handlers run only after app, target, and endpoint access checks, while custom MCP tools use permission-based entity access for the MCP caller.

Use the module-specific reference to determine which `ctx` properties and APIs are available.

## JavaScript Compatibility

The backend runtime supports the latest ECMAScript specification available in the corresponding YouTrack version. Standard JavaScript declarations, values, functions, expressions, and operators can be used together with the YouTrack API.

> **Note: Set-related Methods**
> The YouTrack API exposes set-like collections with additional operations for entity changes. For details, see [Working with Set Objects](using-workflow-api.html#work-with-set-objects).

