# HTTP triggers and routing

> HTTP trigger behavior for JavaScript functions, covering input sources, path parameters, authentication scopes, payload limits, and calling a deployed trigger.

An HTTP function is a JavaScript function that declares a `method` and a `path`, in a project whose `targetRuntime` is `javascript-server`. It is the backend of a [coded app](https://docs.uipath.com/apps/automation-suite/2.2610/user-guide): the app calls the function, and the function holds the credentials and business rules that must never reach the browser.

```typescript
export default defineFunction({
  name: "get-order",
  method: "GET",
  path: "/orders/:id",
  input: defineSchema<{ id: string }>(),
  handler: async (input, ctx) => fetchOrder(input.id),
});
```

The supported methods are:

- `GET`
- `POST`
- `PUT`
- `PATCH`
- `DELETE`

## Where the input comes from

| Method | Request data read as input |
|---|---|
| `GET` | The query string |
| `POST`, `PUT`, `PATCH`, `DELETE` | The JSON request body |

Path parameters are merged in as well, so `/orders/:id` supplies `id` alongside the rest of the input. Every path parameter must be declared in the input type: the derived schema is closed, so an undeclared one is rejected as an unknown property.

Path parameters merge underneath the body, so a body field of the same name wins. Distinct names avoid a silent override.

## Path parameters

| Pattern | Matches |
|---|---|
| `:param` | Exactly one segment — `/users/:id` matches `/users/42` |
| `:param{regex}` | One segment, constrained — `/users/:id{[0-9]+}` |
| `:param?` | The segment, or nothing — `/list/:filter?` matches `/list` and `/list/open` |
| `*` | A trailing catch-all, including the bare prefix |

Values are also available as strings on `ctx.params`, keyed by name. More specific routes win regardless of declaration order, so a literal `/users/me` takes precedence over `/users/:id`. Routing behaves identically in a local `serve` and when deployed.

## Calling a deployed trigger

Publishing and deploying the package creates an Orchestrator HTTP trigger for each function, at its `path`. The caller sends a bearer token, and the function receives the caller's identity as [`ctx.user`](javascript-function-context.md).

From a coded app, call the function by name with the `Functions` service of the [UiPath TypeScript SDK](https://uipath.github.io/uipath-typescript/):

```typescript

const orders = await new Functions(sdk).invoke({ name: "list-orders" }, { status: "open" }, { folderId });
```

`Functions.invoke()` calls functions whose `path` has no parameters. Give a function that a coded app calls a fixed path, and pass the values as input.

## Authentication

Callers authenticate with a bearer token from an External Application. Register a coded app's External Application with `OR.Jobs`, which lets the app find and call the function, plus the scopes of anything else the app calls:

```bash
uip admin external-apps create "My App" \
  --non-confidential \
  --redirect-uri "https://<org>.uipath.host/my-app" \
  --user-scope "OR.Execution,OR.Folders.Read,OR.Jobs"
```

Request the same scopes in the coded app's `uipath.json`.

Each user of the app also needs two permissions in the function's folder: **Triggers** View (`Schedules.View`), to find the function, and **Jobs** Create (`Jobs.Create`), to call it.

## Payload limits

The request and the response of an HTTP function are both limited.

| Direction | Limit | Past the limit |
|---|---|---|
| Request | 10,000 characters of serialized input | `500`, with `errorCode 4801` and the message `JobArguments length should be less than 10000 characters` |
| Response | About 512 KB | The call fails |

When a payload can exceed either limit, make the function a job function. A job carries large input and output as attachments. See [Invoking functions](invoking-functions.md).

:::tip
Returning a reference rather than the data itself — a storage bucket path, or an identifier the caller fetches separately — keeps the limits from constraining the design.
:::

## Next steps

- [Function context](javascript-function-context.md) — read the caller's identity and the request.
- [Accessing platform services](javascript-platform-services.md) — reach Orchestrator from the handler.
- [Routing reference](https://uipath.github.io/uipath-typescript/js-functions/platform-context/) — the full matching rules.
