---
title: Input prompts and tool approvals
description: "Ask a person for input mid-tool with ctx.elicit and declare per-tool approval rules with always, never, Approval, withApproval, and withApprovals."
slug: "/build/input-and-approvals"
---

A tool can pause for review or input in two ways: declare an `approval` rule (`always()`, `never()`, or a custom `Approval<Input>` function) to gate execution, or call `ctx.elicit` mid-tool to collect form input. Both work on **Local**, **Self-host**, and **Cloud**.

**The step that matters most:** add `approval` to each query or mutation that needs one (or wrap an imported router with `withApprovals`), because an omitted rule permits execution and nothing is inferred from `query` or `readOnlyHint`.

**Prerequisites and permissions:** an app you can edit and deploy (**Local** owner, or app creator, **admin**, or **owner** on **Cloud** and **Self-host**; see [Build an app](/docs/build)), and an MCP client configured for the approval mode you want ([Choosing where approvals appear](/docs/mcp-clients#choosing-where-approvals-appear)).

**You'll know it worked when…** `deleteArchive` pauses for approval in the dashboard **Tools** tab or MCP, and `issueRefund` pauses for approval and then form input through an interactive MCP connection or CLI session.

## How to use it

Approval declarations and `ctx.elicit` code are identical across **Local**, **Self-host**, and **Cloud**. How an approval request is answered depends on where the tool runs:

- **Dashboard Tools tab:** supports before-run tool approvals (such as `deleteArchive`), but does not supply an elicitation handler—calling `ctx.elicit` from the **Tools** tab rejects with `ElicitationFailed` (`reason: "unavailable"`).
- **Interactive MCP connections:** handle both before-run approvals and mid-tool `ctx.elicit` forms according to the connection's approval mode (**In your browser**, **Through your agent** (`model`), **Native**, or **Automatic**; see [Choosing where approvals appear](/docs/mcp-clients#choosing-where-approvals-appear)).
- **Per-user schedules (`userCron`, `userInterval`):** can pause for before-run tool approvals on the [Approvals](/docs/approvals) page when configured for **Browser approvals** (their default **Skip approvals** accepts requests automatically). Scheduled runs cannot deliver mid-tool `ctx.elicit` forms.

### 1. Declare approval rules on queries and mutations

Import `always` and `never` from `apps/operations/approval` and set `approval` on an operation:

- `approval: always()` returns `"user-approval"` for every new invocation. Your connection's approval mode or schedule setting determines whether Executor prompts a person, relays the decision through the client, or accepts the request automatically.
- `approval: never()` returns `"approved"` without asking (organization, app, and account access checks, schema validation, and any `ctx.elicit` prompts still apply).
- A custom `Approval<Input>` function `async ({ toolName, toolInput, signal }) => ...` inspects the decoded input and returns `"approved"`, `"denied"`, or `"user-approval"`. An explicit `"denied"` always blocks the call.

### 2. Reuse rules or wrap imported routers

- Share a typed `Approval<Input>` function across operations, or attach a rule to an existing operation with `withApproval(operation, rule)`.
- Attach rules to imported MCP, OpenAPI, or GraphQL routers with `withApprovals(router, (operation, name) => rule)`. The picker receives the operation (`operation.kind` and `toolAnnotations(operation)`) and its relative `name` as the second argument, and returns an `Approval` or `undefined` to keep the operation's existing rule.

### 3. Ask for input mid-tool with `ctx.elicit`

Call `ctx.elicit({ mode: "form", message, requestedSchema })` inside a tool handler to collect missing values or confirmation details mid-call:

- `requestedSchema` is a flat JSON Schema object (`type: "object"`) with `string` (including `enum`, `oneOf`, and `format: "email" | "uri" | "date" | "date-time"`), enumerated `array`, `number`, `integer`, or `boolean` properties.
- Check `response.action`: `"accept"` carries validated values in `response.content`; if someone selects `"decline"` or `"cancel"`, the tool receives that action and your code decides how to finish.
- Catch `ElicitationFailed` (exported from `apps`) when the host supplies no interactive delivery handler (for example in the dashboard **Tools** tab, schedules, webhooks, or workflows).

## Example

Both actions below return simulated results and call no refund or archive service. Save these files in `./review-refunds` (replacing `0.0.1-beta.148` with the `version` reported by `executor apps framework` if your host reports a different release):

```json review-refunds/package.json
{
  "name": "review-refunds",
  "private": true,
  "dependencies": {
    "apps": "0.0.1-beta.148"
  }
}
```

```ts review-refunds/index.ts
import {
  defineApp,
  ElicitationFailed,
  mutation,
  number,
  object,
  router,
  string,
  type Approval,
} from "apps";
import { always } from "apps/operations/approval";

const refundApproval: Approval<{ amountCents: number }> = async ({ toolInput }) =>
  toolInput.amountCents > 10_000 ? "user-approval" : "approved";

const issueRefund = mutation(
  {
    description: "Issue a customer refund",
    input: object({
      orderId: string(),
      amountCents: number(),
    }),
    output: object({ status: string(), reason: string().optional() }),
    approval: refundApproval,
  },
  async ({ elicit }, { orderId, amountCents }) => {
    try {
      const reply = await elicit({
        mode: "form",
        message: `Enter a refund reason for order ${orderId} ($${(amountCents / 100).toFixed(2)}).`,
        requestedSchema: {
          type: "object",
          properties: {
            reason: {
              type: "string",
              title: "Reason",
              enum: ["damaged", "duplicate", "customer_request"],
            },
          },
          required: ["reason"],
        },
      });
      if (reply.action !== "accept") {
        return { status: "cancelled" };
      }
      return { status: "refunded", reason: String(reply.content?.reason ?? "") };
    } catch (error) {
      if (error instanceof ElicitationFailed) {
        return { status: `elicit_failed:${error.reason}` };
      }
      throw error;
    }
  },
);

const deleteArchive = mutation(
  {
    description: "Permanently delete archived records",
    input: object({ archiveId: string() }),
    output: object({ deleted: string() }),
    approval: always(),
  },
  async (_ctx, { archiveId }) => ({ deleted: archiveId }),
);

export default defineApp({}, { tools: router({ issueRefund, deleteArchive }) });
```

Create and deploy `./review-refunds` as **Review Refunds** on **Local** (where the bare Local CLI runs in `model` mode by default when no hosted sign-in is active):

```bash
APP_ID=$(executor apps create --name "Review Refunds" --files ./review-refunds | node -pe 'JSON.parse(require("fs").readFileSync(0, "utf8")).id')
executor apps deploy --app "$APP_ID" --files ./review-refunds
```

Exercise the approval and mid-tool form flow with `executor call` and `executor resume`:

```bash
APPROVAL_ID=$(executor call 'tools["review-refunds"].issueRefund' --input '{"orderId":"ORDER-TEST","amountCents":20000}' | node -pe 'JSON.parse(require("fs").readFileSync(0, "utf8")).requestId')
INPUT_ID=$(executor resume "$APPROVAL_ID" --action accept | node -pe 'JSON.parse(require("fs").readFileSync(0, "utf8")).requestId')
executor resume "$INPUT_ID" --action accept --content '{"reason":"duplicate"}'
```

The first call returns `approval-required`, the first `resume` returns `input-required`, and the second `resume` completes with `{"status":"refunded","reason":"duplicate"}`. Declining `deleteArchive` returns `ApprovalDenied` (and you can also run `deleteArchive` from the dashboard **Tools** tab to see a before-run approval prompt).

## Limits

- **15-minute timeout:** pending tool approvals and `ctx.elicit` form prompts expire after 15 minutes.
- **Where `ctx.elicit` cannot run:** call `ctx.elicit` before or after a SQL transaction—a `ctx.sql.transaction` callback is synchronous and cannot `await` a prompt. In runs with no interactive delivery handler (the dashboard **Tools** tab, schedules, webhooks, and workflows), `ctx.elicit` rejects with `ElicitationFailed` (`reason: "unavailable"`). Even in **Automatic** approval mode, `ctx.elicit` forms still require real input.
- **App-scoped schedules cannot ask:** mutations referenced by `appCron` or `appInterval` cannot declare any `approval` rule (even one returning `"approved"`). Only per-user schedules (`userCron`, `userInterval`) configured for **Browser approvals** pause for review on the [Approvals](/docs/approvals) page.
- **Delivery modes and saved versions:** **Automatic** accepts app approval requests without a separate Executor prompt; **Through your agent** (`model`) accepts the decision from the client; **Native** sends forms to the client on `execute` and uses the client-approved path on `call` (Executor cannot verify a client confirmation happened); **In your browser** requires the credential owner's hosted browser session or a paired Local browser. A paused call can resume on its saved, retained version after a new deploy, and Executor rechecks the saved invocation and applicable access.
- **No editing arguments in approval prompts:** before-run approval prompts show the saved call arguments (the compact consent message can abbreviate long arguments to 4,000 UTF-16 code units); reviewers approve or decline the exact call rather than editing arguments.
- **Declining does not roll back earlier calls:** declining or cancelling an invocation approval stops only the paused tool call; earlier external effects in the same program are not undone.
- **Scope of approvals:** the app's factory setup code can run with its invocation accounts (containing scoped credential handles where configured) before the selected tool's approval rule is evaluated. Approval governs the selected tool call, not trust in the app's code. Skill `allowed-tools` metadata grants no permissions and never bypasses authorization or tool approvals.
- **App web UI calls:** calling a tool whose approval rule asks for confirmation from an app's own web UI fails rather than opening an approval prompt.

## Related

- [Approvals](/docs/approvals)
- [Tools, routers, and schemas](/docs/build/tools)
- [Import MCP, OpenAPI, and GraphQL](/docs/build/import)
- [Tools and approvals](/docs/concepts/tools-and-approvals)
